Example #1
0
    def fight_round(self):
        """Initiates one phase of combat between the player and enemy
        Two dice rolls + skill level = attack value
        Character with lowest attack value takes 2 damage, this ends the 'round'
        Tie if equal attack value - ends 'round' with no damage"""
        self.update_from_entrys()

        p_power, p_log = self.get_attack('p')
        e_power, e_log = self.get_attack('e')
        if p_power > e_power:
            #Player wins round
            self.last_round = 'p_win'
            self.change_stat('e', 'stamina', STD_DMG * -1, sle=True)
            r_log = ff_logbook.Log('take_dmg', self.enemy.name, STD_DMG)
        elif p_power < e_power:
            #Enemy wins round
            self.last_round = 'e_win'
            self.change_stat('p', 'stamina', STD_DMG * -1, sle=True)
            r_log = ff_logbook.Log('take_dmg', self.player.name, STD_DMG)
        else:  #Draw
            self.last_round = 'draw'
            r_log = ff_logbook.Log('draw')

        self.combat_logs.add_log(ff_logbook.Log('space'))
        self.combat_logs.add_log(r_log)
        self.combat_logs.add_log(e_log)
        self.combat_logs.add_log(p_log)
        self.refresh_logbook()
        self.update_primary_entrys()
 def eat_ration(self):
     """Consume a ration and increase stamina by default value"""
     self.char_logs.add_log(ff_logbook.Log('space'))
     self.change_stat('stamina', RATION_RESTORES)
     self.change_stat('rations', -1)
     self.update_from_entrys()
     self.char_logs.add_log(ff_logbook.Log('eat', self.character.name))
     self.refresh_logbook()
 def roll_luck(self):
     """Determine whether a luck roll was successful"""
     roll = ff_extras.roll_dice(
         dice=2)  #Is it one or two dice? Neither seem quite right
     self.char_logs.add_log(ff_logbook.Log('space'))
     if roll <= self.character.stats['luck']:
         self.change_stat('luck', -1)
         self.char_logs.add_log(ff_logbook.Log('success'))
     else:
         self.char_logs.add_log(ff_logbook.Log('unchanged', "Luck"))
         self.char_logs.add_log(ff_logbook.Log('failure'))
     self.char_logs.add_log(ff_logbook.Log('roll_luck', roll))
     self.refresh_logbook()
 def change_stat(self, stat, change):
     """Calls the change_char_stat method of the character,
     then updates primary labels"""
     self.character.change_char_stat(stat, change)
     #Should I update all labels or use if statements and only update the one changed?
     #I prefer the former as it's more of a catch-all and still isn't too taxing
     self.update_primary_labels()
     if change >= 0:
         self.char_logs.add_log(
             ff_logbook.Log("stat_up", stat.title(), change))
     else:
         self.char_logs.add_log(
             ff_logbook.Log("stat_down", stat.title(), change * -1))
     self.refresh_logbook()
 def auto_stats(self):
     """Calls the roll_stats method of the character, then updates related labels"""
     self.character.roll_stats()
     self.update_primary_labels()
     self.update_from_entrys()
     self.char_logs.add_log(ff_logbook.Log("new_stats"))
     self.refresh_logbook()
Example #6
0
 def roll_luck(self):
     """Depending on the result of the previous engagement, makes a luck roll"""
     self.update_from_entrys()
     self.combat_logs.add_log(ff_logbook.Log('space'))
     if self.last_round == "p_win":
         self.luck_check("more")
     elif self.last_round == "e_win":
         self.luck_check("less")
     elif self.last_round == "draw":
         self.combat_logs.add_log(ff_logbook.Log('err_draw'))
     elif self.last_round is None:
         self.combat_logs.add_log(ff_logbook.Log('err_no_fight'))
     else:  #impossible
         raise ValueError("Previous round set to unknown value: {}".format(
             self.last_round))
     self.last_round = None
     self.refresh_logbook()
def external_fight(player1, player2):
    """It is 'external' cos it is outside of the CharacterSheetGui class object that calls it.
    Runs the combat gui with the two characters specified. player2 is a standard enemy if None.
    Afterwards it brings up a new CharacterSheetGui with the updated player1.
    
    Currently the updated player2 is ignored, but some framework exists for a potential
    combat between two 'main' characters
    """
    #Do the fight
    ff_combatscreen.run_combat_gui(player1, player2)

    #Get the window back again (Well actually make a new one with the saved character)
    #This could potentially overextend the memory, depending on how much of the old classes are kept
    new_characterwindow = Tk()
    new_character_gui = CharacterSheetGui(new_characterwindow, player1)
    new_character_gui.char_logs.add_log(ff_logbook.Log('space'))
    new_character_gui.char_logs.add_log(ff_logbook.Log('refresh'))
    new_character_gui.char_logs.add_log(ff_logbook.Log('battle', player1.name))
    new_character_gui.refresh_logbook()
    new_characterwindow.mainloop()
Example #8
0
 def change_stat(self, p_or_e, stat, change, sle=False):
     """sle: Suppress Log Entry - Used if a new log entry about the change is not required
     Changes the [stat] of the player or enemy by [change]"""
     if p_or_e == 'p':
         self.player.change_char_stat(stat, change)
     elif p_or_e == 'e':
         self.enemy.change_char_stat(stat, change)
     else:  #Impossible
         raise ValueError(
             "p_or_e is somehow not p and not e, geez you broke it wth man")
     #Should I update all labels or use if statements and only update the one changed?
     #I prefer the former as it's more of a catch-all and still isn't too taxing
     self.update_primary_entrys()
     if not sle:
         if change >= 0:
             self.combat_logs.add_log(
                 ff_logbook.Log("stat_up", stat.title(), change))
         else:  #change < 0:
             self.combat_logs.add_log(
                 ff_logbook.Log("stat_down", stat.title(), change * -1))
     self.refresh_logbook()
Example #9
0
 def luck_check(self, more_or_less):
     """On a successful luck roll, reduces or increases damage done by CHANGE_ON_LUCK"""
     roll = ff_extras.roll_dice(
         dice=2)  #Is it one or two dice? Neither seem quite right
     if roll <= self.player.stats['luck']:
         self.change_stat('p', 'luck', -1)
         if more_or_less == 'less':
             self.combat_logs.add_log(
                 ff_logbook.Log('less_dmg', self.player.name,
                                CHANGE_ON_LUCK))
             self.change_stat('p', 'stamina', CHANGE_ON_LUCK * 1, sle=True)
         elif more_or_less == 'more':
             self.combat_logs.add_log(
                 ff_logbook.Log('more_dmg', self.enemy.name,
                                CHANGE_ON_LUCK))
             self.change_stat('e', 'stamina', CHANGE_ON_LUCK * -1, sle=True)
         else:  #Impossible
             raise ValueError(
                 "more_or_less is somehow not more or less, dude you broke it"
             )
         self.combat_logs.add_log(ff_logbook.Log('success'))
     else:
         self.combat_logs.add_log(ff_logbook.Log('unchanged', "Luck"))
         self.combat_logs.add_log(ff_logbook.Log('failure'))
     self.combat_logs.add_log(ff_logbook.Log('roll_luck', roll))
     self.refresh_logbook()
Example #10
0
 def get_attack(self, character):
     """Returns attack power and a new Log, for the given character"""
     roll1 = ff_extras.roll_dice()
     roll2 = ff_extras.roll_dice()
     total = roll1 + roll2
     if character == 'p':  #Player
         power = total + self.player.stats['skill']
         log = ff_logbook.Log('roll_die', self.player.name, roll1)
         log.append_log(ff_logbook.Log('roll_die_ext', roll2))
         log.append_log(ff_logbook.Log('total_roll', total))
         log.append_log(ff_logbook.Log('attack_val', power))
     elif character == 'e':  #Enemy
         power = total + self.enemy.stats['skill']
         log = ff_logbook.Log('roll_die', self.enemy.name, roll1)
         log.append_log(ff_logbook.Log('roll_die_ext', roll2))
         log.append_log(ff_logbook.Log('total_roll', total))
         log.append_log(ff_logbook.Log('attack_val', power))
     return power, log
 def clear_potion(self):
     """Clears the potion entry widget and updates Character attributes"""
     self.potion_entry.delete(0, 'end')
     self.update_from_entrys()
     self.char_logs.add_log(ff_logbook.Log('clear_pot'))
     self.refresh_logbook()