예제 #1
0
 public SimRoundResult(SimRoundPlayerInfo firstPlayer, SimRoundPlayerInfo secondPlayer, SimRoundPlayerInfo lastWinningPlayer)
     : this(firstPlayer, secondPlayer)
 {
     this.FirstPlayer  = firstPlayer;
     this.SecondPlayer = secondPlayer;
     this.LastWinner   = lastWinningPlayer;
 }
예제 #2
0
 public SimRoundResult(SimRoundPlayerInfo firstPlayer, SimRoundPlayerInfo secondPlayer, SimRoundPlayerInfo lastWinningPlayer)
     : this(firstPlayer, secondPlayer)
 {
     this.FirstPlayer = firstPlayer;
     this.SecondPlayer = secondPlayer;
     this.LastWinner = lastWinningPlayer;
 }
예제 #3
0
        private static SimPlayerAction GetPlayerAction(SimRoundPlayerInfo playerInfo, SimPlayerTurnContext context)
        {
            var action        = playerInfo.Player.GetTurn(context.DeepClone());
            var isActionValid = SimPlayerActionValidator.Instance.IsValid(action, context, playerInfo.Cards);

            if (!isActionValid)
            {
                throw new InternalGameException($"Invalid action played from {playerInfo.Player.Name}");
            }

            return(action);
        }
예제 #4
0
 public SimTrick(
     SimRoundPlayerInfo firstToPlay,
     SimRoundPlayerInfo secondToPlay,
     ISimStateManager stateManager,
     IDeck deck,
     IGameRules gameRules)
 {
     this.firstToPlay  = firstToPlay;
     this.secondToPlay = secondToPlay;
     this.stateManager = stateManager;
     this.deck         = deck;
     this.gameRules    = gameRules;
 }
예제 #5
0
        private void CallStartRoundAndDealCardsSimulation(SimRoundPlayerInfo player, int playerTotalPoints, int opponentTotalPoints, ICollection <Card> currentCards)
        {
            var cards = new List <Card>();

            // TODO: 6 should be constant
            foreach (var card in currentCards)
            {
                cards.Add(card);
                player.Cards.Add(card);
            }

            player.Player.StartRound(cards, this.deck.TrumpCard, playerTotalPoints, opponentTotalPoints);
        }
예제 #6
0
 public SimTrick(
     SimRoundPlayerInfo firstToPlay,
     SimRoundPlayerInfo secondToPlay,
     ISimStateManager stateManager,
     IDeck deck,
     IGameRules gameRules)
 {
     this.firstToPlay = firstToPlay;
     this.secondToPlay = secondToPlay;
     this.stateManager = stateManager;
     this.deck = deck;
     this.gameRules = gameRules;
 }
예제 #7
0
        public SimRound(
            ISimPlayer firstPlayer,
            ISimPlayer secondPlayer,
            IGameRules gameRules,
            PlayerPosition firstToPlay = PlayerPosition.FirstPlayer)
        {
            this.gameRules = gameRules;
            this.deck = new SimDeck();
            this.stateManager = new SimStateManager();

            this.firstPlayer = new SimRoundPlayerInfo(firstPlayer);
            this.secondPlayer = new SimRoundPlayerInfo(secondPlayer);

            this.firstToPlay = firstToPlay;
        }
예제 #8
0
        public SimRound(
            ISimPlayer firstPlayer,
            ISimPlayer secondPlayer,
            IGameRules gameRules,
            PlayerPosition firstToPlay = PlayerPosition.FirstPlayer)
        {
            this.gameRules    = gameRules;
            this.deck         = new SimDeck();
            this.stateManager = new SimStateManager();

            this.firstPlayer  = new SimRoundPlayerInfo(firstPlayer);
            this.secondPlayer = new SimRoundPlayerInfo(secondPlayer);

            this.firstToPlay = firstToPlay;
        }
예제 #9
0
        private void CallStartRoundAndDealCards(SimRoundPlayerInfo player, int playerTotalPoints, int opponentTotalPoints)
        {
            var cards = new List <Card>();

            // TODO: 6 should be constant
            for (var i = 0; i < 6; i++)
            {
                if (this.deck.CardsLeft == 0)
                {
                    break;
                }

                var card = this.deck.GetNextCard();
                cards.Add(card);
                player.Cards.Add(card);
            }

            player.Player.StartRound(cards, this.deck.TrumpCard, playerTotalPoints, opponentTotalPoints);
        }
예제 #10
0
        private SimPlayerAction GetFirstPlayerAction(SimRoundPlayerInfo playerInfo, SimPlayerTurnContext context)
        {
            while (true)
            {
                var action = GetPlayerAction(playerInfo, context);
                switch (action.Type)
                {
                case PlayerActionType.ChangeTrump:
                {
                    var oldTrumpCard = this.deck.TrumpCard;
                    var nineOfTrump  = new Card(oldTrumpCard.Suit, CardType.Nine);

                    this.deck.ChangeTrumpCard(nineOfTrump);
                    context.TrumpCard = nineOfTrump;

                    // Only swap cards from the local cards list (player should swap its own cards)
                    playerInfo.Cards.Remove(nineOfTrump);
                    playerInfo.Cards.Add(oldTrumpCard);
                    continue;
                }

                case PlayerActionType.CloseGame:
                {
                    this.stateManager.State.Close();
                    context.State         = this.stateManager.State;
                    playerInfo.GameCloser = true;
                    continue;
                }

                case PlayerActionType.PlayCard:
                {
                    if (action.Announce != Announce.None)
                    {
                        playerInfo.Announces.Add(action.Announce);
                    }

                    return(action);
                }
                }
            }
        }
예제 #11
0
 private void GiveCardToPlayer(SimRoundPlayerInfo player)
 {
     var card = this.deck.GetNextCard();
     player.AddCard(card);
 }
예제 #12
0
        private void CallStartRoundAndDealCardsSimulation(SimRoundPlayerInfo player, int playerTotalPoints, int opponentTotalPoints, ICollection<Card> currentCards)
        {
            var cards = new List<Card>();

            // TODO: 6 should be constant
            foreach (var card in currentCards)
            {
                cards.Add(card);
                player.Cards.Add(card);
            }

            player.Player.StartRound(cards, this.deck.TrumpCard, playerTotalPoints, opponentTotalPoints);
        }
예제 #13
0
        private SimPlayerAction GetFirstPlayerAction(SimRoundPlayerInfo playerInfo, SimPlayerTurnContext context)
        {
            while (true)
            {
                var action = GetPlayerAction(playerInfo, context);
                switch (action.Type)
                {
                    case PlayerActionType.ChangeTrump:
                        {
                            var oldTrumpCard = this.deck.TrumpCard;
                            var nineOfTrump = new Card(oldTrumpCard.Suit, CardType.Nine);

                            this.deck.ChangeTrumpCard(nineOfTrump);
                            context.TrumpCard = nineOfTrump;

                            // Only swap cards from the local cards list (player should swap its own cards)
                            playerInfo.Cards.Remove(nineOfTrump);
                            playerInfo.Cards.Add(oldTrumpCard);
                            continue;
                        }

                    case PlayerActionType.CloseGame:
                        {
                            this.stateManager.State.Close();
                            context.State = this.stateManager.State;
                            playerInfo.GameCloser = true;
                            continue;
                        }

                    case PlayerActionType.PlayCard:
                        {
                            if (action.Announce != Announce.None)
                            {
                                playerInfo.Announces.Add(action.Announce);
                            }

                            return action;
                        }
                }
            }
        }
예제 #14
0
 public SimRoundResult(SimRoundPlayerInfo firstPlayer, SimRoundPlayerInfo secondPlayer)
 {
     this.FirstPlayer  = firstPlayer;
     this.SecondPlayer = secondPlayer;
 }
예제 #15
0
        private void GiveCardToPlayer(SimRoundPlayerInfo player)
        {
            var card = this.deck.GetNextCard();

            player.AddCard(card);
        }
예제 #16
0
        private void CallStartRoundAndDealCards(SimRoundPlayerInfo player, int playerTotalPoints, int opponentTotalPoints)
        {
            var cards = new List<Card>();

            // TODO: 6 should be constant
            for (var i = 0; i < 6; i++)
            {
                if (this.deck.CardsLeft == 0)
                {
                    break;
                }

                var card = this.deck.GetNextCard();
                cards.Add(card);
                player.Cards.Add(card);
            }

            player.Player.StartRound(cards, this.deck.TrumpCard, playerTotalPoints, opponentTotalPoints);
        }
예제 #17
0
 public SimRoundResult(SimRoundPlayerInfo firstPlayer, SimRoundPlayerInfo secondPlayer)
 {
     this.FirstPlayer = firstPlayer;
         this.SecondPlayer = secondPlayer;
 }
예제 #18
0
        private static SimPlayerAction GetPlayerAction(SimRoundPlayerInfo playerInfo, SimPlayerTurnContext context)
        {
            var action = playerInfo.Player.GetTurn(context.DeepClone());
            var isActionValid = SimPlayerActionValidator.Instance.IsValid(action, context, playerInfo.Cards);
            if (!isActionValid)
            {
                throw new InternalGameException($"Invalid action played from {playerInfo.Player.Name}");
            }

            return action;
        }