private void GameLoop() { State.GameHasNoWinner = true; List <Player> playerWinOrder = new(); while (State.GameHasNoWinner) { while (!PlayerFunctions.CheckIfActivePlayerIsInTheGame(State)) { NextPlayer(); } ShouldTheEngineAskThePlayerIfTheyWantToSave(); Turn currentTurn = new(); currentTurn.Roll = State.Players[State.ActivePlayer].Dice.Roll(); Console.WriteLine($"{State.Players[State.ActivePlayer].Name} rolled a {currentTurn.Roll}"); if (Movement.AreThereLegalMoves((int)currentTurn.Roll, State)) { currentTurn = State.Players[State.ActivePlayer].Selector .Selector(State, currentTurn, Movement.ListLegalMoves( (int)currentTurn.Roll, State )); bool pushed = ExecuteTurn(currentTurn); if (!pushed && currentTurn.Roll != 6) { NextPlayer(); } } else { Console.WriteLine("No legal moves found, moving to next player"); if (currentTurn.Roll != 6) { NextPlayer(); } } State.Turnlist.Add(currentTurn); if (State.Players[State.ActivePlayer].Score == 4) { playerWinOrder = RemoveActivePlayerFromTheGame(playerWinOrder); State.GameHasNoWinner = false; } } Console.WriteLine($"Player {playerWinOrder[0].Name} won the game!\n~~Congratulations~~"); }
internal void RunLoadedTurns(List <Turn> executedTurns) { foreach (Turn t in executedTurns) { while (!PlayerFunctions.CheckIfActivePlayerIsInTheGame(State)) { NextPlayer(); } bool pushed = ExecuteTurn(t); if (!pushed && t.Roll != 6) { NextPlayer(); } State.Turnlist.Add(t); } GameLoop(); }