本文整理汇总了Python中hero.Hero.setMana方法的典型用法代码示例。如果您正苦于以下问题:Python Hero.setMana方法的具体用法?Python Hero.setMana怎么用?Python Hero.setMana使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hero.Hero
的用法示例。
在下文中一共展示了Hero.setMana方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GameController
# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import setMana [as 别名]
class GameController(object):
def __init__(self):
self.player = None
self.monster = None
self.steps = 0
def intro(self):
self.potions = Potions(None)
print "Are you ready to start? Press any button!"
raw_input("Press Enter to continue...")
self.createHero()
print "***********************"
print "Welcome " + self.player.getHeroName() + " the " + self.player.getHeroClass() + "!"
self.gameplay()
def gameplay(self):
print "***********************"
print "Your HP is " + str(self.player.getHp()) + " and your mana is " + str(self.player.getMana())+"."
print "***********************"
while True:
print "What do you want to do?"
print "1.Walk 2.Look around 3.Sleep 4.Check stats 5.Exit"
nextMove = raw_input("Choose a number between 1-5: ")
if nextMove == str(1):
self.walk()
elif nextMove == str(2):
self.look(self.steps)
elif nextMove == str(3):
selfsleep()
elif nextMove == str(4):
print "Your HP is " + str(self.player.getHp()) + " and your mana is " + str(self.player.getMana())+"."
elif nextMove == str(5):
print "Bye!"
return False
def createHero(self):
name = raw_input("Whats your heros name? ")
print "***********************"
print "What kind of hero do you want to be?"
print "1. Knight 2.Wizard 3.Paladin"
while True:
heroKind = raw_input("Choose the number of the kind of hero you want to be: ")
if heroKind == "1":
heroClass = "Knight"
hp = random.randint(100,120)
mana = random.randint(20,40)
break
elif heroKind == "2":
heroClass = "Wizard"
hp = random.randint(60,80)
mana = random.randint(100,120)
break
elif heroKind == "3":
heroClass = "Paladin"
hp = random.randint(80,100)
mana = random.randint(40,60)
break
else:
print "It needs to be a number between 1-3!"
print "1. Knight 2.Wizard 3.Paladin"
self.player = Hero(heroClass, name, hp, mana)
def walk(self):
self.steps = self.steps + 1
if self.steps == 10:
self.steps = 0
roll = random.randint(1,10)
if roll == 1:
print "You find a health potion!"
newHp = self.potions.healingPotion(10, self.player.getHp())
self.player.setHp(newHp)
art.bottleHealth()
print "***********************"
print "Your new HP is: " + str(self.player.getHp())
print "***********************"
elif roll == 2:
print "You find a mana potion!"
newMana = self.potions.manaPotion(10, self.player.getMana())
self.player.setMana(newMana)
art.bottleMana()
print "***********************"
print "Your new mana is: " + str(self.player.getMana())
print "***********************"
elif 3 <= roll <=6:
print "***********************"
print "Oh shit a MONSTER!!!!"
print "***********************"
self.createMonster()
fight = Areas(self.monster,self.player)
fight.battleArena()
elif 7 <= roll <= 10:
print "***********************"
print "Nothing happen!"
print "***********************"
def createMonster(self):
monsterRoll = random.randint(1,3)
if monsterRoll == 1:
monsterKind = "Imp"
#.........这里部分代码省略.........