public BooksPlayed(Player somePlayer, List <BookOfCards> someBooks)
        {
            if (somePlayer == null || someBooks == null)
            {
                throw new ArgumentNullException();
            }

            PlayerInfo = new PlayerSnapShot(somePlayer);
            books      = DeepCopyBooks(someBooks);
        }
        public RankRequested(Player playerA, Player playerB, Rank rank)
        {
            if (playerA == null || playerB == null)
            {
                throw new ArgumentNullException();
            }

            SubjectPlayerInfo = new PlayerSnapShot(playerA);
            ObjectPlayerInfo  = new PlayerSnapShot(playerB);
            RequestedRank     = rank;
        }
        public BeginTurn(Player player)
        {
            PlayerInfo = new PlayerSnapShot(player);

            string statusTitle     = $"it is {player.Name}'s turn : ";
            string currentScore    = $"       | current score  : {player.Score}";
            string currentHandSize = $"       | currently hold : {player.Hand.Size()}";
            string currentHand     = $"       | current hand   : {player.Hand}";

            info = statusTitle + '\n' + currentScore + '\n' + currentHandSize + '\n' + currentHand;
        }
        public CardsDrawn(Player player, int numberOfCards)
        {
            if (player == null)
            {
                throw new ArgumentNullException();
            }
            if (numberOfCards < 0)
            {
                throw new ArgumentException("one cannot draw a negative number of cards");
            }

            PlayerInfo         = new PlayerSnapShot(player);
            NumberOfCardsDrawn = numberOfCards;
        }
Exemple #5
0
        public PlayerActor(string playerName, int health)
        {
            _state = new PlayerSnapShot(playerName, health);
            //
            // The commands will handle the message and is used to persist the message/event
            //
            Command <HitPlayerCommand>(command => HitPlayerCommandHandler(command));
            Command <CauseErrorCommand>(command => CauseErrorCommandHandler());
            Command <DisplayStatusCommand>(command => DisplayStatusCommandHandler());
            //
            // The "recover" methods will be called when the actor is restarted
            //
            Recover <PlayerGotHitEvent>(@event =>
            {
                DisplayHelper.ShowInfo("Recovering", @event.PlayerName);
                _state.Health -= @event.Damage;
            });

            Recover <SnapshotOffer>(offer =>
            {
                _state = offer.Snapshot as PlayerSnapShot;
            });
        }
        public RequestAnswered(Player responder, Player asker, List <Card> cards)
        {
            if (asker == null || responder == null || cards == null)
            {
                string exceptionMessage = "";
                if (asker == null)
                {
                    exceptionMessage += "(\"asker\" was null )";
                }
                if (responder == null)
                {
                    exceptionMessage += "(\"responder\" was null )";
                }
                if (cards == null)
                {
                    exceptionMessage += "(\"cards\" was null )";
                }
                throw new ArgumentNullException(exceptionMessage);
            }

            Responder  = new PlayerSnapShot(responder);
            Asker      = new PlayerSnapShot(asker);
            cardsGiven = DeepCopyCards(cards);
        }
 public PlayerSnapShot(PlayerSnapShot playerSnapShot)
 {
     this.Name     = playerSnapShot.Name;
     this.HandSize = playerSnapShot.HandSize;
     this.Score    = playerSnapShot.Score;
 }