Example #1
0
    def buy_items(self, party):
        if len(self.items) == 0:
            input('Shop has no items for sale.')
            return

        print('------------- Shop items ------------------------------')
        for i in range(len(self.items)):
            print('[%i] %s' % (i, self.items[i].shop_list()))

        print()
        print('Party has %i gold' % party.party_gold())
        selection = -1
        while selection not in range(len(self.items)):
            stream = input('Choose item number to buy: ').rstrip()
            if isInt(stream):
                selection = int(stream)
        item = self.items[selection]

        num = -1
        # plus one because human vs computer counting
        while num not in range(item.num + 1):
            stream = input('Buy how many? ').rstrip()
            if isInt(stream):
                num = int(stream)

        buyItem = item.copy(num)
        buyItem.set_num(num)
        if party.get_gold() >= buyItem.total_value():
            party.buy_item(buyItem)
            self.items[selection].shop_sell(num)
        else:
            input('Not enough gold to buy.')
Example #2
0
def get_item_target(user, targetParty):
    print()
    for i in range(len(targetParty)):
        print('[%i] %s' % (i, targetParty[i]))
    target = -1
    while target not in range(len(targetParty)):
        stream = input('Choose target number for %s: ' % user.name).rstrip()
        if isInt(stream):
            target = int(stream)
    print()
    return targetParty[target]
Example #3
0
 def choose_battle_item(self, user):
     print('------------- Items -----------------------------------')
     itms = list(self.inventory.keys())
     for i in range(len(itms)):
         if self.inventory[itms[i]].isBattleItem:
             print('[%i] %s' % (i, self.inventory[itms[i]]))
     selection = -1
     while selection not in range(len(itms)):
         stream = input('Choose item number for %s: ' % user.name).rstrip()
         if isInt(stream):
             selection = int(stream)
     return self.inventory[itms[selection]]
 def choose_heal(self):
     hls = list(self.heals.keys())
     print('------------- Heals -----------------------------------')
     for i in range(len(hls)):
         print('[%i] %s' % (i, self.heals[hls[i]]))
     selection = -1
     while selection not in range(len(hls)):
         stream = input('Choose attack number for %s: ' %
                        self.name).rstrip()
         if isInt(stream):
             selection = int(stream)
     print('\n%s used %s!' % (self.name, hls[selection]))
     return self.heals[hls[selection]]
Example #5
0
    def sell_items(self, party):
        if len(party.inventory) == 0:
            input('Party has no items to sell.')
            return

        items = list(party.inventory.keys())
        print('------------- Party items -----------------------------')
        for i in range(len(items)):
            print('[%i] %s' % (i, party.inventory[items[i]]))
            selection = -1
        while selection not in range(len(items)):
            stream = input('Choose item number to sell: ').rstrip()
            if isInt(stream):
                selection = int(stream)
        sellItem = party.inventory[items[selection]]

        num = -1
        while num not in range(sellItem.num + 1):
            stream = input('Sell how many? ').rstrip()
            if isInt(stream):
                num = int(stream)
        party.sell_item(sellItem, num)
    def choose_attack(self):
        atks = list(self.attacks.keys())
        print('------------- Attacks ---------------------------------')
        for i in range(len(atks)):
            print('[%i] %s' % (i, self.attacks[atks[i]]))
        selection = -1
        while selection not in range(len(atks)):
            stream = input('Choose attack number for %s: ' %
                           self.name).rstrip()
            if isInt(stream):
                selection = int(stream)
        print('\n%s used %s!' % (self.name, atks[selection]))

        return self.attacks[atks[selection]]
Example #7
0
def get_players_target(user, targetParty):
    party = targetParty.get_alive_members()
    defendingPlayers = targetParty.get_defending_members()
    if defendingPlayers:
        party = defendingPlayers
    print()
    for i in range(len(party)):
        print('[%i] %s' % (i, party[i]))
    target = -1
    while target not in range(len(party)):
        stream = input('Choose target number for %s: ' % user.name).rstrip()
        if isInt(stream):
            target = int(stream)
    print()
    return party[target]
def choose_campaign(party):
    campaigns = ['Orc Hideout', 'Enemy Hell']
    print()
    print('------------- Campaigns -------------------------------')
    for i in range(len(campaigns)):
        print('[%i] %s' % (i, campaigns[i]))

    choice = -1
    while choice not in range(len(campaigns)):
        stream = input('Choose campaign number: ').rstrip()
        if isInt(stream):
            choice = int(stream)

    campaign = campaigns[choice]

    if campaign == 'Orc Hideout':
        orc_hideout(party)
    if campaign == 'Enemy Hell':
        enemy_hell(party)
Example #9
0
def new_character():

    for i in range(len(classes)):
        print('[%i] %s' % (i, classes[i]))
    selection = -1
    while selection not in range(len(classes)):
        stream = input('Choose number of class: ').rstrip().lower().title()
        if isInt(stream):
            selection = int(stream)

    choice = classes[selection]
    name = input('Name your %s: ' % choice)

    if choice == 'Warrior':
        return Warrior(name)
    if choice == 'Mage':
        return Mage(name)
    if choice == 'Sage':
        return Sage(name)
    if choice == 'Berserker':
        return Berserker(name)
Example #10
0
def choose_save():
    listFile = '.saveList.txt'
    saves = []

    if not os.path.isfile(listFile):
        input('No saves found, creating new save.')
        return new_party()
    with open(listFile) as f:
        for line in f:
            saves.append(line.rstrip())
        f.close()
    print('------------- Saves -----------------------------------')
    for i in range(len(saves)):
        print('[%i] %s' % (i, saves[i]))

    saveNum = -1
    while saveNum not in range(len(saves)):
        stream = input('Load save number: ').rstrip()
        if isInt(stream):
            saveNum = int(stream)

    return load_party(saves[saveNum])