data/states/battle.py (view raw)
1"""This is the state that handles battles against
2monsters"""
3import random
4import pygame as pg
5from .. import tools, battlegui, observer, setup
6from .. components import person, attack, attackitems
7from .. import constants as c
8
9
10class Battle(tools._State):
11 def __init__(self):
12 super(Battle, self).__init__()
13 self.name = 'battle'
14 self.music = setup.MUSIC['high_action']
15
16 def startup(self, current_time, game_data):
17 """Initialize state attributes"""
18 self.current_time = current_time
19 self.timer = current_time
20 self.allow_input = False
21 self.game_data = game_data
22 self.inventory = game_data['player inventory']
23 self.state = 'transition in'
24 self.next = game_data['last state']
25 self.run_away = False
26
27 self.player = self.make_player()
28 self.attack_animations = pg.sprite.Group()
29 self.sword = attackitems.Sword(self.player)
30 self.enemy_group, self.enemy_pos_list, self.enemy_list = self.make_enemies()
31 self.experience_points = self.get_experience_points()
32 self.new_gold = self.get_new_gold()
33 self.background = self.make_background()
34 self.info_box = battlegui.InfoBox(game_data,
35 self.experience_points,
36 self.new_gold)
37 self.arrow = battlegui.SelectArrow(self.enemy_pos_list,
38 self.info_box)
39 self.select_box = battlegui.SelectBox()
40 self.player_health_box = battlegui.PlayerHealth(self.select_box.rect,
41 self.game_data)
42
43 self.select_action_state_dict = self.make_selection_state_dict()
44 self.observers = [observer.Battle(self)]
45 self.player.observers.extend(self.observers)
46 self.observers.append(observer.SoundEffects())
47 self.damage_points = pg.sprite.Group()
48 self.player_actions = []
49 self.player_action_dict = self.make_player_action_dict()
50 self.player_level = self.game_data['player stats']['Level']
51 self.enemies_to_attack = []
52 self.action_selected = False
53 self.just_leveled_up = False
54 self.transition_rect = setup.SCREEN.get_rect()
55 self.transition_alpha = 255
56
57 def make_player_action_dict(self):
58 """
59 Make the dict to execute player actions.
60 """
61 action_dict = {c.PLAYER_ATTACK: self.enter_player_attack_state,
62 c.CURE_SPELL: self.cast_cure,
63 c.FIRE_SPELL: self.cast_fire_blast,
64 c.DRINK_HEALING_POTION: self.enter_drink_healing_potion_state,
65 c.DRINK_ETHER_POTION: self.enter_drink_ether_potion_state}
66
67 return action_dict
68
69 def make_enemy_level_dict(self):
70 new_dict = {c.OVERWORLD: 1,
71 c.DUNGEON: 2,
72 c.DUNGEON2: 2,
73 c.DUNGEON3: 3,
74 c.DUNGEON4: 2,
75 c.DUNGEON5: 5}
76
77 return new_dict
78
79 def set_enemy_level(self, enemy_list):
80 dungeon_level_dict = self.make_enemy_level_dict()
81
82 for enemy in enemy_list:
83 enemy.level = dungeon_level_dict[self.previous]
84
85 def get_experience_points(self):
86 """
87 Calculate experience points based on number of enemies
88 and their levels.
89 """
90 experience_total = 0
91
92 for enemy in self.enemy_list:
93 experience_total += (random.randint(5,10)*enemy.level)
94
95 return experience_total
96
97 def get_new_gold(self):
98 """
99 Calculate the gold collected at the end of the battle.
100 """
101 gold = 0
102
103 for enemy in self.enemy_list:
104 max_gold = enemy.level * 20
105 gold += (random.randint(1, max_gold))
106
107 return gold
108
109 def make_background(self):
110 """Make the blue/black background"""
111 background = pg.sprite.Sprite()
112 surface = pg.Surface(c.SCREEN_SIZE).convert()
113 surface.fill(c.BLACK_BLUE)
114 background.image = surface
115 background.rect = background.image.get_rect()
116 background_group = pg.sprite.Group(background)
117
118 return background_group
119
120 def make_enemies(self):
121 """Make the enemies for the battle. Return sprite group"""
122 pos_list = []
123
124 for column in range(3):
125 for row in range(3):
126 x = (column * 100) + 100
127 y = (row * 100) + 100
128 pos_list.append([x, y])
129
130 enemy_group = pg.sprite.Group()
131
132 if self.game_data['battle type']:
133 enemy = person.Enemy('evilwizard', 0, 0,
134 'down', 'battle resting')
135 enemy_group.add(enemy)
136 else:
137 for enemy in range(random.randint(1, 6)):
138 enemy_group.add(person.Enemy('devil', 0, 0,
139 'down', 'battle resting'))
140
141 for i, enemy in enumerate(enemy_group):
142 enemy.rect.topleft = pos_list[i]
143 enemy.image = pg.transform.scale2x(enemy.image)
144 enemy.index = i
145 enemy.level = self.make_enemy_level_dict()[self.previous]
146 enemy.health = enemy.level * 7
147
148 enemy_list = [enemy for enemy in enemy_group]
149
150 return enemy_group, pos_list[0:len(enemy_group)], enemy_list
151
152 def make_player(self):
153 """Make the sprite for the player's character"""
154 player = person.Player('left', self.game_data, 630, 220, 'battle resting', 1)
155 player.image = pg.transform.scale2x(player.image)
156 return player
157
158 def make_selection_state_dict(self):
159 """
160 Make a dictionary of states with arrow coordinates as keys.
161 """
162 pos_list = self.arrow.make_select_action_pos_list()
163 state_list = [self.enter_select_enemy_state, self.enter_select_item_state,
164 self.enter_select_magic_state, self.try_to_run_away]
165 return dict(zip(pos_list, state_list))
166
167 def update(self, surface, keys, current_time):
168 """Update the battle state"""
169 self.current_time = current_time
170 self.check_input(keys)
171 self.check_timed_events()
172 self.check_if_battle_won()
173 self.enemy_group.update(current_time)
174 self.player.update(keys, current_time)
175 self.attack_animations.update()
176 self.info_box.update()
177 self.arrow.update(keys)
178 self.sword.update(current_time)
179 self.damage_points.update()
180 self.execute_player_actions()
181
182 self.draw_battle(surface)
183
184 def check_input(self, keys):
185 """
186 Check user input to navigate GUI.
187 """
188 if self.allow_input:
189 if keys[pg.K_RETURN]:
190 self.end_battle()
191
192 elif keys[pg.K_SPACE]:
193 if self.state == c.SELECT_ACTION:
194 enter_state_function = self.select_action_state_dict[
195 self.arrow.rect.topleft]
196 enter_state_function()
197
198 elif self.state == c.SELECT_ENEMY:
199 self.player_actions.append(c.PLAYER_ATTACK)
200 self.enemies_to_attack.append(self.get_enemy_to_attack())
201 self.action_selected = True
202
203 elif self.state == c.SELECT_ITEM:
204 if self.arrow.index == (len(self.arrow.pos_list) - 1):
205 self.enter_select_action_state()
206 elif self.info_box.item_text_list[self.arrow.index][:14] == 'Healing Potion':
207 self.player_actions.append(c.DRINK_HEALING_POTION)
208 self.action_selected = True
209 elif self.info_box.item_text_list[self.arrow.index][:5] == 'Ether':
210 self.player_actions.append(c.DRINK_ETHER_POTION)
211 self.action_selected = True
212 elif self.state == c.SELECT_MAGIC:
213 if self.arrow.index == (len(self.arrow.pos_list) - 1):
214 self.enter_select_action_state()
215 elif self.info_box.magic_text_list[self.arrow.index] == 'Cure':
216 magic_points = self.game_data['player inventory']['Cure']['magic points']
217 if self.game_data['player stats']['magic']['current'] >= magic_points:
218 self.player_actions.append(c.CURE_SPELL)
219 self.action_selected = True
220 elif self.info_box.magic_text_list[self.arrow.index] == 'Fire Blast':
221 magic_points = self.game_data['player inventory']['Fire Blast']['magic points']
222 if self.game_data['player stats']['magic']['current'] >= magic_points:
223 self.player_actions.append(c.FIRE_SPELL)
224 self.action_selected = True
225
226 self.allow_input = False
227
228 if keys[pg.K_RETURN] == False and keys[pg.K_SPACE] == False:
229 self.allow_input = True
230
231 def check_timed_events(self):
232 """
233 Check if amount of time has passed for timed events.
234 """
235 timed_states = [c.PLAYER_DAMAGED,
236 c.ENEMY_DAMAGED,
237 c.ENEMY_DEAD,
238 c.DRINK_HEALING_POTION,
239 c.DRINK_ETHER_POTION]
240 long_delay = timed_states[1:]
241
242 if self.state in long_delay:
243 if (self.current_time - self.timer) > 1000:
244 if self.state == c.ENEMY_DAMAGED:
245 if self.player_actions:
246 self.player_action_dict[self.player_actions[0]]()
247 self.player_actions.pop(0)
248 else:
249 if len(self.enemy_list):
250 self.enter_enemy_attack_state()
251 else:
252 self.enter_battle_won_state()
253 elif (self.state == c.DRINK_HEALING_POTION or
254 self.state == c.CURE_SPELL or
255 self.state == c.DRINK_ETHER_POTION):
256 if self.player_actions:
257 self.player_action_dict[self.player_actions[0]]()
258 self.player_actions.pop(0)
259 else:
260 if len(self.enemy_list):
261 self.enter_enemy_attack_state()
262 else:
263 self.enter_battle_won_state()
264 self.timer = self.current_time
265
266 elif self.state == c.FIRE_SPELL or self.state == c.CURE_SPELL:
267 if (self.current_time - self.timer) > 1500:
268 if self.player_actions:
269 self.player_action_dict[self.player_actions[0]]()
270 self.player_actions.pop(0)
271 else:
272 if len(self.enemy_list):
273 self.enter_enemy_attack_state()
274 else:
275 self.enter_battle_won_state()
276 self.timer = self.current_time
277
278 elif self.state == c.RUN_AWAY:
279 if (self.current_time - self.timer) > 1500:
280 self.end_battle()
281
282 elif self.state == c.BATTLE_WON:
283 if (self.current_time - self.timer) > 1800:
284 self.enter_show_gold_state()
285
286 elif self.state == c.SHOW_GOLD:
287 if (self.current_time - self.timer) > 1800:
288 self.enter_show_experience_state()
289
290 elif self.state == c.LEVEL_UP:
291 if (self.current_time - self.timer) > 2200:
292 if self.game_data['player stats']['Level'] == 3:
293 self.enter_two_actions_per_turn_state()
294 else:
295 self.end_battle()
296
297 elif self.state == c.TWO_ACTIONS:
298 if (self.current_time - self.timer) > 3000:
299 self.end_battle()
300
301 elif self.state == c.SHOW_EXPERIENCE:
302 if (self.current_time - self.timer) > 2200:
303 player_stats = self.game_data['player stats']
304 player_stats['experience to next level'] -= self.experience_points
305 if player_stats['experience to next level'] <= 0:
306 player_stats['Level'] += 1
307 player_stats['health']['maximum'] += int(player_stats['health']['maximum']*.25)
308 player_stats['magic']['maximum'] += int(player_stats['magic']['maximum']*.20)
309 new_experience = int((player_stats['Level'] * 50) * .75)
310 player_stats['experience to next level'] = new_experience
311 self.enter_level_up_state()
312 self.just_leveled_up = True
313 else:
314 self.end_battle()
315
316 elif self.state == c.PLAYER_DAMAGED:
317 if (self.current_time - self.timer) > 600:
318 if self.enemy_index == (len(self.enemy_list) - 1):
319 if self.run_away:
320 self.enter_run_away_state()
321 else:
322 self.enter_select_action_state()
323 else:
324 self.switch_enemy()
325 self.timer = self.current_time
326
327 def check_if_battle_won(self):
328 """
329 Check if state is SELECT_ACTION and there are no enemies left.
330 """
331 if self.state == c.SELECT_ACTION:
332 if len(self.enemy_group) == 0:
333 self.enter_battle_won_state()
334
335 def notify(self, event):
336 """
337 Notify observer of event.
338 """
339 for new_observer in self.observers:
340 new_observer.on_notify(event)
341
342 def end_battle(self):
343 """
344 End battle and flip back to previous state.
345 """
346 if self.game_data['battle type'] == 'evilwizard':
347 self.game_data['crown quest'] = True
348 self.game_data['last state'] = self.name
349 self.game_data['battle counter'] = random.randint(50, 255)
350 self.game_data['battle type'] = None
351 self.state = 'transition out'
352
353 def attack_enemy(self, enemy_damage):
354 enemy = self.player.attacked_enemy
355 enemy.health -= enemy_damage
356 self.set_enemy_indices()
357
358 if enemy:
359 enemy.enter_knock_back_state()
360 if enemy.health <= 0:
361 self.enemy_list.pop(enemy.index)
362 enemy.state = c.FADE_DEATH
363 self.arrow.remove_pos(self.player.attacked_enemy)
364 self.enemy_index = 0
365
366 def set_enemy_indices(self):
367 for i, enemy in enumerate(self.enemy_list):
368 enemy.index = i
369
370 def draw_battle(self, surface):
371 """Draw all elements of battle state"""
372 self.background.draw(surface)
373 self.enemy_group.draw(surface)
374 self.attack_animations.draw(surface)
375 self.sword.draw(surface)
376 surface.blit(self.player.image, self.player.rect)
377 surface.blit(self.info_box.image, self.info_box.rect)
378 surface.blit(self.select_box.image, self.select_box.rect)
379 surface.blit(self.arrow.image, self.arrow.rect)
380 self.player_health_box.draw(surface)
381 self.damage_points.draw(surface)
382 self.draw_transition(surface)
383
384 def draw_transition(self, surface):
385 """
386 Fade in and out of state.
387 """
388 if self.state == 'transition in':
389
390 transition_image = pg.Surface(self.transition_rect.size)
391 transition_image.fill(c.TRANSITION_COLOR)
392 transition_image.set_alpha(self.transition_alpha)
393 surface.blit(transition_image, self.transition_rect)
394 self.transition_alpha -= c.TRANSITION_SPEED
395 if self.transition_alpha <= 0:
396 self.state = c.SELECT_ACTION
397 self.transition_alpha = 0
398
399 elif self.state == 'transition out':
400 transition_image = pg.Surface(self.transition_rect.size)
401 transition_image.fill(c.TRANSITION_COLOR)
402 transition_image.set_alpha(self.transition_alpha)
403 surface.blit(transition_image, self.transition_rect)
404 self.transition_alpha += c.TRANSITION_SPEED
405 if self.transition_alpha >= 255:
406 self.done = True
407
408 def player_damaged(self, damage):
409 self.game_data['player stats']['health']['current'] -= damage
410
411 def player_healed(self, heal, magic_points=0):
412 """
413 Add health from potion to game data.
414 """
415 health = self.game_data['player stats']['health']
416
417 health['current'] += heal
418 if health['current'] > health['maximum']:
419 health['current'] = health['maximum']
420
421 if self.state == c.DRINK_HEALING_POTION:
422 self.game_data['player inventory']['Healing Potion']['quantity'] -= 1
423 if self.game_data['player inventory']['Healing Potion']['quantity'] == 0:
424 del self.game_data['player inventory']['Healing Potion']
425 elif self.state == c.CURE_SPELL:
426 self.game_data['player stats']['magic']['current'] -= magic_points
427
428 def magic_boost(self, magic_points):
429 """
430 Add magic from ether to game data.
431 """
432 magic = self.game_data['player stats']['magic']
433 magic['current'] += magic_points
434 if magic['current'] > magic['maximum']:
435 magic['current'] = magic['maximum']
436
437 self.game_data['player inventory']['Ether Potion']['quantity'] -= 1
438 if not self.game_data['player inventory']['Ether Potion']['quantity']:
439 del self.game_data['player inventory']['Ether Potion']
440
441 def set_timer_to_current_time(self):
442 """Set the timer to the current time."""
443 self.timer = self.current_time
444
445 def cast_fire_blast(self):
446 """
447 Cast fire blast on all enemies.
448 """
449 self.notify(c.FIRE)
450 self.state = self.info_box.state = c.FIRE_SPELL
451 POWER = self.inventory['Fire Blast']['power']
452 POWER += self.game_data['player stats']['Level'] * 5
453 MAGIC_POINTS = self.inventory['Fire Blast']['magic points']
454 self.game_data['player stats']['magic']['current'] -= MAGIC_POINTS
455 for enemy in self.enemy_list:
456 DAMAGE = random.randint(POWER//2, POWER)
457 self.damage_points.add(
458 attackitems.HealthPoints(DAMAGE, enemy.rect.topright))
459 enemy.health -= DAMAGE
460 posx = enemy.rect.x - 32
461 posy = enemy.rect.y - 64
462 fire_sprite = attack.Fire(posx, posy)
463 self.attack_animations.add(fire_sprite)
464 if enemy.health <= 0:
465 enemy.kill()
466 self.arrow.remove_pos(enemy)
467 else:
468 enemy.enter_knock_back_state()
469 self.enemy_list = [enemy for enemy in self.enemy_list if enemy.health > 0]
470 self.enemy_index = 0
471 self.arrow.index = 0
472 self.arrow.state = 'invisible'
473 self.set_timer_to_current_time()
474
475 def cast_cure(self):
476 """
477 Cast cure spell on player.
478 """
479 self.state = c.CURE_SPELL
480 HEAL_AMOUNT = self.inventory['Cure']['power']
481 MAGIC_POINTS = self.inventory['Cure']['magic points']
482 self.player.healing = True
483 self.set_timer_to_current_time()
484 self.arrow.state = 'invisible'
485 self.enemy_index = 0
486 self.damage_points.add(
487 attackitems.HealthPoints(HEAL_AMOUNT, self.player.rect.topright, False))
488 self.player_healed(HEAL_AMOUNT, MAGIC_POINTS)
489 self.info_box.state = c.DRINK_HEALING_POTION
490
491 def drink_ether(self):
492 """
493 Drink ether potion.
494 """
495 self.state = self.info_box.state = c.DRINK_ETHER_POTION
496 self.player.healing = True
497 self.set_timer_to_current_time()
498 self.arrow.state = 'invisible'
499 self.enemy_index = 0
500 self.damage_points.add(
501 attackitems.HealthPoints(30,
502 self.player.rect.topright,
503 False,
504 True))
505 self.magic_boost(30)
506
507 def drink_healing_potion(self):
508 """
509 Drink Healing Potion.
510 """
511 self.state = self.info_box.state = c.DRINK_HEALING_POTION
512 self.player.healing = True
513 self.arrow.state = 'invisible'
514 self.enemy_index = 0
515 self.damage_points.add(
516 attackitems.HealthPoints(30,
517 self.player.rect.topright,
518 False))
519 self.player_healed(30)
520 self.set_timer_to_current_time()
521
522 def enter_select_enemy_state(self):
523 """
524 Transition battle into the select enemy state.
525 """
526 self.state = self.arrow.state = c.SELECT_ENEMY
527 self.arrow.index = 0
528
529 def enter_select_item_state(self):
530 """
531 Transition battle into the select item state.
532 """
533 self.state = self.info_box.state = c.SELECT_ITEM
534 self.arrow.become_select_item_state()
535
536 def enter_select_magic_state(self):
537 """
538 Transition battle into the select magic state.
539 """
540 self.state = self.info_box.state = c.SELECT_MAGIC
541 self.arrow.become_select_magic_state()
542
543 def try_to_run_away(self):
544 """
545 Transition battle into the run away state.
546 """
547 self.run_away = True
548 self.arrow.state = 'invisible'
549 self.enemy_index = 0
550 self.enter_enemy_attack_state()
551
552 def enter_enemy_attack_state(self):
553 """
554 Transition battle into the Enemy attack state.
555 """
556 self.state = self.info_box.state = c.ENEMY_ATTACK
557 enemy = self.enemy_list[self.enemy_index]
558 enemy.enter_enemy_attack_state()
559
560 def enter_player_attack_state(self):
561 """
562 Transition battle into the Player attack state.
563 """
564 self.state = self.info_box.state = c.PLAYER_ATTACK
565 enemy_to_attack = self.enemies_to_attack.pop(0)
566 if enemy_to_attack in self.enemy_list:
567 self.player.enter_attack_state(enemy_to_attack)
568 else:
569 if self.enemy_list:
570 self.player.enter_attack_state(self.enemy_list[0])
571 else:
572 self.enter_battle_won_state()
573 self.arrow.state = 'invisible'
574
575 def get_enemy_to_attack(self):
576 """
577 Get enemy for player to attack by arrow position.
578 """
579 enemy_posx = self.arrow.rect.x + 60
580 enemy_posy = self.arrow.rect.y - 20
581 enemy_pos = (enemy_posx, enemy_posy)
582 enemy_to_attack = None
583
584 for enemy in self.enemy_list:
585 if enemy.rect.topleft == enemy_pos:
586 enemy_to_attack = enemy
587
588 return enemy_to_attack
589
590
591 def enter_drink_healing_potion_state(self):
592 """
593 Transition battle into the Drink Healing Potion state.
594 """
595 self.state = self.info_box.state = c.DRINK_HEALING_POTION
596 self.player.healing = True
597 self.set_timer_to_current_time()
598 self.arrow.state = 'invisible'
599 self.enemy_index = 0
600 self.damage_points.add(
601 attackitems.HealthPoints(30,
602 self.player.rect.topright,
603 False))
604 self.player_healed(30)
605
606 def enter_drink_ether_potion_state(self):
607 """
608 Transition battle into the Drink Ether Potion state.
609 """
610 self.state = self.info_box.state = c.DRINK_ETHER_POTION
611 self.player.healing = True
612 self.arrow.state = 'invisible'
613 self.enemy_index = 0
614 self.damage_points.add(
615 attackitems.HealthPoints(30,
616 self.player.rect.topright,
617 False,
618 True))
619 self.magic_boost(30)
620 self.set_timer_to_current_time()
621
622 def enter_select_action_state(self):
623 """
624 Transition battle into the select action state
625 """
626 self.state = self.info_box.state = c.SELECT_ACTION
627 self.arrow.index = 0
628 self.arrow.state = self.state
629
630 def enter_player_damaged_state(self):
631 """
632 Transition battle into the player damaged state.
633 """
634 self.state = self.info_box.state = c.PLAYER_DAMAGED
635 if self.enemy_index > len(self.enemy_list) - 1:
636 self.enemy_index = 0
637 enemy = self.enemy_list[self.enemy_index]
638 player_damage = enemy.calculate_hit(self.inventory['equipped armor'],
639 self.inventory)
640 self.damage_points.add(
641 attackitems.HealthPoints(player_damage,
642 self.player.rect.topright))
643 self.info_box.set_player_damage(player_damage)
644 self.set_timer_to_current_time()
645 self.player_damaged(player_damage)
646 if player_damage:
647 self.player.damaged = True
648 self.player.enter_knock_back_state()
649
650 def enter_enemy_damaged_state(self):
651 """
652 Transition battle into the enemy damaged state.
653 """
654 self.state = self.info_box.state = c.ENEMY_DAMAGED
655 enemy_damage = self.player.calculate_hit()
656 self.damage_points.add(
657 attackitems.HealthPoints(enemy_damage,
658 self.player.attacked_enemy.rect.topright))
659
660 self.info_box.set_enemy_damage(enemy_damage)
661
662 self.arrow.index = 0
663 self.attack_enemy(enemy_damage)
664 self.set_timer_to_current_time()
665
666 def switch_enemy(self):
667 """
668 Switch which enemy the player is attacking.
669 """
670 if self.enemy_index < len(self.enemy_list) - 1:
671 self.enemy_index += 1
672 self.enter_enemy_attack_state()
673
674 def enter_run_away_state(self):
675 """
676 Transition battle into the run away state.
677 """
678 self.state = self.info_box.state = c.RUN_AWAY
679 self.arrow.state = 'invisible'
680 self.player.state = c.RUN_AWAY
681 self.set_timer_to_current_time()
682
683 def enter_battle_won_state(self):
684 """
685 Transition battle into the battle won state.
686 """
687 self.state = self.info_box.state = c.BATTLE_WON
688 self.player.state = c.VICTORY_DANCE
689 self.set_timer_to_current_time()
690
691 def enter_show_gold_state(self):
692 """
693 Transition battle into the show gold state.
694 """
695 self.inventory['GOLD']['quantity'] += self.new_gold
696 self.state = self.info_box.state = c.SHOW_GOLD
697 self.set_timer_to_current_time()
698
699 def enter_show_experience_state(self):
700 """
701 Transition battle into the show experience state.
702 """
703 self.state = self.info_box.state = c.SHOW_EXPERIENCE
704 self.set_timer_to_current_time()
705
706 def enter_level_up_state(self):
707 """
708 Transition battle into the LEVEL UP state.
709 """
710 self.state = self.info_box.state = c.LEVEL_UP
711 self.info_box.reset_level_up_message()
712 self.set_timer_to_current_time()
713
714 def enter_two_actions_per_turn_state(self):
715 self.state = self.info_box.state = c.TWO_ACTIONS
716 self.set_timer_to_current_time()
717
718 def execute_player_actions(self):
719 """
720 Execute the player actions.
721 """
722 if self.player_level < 3:
723 if self.player_actions:
724 enter_state = self.player_action_dict[self.player_actions[0]]
725 enter_state()
726 self.player_actions.pop(0)
727 else:
728 if len(self.player_actions) == 2:
729 enter_state = self.player_action_dict[self.player_actions[0]]
730 enter_state()
731 self.player_actions.pop(0)
732 self.action_selected = False
733 else:
734 if self.action_selected:
735 self.enter_select_action_state()
736 self.action_selected = False
737
738
739
740
741
742
743
744
745