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


Python State.game_state["party"]方法代码示例

本文整理汇总了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
开发者ID:aqisnotliquid,项目名称:python_rpg,代码行数:28,代码来源:combat.py

示例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()
开发者ID:aqisnotliquid,项目名称:python_rpg,代码行数:57,代码来源:combat.py


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