Class: ExchangeCarrots
- Defined in:
- lib/software_challenge_client/action.rb
Overview
Karottentauschaktion. Es können auf einem Karottenfeld 10 Karotten abgegeben oder aufgenommen werden. Dies kann beliebig oft hintereinander ausgeführt werden.
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(value) ⇒ ExchangeCarrots
constructor
A new instance of ExchangeCarrots.
- #perform!(gamestate) ⇒ Object
- #type ⇒ Object
Methods inherited from Action
Constructor Details
#initialize(value) ⇒ ExchangeCarrots
Returns a new instance of ExchangeCarrots.
182 183 184 |
# File 'lib/software_challenge_client/action.rb', line 182 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
180 181 182 |
# File 'lib/software_challenge_client/action.rb', line 180 def value @value end |
Instance Method Details
#==(other) ⇒ Object
197 198 199 |
# File 'lib/software_challenge_client/action.rb', line 197 def ==(other) other.type == type && other.value == value end |
#perform!(gamestate) ⇒ Object
186 187 188 189 190 191 |
# File 'lib/software_challenge_client/action.rb', line 186 def perform!(gamestate) valid, = GameRules.is_valid_to_exchange_carrots(gamestate, value) invalid("Es können nicht #{value} Karotten aufgenommen werden. " + ) unless valid gamestate.current_player.carrots += value gamestate.set_last_action(self) end |
#type ⇒ Object
193 194 195 |
# File 'lib/software_challenge_client/action.rb', line 193 def type :exchange_carrots end |