本文整理汇总了Python中fight.Fight.fight方法的典型用法代码示例。如果您正苦于以下问题:Python Fight.fight方法的具体用法?Python Fight.fight怎么用?Python Fight.fight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fight.Fight
的用法示例。
在下文中一共展示了Fight.fight方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: hero_attack
# 需要导入模块: from fight import Fight [as 别名]
# 或者: from fight.Fight import fight [as 别名]
def hero_attack(self, by=""):
if by == 'weapon' and self.hero.weapon is None:
raise Exception("Hero cannot attack by weapon")
if by == 'spell' and self.hero.spell is None:
raise Exception("Hero cannot attack by spell")
if by == 'spell' and self.hero.spell is not None:
for i in range(self.__coords[1]+1, self.__coords[1]+1+self.hero.spell.cast_range**2):
try:
print(self.map[self.__coords[0]][i], self.__coords[1], self.__coords[1]+1+self.hero.spell.cast_range**2)
if self.map[self.__coords[0]][i] == Dungeon.WALKABLE_PATH:
continue
elif self.map[self.__coords[0]][i] == Dungeon.ENEMY:
print("A fight is started between our {} and {}".format(repr(self.hero), repr(self.enemy)))
f = Fight(self.hero, self.enemy)
f.fight(self.hero.weapon_to_fight())
break
print("Nothing in casting range {}".format(self.hero.spell.cast_range))
return False
except IndexError:
break
if by == 'weapon' and self.hero.weapon is not None:
print("A fight is started between our {} and {}".format(repr(self.hero), repr(self.enemy)))
Fight(self.hero, self.enemy).fight(self.hero.weapon_to_fight())
return True
示例2: attack
# 需要导入模块: from fight import Fight [as 别名]
# 或者: from fight.Fight import fight [as 别名]
def attack(self, req, replysock):
# assume we're attacking the first enemy
loc = self.places[req.location]
user = self.users[req.user]
if len(loc.enemies) == 0:
replysock.send('/attack No enemies to attack')
else:
enemy = loc.enemies[0]
fight = Fight(user, enemy, self.event_pub, ['player-' + user.name])
winner = fight.fight()
if winner != enemy:
loc.enemies.remove(enemy)
loc.dead.append(enemy)
replysock.send('/attack {0} wins'.format(winner.name))