示例#1
0
        /// <summary>
        /// Trash the card from the field.
        /// </summary>
        /// <param name="fieldIndex">Field index.</param>
        /// <param name="cardStr">Card string.</param>
        /// <returns>Trashed card instance.</returns>
        public Card Trash(int fieldIndex, string cardStr)
        {
            GameStatus.Status nextStatus = status.Act(GameStatus.Action.Trash);
            if (GameStatus.Status.Error == nextStatus)
            {
                throw GameException.getAlreadyTrashedException();
            }
            if (fieldIndex >= FIELD_NUM || fieldIndex < 0)
            {
                throw GameException.getFieldIndexException();
            }

            CardDeck deck = this.fields[fieldIndex].CardList[this.turn];

            if (this.fields[fieldIndex].IsFixed || deck.Last().Name != cardStr)
            {
                throw GameException.getCardAlreadyFixedException();
            }


            Card card = deck.Move(cardStr, this.talon.Trash);

            this.lastTrashed      = card;
            this.lastTrashedField = this.fields[fieldIndex];

            status.Current = card.HasSpecial ? nextStatus : GameStatus.Status.Trashed;
            return(card);
        }
示例#2
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);
        }
示例#3
0
        /// <summary>
        /// Discard the card to the field.
        /// </summary>
        /// <param name="fieldIndex">Field index.</param>
        /// <param name="cardStr">Card string.</param>
        /// <returns>Discarded card instance.</returns>
        public Card Discard(int fieldIndex, string cardStr)
        {
            GameStatus.Status nextStatus = status.Act(GameStatus.Action.Discard);
            if (GameStatus.Status.Error == nextStatus)
            {
                throw GameException.getAlreadyDiscardedException();
            }

            if (fieldIndex >= FIELD_NUM || fieldIndex < 0)
            {
                throw GameException.getFieldIndexException();
            }

            CardDeck hand = this.players[turn].Hand;
            Card     card = hand.Get(cardStr);

            if (card == null)
            {
                throw GameException.getCardNotFoundException(cardStr);
            }
            hand.Move(cardStr, this.fields[fieldIndex].CardList[turn]);

            if (this.players[turn].Hand.Count() == 0 || this.IsFilled)
            {
                status.Current = GameStatus.Status.End;
            }
            else if (this.card9[turn] == Constants.CARD9_AFFECTED)
            {
                status.Current = GameStatus.Status.Trashed;
            }
            else
            {
                status.Current = nextStatus;
            }
            return(card);
        }