public PlayerTurnContext(
     BaseRoundState state,
     Card trumpCard,
     int cardsLeftInDeck)
 {
     this.State           = state;
     this.TrumpCard       = trumpCard;
     this.CardsleftInDeck = cardsLeftInDeck;
 }
 public PlayerTurnContext(
     BaseRoundState state,
     Card trumpCard,
     int cardsLeftInDeck,
     int firstPlayerRoundPoints,
     int secondPlayerRoundPoints)
 {
     this.State                   = state;
     this.TrumpCard               = trumpCard;
     this.CardsLeftInDeck         = cardsLeftInDeck;
     this.FirstPlayerRoundPoints  = firstPlayerRoundPoints;
     this.SecondPlayerRoundPoints = secondPlayerRoundPoints;
 }
        public static bool CanChangeTrump(bool isThePlayerFirst, BaseRoundState state, Card trumpCard, ICollection <Card> playerCards)
        {
            if (!isThePlayerFirst)
            {
                return(false);
            }

            if (!state.CanChangeTrump)
            {
                return(false);
            }

            return(playerCards.Contains(new Card(trumpCard.Suit, CardType.Nine)));
        }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="player"></param>
        /// <returns>True => played card; False => another action</returns>
        private PlayerAction FirstPlayerTurn(
            IPlayer player,
            PlayerTurnContext context)
        {
            var playerTurn = player.GetTurn(context, this.actionValidator);

            if (playerTurn.Type == PlayerActionType.CloseGame)
            {
                this.state.Close();
                context.State = new FinalRoundState();
                this.state    = new FinalRoundState();
                if (player == this.firstPlayer)
                {
                    this.whoClosedTheGame = PlayerPosition.FirstPlayer;
                }
                else
                {
                    this.whoClosedTheGame = PlayerPosition.SecondPlayer;
                }
            }

            if (playerTurn.Type == PlayerActionType.ChangeTrump)
            {
                var changeTrump = new Card(this.deck.GetTrumpCard.Suit, CardType.Nine);
                var oldTrump    = this.deck.GetTrumpCard;
                context.TrumpCard = changeTrump;
                this.deck.ChangeTrumpCard(changeTrump);

                if (player == this.firstPlayer)
                {
                    this.firstPlayerCards.Remove(changeTrump);
                    this.firstPlayerCards.Add(oldTrump);
                    this.firstPlayer.AddCard(oldTrump);
                }
                else
                {
                    this.secondPlayerCards.Remove(changeTrump);
                    this.secondPlayerCards.Add(oldTrump);
                    this.secondPlayer.AddCard(oldTrump);
                }
            }

            return(playerTurn);
        }
Esempio n. 5
0
 public GameHand(
     PlayerPosition whoWillPlayFirst,
     IPlayer firstPlayer,
     IList <Card> firstPlayerCards,
     IPlayer secondPlayer,
     IList <Card> secondPlayerCards,
     BaseRoundState state,
     IDeck deck)
 {
     this.whoWillPlayFirst  = whoWillPlayFirst;
     this.firstPlayer       = firstPlayer;
     this.firstPlayerCards  = firstPlayerCards;
     this.secondPlayer      = secondPlayer;
     this.secondPlayerCards = secondPlayerCards;
     this.state             = state;
     this.deck             = deck;
     this.actionValidator  = new PlayerActionValidator();
     this.whoClosedTheGame = PlayerPosition.NoOne;
 }
Esempio n. 6
0
 public void SetState(BaseRoundState newState)
 {
     this.State = newState;
 }
Esempio n. 7
0
 public void SetState(BaseRoundState newState)
 {
     this.State = newState;
 }
Esempio n. 8
0
 public static bool CanCloseGame(bool isThePlayerFirst, BaseRoundState state)
 {
     return(isThePlayerFirst && state.CanClose);
 }