コード例 #1
0
        /// <summary>
        /// The special skill of this card.
        /// </summary>
        /// <param name="game">Game instance.</param>
        /// <param name="opt">Input option parameter.</param>
        /// <returns>Result.</returns>
        public bool Special(CardGame game, params string[] opt)
        {
            bool ret = true;

            if (this.power == 1)
            {
                Field field = game.Fields[Int32.Parse(opt[1])];
                if (field.IsFixed)
                {
                    throw GameException.getCardAlreadyFixedException();
                }
                string cardStr = opt[0];
                game.Trash(field.Number, cardStr);
                //CardDeck fieldDeck = field.CardList[game.Turn];
                //fieldDeck.Move(cardStr, game.Talon.Trash);
                ret = false;
            }
            else if (this.power == 3)
            {
                int count = game.Player.Hand.Count();
                game.Player.Hand.MoveAll(game.Talon.Trash);
                for (int i = 0; i < count; i++)
                {
                    game.Draw();
                }
            }
            else if (this.power == 5)
            {
                Field field = game.LastTrashedField;
                char  c     = ((string)opt[0])[0];
                field.Color = Color.Get(c);
            }
            else if (this.power == 7)
            {
                Field field = game.Fields[Int32.Parse(opt[1])];
                if (field.IsFixed)
                {
                    throw GameException.getCardAlreadyFixedException();
                }
                string   cardStr   = (string)opt[0];
                CardDeck fieldDeck = field.CardList[(game.Turn + 1) % 2];
                fieldDeck.Move(cardStr, game.Talon.Trash);
            }
            else if (this.power == 9)
            {
                game.Card9[(game.Turn + 1) % 2] = Constants.CARD9_AFFECTED;
            }
            return(ret);
        }
コード例 #2
0
        private IEnumerable <GameInput> Turn()
        {
            CardGame game = round.Current;

            observer.TurnStart(round);

            while (true)
            {
                GameInput gi = new GameInput();
                yield return(gi);

                observer.Input(round, gi);
                try
                {
                    Command  mode = gi.Command;
                    string[] opt  = gi.Options;
                    if (mode == Command.Discard)
                    {
                        string cardStr = opt[0];
                        int    field   = Int32.Parse(opt[1]);
                        game.Discard(field, cardStr);
                        observer.CmdEnd(round);
                    }
                    else if (mode == Command.Trash)
                    {
                        string cardStr = opt[0];
                        int    field   = Int32.Parse(opt[1]);
                        game.Trash(field, cardStr);
                        observer.CmdEnd(round);
                    }
                    else if (mode == Command.Special)
                    {
                        game.Special(opt);
                        observer.CmdEnd(round);
                    }
                    else if (mode == Command.Next)
                    {
                        observer.TurnEnd(round);
                        game.nextTurn();
                        break;
                    }
                }
                catch (GameException ex)
                {
                    observer.CmdError(round, ex);
                }
            }
        }