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