public Player(String id, List<Card> cards, Card currentCard, PlayerType playerType) { this.id = id; this.cards = cards; this.currentCard = currentCard; this.playerType = playerType; }
private Property getBestProperty(Card card) { return properties.Aggregate((prop1, prop2) => { FieldInfo field1 = typeof(Card).GetField(prop1.ToString().ToLower()); FieldInfo field2 = typeof(Card).GetField(prop2.ToString().ToLower()); int card1Value = (int) field1.GetValue(card); int card2Value = (int) field2.GetValue(card); return card1Value > card2Value ? prop1 : prop2; }); }
public Play(Player player, Card card) { this.player = player; this.selectedCard = card; }
public void play(Card chosenCard, Player player) { if (currentPlayer != player){ throw new InvalidOperationException("That's not the current player.\nWhat's That?"); } if (currentPlayer.cards.IndexOf(chosenCard) == -1){ throw new InvalidOperationException("Current Player does not have that card.\nWhat's That?"); } if (cardsOnTable.Values.Contains(currentPlayer)) { throw new InvalidOperationException("Current Player already chose his card for this turn.\nWhat's That?"); } gameObserver.trigger(Events.CARD_TO_TABLE, new Play(player, chosenCard)); if (isTrumph(chosenCard)) { gameObserver.trigger(Events.TRUMPH_ON_GAME, player); } cardsOnTable[chosenCard] = currentPlayer; currentPlayer.cards.Remove(chosenCard); currentPlayer = nextPlayer; currentHand++; if(currentHand > currentRoom.players.Count){ endTurn(); } else { gameObserver.trigger(Events.NEXT_PLAYERS_TURN, currentPlayer); } }
public Boolean isTrumph(Card card) { return card.id.Equals(SUPER_TRUMPH); }
public Boolean isHead(Card card) { return Array.IndexOf(HEADS, card) != -1; }