コード例 #1
0
ファイル: shopmode.py プロジェクト: thingywhat/PotionWars
def select_gem_interpreter(keyEvent, testing=False):
    global partialNum, chosenPersonGem
    if keyEvent.key in NUMBER_KEYS:
        if len(gemList) < 10:
            num = int(pygame.key.name(keyEvent.key)) - 1
            if 0 <= num and num < len(gemList):
                global chosenPersonGem
                chosenPersonGem = gemList[num]
                if not testing:
                    select_equipment()
        else:
            partialNum += pygame.key.name(keyEvent.key)
            set_commands(['(#) Select Gem:' + str(partialNum) + '_', '<==Back'])
    elif keyEvent.key == K_BACKSPACE:
        if len(gemList) >= 10 and partialNum != '':
            partialNum = partialNum[:-1]
        elif litany is None:
            townmode.town_mode()
        else:
            shopkeeper.litany = litany
            conversation.converse_with(shopkeeper, townmode.town_mode)
    elif keyEvent.key == K_RETURN:
        if len(gemList) >= 10 and partialNum:
            try:
                chosenPersonGem = gemList[int(partialNum)-1]
            except IndexError:
                return
            else:
                if not testing:
                    select_equipment()
コード例 #2
0
ファイル: pwutilities.py プロジェクト: thingywhat/PotionWars
def trigger_event(nodeName, eventTitle):
    """
    Given the name of a conversation node, and the title of the desired dungeon event, begins the
    dungeon event.
    This should be called in every event function that needs to display automatically generated conversation nodes.
    """
    node = conversation.allNodeNames[nodeName]
    global maze
    maze.printedName = eventTitle
    maze.litany = node.index
    conversation.converse_with(maze, dungeonmode.dungeon_mode)
コード例 #3
0
ファイル: townmode.py プロジェクト: thingywhat/PotionWars
def talk_interpreter(keyEvent):
    global previousMode
    if keyEvent.key == K_BACKSPACE:
        if previousMode is None:
            previousMode = town_mode
        previousMode()
    elif keyEvent.key in NUMBER_KEYS:
        chosenNum = int(pygame.key.name(keyEvent.key)) - 1
        talkableCharacters = [c for cName, c in universal.state.location.characters.iteritems() if c and c not in person.get_party().members]
        if 0 <= chosenNum and chosenNum < len(talkableCharacters):
            conversation.converse_with(talkableCharacters[chosenNum], town_mode)
コード例 #4
0
ファイル: shopmode.py プロジェクト: thingywhat/PotionWars
def shop_interpreter(keyEvent):
    if keyEvent.key == K_b: 
        window_shop() 
    elif keyEvent.key == K_s:
        window_sell()
    elif keyEvent.key == K_BACKSPACE:
        if litany is None:
            townmode.town_mode()
        else:
            shopkeeper.litany = litany
            say_title(universal.state.location.name)
            conversation.converse_with(shopkeeper, townmode.town_mode)
コード例 #5
0
ファイル: shopmode.py プロジェクト: thingywhat/PotionWars
def select_equipment_interpreter(keyEvent, testing=False):
    global partialNum, chosenEquipment
    if keyEvent.key in NUMBER_KEYS:
        if len(equipmentList) < 10:
            num = int(pygame.key.name(keyEvent.key)) - 1
            if 0 <= num and num < len(equipmentList):
                global chosenEquipment
                chosenEquipment = equipmentList[num][1]
                gem = chosenPersonGem[1]
                maxEnchantment = chosenEquipment.maxEnchantment
                enchantmentLevel = chosenEquipment.enchantment_level()
                if maxEnchantment - enchantmentLevel < gem.cost:
                    universal.say(' '.join(["Cannot enchant", chosenEquipment.name, "with", 
                        gem.name + ".", gem.name, "requires", str(gem.cost), "enchantment points,",
                        "but", chosenEquipment.name, "only has", str(maxEnchantment - 
                            enchantmentLevel), "points available."]))
                    universal.acknowledge(select_equipment, ())
                else:
                    if not testing:
                        confirm_enchantment()
        else:
            partialNum += pygame.key.name(keyEvent.key)
            set_commands(['(#) Select Equipment:' + str(partialNum) + '_', '<==Back'])
    elif keyEvent.key == K_BACKSPACE:
        if len(equipmentList) >= 10 and partialNum != '':
            partialNum = partialNum[:-1]
        elif litany is None:
            townmode.town_mode()
        else:
            shopkeeper.litany = litany
            conversation.converse_with(shopkeeper, townmode.town_mode)
    elif keyEvent.key == K_RETURN:
        if len(equipmentList) < 10 and partialNum:
            try:
                chosenEquipment = equipmentList[int(partialNum)-1][1]
            except IndexError:
                return
            else:
                gem = chosenPersonGem[1]
                maxEnchantment = chosenEquipment.maxEnchantment
                enchantmentLevel = chosenEquipment.enchantment_level()
                if maxEnchantment - enchantmentLevel < gem.cost:
                    universal.say(' '.join(["Cannot enchant", chosenEquipment.name, "with", 
                        gem.name + ".", gem.name, "requires", str(gem.cost), "enchantment points,",
                        "but", chosenEquipment.name, "only has", str(maxEnchantment - 
                            enchantmentLevel), "points available."]))
                    universal.acknowledge(select_equipment, ())
                else:
                    if not testing:
                        confirm_enchantment()
コード例 #6
0
ファイル: shopmode.py プロジェクト: thingywhat/PotionWars
def done_shopping():
    if litany is None:
        townmode.town_mode()
    else:
        shopkeeper.litany = litany
        conversation.converse_with(shopkeeper, townmode.town_mode)