public static MoveStatus MovCommand(int userId, Direction direction) { Lobby lobby = LobbyRepository.Read(0); var currentPlayer = lobby.Players.Find(e => e.TelegramUserId == userId); var actionList = PlayerLogic.TryMove(lobby, currentPlayer, direction); LobbyRepository.Update(lobby); FormatAnswers.ConsoleApp(lobby); if (actionList.Contains(PlayerAction.GameEnd)) { return(new MoveStatus { IsGameEnd = true, CurrentPlayer = currentPlayer, PlayerActions = actionList }); } MoveStatus status = new MoveStatus { IsOtherTurn = false, IsGameEnd = false, CurrentPlayer = currentPlayer, PlayerActions = actionList }; return(status); }
public static MoveStatus MoveCommand(int userId, Direction direction) { Lobby lobby = LobbyRepository.Read(MemberRepository.ReadLobbyId(userId)); if (LobbyService.CanMakeTurn(lobby, userId) == false) { return(new MoveStatus() { IsOtherTurn = true }); } var currentPlayer = lobby.Players[lobby.CurrentTurn]; var actionList = PlayerLogic.TryMove(lobby, currentPlayer, direction); LobbyService.EndTurn(lobby); //TODO: Вывод для дебага FormatAnswers.ConsoleApp(lobby); if (actionList.Contains(PlayerAction.GameEnd)) { lobby.IsActive = false; MemberRepository.Delete(lobby.GameId); LobbyService.EndTurn(lobby); return(new MoveStatus { IsGameEnd = true, CurrentPlayer = currentPlayer, PlayerActions = actionList }); } MoveStatus status = new MoveStatus { IsOtherTurn = false, IsGameEnd = false, CurrentPlayer = currentPlayer, PlayerActions = actionList }; if (actionList.Contains(PlayerAction.MeetPlayer)) { status.PlayersOnSameCell = MazeLogic.PlayersOnCell(currentPlayer, lobby); } return(status); }