Beispiel #1
0
 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;
            });
        }
Beispiel #3
0
 public Play(Player player, Card card)
 {
     this.player = player;
     this.selectedCard = card;
 }
Beispiel #4
0
        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);
            }
        }
Beispiel #5
0
 public Boolean isTrumph(Card card)
 {
     return card.id.Equals(SUPER_TRUMPH);
 }
Beispiel #6
0
 public Boolean isHead(Card card)
 {
     return Array.IndexOf(HEADS, card) != -1;
 }