/// <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> /// Proceed to the next turn. /// </summary> public void nextTurn() { foreach (Field field in this.fields) { field.Eval(); } if (this.Winner >= 0) { this.status.Current = GameStatus.Status.RoundEnd; return; } GameStatus.Status nextStatus = this.IsFilled ? GameStatus.Status.First : status.Act(GameStatus.Action.Next); if (GameStatus.Status.Error == nextStatus) { throw GameException.getNotTrashedException(); } this.card9 [this.turn] = Constants.CARD9_NONE; this.turn = (this.turn + 1) % 2; this.lastTrashedField = null; this.lastTrashed = null; int drawNum = 5 - this.Player.Hand.Count(); for (int i = 0; i < drawNum; i++) { this.Draw(); } this.status.Current = nextStatus; }
/// <summary> /// Fire the special effect of the card. /// </summary> /// <param name="opt">Special effect option.</param> public void Special(params string[] opt) { GameStatus.Status nextStatus = status.Act(GameStatus.Action.Special); if (GameStatus.Status.Error == nextStatus) { throw GameException.getAlreadyTrashedException(); } bool ret = this.lastTrashed.Special(this, opt); if (ret) { status.Current = nextStatus; } }
/// <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); }