public override void Action(GameStateArgs gmStateArgs)
        {
            string input;

            //Check if WaitingtoStart state was invoked with input string argument
            if (gmStateArgs != null)
            {
                input = gmStateArgs.StringData;
            }
            else
            {
                input = Console.ReadLine();
            }

            if (input != null && _startGameCommandRegEx.IsMatch(input))
            {
                GameStateArgs gStateArgs = new GameStateArgs();
                gStateArgs.StringData = input;

                InvokingFSM.PerformTransitionTo(GameStateID.Playing, gStateArgs);
            }
            else
            {
                InvokingFSM.PerformTransitionTo(GameStateID.EndSession, null);
            }
        }
        public void Start(GameStateID startingState, GameStateArgs startingStateArgs)
        {
            PerformTransitionTo(startingState, startingStateArgs);

            while (!_ended)
            {
                ExecuteCurrentStateAction();
            }
        }
        public override void Action(GameStateArgs gmStateArgs)
        {
            //Extract all card signatures from input string
            string allCardsSignatures = gmStateArgs.StringData.Substring(25);

            PrepareNewGame(allCardsSignatures);
            DisplayCurrentGameInformation();
            while (!_endGame)
            {
                string input = Console.ReadLine();

                if (CheckIfInputIsValid(input))
                {
                    _turn += 1;

                    switch (input.Substring(0, 9))
                    {
                    case "Play card":
                        PlayCard(input);
                        break;

                    case "Drop card":
                        DropCard(input);
                        break;

                    case "Tell colo":
                        TellColor(input);
                        break;

                    case "Tell rank":
                        TellRank(input);
                        break;
                    }
                    SwapPlayers();
                    DisplayCurrentGameInformation();
                }
                //If input is "Start new game" command
                else if (_startNewGameRegEx.IsMatch(input))
                {
                    //We will take this "Start new game" command
                    //and pass it to WaitingToStartState
                    GameStateArgs argsForWaitingToStartState = new GameStateArgs();
                    argsForWaitingToStartState.StringData = input;
                    RestartGame(argsForWaitingToStartState);
                }
                else
                {
                    StopGameSession();
                }
            }
        }
        public void PerformTransitionTo(GameStateID stateID, GameStateArgs gmStateArgs)
        {
            if (_allPossibleStates.ContainsKey(stateID))
            {
                _currentState = _allPossibleStates[stateID];
            }
            else
            {
                Console.WriteLine("Invalid transition, the state has not been found");
                return;
            }

            _currentStateArgs = gmStateArgs;
            _currentStateID   = stateID;
        }
        void RestartGame(GameStateArgs argsForWaitingToStartState)
        {
            _endGame = true;

            if (argsForWaitingToStartState == null)
            {
                InvokingFSM.PerformTransitionTo(GameStateID.WaitingToStart);
            }
            else
            {
                InvokingFSM.PerformTransitionTo(GameStateID.WaitingToStart, argsForWaitingToStartState);
            }

            if (_turn > 0)
            {
                //If there were turns, we'll display infromation about last game
                Console.WriteLine("Turn: {0}, cards: {1}", _turn, _currentTable.Values.Sum((x) => x.Count));
            }
        }
 public override void Action(GameStateArgs gmStateArgs)
 {
     InvokingFSM.Stop();
 }
 //This method is the "Main" method for the GameState
 public abstract void Action(GameStateArgs gmStateArgs);