/// <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); }
/// <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); }