|
@@ -244,8 +244,12 @@ discard block |
|
|
block discarded – undo |
|
244
|
244
|
$opponent_move = $opponent->getLastMoveIndex(); |
|
245
|
245
|
|
|
246
|
246
|
// verify moves have been set |
|
247
|
|
- if (!is_array($player_move)) throw new RockPaperScissorsSpockLizardException($player->getName() . ' has not set a move!'); |
|
248
|
|
- if (!is_array($opponent_move)) throw new RockPaperScissorsSpockLizardException($opponent->getName() . ' has not set a move!'); |
|
|
247
|
+ if (!is_array($player_move)) { |
|
|
248
|
+ throw new RockPaperScissorsSpockLizardException($player->getName() . ' has not set a move!'); |
|
|
249
|
+ } |
|
|
250
|
+ if (!is_array($opponent_move)) { |
|
|
251
|
+ throw new RockPaperScissorsSpockLizardException($opponent->getName() . ' has not set a move!'); |
|
|
252
|
+ } |
|
249
|
253
|
|
|
250
|
254
|
// move labels |
|
251
|
255
|
$player_move_label = ucfirst(key($player_move)); |
|
@@ -256,10 +260,18 @@ discard block |
|
|
block discarded – undo |
|
256
|
260
|
$opponent_move_index = $this->getMoveIndex($opponent_move); |
|
257
|
261
|
|
|
258
|
262
|
// Exceptions |
|
259
|
|
- if (!is_numeric($player_move_index)) throw new RockPaperScissorsSpockLizardException($player->getName() . ' made an illegal move!'); |
|
260
|
|
- if (!is_numeric($opponent_move_index)) throw new RockPaperScissorsSpockLizardException($opponent->getName() . ' made an illegal move!'); |
|
261
|
|
- if (current($player_move) === true) throw new RockPaperScissorsSpockLizardException($player->getName() . ' has already made this move!'); |
|
262
|
|
- if (current($opponent_move) === true) throw new RockPaperScissorsSpockLizardException($opponent->getName() . ' has already made this move!'); |
|
|
263
|
+ if (!is_numeric($player_move_index)) { |
|
|
264
|
+ throw new RockPaperScissorsSpockLizardException($player->getName() . ' made an illegal move!'); |
|
|
265
|
+ } |
|
|
266
|
+ if (!is_numeric($opponent_move_index)) { |
|
|
267
|
+ throw new RockPaperScissorsSpockLizardException($opponent->getName() . ' made an illegal move!'); |
|
|
268
|
+ } |
|
|
269
|
+ if (current($player_move) === true) { |
|
|
270
|
+ throw new RockPaperScissorsSpockLizardException($player->getName() . ' has already made this move!'); |
|
|
271
|
+ } |
|
|
272
|
+ if (current($opponent_move) === true) { |
|
|
273
|
+ throw new RockPaperScissorsSpockLizardException($opponent->getName() . ' has already made this move!'); |
|
|
274
|
+ } |
|
263
|
275
|
|
|
264
|
276
|
// compare player with opponent |
|
265
|
277
|
if (isset($this->move_outcomes[$player_move_index][$opponent_move_index])) { |