コード例 #1
0
        private bool Load(string s)
        {
            char[] sep1 = new char[] { '|' };
            char[] sep2 = new char[] { '-' };

            string[] tokens  = s.Split(sep1, StringSplitOptions.RemoveEmptyEntries);
            string[] tokens2 = tokens[0].Split(sep2, StringSplitOptions.RemoveEmptyEntries);

            ScoreType   = (ScoreType)Enum.Parse(typeof(ScoreType), tokens2[0]);
            Total       = Convert.ToInt32(tokens2[1]);
            Accepted    = Convert.ToBoolean(tokens2[2]);
            ActualScore = Convert.ToInt32(tokens2[3]);

            for (int i = 1; i < tokens.Count(); i++)
            {
                ScoreInstance scoreInstance = new ScoreInstance(tokens[i]);
                Scores.Add(scoreInstance);
            }
            return(true);
        }
コード例 #2
0
        /// <summary>
        /// peek ahead to see which player can play a card.  if neither player can play a card, it is up to the Match object to check the Reset bit, record
        /// information about this play, and then reset the count
        /// </summary>
        private void UpdateTurnState()
        {
            if (!HasCardsToPlay)
            {
                return; // done with counting
            }
            Player currentPlayer = _state.TurnPlayer;
            Player nextPlayer    = _state.NextTurnPlayer;

            CardView card = PickCard(nextPlayer);

            if (card == null)
            {
                _state.NextPlayerCanGo = false;
            }
            else
            {
                _state.NextPlayerCanGo = true;
            }

            card = PickCard(currentPlayer);
            if (card == null)
            {
                _state.ThisPlayerCanGo = false;
            }
            else
            {
                _state.ThisPlayerCanGo = true;
            }


            if (_state.NextPlayerCanGo)
            {
                _state.TurnPlayer = nextPlayer;
            }
            else if (_state.ThisPlayerCanGo)
            {
                _state.TurnPlayer = currentPlayer;
            }
            else
            {
                if (_state.Count < 31)
                {
                    //  Debug.WriteLine("Setting isGo to true");
                    _state.isGo = true;
                    _state.LastScore++;
                    List <int> indexList = new List <int>();
                    indexList.Add(_countedCards[0].Index); // we isert into the list at the head
                    ScoreInstance score = new ScoreInstance(StatName.CountingGo, 1, 1, indexList);
                    _state.ScoreStory.Scores.Add(score);
                    _state.ScoreStory.Total++;
                }

                _state.ResetCount       = true;
                _state.CountBeforeReset = _state.Count;
                _state.Count            = 0;

                _countedCards.Clear();

                UpdateTurnState();  //recurse
            }
        }