Пример #1
0
 public function move(Request $request)
 {
     $tigerId = $request->input('tiger');
     $goatId = $request->input('goat');
     $player = $request->input('player');
     $move = json_decode($request->input('move'));
     if (Game::checkMove($tigerId, $goatId, $move, $player)) {
         $move = Game::movePlayer($tigerId, $goatId, $player, $move);
     }
     Event::fire(new PlayerMoved($tigerId, $goatId, $move, true));
 }
Пример #2
0
 public static function checkMove($tigerId, $goatId, $move, $player)
 {
     $return = false;
     $game = Game::getActivePosition($tigerId, $goatId);
     $moves = (new Moves($game))->generateAllowedMoves();
     $data = array_merge($game->getLayout(), $moves);
     if ($data['nextMove'][$player]) {
         switch ($player) {
             case 'Goat':
                 if ($data['GoatData'] > 20) {
                     foreach ($data['PlaceGoat'] as $places) {
                         if ($places === $move->x . ',' . $move->y) {
                             $return = true;
                             break;
                         }
                     }
                 } else {
                 }
                 break;
             case 'Tiger':
                 break;
         }
     }
     return $return;
 }