all repos — Legends-RPG @ ec8acadd87fd2c29f7c43052dd4f84a643683176

A fantasy mini-RPG built with Python and Pygame.

Refactored battle state and observer so that almost all code is within battle state.
Justin Armstrong justinmeister@gmail.com
Wed, 21 May 2014 22:58:03 -0700
commit

ec8acadd87fd2c29f7c43052dd4f84a643683176

parent

aef47eaae27734e81f7d2804e5782652e20a6bbc

5 files changed, 224 insertions(+), 265 deletions(-)

jump to
M data/battlegui.pydata/battlegui.py

@@ -41,9 +41,9 @@ c.SELECT_ENEMY: 'Select an enemy.',

c.ENEMY_ATTACK: 'Enemy attacks player!', c.PLAYER_ATTACK: 'Player attacks enemy.', c.RUN_AWAY: 'RUN AWAY!!!', - c.ENEMY_HIT: self.enemy_hit(), + c.ENEMY_DAMAGED: self.enemy_damaged(), c.ENEMY_DEAD: 'Enemy killed.', - c.DISPLAY_ENEMY_ATTACK_DAMAGE: self.player_hit(), + c.PLAYER_DAMAGED: self.player_hit(), c.DRINK_HEALING_POTION: 'Player healed.', c.DRINK_ETHER_POTION: 'Magic Points Increased.', c.FIRE_SPELL: 'FIRE BLAST!',

@@ -53,7 +53,7 @@ c.LEVEL_UP: self.level_up()}

return state_dict - def enemy_hit(self): + def enemy_damaged(self): """ Return text of enemy being hit using calculated damage. """

@@ -144,14 +144,14 @@ """

Set enemy damage in state dictionary. """ self.enemy_damage = enemy_damage - self.state_dict[c.ENEMY_HIT] = self.enemy_hit() + self.state_dict[c.ENEMY_DAMAGED] = self.enemy_damaged() def set_player_damage(self, player_damage): """ Set player damage in state dictionary. """ self.player_damage = player_damage - self.state_dict[c.DISPLAY_ENEMY_ATTACK_DAMAGE] = self.player_hit() + self.state_dict[c.PLAYER_DAMAGED] = self.player_hit() def player_hit(self): if self.player_damage:
M data/components/person.pydata/components/person.py

@@ -318,7 +318,7 @@ self.image = self.spritesheet_dict['facing left 1']

self.image = pg.transform.scale2x(self.image) if self.rect.x <= self.origin_pos[0] - 110: self.x_vel = FAST_BACK - self.notify('attack animation') + self.notify(c.ENEMY_DAMAGED) else: if self.rect.x >= self.origin_pos[0]: self.rect.x = self.origin_pos[0]

@@ -351,7 +351,7 @@ if self.move_counter == 3:

self.x_vel = 0 self.state = 'battle resting' self.rect.x = STARTX - self.notify(c.ENEMY_ATTACK_DAMAGE) + self.notify(c.PLAYER_DAMAGED) elif self.x_vel == FAST_LEFT: if self.rect.x <= (STARTX - 15):
M data/constants.pydata/constants.py

@@ -51,11 +51,10 @@ SELECT_MAGIC = 'select magic'

RUN_AWAY = 'run away' ATTACK_ANIMATION = 'attack animation' BATTLE_WON = 'battle won' -ENEMY_HIT = 'enemy hit' +ENEMY_DAMAGED = 'enemy damaged' ENEMY_DEAD = 'enemy dead' PLAYER_FINISHED_ATTACK = 'player finished attack' -ENEMY_ATTACK_DAMAGE = 'enemy attack damage' -DISPLAY_ENEMY_ATTACK_DAMAGE = 'display enemy attack damage' +PLAYER_DAMAGED = 'enemy attack damage' DRINK_HEALING_POTION = 'drink healing potion' DRINK_ETHER_POTION = 'drink ether potion' CURE_SPELL = 'cure spell'
M data/observer.pydata/observer.py

@@ -11,18 +11,12 @@ Observes events of battle and passes info to components.

""" def __init__(self, level): self.level = level - self.info_box = level.info_box - self.select_box = level.info_box - self.arrow = level.arrow self.player = level.player - self.enemies = level.enemy_group - self.enemy_list = level.enemy_list - self.enemy_index = level.enemy_index self.set_observer_for_enemies() self.event_dict = self.make_event_dict() def set_observer_for_enemies(self): - for enemy in self.enemies: + for enemy in self.level.enemy_list: enemy.observers.append(self) def make_event_dict(self):

@@ -30,26 +24,9 @@ """

Make a dictionary of events the Observer can receive. """ - event_dict = {c.END_BATTLE: self.end_battle, - c.SELECT_ACTION: self.select_action, - c.SELECT_ITEM: self.select_item, - c.SELECT_ENEMY: self.select_enemy, - c.SELECT_MAGIC: self.select_magic, - c.ENEMY_ATTACK: self.enemy_attack, - c.ENEMY_DEAD: self.enemy_dead, - c.SWITCH_ENEMY: self.switch_enemy, - c.PLAYER_ATTACK: self.player_attack, - c.ATTACK_ANIMATION: self.enemy_damaged, - c.RUN_AWAY: self.try_to_run_away, - c.FLEE: self.flee, - c.BATTLE_WON: self.battle_won, - c.ENEMY_ATTACK_DAMAGE: self.player_damaged, - c.DRINK_HEALING_POTION: self.drink_healing_potion, - c.DRINK_ETHER_POTION: self.drink_ether_potion, - c.CURE_SPELL: self.cure_spell, - c.FIRE_SPELL: self.fire_spell, - c.SHOW_EXPERIENCE: self.show_experience, - c.LEVEL_UP: self.level_up} + event_dict = {c.ENEMY_DEAD: self.enemy_dead, + c.ENEMY_DAMAGED: self.enemy_damaged, + c.PLAYER_DAMAGED: self.player_damaged} return event_dict

@@ -60,168 +37,22 @@ """

if event in self.event_dict: self.event_dict[event]() - def end_battle(self): - """ - End Battle and flip to previous state. - """ - self.level.end_battle() - - def select_action(self): - """ - Set components to select action. - """ - self.level.state = c.SELECT_ACTION - self.arrow.index = 0 - self.arrow.state = c.SELECT_ACTION - self.arrow.image = setup.GFX['smallarrow'] - self.info_box.state = c.SELECT_ACTION - - def select_enemy(self): - self.level.state = c.SELECT_ENEMY - self.arrow.index = 0 - self.arrow.state = c.SELECT_ENEMY - - def select_item(self): - self.level.state = c.SELECT_ITEM - self.info_box.state = c.SELECT_ITEM - self.arrow.become_select_item_state() - - def select_magic(self): - self.level.state = c.SELECT_MAGIC - self.info_box.state = c.SELECT_MAGIC - self.arrow.become_select_magic_state() - - def enemy_attack(self): - enemy = self.level.enemy_list[self.level.enemy_index] - enemy.enter_enemy_attack_state() - self.info_box.state = c.ENEMY_ATTACK - - def switch_enemy(self): - """Switch which enemy is attacking player.""" - if self.level.enemy_index < len(self.level.enemy_list) - 1: - self.level.enemy_index += 1 - self.on_notify(c.ENEMY_ATTACK) - def player_damaged(self): - if self.enemy_index > len(self.enemy_list) - 1: - self.enemy_index = 0 - enemy = self.enemy_list[self.enemy_index] - player_damage = enemy.calculate_hit() - self.level.damage_points.add( - attackitems.HealthPoints(player_damage, - self.player.rect.topright)) - self.info_box.set_player_damage(player_damage) - self.info_box.state = c.DISPLAY_ENEMY_ATTACK_DAMAGE - self.level.state = c.DISPLAY_ENEMY_ATTACK_DAMAGE - self.level.set_timer_to_current_time() - self.level.player_damaged(player_damage) - if player_damage: - self.player.damaged = True - self.player.enter_knock_back_state() - - def player_attack(self): - enemy_posx = self.arrow.rect.x + 60 - enemy_posy = self.arrow.rect.y - 20 - enemy_pos = (enemy_posx, enemy_posy) - enemy_to_attack = None - - for enemy in self.enemies: - if enemy.rect.topleft == enemy_pos: - enemy_to_attack = enemy - - self.player.enter_attack_state(enemy_to_attack) - self.arrow.become_invisible_surface() + self.level.enter_player_damaged_state() def enemy_damaged(self): """ Make an attack animation over attacked enemy. """ - enemy_damage = self.player.calculate_hit() - self.level.damage_points.add( - attackitems.HealthPoints(enemy_damage, - self.player.attacked_enemy.rect.topright)) - - self.info_box.set_enemy_damage(enemy_damage) - self.info_box.state = c.ENEMY_HIT - - self.arrow.state = c.SELECT_ACTION - self.arrow.index = 0 - self.level.attack_enemy(enemy_damage) - self.level.set_timer_to_current_time() - self.level.state = c.ENEMY_HIT - - - def try_to_run_away(self): - """ - Sets a flag in the battle state indicating a desire to run. - Allows enemies to get one last hit in. - """ - self.level.run_away = True - self.level.state = c.ENEMY_ATTACK - self.arrow.become_invisible_surface() - self.level.enemy_index = 0 - self.on_notify(c.ENEMY_ATTACK) - - def flee(self): - """ - Actually run away after enemies get there chance to attack. - """ - self.info_box.state = c.RUN_AWAY - self.level.set_timer_to_current_time() - self.arrow.become_invisible_surface() - self.player.state = c.RUN_AWAY - - - def battle_won(self): - self.info_box.state = c.BATTLE_WON - self.level.set_timer_to_current_time() - self.player.state = c.VICTORY_DANCE - - - def drink_healing_potion(self): - """ - Give player a healing potion. - """ - self.level.drink_healing_potion() - - def drink_ether_potion(self): - """ - Give player a ether potion. - """ - self.level.drink_ether() - - def cure_spell(self): - """ - Cast cure spell on player. - """ - self.level.cast_cure() - - def fire_spell(self): - """ - Cast fire spell on all enemies. - """ - self.level.cast_fire_blast() + self.level.enter_enemy_damaged_state() def enemy_dead(self): """ Eliminate all traces of enemy. """ - self.player.attacked_enemy = None + self.level.player.attacked_enemy = None - def show_experience(self): - """ - Show the experience the player gained that battle. - """ - self.info_box.state = c.SHOW_EXPERIENCE - self.level.set_timer_to_current_time() - def level_up(self): - """ - Display message that the player leveled up. - """ - self.info_box.reset_level_up_message() - self.info_box.state = c.LEVEL_UP - self.level.set_timer_to_current_time()
M data/states/battle.pydata/states/battle.py

@@ -1,8 +1,8 @@

"""This is the state that handles battles against monsters""" -import random, copy +import random import pygame as pg -from .. import tools, battlegui, observer +from .. import tools, battlegui, observer, setup from .. components import person, attack, attackitems from .. import constants as c

@@ -10,34 +10,7 @@

class Battle(tools._State): def __init__(self): super(Battle, self).__init__() - self.game_data = {} - self.current_time = 0.0 - self.timer = 0.0 - self.allow_input = False - self.allow_info_box_change = False self.name = 'battle' - self.state = None - - self.player = None - self.attack_animations = None - self.sword = None - self.enemy_index = 0 - self.attacked_enemy = None - self.attacking_enemy = None - self.enemy_group = None - self.enemy_pos_list = [] - self.enemy_list = [] - self.experience_points = 0 - - self.background = None - self.info_box = None - self.arrow = None - self.select_box = None - self.player_health_box = None - self.select_action_state_dict = {} - self.next = None - self.observers = [] - self.damage_points = pg.sprite.Group() def startup(self, current_time, game_data): """Initialize state attributes"""

@@ -95,8 +68,7 @@ experience_total += (random.randint(5,10)*enemy.level)

return experience_total - @staticmethod - def make_background(): + def make_background(self): """Make the blue/black background""" background = pg.sprite.Sprite() surface = pg.Surface(c.SCREEN_SIZE).convert()

@@ -150,7 +122,8 @@ """

Make a dictionary of states with arrow coordinates as keys. """ pos_list = self.arrow.make_select_action_pos_list() - state_list = [c.SELECT_ENEMY, c.SELECT_ITEM, c.SELECT_MAGIC, c.RUN_AWAY] + state_list = [self.enter_select_enemy_state, self.enter_select_item_state, + self.enter_select_magic_state, self.try_to_run_away] return dict(zip(pos_list, state_list)) def update(self, surface, keys, current_time):

@@ -175,40 +148,33 @@ Check user input to navigate GUI.

""" if self.allow_input: if keys[pg.K_RETURN]: - self.notify(c.END_BATTLE) + self.end_battle() elif keys[pg.K_SPACE]: if self.state == c.SELECT_ACTION: - self.state = self.select_action_state_dict[ + enter_state_function = self.select_action_state_dict[ self.arrow.rect.topleft] - self.notify(self.state) + enter_state_function() elif self.state == c.SELECT_ENEMY: - self.state = c.PLAYER_ATTACK - self.notify(self.state) + self.enter_player_attack_state() elif self.state == c.SELECT_ITEM: if self.arrow.index == (len(self.arrow.pos_list) - 1): - self.state = c.SELECT_ACTION - self.notify(self.state) + self.enter_select_action_state() elif self.info_box.item_text_list[self.arrow.index][:14] == 'Healing Potion': - self.state = c.DRINK_HEALING_POTION - self.notify(self.state) + self.enter_drink_healing_potion_state() elif self.info_box.item_text_list[self.arrow.index][:5] == 'Ether': - self.state = c.DRINK_ETHER_POTION - self.notify(self.state) + self.enter_drink_ether_potion_state() elif self.state == c.SELECT_MAGIC: if self.arrow.index == (len(self.arrow.pos_list) - 1): - self.state = c.SELECT_ACTION - self.notify(self.state) + self.enter_select_action_state() elif self.info_box.magic_text_list[self.arrow.index] == 'Cure': if self.game_data['player stats']['magic points']['current'] >= 25: - self.state = c.CURE_SPELL - self.notify(self.state) + self.cast_cure() elif self.info_box.magic_text_list[self.arrow.index] == 'Fire Blast': if self.game_data['player stats']['magic points']['current'] >= 25: - self.state = c.FIRE_SPELL - self.notify(self.state) + self.cast_fire_blast() self.allow_input = False

@@ -219,8 +185,8 @@ def check_timed_events(self):

""" Check if amount of time has passed for timed events. """ - timed_states = [c.DISPLAY_ENEMY_ATTACK_DAMAGE, - c.ENEMY_HIT, + timed_states = [c.PLAYER_DAMAGED, + c.ENEMY_DAMAGED, c.ENEMY_DEAD, c.DRINK_HEALING_POTION, c.DRINK_ETHER_POTION]

@@ -228,38 +194,35 @@ long_delay = timed_states[1:]

if self.state in long_delay: if (self.current_time - self.timer) > 1000: - if self.state == c.ENEMY_HIT: + if self.state == c.ENEMY_DAMAGED: if len(self.enemy_list): - self.state = c.ENEMY_ATTACK + self.enter_enemy_attack_state() else: - self.state = c.BATTLE_WON + self.enter_battle_won_state() elif (self.state == c.DRINK_HEALING_POTION or self.state == c.CURE_SPELL or self.state == c.DRINK_ETHER_POTION): if len(self.enemy_list): - self.state = c.ENEMY_ATTACK + self.enter_enemy_attack_state() else: - self.state = c.BATTLE_WON + self.enter_battle_won_state() self.timer = self.current_time - self.notify(self.state) elif self.state == c.FIRE_SPELL or self.state == c.CURE_SPELL: if (self.current_time - self.timer) > 1500: if len(self.enemy_list): - self.state = c.ENEMY_ATTACK + self.enter_enemy_attack_state() else: - self.state = c.BATTLE_WON + self.enter_battle_won_state() self.timer = self.current_time - self.notify(self.state) - elif self.state == c.FLEE: + elif self.state == c.RUN_AWAY: if (self.current_time - self.timer) > 1500: self.end_battle() elif self.state == c.BATTLE_WON: if (self.current_time - self.timer) > 1800: - self.state = c.SHOW_EXPERIENCE - self.notify(self.state) + self.enter_show_experience_state() elif self.state == c.SHOW_EXPERIENCE: if (self.current_time - self.timer) > 2200:

@@ -271,21 +234,20 @@ player_stats['health']['maximum'] += int(player_stats['health']['maximum']*.25)

player_stats['magic points']['maximum'] += int(player_stats['magic points']['maximum']*.20) new_experience = int((player_stats['Level'] * 100) * .75) player_stats['experience to next level'] = new_experience - self.notify(c.LEVEL_UP) + self.enter_level_up_state() else: self.end_battle() - elif self.state == c.DISPLAY_ENEMY_ATTACK_DAMAGE: + elif self.state == c.PLAYER_DAMAGED: if (self.current_time - self.timer) > 600: if self.enemy_index == (len(self.enemy_list) - 1): if self.run_away: - self.state = c.FLEE + self.enter_run_away_state() else: - self.state = c.SELECT_ACTION + self.enter_select_action_state() else: - self.state = c.SWITCH_ENEMY + self.switch_enemy() self.timer = self.current_time - self.notify(self.state) def check_if_battle_won(self): """

@@ -293,7 +255,7 @@ Check if state is SELECT_ACTION and there are no enemies left.

""" if self.state == c.SELECT_ACTION: if len(self.enemy_group) == 0: - self.notify(c.BATTLE_WON) + self.enter_battle_won_state() def notify(self, event): """

@@ -323,7 +285,6 @@ enemy.enter_knock_back_state()

if enemy.health <= 0: self.enemy_list.pop(enemy.index) enemy.state = c.FADE_DEATH - self.notify(c.FADE_DEATH) self.arrow.remove_pos(self.player.attacked_enemy) self.enemy_index = 0

@@ -343,7 +304,6 @@ surface.blit(self.select_box.image, self.select_box.rect)

surface.blit(self.arrow.image, self.arrow.rect) self.player_health_box.draw(surface) self.damage_points.draw(surface) - def player_damaged(self, damage): self.game_data['player stats']['health']['current'] -= damage

@@ -386,6 +346,7 @@ def cast_fire_blast(self):

""" Cast fire blast on all enemies. """ + self.state = self.info_box.state = c.FIRE_SPELL POWER = self.inventory['Fire Blast']['power'] MAGIC_POINTS = self.inventory['Fire Blast']['magic points'] self.game_data['player stats']['magic points']['current'] -= MAGIC_POINTS

@@ -408,19 +369,17 @@ self.enemy_index = 0

self.arrow.index = 0 self.arrow.become_invisible_surface() self.arrow.state = c.SELECT_ACTION - self.state = c.FIRE_SPELL self.set_timer_to_current_time() - self.info_box.state = c.FIRE_SPELL def cast_cure(self): """ Cast cure spell on player. """ + self.state = c.CURE_SPELL HEAL_AMOUNT = self.inventory['Cure']['power'] MAGIC_POINTS = self.inventory['Cure']['magic points'] self.player.healing = True self.set_timer_to_current_time() - self.state = c.CURE_SPELL self.arrow.become_invisible_surface() self.enemy_index = 0 self.damage_points.add(

@@ -432,9 +391,9 @@ def drink_ether(self):

""" Drink ether potion. """ + self.state = self.info_box.state = c.DRINK_ETHER_POTION self.player.healing = True self.set_timer_to_current_time() - self.state = c.DRINK_ETHER_POTION self.arrow.become_invisible_surface() self.enemy_index = 0 self.damage_points.add(

@@ -443,15 +402,84 @@ self.player.rect.topright,

False, True)) self.magic_boost(30) - self.info_box.state = c.DRINK_ETHER_POTION def drink_healing_potion(self): """ Drink Healing Potion. """ + self.state = self.info_box.state = c.DRINK_HEALING_POTION self.player.healing = True + self.arrow.become_invisible_surface() + self.enemy_index = 0 + self.damage_points.add( + attackitems.HealthPoints(30, + self.player.rect.topright, + False)) + self.player_healed(30) self.set_timer_to_current_time() - self.state = c.DRINK_HEALING_POTION + + def enter_select_enemy_state(self): + """ + Transition battle into the select enemy state. + """ + self.state = self.arrow.state = c.SELECT_ENEMY + self.arrow.index = 0 + + def enter_select_item_state(self): + """ + Transition battle into the select item state. + """ + self.state = self.info_box.state = c.SELECT_ITEM + self.arrow.become_select_item_state() + + def enter_select_magic_state(self): + """ + Transition battle into the select magic state. + """ + self.state = self.info_box.state = c.SELECT_MAGIC + self.arrow.become_select_magic_state() + + def try_to_run_away(self): + """ + Transition battle into the run away state. + """ + self.run_away = True + self.arrow.become_invisible_surface() + self.enemy_index = 0 + self.enter_enemy_attack_state() + + def enter_enemy_attack_state(self): + """ + Transition battle into the Enemy attack state. + """ + self.state = self.info_box.state = c.ENEMY_ATTACK + enemy = self.enemy_list[self.enemy_index] + enemy.enter_enemy_attack_state() + + def enter_player_attack_state(self): + """ + Transition battle into the Player attack state. + """ + self.state = c.PLAYER_ATTACK + enemy_posx = self.arrow.rect.x + 60 + enemy_posy = self.arrow.rect.y - 20 + enemy_pos = (enemy_posx, enemy_posy) + enemy_to_attack = None + + for enemy in self.enemy_list: + if enemy.rect.topleft == enemy_pos: + enemy_to_attack = enemy + + self.player.enter_attack_state(enemy_to_attack) + self.arrow.become_invisible_surface() + + def enter_drink_healing_potion_state(self): + """ + Transition battle into the Drink Healing Potion state. + """ + self.state = self.info_box.state = c.DRINK_HEALING_POTION + self.player.healing = True + self.set_timer_to_current_time() self.arrow.become_invisible_surface() self.enemy_index = 0 self.damage_points.add(

@@ -459,7 +487,108 @@ attackitems.HealthPoints(30,

self.player.rect.topright, False)) self.player_healed(30) - self.info_box.state = c.DRINK_HEALING_POTION + + def enter_drink_ether_potion_state(self): + """ + Transition battle into the Drink Ether Potion state. + """ + self.state = self.info_box.state = c.DRINK_ETHER_POTION + self.player.healing = True + self.arrow.become_invisible_surface() + self.enemy_index = 0 + self.damage_points.add( + attackitems.HealthPoints(30, + self.player.rect.topright, + False, + True)) + self.magic_boost(30) + self.set_timer_to_current_time() + + def enter_select_action_state(self): + """ + Transition battle into the select action state + """ + self.state = self.info_box.state = c.SELECT_ACTION + self.arrow.index = 0 + self.arrow.state = self.state + self.arrow.image = setup.GFX['smallarrow'] + + def enter_player_damaged_state(self): + """ + Transition battle into the player damaged state. + """ + self.state = self.info_box.state = c.PLAYER_DAMAGED + if self.enemy_index > len(self.enemy_list) - 1: + self.enemy_index = 0 + enemy = self.enemy_list[self.enemy_index] + player_damage = enemy.calculate_hit() + self.damage_points.add( + attackitems.HealthPoints(player_damage, + self.player.rect.topright)) + self.info_box.set_player_damage(player_damage) + self.set_timer_to_current_time() + self.player_damaged(player_damage) + if player_damage: + self.player.damaged = True + self.player.enter_knock_back_state() + + def enter_enemy_damaged_state(self): + """ + Transition battle into the enemy damaged state. + """ + self.state = self.info_box.state = c.ENEMY_DAMAGED + enemy_damage = self.player.calculate_hit() + self.damage_points.add( + attackitems.HealthPoints(enemy_damage, + self.player.attacked_enemy.rect.topright)) + + self.info_box.set_enemy_damage(enemy_damage) + + self.arrow.state = c.SELECT_ACTION + self.arrow.index = 0 + self.attack_enemy(enemy_damage) + self.set_timer_to_current_time() + + def switch_enemy(self): + """ + Switch which enemy the player is attacking. + """ + if self.enemy_index < len(self.enemy_list) - 1: + self.enemy_index += 1 + self.enter_enemy_attack_state() + + def enter_run_away_state(self): + """ + Transition battle into the run away state. + """ + self.state = self.info_box.state = c.RUN_AWAY + self.arrow.become_invisible_surface() + self.player.state = c.RUN_AWAY + self.set_timer_to_current_time() + + def enter_battle_won_state(self): + """ + Transition battle into the battle won state. + """ + self.state = self.info_box.state = c.BATTLE_WON + self.player.state = c.VICTORY_DANCE + self.set_timer_to_current_time() + + def enter_show_experience_state(self): + """ + Transition battle into the show experience state. + """ + self.state = self.info_box.state = c.SHOW_EXPERIENCE + self.set_timer_to_current_time() + + def enter_level_up_state(self): + """ + Transition battle into the LEVEL UP state. + """ + self.state = self.info_box.state = c.LEVEL_UP + self.info_box.reset_level_up_message() + self.set_timer_to_current_time() +