本文整理汇总了Python中state.State.game_state["party"]方法的典型用法代码示例。如果您正苦于以下问题:Python State.game_state["party"]方法的具体用法?Python State.game_state["party"]怎么用?Python State.game_state["party"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类state.State
的用法示例。
在下文中一共展示了State.game_state["party"]方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fight_monsters
# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import game_state["party"] [as 别名]
def fight_monsters(self):
print("Enemies Appear!")
import sys
import inspect
monster_list = []
for name, obj in inspect.getmembers(sys.modules['monsters']):
if inspect.isclass(obj) and obj != classes.Character:
monster_list.append(obj)
cur_state = State()
cur_state.load_quicksave()
party = cur_state.game_state["party"]
avg_lvl = math.floor(sum(char.level for char in party)/len(party))
enemies = []
num_enemies = self.get_num_enemies()
for x in range(0, num_enemies):
enemies.append(random.choice(monster_list)(avg_lvl))
all_combatants = party + enemies
self.battle(all_combatants)
cur_state.game_state["party"] = party
示例2: battle
# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import game_state["party"] [as 别名]
def battle(self, all_combatants):
all_combatants = self.turn_order(all_combatants)
party_alive = True
enemies_alive = True
while party_alive and enemies_alive:
cur_party = []
cur_enemies = []
print()
print("*-------------------*")
for char in all_combatants:
print("{}'s HP: {} / MP: {}".format(char.name, char.cur_stats['health'], char.cur_stats['mana']))
print("Stats: {}".format(char.cur_stats))
print("Effects: {}".format(char.effects))
if issubclass(char.__class__, monsters.classes.Monster):
cur_enemies.append(char)
else:
cur_party.append(char)
print("*-------------------*")
print()
for cur_char in all_combatants:
for idx, cur_effect in enumerate(cur_char.effects):
self.init_effect(cur_char, idx)
print("{}'s Turn".format(cur_char.name))
if issubclass(cur_char.__class__, monsters.classes.Monster):
self.basic_attack(cur_char, self.get_random_target(cur_party))
else:
self.get_character_action(cur_char, cur_party, cur_enemies)
party_alive = self.check_health(cur_party)
if not party_alive:
break
enemies_alive = self.check_health(cur_enemies)
if not enemies_alive:
break
if not party_alive and enemies_alive:
print("You're party has died...")
elif not enemies_alive and party_alive:
print("All enemies have been defeated!")
for character in cur_party:
self.calculate_experience(character, cur_enemies)
self.take_loot(cur_enemies)
for enemy in cur_enemies:
del enemy
del cur_enemies
cur_state = State()
cur_state.load_quicksave()
cur_state.game_state["party"] = cur_party
cur_state.save_cur_state()