当前位置: 首页>>代码示例>>Python>>正文


Python Fight.fight方法代码示例

本文整理汇总了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
开发者ID:animilh,项目名称:Dungeons-and-Pythons,代码行数:30,代码来源:dungeon.py

示例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))
开发者ID:dantheta,项目名称:cursesfrp,代码行数:16,代码来源:request.py


注:本文中的fight.Fight.fight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。