Commit 55fbbb8d by BellCodeEditor

save project

parent dfb5d1b6
Showing with 50 additions and 0 deletions
class country:
def __init__(self,name,hp,attack):
self.level=1
self.name=name
self.hp=hp
self.attack=attack
def upgrade(self):
if self.name=="德意志国":
self.level+=1
self.hp+=30
self.attack+=12
if self.name=="Soviet Union":
self.level+=1
self.hp+=45
self.attack+=6
if self.level==10:
self.level+=1
self.hp-=20
self.attack+=100
def combat(self,enemy):
info1 =self.name+"对"+enemy.name+"发起进攻"
info2 = "歼灭"+str(self.attack)+"支部队"
enemy.hp-=self.attack
if enemy.hp>0:
info3=enemy.name+"还剩下"+str(enemy.hp)+"支部队"
info=info1+info2+info3
print(info)
else:
info3="和平! "+enemy.name+"被"+self.name+"傀儡"
info=info1+info2+info3
print(info)
class player(country):
def __init__(self,name,hp,attack):
super(player,self).__init__(name)
self.level=1
self.hp=hp
self.attack=attack
self.party_type="德意志民族社会主义工人党(法西斯主义)"
self.army_type="机动作战学说"
self.airforce_type="战场支援学说"
print("国家"+player.name+"作战指挥连接成功,国家政党为"+self.party_type+"陆军学说为"+self.army_type+"空军学说为"+self.airforce_type)
print("当前军队level,hp,attack分别为",self.level,self.hp,self.attack)
player=player("德意志国",350,50)
ger=country("德意志国",350,50)
sov=country("Soviet Union",600,20)
ger.upgrade()
print(player.hp)
print(sov.hp)
player.combat(sov)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment