Ejemplo n.º 1
0
def goToVendor(vendor):
    global previousVendor
    previousVendor = vendor
    entities.player.location = entities.getLocation('Market')
    entities.player.location.entity = vendor
    print('%s\nItems for sale:' % vendor.message)
    vendor.say(vendor.goods)
    while True:
        command = input('Market > %s : ' % vendor.name).split(' ')
        thingToBuy = None
        buying = False
        for good in vendor.goods:
            if good.name == command[0]:
                thingToBuy = good
                buying = True
                break
        if buying:
            entities.player.inventory.append(thingToBuy)
            entities.player.spend(thingToBuy.cost)
            print('%s purchased for %s money.' % (thingToBuy.name, thingToBuy.cost))
        elif command[0].upper() == 'INFO':
            thingToGetInfoOn = command[1]
            itemInShop = False
            for item in vendor.goods:
                if item.name == thingToGetInfoOn:
                    itemInShop = True
                    break
            if not itemInShop:
                print('Item not found.')
            else:
                if isinstance(item, obj.Weapon):
                    print('Power: %s' % item.power)
                elif isinstance(item, obj.Food):
                    print('Healing power: %s' % item.hp)
                print('Description: ' + item.description)
        elif command[0].upper() == 'EXIT':
            print('You left the store.')
            entities.player.location.entity = entities.getLocation('Main')
            return
        elif command[0].upper() == 'HELP':
            entities.getHelpMsg('Market').printMsg()
        elif command[0].upper() == 'MONEY':
            print(entities.player.money + ' coins')
        else:
            print('Command not found.')
Ejemplo n.º 2
0
def execute(command):
    if command[0] == '?' or command[0].upper() == 'HELP':
        print('Possible commands:')
        entities.getHelpMsg('Main').printMsg()
    elif command[0].upper() == 'GOTO':
        if command[1].upper() == 'INTERACT':
            locations.personInteraction()
        elif command[1].upper() == 'MARKET':
            print('Going to market...')
            locations.market()
        elif command[1].upper() == 'INVENTORY':
            print('Entering Inventory...')
            locations.inventory()
        elif command[1].upper() == 'MEMORY':
            locations.memory()
        else:
            print('Location not found.')
    else:
        print('Command not found. Type "help" or "?" for help.')
Ejemplo n.º 3
0
def inventory():
    entities.player.location = entities.getLocation('Inventory')
    while True:
        command = input('Inventory : ').split(' ')
        if command[0] == '?' or command[0].upper() == 'HELP':
            entities.getHelpMsg('Inventory').printMsg()
        elif command[0].upper() == 'LIST':
            if len(command) > 1:
                if command[1].upper() == 'WEAPONS':
                    utils.listItems(listedItems=entities.player.inventory, objType=obj.Weapon)
                elif command[1].upper() == 'FOOD':
                    utils.listItems(listedItems=entities.player.inventory, objType=obj.Food)
                elif command[1].upper() == 'HEALTH':
                    print(entities.player.health)
                elif command[1].upper() == 'MONEY':
                    print(entities.player.money)
                else:
                    print('Usage: list\nlist <type>')
            else:
                utils.listItems(listedItems=entities.player.inventory)
        elif command[0].upper() == 'EAT':
            failed = False
            for item in entities.player.inventory:
                if item.name.upper() == command[1].upper():
                    if isinstance(item, obj.Food):
                        entities.player.inventory.remove(item)
                        entities.player.health += item.hp
                        print('%s points added to health!' % item.hp)
                        failed = False
                        break
            if failed:
                print('Food not in Inventory.')

        elif command[0].upper() == 'EXIT':
            print('You left your Inventory.')
            break

        else:
            print('Inventory command "' + command[0] + '" not found. Type "help" for help.')