public Card(CardIdType id, CardIndexType index, CardColorType color, CardValueType value) { this.Id = id; this.Index = index; this.Color = color; this.Value = value; this.Information = new CardInformation(); }
public void Discard(IHanabiPlayer player, RequestDiscardCard card) { if (!IsCurrentPlayer(player)) { ResponseDiscardCard invalidResponse = new ResponseDiscardCard(); invalidResponse.Result = DiscardCardResult.InvalidTurn; SendCommandToPlayer(player, ActionType.DiscardCard, invalidResponse); return; } CardIndexType cardIndex = new CardIndexType(card.CardIndex); Card oldCard = player.GetCard(cardIndex); Card newCard = null; DiscardCardResult result = Rule.DiscardCard(cardIndex, player, Board, out newCard); if (result != DiscardCardResult.Success) { ResponseDiscardCard invalidResponse = new ResponseDiscardCard(); invalidResponse.Result = result; SendCommandToPlayer(player, ActionType.DiscardCard, invalidResponse); return; } ResponseDiscardCard response = new ResponseDiscardCard(); response.Result = result; response.Nickname = player.Nickname.Value; response.OldCard = oldCard.Info; response.NewCard = (newCard != null) ? newCard.Info : null; response.Token = Board.Tokens.Info; response.DrawPileCount = Board.Size; CardInfo info = (newCard != null) ? newCard.Info : null; if (info != null) { info.Color = ( int )CardColorType.Unknown; info.Value = ( int )CardValueType.Unknown; } ResponseDiscardCard notify = new ResponseDiscardCard(); notify.Result = result; notify.Nickname = player.Nickname.Value; notify.OldCard = oldCard.Info; notify.NewCard = info; notify.Token = Board.Tokens.Info; notify.DrawPileCount = Board.Size; foreach (var notifyPlayer in Players) { if (notifyPlayer == player) { SendCommandToPlayer(notifyPlayer, ActionType.DiscardCard, notify); } else { SendCommandToPlayer(notifyPlayer, ActionType.DiscardCard, response); } } CheckLastRound(); NextActivePlayer(); NotifyNextPlayer(); }