Exemplo n.º 1
0
        public static void LogLegBets()
        {
            string pretty = "";

            ConsoleManager.Print("Leg bet cards with players", 100);
            var players = GetAllPlayers().Where(x => x.legBetCards.Count > 0).ToList();

            for (int i = 0; i < players.Count; i++)
            {
                var player = players[i];
                for (int j = 0; j < player.legBetCards.Count; j++)
                {
                    var card = player.legBetCards[j];
                    pretty = (j == player.legBetCards.Count - 1 && i == players.Count - 1) ? "  ╚═ " : "  ╠═ ";
                    ConsoleManager.Print(pretty + $"{player.name} has {card.ToString()}", 100);
                }
            }
            if (players.Count == 0)
            {
                ConsoleManager.Print("  ╚═ None");
            }

            ConsoleManager.Print("Leg Bet cards availables", 100);
            var bestCards = GetBestLegCardFromEachCamel();

            for (int i = 0; i < bestCards.Count; i++)
            {
                pretty = i == bestCards.Count - 1 ? "  ╚═ " : "  ╠═ ";
                ConsoleManager.Print(pretty + bestCards[i].ToString(), 100);
            }
            if (bestCards.Count == 0)
            {
                ConsoleManager.Print("  ╚═ None");
            }
        }
Exemplo n.º 2
0
        private static void PlayerTurn(int index)
        {
            if (isGameOver)
            {
                return;
            }

            mCurrentPlayer = GameManager.GetPlayer(index);

            ConsoleManager.Print($"═ New turn ═ Player({index}): {mCurrentPlayer.name}", 200);

            var action = GetPlayerAction();

            ConsoleManager.JumpLine();

            action.DoAction(mCurrentPlayer);
            action.AskActionParameters();

            ConsoleManager.JumpLine();

            mCurrentPlayerIndex++;
            if (mCurrentPlayerIndex >= GameManager.PlayerCount())
            {
                mCurrentPlayerIndex = 0;
            }

            if (GameManager.GetDiceCount() == 0)
            {
                EndRound();
            }

            PlayerTurn(mCurrentPlayerIndex);
        }
Exemplo n.º 3
0
        public static string GetMultipleChoiseAnswer(List <string> options)
        {
            string optionsText = "";

            options.ForEach(x => optionsText += x + ", ");
            optionsText = optionsText.Remove(optionsText.Length - 2);

            string invalidAnswer = "Invalid answer, please type one of these options: " + optionsText;

            bool   loop   = true;
            string answer = "";

            do
            {
                answer = Console.ReadLine().ToUpper();
                CheckCustomCommands(answer);
                if (options.Exists(x => x.ToUpper().Equals(answer.ToUpper())))
                {
                    loop = false;
                }
                else
                {
                    ConsoleManager.Print(invalidAnswer);
                }
            } while (loop);

            return(answer);
        }
Exemplo n.º 4
0
        public static void LogAvailableCamels()
        {
            ConsoleManager.Print("Camels that didn't moved this leg");
            string pretty;

            for (int i = 0; i < mDices.Count; i++)
            {
                pretty = i == mDices.Count - 1 ? "  ╚═ " : "  ╠═ ";
                ConsoleManager.Print(pretty + $"{ColorUtils.colorsName[mDices[i].color]}");
            }
        }
Exemplo n.º 5
0
        public static void DumpCommands()
        {
            ConsoleManager.Print("Available commands", 100);
            string pretty = "";

            for (int i = 0; i < customCommands.Count; i++)
            {
                pretty = i == customCommands.Count - 1 ? "  ╚═ " : "  ╠═ ";
                ConsoleManager.Print(pretty + customCommands[i].ToString(), 200);
            }
        }
Exemplo n.º 6
0
        private static BaseAction GetPlayerAction()
        {
            ConsoleManager.Print($"╦═ {mCurrentPlayer.name}, you have these actions to choose:", 200);
            var           actions = GetActions();
            List <string> options = new List <string>();

            for (int i = 0; i < actions.Count; i++)
            {
                string pretty = i == actions.Count - 1 ? "╚═" : "╠═";
                ConsoleManager.Print(pretty + $"[{i}] {actions[i].description}", 100);
                options.Add(i.ToString());
            }
            var playerOption = int.Parse(CommandManager.GetMultipleChoiseAnswer(options));

            return(actions[playerOption]);
        }
Exemplo n.º 7
0
        public static void RegisterPlayers()
        {
            ResetPlayers();

            bool addPlayers  = true;
            int  playerCount = 0;

            while (addPlayers)
            {
                ConsoleManager.Print($"Adding players. Type player({playerCount}) name:");
                AddPlayer(new Player(Console.ReadLine()));
                ConsoleManager.Print($"{GetPlayer(playerCount).name} added as player number: {playerCount}");
                ConsoleManager.Print("Add more players? (Y / N)", 200);
                addPlayers = CommandManager.GetYesNoAnswer();
                playerCount++;
            }
        }
Exemplo n.º 8
0
        public void Dump()
        {
            string betCardsDump = String.Empty;
            string pretty       = "";

            for (int i = 0; i < legBetCards.Count; i++)
            {
                pretty        = i == legBetCards.Count - 1 ? "      ╚═ " : "      ╠═ ";
                betCardsDump += Environment.NewLine + pretty + legBetCards[i].ToString();
            }

            if (betCardsDump.Equals(string.Empty))
            {
                betCardsDump = "None";
            }

            ConsoleManager.Print($"{name} " + Environment.NewLine + $"  ╠═ Coins: {coins}" + Environment.NewLine + $"  ╚═ Bet cards: {betCardsDump}", 200);
        }
Exemplo n.º 9
0
        public static bool GetYesNoAnswer()
        {
            bool   loop   = true;
            string answer = "";

            do
            {
                answer = Console.ReadLine().ToUpper();
                CheckCustomCommands(answer);
                if (answer == "Y" || answer == "N")
                {
                    loop = false;
                }
                else
                {
                    ConsoleManager.Print("Invalid answer, please type Y for yes or N for no.");
                }
            } while (loop);

            return(answer == "Y");
        }
Exemplo n.º 10
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();
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
0
 public static void LogOverallBets()
 {
     ConsoleManager.Print("Overall bets", 100);
     ConsoleManager.Print($"  ╠═ Bets in winner: {mWinnerOverwallBet.Count}", 100);
     ConsoleManager.Print($"  ╚═ Bets in looser: {mLooserOverwallBet.Count}", 100);
 }