예제 #1
0
def delete_hero_loop():
    print('Here we delete a hero')
    delete_loop = True
    while delete_loop:
        present = DM.show_all_heroes()
        if present == False:
            print('Sorry, there are no Heros as you can see.')
            break
        else:
            to_delete = input(
                'Which Hero do you want to delete? Enter it\'s name.')
            while True:
                y_o_n = input(
                    'You are trying to delete {}, is that the record you mean to delete?'
                    .format(to_delete))
                if y_o_n.lower() == 'y' or y_o_n.lower == 'yes':
                    try:
                        this_record = Hero_Model.get(
                            Hero_Model.name.startswith(to_delete))
                    except DoesNotExist:
                        print('That Hero Does not exist.')
                        delete_loop = False
                        break
                    this_record.delete_instance()
                    # TODO: Make sure that if there are no records at all this either stops or doesn't begin at all.
                    delete_loop = False
                    break
                else:
                    print('The delete was aborted.')
                    break
예제 #2
0
def insert_merchant_loop():
    print('Here we insert a merchant')
    name = input('Give the merchant a name')
    while True:
        try:
            max_hp = int(input('What is the merchants maximum HP?'))
            if max_hp < 1:
                print('Value has to be greater than 0')
            else:
                break
        except ValueError:
            print('It has to be an Integer value.')
    while True:
        try:
            armor = int(input('What is the merchants Armor? Minimum of 0.'))
            if armor < 0:
                print(' Invalid value, it has to be 0 or greater.')
            else:
                break
        except ValueError:
            print('Armor value has to be an integer.')
    while True:
        try:
            money = int(
                input(
                    'How much Money does the merchant have? Minimum of 500.'))
            if money < 500:
                print(' Remember, the value has to be 500 minimum.')
            else:
                break
        except ValueError:
            print('Money value has to be an integer.')
    while True:
        try:
            #probably it needs to be expanded to add more than two items
            inventory = inventory.add_item(
                input('What is the merchant carrying?'))
            y_o_n = input('Do you want to add another item?')
            if y_o_n.lower() == 'y' or y_o_n.lower == 'yes':
                inventory = inventory.add_item(
                    input('What is the merchant carrying?'))
        except ValueError:
            print('We got an error')
    new_merchant = Merchant(name, money)
    new_merchant.set_armor_max_hp(armor, max_hp)
    DM.add_merchant(new_merchant)
예제 #3
0
def login_loop():
    make_default_admin()
    valid_or_not = False
    while valid_or_not == False:
        admin_displays.display_admin_login()
        u_name = input('Please enter your username.\n')
        pw = input('Please enter your password\n')
        valid_or_not = DM.check_for_admin_priveleges(u_name, pw)
    admin_db()
예제 #4
0
def delete_merchant_loop():
    print('Here we Delete a merchant')
    delete_loop = True
    while delete_loop:
        DM.show_all_merchants()
        to_delete = input(
            'Which merchant do you want to delete? Enter the name of the merchant.'
        )
        while True:
            y_o_n = input(
                'You are trying to delete {}, is that the record you mean to delete?'
                .format(to_delete))
            if y_o_n.lower() == 'y' or y_o_n.lower == 'yes':
                this_record = Merchant_Model.get(
                    Merchant_Model.name.startswith(to_delete))
                this_record.delete_instance()
                delete_loop = False
                break
            else:
                print('Couldnt perform the delete operation.')
                break
예제 #5
0
def delete_monster_loop():
    print('Here we Delete a monster')
    # Call the show monster function from db.py
    delete_loop = True
    while delete_loop:
        DM.show_all_monsters()
        to_delete = input(
            'Which monster do you want to delete? Enter it\'s name.')
        while True:
            y_o_n = input(
                'You are trying to delete {}, is that the record you mean to delete?'
                .format(to_delete))
            if y_o_n.lower() == 'y' or y_o_n.lower == 'yes':
                this_record = Monster_Model.get(
                    Monster_Model.name.startswith(to_delete))
                this_record.delete_instance()
                # TODO: Make sure that if there are no records at all this either stops or doesn't begin at all.
                delete_loop = False
                break
            else:
                print('The delete was aborted.')
                break
예제 #6
0
    def battle_time(self, hero):
        # get a monster from the list, remove it so if it dies it is gone

        if len(self.all_monsters) == 0:
            self.all_monsters = DM.generate_monster_list(self.hero)
        try:
            self.monster = self.all_monsters.pop()
        except IndexError:
            print('out of monsters')
            self.hero.state = self.hero.states[4]
        # set to combat state so graphics will change
        self.hero.state = self.hero.states[1]
        list_of_participants = [self.hero, self.monster]
        shuffle(list_of_participants)
        # TODO: send a call to Text_Manager to display the combat options

        # While they both have life, keep battle going
        while self.hero.current_hp >= 1 and self.monster.current_hp >= 1:
            round_counter = 0
            # for each person in combat, let them take their turn
            for participant in list_of_participants:
                if hero.state == 'flee':
                    self.all_monsters.append(self.monster)
                    # randomize again
                    shuffle(self.all_monsters)
                    break
                else:
                    # This variable is for implementatino of potions and special attacks (since they last a limited time)
                    # THERE IS A LOOP THAT IS GOING FOREVER
                    self.take_a_turn(participant)
                    round_counter += 1
            #         if you are dead... exit combat after calling a HighScoreSave() method
        if self.hero.current_hp <= 0:
            # TODO: this becomes a call to text_manager --> GAME OVER SCREEN
            '''hero state set for game over mode'''
            hero.state = hero.states[3]
            '''This part here will be where the hall of fame stuff happens.  To be figured out later.
            My need to add 'state' to the DB in order to track who has died and who hasnt.'''
        #     If the monster is dead, get that cash and xp
        if self.monster.current_hp <= 0:
            self.hero.gain_xp(self.monster.xp_val)
            self.hero.money += self.monster.money
            # reset game_state to explore
            self.hero.state = hero.states[0]
예제 #7
0
 def __init__(self, hero):
     self.hero = hero
     self.all_monsters = DM.generate_monster_list(hero)
     self.monster = None
     self.clock = pg.time.Clock()
예제 #8
0
def insert_monster_loop():
    print('Here we insert a monster')
    name = input('Please Give Monster Name')
    while True:
        try:
            max_hp = int(input('What is the monsters Max HP? Minimum of 1.'))
            if max_hp < 1:
                print('That was not greater than 0')
            else:
                break
        except ValueError:
            print('Sorry that was not an Integer.')
    while True:
        try:
            strength = int(
                input('what is this monsters strength? Minimum is 1.'))
            if strength < 1:
                print('Sorry that was not 1 or greater.')
            else:
                break
        except ValueError:
            print('Sorry, that wasn\'t a Integer.')
    while True:
        try:
            armor = int(input('What is the monsters Armor? Minimum of 0.'))
            if armor < 0:
                print(' That was an invalid number, positive numbers only.')
            else:
                break
        except ValueError:
            print('Sorry that was not an Integer.')
    while True:
        try:
            xp_val = int(input('What is the monsters XP Value? Minimum of 1.'))
            if xp_val < 0:
                print(
                    ' That was an invalid number, positive numbers only, greater than 0.'
                )
            else:
                break
        except ValueError:
            print('That is not an integer.')
    while True:
        try:
            money = int(
                input('How much Money does the monster have? Minimum of 0.'))
            if money < 0:
                print(' That was an invalid number, positive numbers only.')
            else:
                break
        except ValueError:
            print('Sorry that was not an Integer.')
    while True:
        try:
            level = int(input('What is the monsters level? Minimum of 1.'))
            if level < 0:
                print(' That was an invalid number, positive numbers only.')
            else:
                break
        except ValueError:
            print('Sorry that was not an Integer.')
    # Now that all that data has been collected we toss it into the Peewee model, and send it to the DB
    new_monster = Monster(name, xp_val, money, level)
    new_monster.set_str_and_armor(strength, armor, max_hp)
    DM.add_monster(new_monster)