public static void EndGame(Camel camel) { isGameOver = true; Board.Dump(); ConsoleManager.JumpLine(); ConsoleManager.Print($"The game is over. Camel {camel.fullName} crossed the line.", 200); var camels = GameManager.GetAllCamels(); string pretty = ""; for (int i = 0; i < camels.Count; i++) { pretty = camels.Count - 1 == 0 ? " ╚═" : " ╠═"; ConsoleManager.Print(pretty + $"{TextUtils.Colocation(i+1)} camel: {Board.GetCamelAtPosition(i).fullName}", 200); } int betIndex = 0; pretty = ""; Camel winner = Board.GetCamelAtPosition(0); ConsoleManager.JumpLine(); ConsoleManager.Print("Checking overall winner bets cards", 200); var winQueue = GameManager.GetOverallWinnerQueue(); if (winQueue.Count == 0) { ConsoleManager.Print($" ╚═No one placed a bet on winner, so no one get coins.", 200); } else { do { var bet = winQueue.Dequeue(); pretty = winQueue.Count == 0 ? " ╚═" : " ╠═"; var value = 0; if (bet.camel.name.Equals(winner.name)) { value = GameManager.overallBetPaytable[betIndex]; betIndex++; } else { value = GameManager.overallMissBet; } ConsoleManager.Print(pretty + $"{bet.owner.name} made a bet on {bet.camel.fullName} to win and {TextUtils.EarnedOrLost(value)} {TextUtils.NoSignal(value)} {TextUtils.CoinOrCoins(value)}.", 200); bet.owner.ChangeCoins(value); } while (winQueue.Count > 0); } Camel looser = Board.GetCamelAtPosition(GameManager.GetAllCamels().Count - 1); betIndex = 0; ConsoleManager.JumpLine(); ConsoleManager.Print("Checking overall looser bets cards", 200); var looseQueue = GameManager.GetOverallLooserQueue(); if (looseQueue.Count == 0) { ConsoleManager.Print($" ╚═ No one placed a bet on looser, so no one get coins."); } else { do { var bet = looseQueue.Dequeue(); pretty = looseQueue.Count == 0 ? " ╚═" : " ╠═"; var value = 0; if (bet.camel.name.Equals(looser.name)) { value = GameManager.overallBetPaytable[betIndex]; betIndex++; } else { value = GameManager.overallMissBet; } ConsoleManager.Print(pretty + $"{bet.owner.name} made a bet on {bet.camel.fullName} to loose and {TextUtils.EarnedOrLost(value)} {TextUtils.NoSignal(value)} {TextUtils.CoinOrCoins(value)}.", 200); bet.owner.ChangeCoins(value); } while (looseQueue.Count > 0); } ConsoleManager.JumpLine(); GameManager.LogPlayers(); ConsoleManager.JumpLine(); var playerWinner = GameManager.GetAllPlayers().OrderByDescending(x => x.coins).First(); ConsoleManager.Print($"Congratulations {playerWinner.name} you won the game with {playerWinner.coins} {TextUtils.CoinOrCoins(playerWinner.coins)}.!", 200); }
public static void LogLastCamel() { var camel = GetCamelAtPosition(GameManager.GetAllCamels().Count - 1); ConsoleManager.Print($"{TextUtils.Colocation(GameManager.GetAllCamels().Count)} camel {camel.fullName}"); }