Return to repo list

heart-of-gold

Tactical RPG written in python, using pygame.
Return to HMagellan.com

commit 515ce6391a849e50b6dda8bb5c76ce78e989a2b2
parent b72b6139d28a12c7a2c6b50c8ab48d59b5fe3003
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Sun, 25 Apr 2021 17:20:42 -0500

generic exitablity for action buttons and new comments

Diffstat:
Msrc/turn.py | 21++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/turn.py b/src/turn.py @@ -190,7 +190,6 @@ class TurnManager(manager.Manager): rds[p] += p.active_stats["INIT"] + max(1, (p.active_stats["SPD"] // 3)) if rds[p] >= 100: next_turn_candidates.append(p) - rds[p] -= 100 if len(next_turn_candidates) > 0: next_turn_candidates.sort(reverse = True, key = lambda can: (rds[can] + 100, can.active_stats["SPD"])) @@ -270,6 +269,17 @@ class TurnManager(manager.Manager): break # Do action buttons. They are ordered so we know which is which by index + # TODO: Nothing else is index-accessed this way. This should be changed. + # Truly, calling to the bus should be performed by the button object itself. + # This object should have an associated bus method that it is passed when created, + # and it should call this when clicked. This whole structure here should be replaced + # with a call to a 'am i collided-with' function for every button in action buttons. + # The buttons could also have a 'result_ctrl_mode' attribute that represents what + # CTRL_MODE should be switched to when it is clicked. It is possible that the + # easiest way to do this would be to make an abstract action button class that + # works like the current one along with having a generic, overwritable 'be_clicked' + # method and taking a 'result_ctrl_mode' argument in addition to the current ones, + # and then subclassing this into the resultant actual action buttons. if self.action_buttons[0].rect.collidepoint(pos) and self.action_buttons[0].clickable: self.bus.perform_display_move_range_of_piece(self.current_active_piece) self.camera.snap_to_position(self.current_active_piece.rect.center) @@ -278,9 +288,18 @@ class TurnManager(manager.Manager): self.bus.perform_display_attack_range_of_piece(self.current_active_piece) self.camera.snap_to_position(self.current_active_piece.rect.center) self.game.control_mode = CTRL_MODES.Turn_Select_Attack + elif self.action_buttons[2].rect.collidepoint(pos) and self.action_buttons[2].clickable: + self.camera.snap_to_position(self.current_active_piece.rect.center) + self.game.control_mode = CTRL_MODES.Turn_Choose_Skill + elif self.action_buttons[3].rect.collidepoint(pos) and self.action_buttons[3].clickable: + self.camera.snap_to_position(self.current_active_piece.rect.center) + self.game.control_mode = CTRL_MODES.Turn_Choose_Item elif self.action_buttons[4].rect.collidepoint(pos) and self.action_buttons[4].clickable: self.bus.perform_execute_guard(self.current_active_piece) self.game.control_mode = CTRL_MODES.Turn_Watch_Guard + elif self.action_buttons[5].rect.collidepoint(pos) and self.action_buttons[5].clickable: + self.camera.snap_to_position(self.current_active_piece.rect.center) + self.game.control_mode = CTRL_MODES.Turn_Select_Push elif self.action_buttons[6].rect.collidepoint(pos) and self.action_buttons[6].clickable: self.shift_turns()