示例#1
0
        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);
        }
示例#2
0
        private static void EndRound()
        {
            if (isGameOver)
            {
                return;
            }

            ConsoleManager.Print("═ End of leg ═ ", 200);
            ConsoleManager.Print("╦══ Leg result ", 200);

            var players = GameManager.GetAllPlayers();

            for (int i = 0; i < players.Count; i++)
            {
                var    player = players[i];
                string pretty = (player.legBetCards.Count == 0 && i == players.Count - 1) ? "╚═ " : "╠═ ";
                if (player.diceRolled > 0)
                {
                    ConsoleManager.Print(pretty + $"{player.name} rolled {player.diceRolled} so he/she earn {player.diceCoinValue} {TextUtils.CoinOrCoins(player.diceCoinValue)} coins.", 200);
                    player.ChangeCoins(player.diceCoinValue);
                }

                for (int j = 0; j < player.legBetCards.Count; j++)
                {
                    var card     = player.legBetCards[j];
                    var betValue = card.rewards[Board.GetCamelPosition(card.camel)];
                    player.ChangeCoins(betValue);

                    pretty = (i == players.Count - 1 && j == player.legBetCards.Count - 1) ? "╚═ " : "╠═ ";
                    string earnedOrLost = TextUtils.EarnedOrLost(betValue);
                    ConsoleManager.Print(pretty + $"{player.name} {earnedOrLost} {TextUtils.NoSignal(betValue)} {TextUtils.CoinOrCoins(betValue)} betting on {card.camel.fullName}.", 200);
                }

                player.RoundReset();
            }

            ConsoleManager.Print(TextUtils.SEPARATOR, 2000);
            GameManager.ResetDices();
        }