Module: GameEngine::GameResolver
- Defined in:
- lib/smack_engine/game_resolver.rb
Class Method Summary collapse
-
.calc_points ⇒ Object
Calc_points should work when the damage value returned from damage above is negative (when player two has a higher maxstat) or positive (when player one has a higher maxstat).
-
.damage ⇒ Object
if player one has a higher maxstat, the overall damage value returned is positive.
- .deal_cards(game_state) ⇒ Object
- .determine_maxstat(player) ⇒ Object
- .reset_selections ⇒ Object
- .resolve_round(game_state) ⇒ Object
Class Method Details
.calc_points ⇒ Object
Calc_points should work when the damage value returned from damage above is negative (when player two has a higher maxstat) or positive (when player one has a higher maxstat). (For example, consider that the subtraction of a negative value adds a positive value and the addition of negative value subtracts that value.)
22 23 24 25 |
# File 'lib/smack_engine/game_resolver.rb', line 22 def self.calc_points @player_one.points += damage @player_two.points -= damage end |
.damage ⇒ Object
if player one has a higher maxstat, the overall damage value returned is positive. If player two has a higher maxstat, the overall damage value returned is negative.
17 18 19 |
# File 'lib/smack_engine/game_resolver.rb', line 17 def self.damage determine_maxstat(@player_one) - determine_maxstat(@player_two) end |
.deal_cards(game_state) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/smack_engine/game_resolver.rb', line 32 def self.deal_cards(game_state) player_one = game_state.player_one player_two = game_state.player_two until player_one.hand.size == GAME_RULES[:hand_size] player_one.hand << player_one.deck.list.pop end until player_two.hand.size == GAME_RULES[:hand_size] player_two.hand << player_two.deck.list.pop end end |
.determine_maxstat(player) ⇒ Object
12 13 14 |
# File 'lib/smack_engine/game_resolver.rb', line 12 def self.determine_maxstat(player) player.selection.first.nil? ? 0 : player.selection.first.max_stat end |
.reset_selections ⇒ Object
27 28 29 30 |
# File 'lib/smack_engine/game_resolver.rb', line 27 def self.reset_selections @player_one.selection = [] @player_two.selection = [] end |
.resolve_round(game_state) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/smack_engine/game_resolver.rb', line 3 def self.resolve_round(game_state) @player_one = game_state.player_one @player_two = game_state.player_two calc_points reset_selections game_state.phase = :won if game_state.won? end |