# include <iostream>
# include <string>
int monster = 10000 ;
class Hero {
protected :
std:: string name;
int hp;
int attack;
public :
Hero ( ) : hp ( 100 ) , attack ( 10 ) { }
Hero ( const std:: string& n, int h, int a) : name ( n) , hp ( h) , attack ( a) { }
virtual void Atk ( ) {
hp -= 0 ;
}
int GetHP ( ) const {
return hp;
}
} ;
class Mage : public Hero {
private :
int ap_attack;
public :
Mage ( const std:: string& n, int h, int a, int ap) : Hero ( n, h, a) , ap_attack ( ap) { }
void Atk ( ) override {
hp -= ( attack + ap_attack) ;
}
} ;
class Archer : public Hero {
private :
int ac_attack;
public :
Archer ( const std:: string& n, int h, int a, int ac) : Hero ( n, h, a) , ac_attack ( ac) { }
void Atk ( ) override {
hp -= ( attack + ac_attack) ;
}
} ;
int main ( ) {
Mage mage ( "Mage1" , 100 , 20 , 50 ) ;
Archer archer ( "Archer1" , 100 , 15 , 100 ) ;
while ( monster > 0 ) {
mage. Atk ( ) ;
archer. Atk ( ) ;
std:: cout << "Mage's HP: " << mage. GetHP ( ) << ", Archer's HP: " << archer. GetHP ( ) << ", Monster's HP: " << monster << std:: endl;
if ( mage. GetHP ( ) <= 0 && archer. GetHP ( ) <= 0 ) {
std:: cout << "英雄被杀死,野怪胜利" << std:: endl;
break ;
}
if ( monster <= 0 ) {
std:: cout << "野怪被杀死,英雄胜利!" << std:: endl;
break ;
}
}
return 0 ;
}