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


Python State.load_quicksave方法代码示例

本文整理汇总了Python中state.State.load_quicksave方法的典型用法代码示例。如果您正苦于以下问题:Python State.load_quicksave方法的具体用法?Python State.load_quicksave怎么用?Python State.load_quicksave使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在state.State的用法示例。


在下文中一共展示了State.load_quicksave方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: sell_item

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import load_quicksave [as 别名]
    def sell_item():
        cur_state = State()
        ins_state = cur_state.load_quicksave()
        player = ins_state['player']
        player_inventory = player.inventory
        cur_state.save_cur_state()

        if len(player_inventory) == 0:
            print("Your inventory is empty!")
            return
        idx = 0
        for idx, val in enumerate(player_inventory):
            print("[{}] {}".format((idx+1), val))
        print("[{}] Go Back".format(idx+2))
        print("------")
        print()

        item_idx = input("Which item do you want to sell? ")
        print("------")
        print()
        item_keys = ["{}".format(x) for x in range(1, len(player_inventory)+2)]
        if item_idx in item_keys:
            if int(item_idx) == len(player_inventory)+1 \
                    or item_idx == 'exit' \
                    or item_idx == 'back':
                return

            print("Sold: {}".format(player_inventory[int(item_idx)-1]))
            cur_state = State()
            ins_state = cur_state.load_quicksave()
            player = ins_state['player']
            player.gold += (player_inventory[int(item_idx)-1].value * 0.7)
            player.inventory.pop(int(item_idx)-1)
            cur_state.save_cur_state()
            print()
开发者ID:aqisnotliquid,项目名称:python_rpg,代码行数:37,代码来源:navigation.py

示例2: buy_item

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import load_quicksave [as 别名]
    def buy_item(self):
        cur_state = State()
        ins_state = cur_state.load_quicksave()
        player = ins_state['player']
        player_gold = player.gold
        cur_state.save_cur_state()

        self.print_inventory()
        print("[{}] Go Back".format(len(self.inventory)+1))
        print("------")
        print()

        item_idx = input("Which item do you want? ")
        item_keys = ["{}".format(x) for x in range(1, len(self.inventory)+2)]
        if item_idx in item_keys:
            if int(item_idx) == len(self.inventory)+1 \
                    or item_idx == 'exit' \
                    or item_idx == 'back':
                return

            if player_gold >= self.inventory[int(item_idx)-1].value:
                print("Bought: {}".format(self.inventory[int(item_idx)-1]))
                cur_state = State()
                ins_state = cur_state.load_quicksave()
                player = ins_state['player']
                player.gold -= self.inventory[int(item_idx)-1].value
                player.inventory.append(self.inventory[int(item_idx)-1])
                cur_state.save_cur_state()
            else:
                print("You can't afford that!")
            print()
开发者ID:aqisnotliquid,项目名称:python_rpg,代码行数:33,代码来源:navigation.py

示例3: fight_monsters

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import load_quicksave [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

示例4: take_loot

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import load_quicksave [as 别名]
    def take_loot(enemies):
        cur_state = State()
        cur_state.load_quicksave()
        player = cur_state.game_state["player"]

        for enemy in enemies:
            print("Gold dropped: {}".format(enemy.gold))
            player.gold += enemy.gold

        cur_state.save_cur_state()
开发者ID:aqisnotliquid,项目名称:python_rpg,代码行数:12,代码来源:combat.py

示例5: battle

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import load_quicksave [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

示例6: add_to_inv

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import load_quicksave [as 别名]
 def add_to_inv(item):
     from state import State
     cur_state = State()
     ins_state = cur_state.load_quicksave()
     player = ins_state['player']
     player_inventory = player.inventory
     player_inventory.append(item)
     cur_state.save_cur_state()
开发者ID:aqisnotliquid,项目名称:python_rpg,代码行数:10,代码来源:player.py

示例7: add_gold

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import load_quicksave [as 别名]
 def add_gold(amount):
     from state import State
     cur_state = State()
     ins_state = cur_state.load_quicksave()
     player = ins_state['player']
     player_gold = player.gold
     player_gold += amount
     cur_state.save_cur_state()
开发者ID:aqisnotliquid,项目名称:python_rpg,代码行数:10,代码来源:player.py

示例8: equip_item

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import load_quicksave [as 别名]
    def equip_item():
        from state import State
        cur_state = State()
        ins_state = cur_state.load_quicksave()
        player = ins_state['player']
        party = ins_state['party']
        player_inventory = player.inventory

        if len(player_inventory) == 0:
            print("Nothing to equip!")
            return

        print("Inventory: ")
        for idx, val in enumerate(player_inventory):
            print("[{}] {}".format(idx+1, val))
        print("------")
        print()

        item_idx = input("Which item do you want to equip? ")
        print("------")
        print()
        item_keys = ["{:01d}".format(x) for x in range(1, len(player_inventory)+1)]
        if item_idx in item_keys:
            print("Party: ")
            print()
            for idx, val in enumerate(party):
                print("[{}] {}".format(idx+1, val))
            print("------")
            print()
            party_idx = input("Who do you want to equip it to? ")
            print("------")
            print()
            party_keys = ["{:01d}".format(x) for x in range(1, len(player_inventory)+1)]
            if party_idx in party_keys:
                cur_character = party[int(party_idx)-1]
                cur_character.equip_item(player_inventory[int(item_idx)-1], party_idx)

                cur_state = State()
                ins_state = cur_state.load_quicksave()
                player = ins_state['player']
                player_inventory = player.inventory
                player_inventory.pop(int(item_idx)-1)
                cur_state.save_cur_state()

        cur_state.save_cur_state()
开发者ID:aqisnotliquid,项目名称:python_rpg,代码行数:47,代码来源:player.py

示例9: main

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import load_quicksave [as 别名]
def main():
    cur_state = State()
    if not cur_state.game_state:
        cur_state.main_menu()

    player = cur_state.game_state['player']
    player_location = player.location

    party = cur_state.game_state['party']
    party_status = False
    for character in party:
        if character.cur_stats['health'] > 0:
            party_status = True

    while party_status:
        current_location = getattr(navigation, player_location.replace(" ", ""))()

        action_input = input('Choose an action: ')
        available_actions = current_location.available_actions()
        found_action = False
        for action in available_actions:
            if action_input.lower() == 'exit':
                sys.exit()

            if (action_input.lower() == action.hotkey.lower()) or \
                    (action_input.lower() in [a.lower() for a in action.alt]):
                os.system('clear')  # For OSX / Linux
                os.system('cls')  # For Windows
                found_action = True
                actions.do_action(action, action.action_class, **action.kwargs)
                break
        if not found_action:
            os.system('clear')  # For OSX / Linux
            os.system('cls')  # For Windows

        cur_state = State()
        cur_state.load_quicksave()
        player = cur_state.game_state['player']
        player_location = player.location
        cur_state.save_game()
开发者ID:aqisnotliquid,项目名称:python_rpg,代码行数:42,代码来源:pyrpg.py

示例10: print_inventory

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import load_quicksave [as 别名]
    def print_inventory():
        from state import State
        cur_state = State()
        ins_state = cur_state.load_quicksave()
        player = ins_state['player']

        print("Gold: {}".format(player.gold))
        print("Inventory: ")
        if len(player.inventory) == 0:
            print("None")
        else:
            for item in player.inventory:
                print(item, '\n')
        print("------")
        print()
开发者ID:aqisnotliquid,项目名称:python_rpg,代码行数:17,代码来源:player.py

示例11: equip_item

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import load_quicksave [as 别名]
    def equip_item(item, party_member):
        from state import State
        cur_state = State()
        ins_state = cur_state.load_quicksave()
        player = ins_state['player']
        player_inventory = player.inventory

        party = ins_state['party']
        character = party[int(party_member)-1]

        if issubclass(type(item), weapons.Weapon):
            player_inventory.append(character.weapon)
            character.weapon = item
        else:
            player_inventory.append(character.armor)
            character.armor = item

        cur_state.save_cur_state()
开发者ID:aqisnotliquid,项目名称:python_rpg,代码行数:20,代码来源:classes.py

示例12: rest

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import load_quicksave [as 别名]
    def rest():
        from state import State
        from time import sleep
        cur_state = State()
        ins_state = cur_state.load_quicksave()
        party = ins_state['party']

        print(".")
        sleep(0.5)
        print(".")
        sleep(0.5)
        print(".")

        for idx, val in enumerate(party):
            val.cur_stats = val.stats
            val.effects = []

        print("Your party has been healed!")
        print()

        cur_state.save_cur_state()
开发者ID:aqisnotliquid,项目名称:python_rpg,代码行数:23,代码来源:player.py

示例13: change_location

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import load_quicksave [as 别名]
 def change_location(location):
     cur_state = State()
     ins_state = cur_state.load_quicksave()
     player = ins_state['player']
     player.location = location
     cur_state.save_cur_state()
开发者ID:aqisnotliquid,项目名称:python_rpg,代码行数:8,代码来源:navigation.py

示例14: get_party_level

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import load_quicksave [as 别名]
 def get_party_level():
     cur_state = State()
     ins_state = cur_state.load_quicksave()
     party = ins_state['party']
     return math.floor(sum(char.level for char in party)/len(party))
开发者ID:aqisnotliquid,项目名称:python_rpg,代码行数:7,代码来源:navigation.py

示例15: use_item

# 需要导入模块: from state import State [as 别名]
# 或者: from state.State import load_quicksave [as 别名]
    def use_item(self, character, party, enemies):
        cur_state = State()
        cur_state.load_quicksave()

        player = cur_state.game_state["player"]
        player_inventory = player.inventory

        for idx, val in enumerate(player_inventory):
            if player_inventory[idx].item_type == "Equipment":
                player_inventory.pop(idx)

        if len(player_inventory) == 0:
            print("Your inventory is empty!")
            self.get_character_action(character, party, enemies)

        for idx, val in enumerate(player_inventory):
            print("[{}] {}".format((idx+1), val))

        print("[{}] Go Back".format(len(player_inventory)+1))
        print("------")
        print()

        item_idx = input("Which item do you want to use? ")
        print("------")
        print()
        item_keys = ["{}".format(x) for x in range(1, len(player_inventory)+2)]
        if item_idx in item_keys:
            if int(item_idx) == len(player_inventory)+1 \
                    or item_idx == 'exit' \
                    or item_idx == 'back':
                return None

            os.system('clear')  # For OSX / Linux
            os.system('cls')  # For Windows

            cur_item = player_inventory[int(item_idx)-1]

            if cur_item.default_target == 'enemy':
                target_options = enemies
            else:
                target_options = party

            target = self.pick_target(target_options)
            if target is None:
                return None

            if cur_item.effect.scale_type == 'percent':
                effectiveness = target.stats[cur_item.effect.stat] * (cur_item.effect.amount / 100)
                target.cur_stats[cur_item.effect.stat] += effectiveness
            else:
                effectiveness = cur_item.effect.amount
                target.cur_stats[cur_item.effect.stat] += effectiveness

            if int(effectiveness) < 0:
                print("{} did {} damage with {}!".format(character.name, abs(effectiveness), cur_item))
            else:
                print("{} healed for {} with {}!".format(character.name, effectiveness, cur_item))

            if cur_item.effect.turns > 1:
                cur_item.effect.turns -= 1
                target.effects.append(cur_item.effect)

            player_inventory.pop(int(item_idx)-1)

        cur_state.save_cur_state()

        return True
开发者ID:aqisnotliquid,项目名称:python_rpg,代码行数:69,代码来源:combat.py


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