Commit 23f1c601 by BellCodeEditor

save project

parent a685abee
Showing with 80 additions and 0 deletions
import random
class country:
def __init__(self,name,hp,attack,population):
self.level=1
self.name=name
self.hp=hp
self.attack=attack
self.population=population
def upgrade(self):
if self.name=="德意志国":
self.level+=1
self.hp+=30
self.attack+=12
if self.name=="苏维埃联盟":
self.level+=1
self.hp+=45
self.attack+=6
if self.level==10:
self.level+=1
self.hp-=20
self.attack+=100
def Conscription(self):
if self.population>=50:
print(self.name+"重整并征召了部队,征召",50,"部队,目前还剩",self.hp,"支部队")
self.hp+=50
self.population-=50
else:
print(self.name,"无法征召人员","重整部队")
self.hp+=5
def combat(self,enemy):
info1 =self.name+"对"+enemy.name+"发起进攻"
if self.name=="德意志国" and self.level<=5:
info2 = "歼灭"+str(self.attack+20)+"支部队"
else:
info2 = "歼灭"+str(self.attack)+"支部队"
self.upgrade()
if self.name=="德意志国" and self.level<=5:
enemy.hp-=self.attack+20
else:
enemy.hp-=self.attack
if enemy.hp>0:
info3=enemy.name+"还剩下"+str(enemy.hp)+"支部队"
info=info1+info2+info3
print(info)
else:
if enemy.name=="德意志国":
enemy.name="德意志社会主义民主共和国"
else:
enemy.name="乌克兰地区专员辖区,俄罗斯地区专员辖区,东方地区专员辖区,远东地区专员辖区"
info3="和平! "+enemy.name+"被"+self.name+"傀儡"
info=info1+info2+info3
print(info)
exit()
class player(country):
pass
player=player("德意志国",350,50,400)
#ger=country("German Reich",350,50)
sov=country("苏维埃联盟",600,20,1000)
#ger.upgrade()
print("国家"+player.name+"作战指挥连接成功,国家政党为"+"德意志民族社会主义工人党(法西斯主义)"+"陆军学说为"+"机动作战学说"+"空军学说为"+"战场支援学说")
print("当前军队level,hp,attack分别为",player.level,player.hp,player.attack)
print("-"*30)
print("巴巴罗萨行动")
while 1:
print("-"*30)
choice=input("最高作战指令(1进攻/2征召)")
if choice=="1":
player.combat(sov)
elif choice=="2":
player.Conscription()
elif choice=="q":
exit()
else:
print("指令错误")
status=random.randint(1,3)
if status==1:
sov.Conscription()
else:
sov.combat(player)
\ No newline at end of file
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