本文整理汇总了Python中hero.Hero.get_cast_range方法的典型用法代码示例。如果您正苦于以下问题:Python Hero.get_cast_range方法的具体用法?Python Hero.get_cast_range怎么用?Python Hero.get_cast_range使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hero.Hero
的用法示例。
在下文中一共展示了Hero.get_cast_range方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from hero import Hero [as 别名]
# 或者: from hero.Hero import get_cast_range [as 别名]
#.........这里部分代码省略.........
dungeon.spawn(dungeon.get_hero())
return dungeon
def print_map(self):
printable = ""
for row in range(self.__rows):
for col in range(self.__cols):
printable += (self.__map[row][col] + ' ')
printable += '\n'
printable = printable[:-1]
print(printable)
def spawn(self, hero):
weapon = Weapon("Fart gun", 50)
self.__hero.equip(weapon)
self.__hero_pos = 'E'
self.__hero_pos = self.__last_spawn
self.__hero_pos = (0, 0)
self.__map[self.__hero_pos[0]][self.__hero_pos[1]] = 'H'
self.print_map()
def hero_atack(self):
enemy = Enemy(health=random.randrange(50, 150),
mana=random.randrange(20, 100),
damage=random.randrange(20, 80))
# finding the enemy
distance = 0
curr_vec = 1
row = self.__hero_pos[0]
col = self.__hero_pos[1]
choices = []
range_to_enemy = 0
atack_range = self.__hero.get_cast_range()
if atack_range:
while row - curr_vec >= 0 and curr_vec <= atack_range:
if self.__map[row - curr_vec][col] == '#':
break
choices.append((row - curr_vec, col))
curr_vec -= 1
curr_vec = 1
while col + curr_vec < self.__cols and curr_vec <= atack_range:
if self.__map[row][col + curr_vec] == '#':
break
choices.append((row, col + curr_vec))
curr_vec += 1
curr_vec = 1
while row + curr_vec < self.__rows and curr_vec <= atack_range:
if self.__map[row + curr_vec][col] == '#':
break
choices.append((row + curr_vec, col))
curr_vec += 1
curr_vec = 1
while col - \
curr_vec >= 0 and curr_vec <= atack_range and self.__map[row][col - curr_vec] != '#':
if self.__map[row][col - curr_vec] == '#':
break
choices.append(row, col + curr_vec)
curr_vec -= 1
fight = Fight(self.__hero, enemy)