Esempio n. 1
0
        public dynamic GetCurrentGameData(bool detailed = false)
        {
            var currentPlay = m_Game.GetLastPlay();

            var lastTurnPlay       = m_Game.GetLastTurnPlay();
            var lastTurnPlayerName = m_Game.GetLastTurnPlayerName();

            var simpleHistory = lastTurnPlayerName + "=";

            if (lastTurnPlay != null && lastTurnPlay.Count > 0)
            {
                simpleHistory += BigTwoLogic.ToString(lastTurnPlay);
            }

            var data = new
            {
                play    = currentPlay != null && currentPlay.Count > 0 ? BigTwoLogic.ToString(currentPlay) : "",
                history = simpleHistory,
                last    = m_Game.GetLastPlayerName(),
                current = m_Game.GetCurrentTurnPlayerName(),
                state   = m_Game.GetGameState(),
                turns   = m_Game.GetCurrentTurns(),
                players = new List <string>(),
                scores  = new List <int>(),
                cards   = new List <string>(),
            };

            var gamePlayers = m_Game.GetPlayers();

            foreach (var gamePlayer in gamePlayers)
            {
                data.players.Add(gamePlayer.PlayerName);
                data.scores.Add(gamePlayer.GameScore);

                if (detailed)
                {
                    data.cards.Add(BigTwoLogic.EncodeCards(gamePlayer.CurrentHand.GetCards()));
                }
                else
                {
                    data.cards.Add(gamePlayer.CurrentHand.GetNumberOfCards().ToString());
                }
            }

            return(data);
        }
Esempio n. 2
0
        private void btnPlayerA_Click(object sender, EventArgs e)
        {
            var currentName = m_Game.GetCurrentTurnPlayerName();
            var lastName    = m_Game.GetLastPlayerName();

            if (AutoPlay())
            {
                var currentPlayerName = m_Game.GetCurrentTurnPlayerName();
                var lastPlayerName    = m_Game.GetLastPlayerName();
                var lastPlay          = m_Game.GetLastPlay();

                if (m_Game.GetLastTurnPlay().Count <= 0)
                {
                    LogMsg(currentName + " => PASS ");
                }
                else
                {
                    LogMsg(lastPlayerName + " => " + HandToString(lastPlay));
                }

                UpdateGameDisplay();
            }
        }