Esempio n. 1
0
        public void ProcessInputFile(string filePath)
        {
            int headerLineCount = 0;
            var lines           = File.ReadAllLines(filePath);
            var isHint          = false;
            var currentTurn     = new GameTurn();

            foreach (var line in lines)
            {
                headerLineCount++;

                var play = ProcessPlayerLine(line);
                if (headerLineCount <= 4)
                {
                    initialTurn.PlayerMoves.Add(play);
                    continue;
                }

                if (DoesLineBeginWithAsterisk(line))
                {
                    isHint = true;
                    currentTurn.Hints.Add(play);
                }
                else
                {
                    if (isHint)
                    {
                        turns.Add(currentTurn);
                        currentTurn = new GameTurn();
                    }
                    currentTurn.PlayerMoves.Add(play);
                    isHint = false;
                }
            }
        }
Esempio n. 2
0
        public void AddChildren(List <GameTurn> remainingTurns)
        {
            var copyRemainingTurns = CopyOfRemainingTurns(remainingTurns);

            if (copyRemainingTurns.Count == 0)
            {
                return;
            }

            var childTurn = copyRemainingTurns[0];

            copyRemainingTurns.Remove(childTurn);

            for (int i = 0; i < childTurn.Hints.Count; i++)
            {
                var turn = new GameTurn();
                turn.PlayerMoves = new List <PlayerMove>();
                foreach (var origMove in childTurn.PlayerMoves)
                {
                    var newMove = origMove.Copy();
                    turn.PlayerMoves.Add(newMove);
                }
                turn.Hints = new List <PlayerMove>()
                {
                    childTurn.Hints[i]
                };

                var childNode = new GameTreeNode(turn);
                this.AddChild(childNode);
            }
            foreach (var childNode in this.Children)
            {
                childNode.AddChildren(copyRemainingTurns);
            }
        }
Esempio n. 3
0
 public GameTreeNode(GameTurn turn)
 {
     GameTreeNode._lastId++;
     this.Id       = _lastId;
     this.Turn     = turn;
     this.Children = new List <GameTreeNode>();
 }
Esempio n. 4
0
 public CardReader()
 {
     initialTurn = new GameTurn();
     turns       = new List <GameTurn>();
     lilsHand    = new PlayerHand();
 }