本文整理匯總了Python中alien.Alien.attack方法的典型用法代碼示例。如果您正苦於以下問題:Python Alien.attack方法的具體用法?Python Alien.attack怎麽用?Python Alien.attack使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類alien.Alien
的用法示例。
在下文中一共展示了Alien.attack方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: human_battle
# 需要導入模塊: from alien import Alien [as 別名]
# 或者: from alien.Alien import attack [as 別名]
def human_battle():
human = Human()
alien = Alien()
print("There is an alien in front of you")
action = input("What will you do run to bunker or shot it? (run / shoot): ")
while human.distance > 0 or human.health > 0 or alien.lifeForce > 0:
if action == "run":
human.run()
alien.attack(human)
elif action == "shoot":
human.attack(alien)
alien.attack(human)
if human.distance == 0:
print("You made it to the bunker!")
print("The Game is now over!")
break
elif human.health == 0:
print("The Alien kills you!")
print("The Game is now over!")
break
elif alien.lifeForce == 0:
print("You killed the Alien!")
print("The Game is now over!")
break
print("Distance to bunker is: " + str(human.distance) + " feet!")
print("Human Life is: " + str(human.health))
print("Alien life is: " + str(alien.lifeForce))
action = input("What will you do run to bunker or shot it? (run / shoot) ")