Beispiel #1
0
        public void PlayEventCard(EventCard eventCard, City?city = null)
        {
            var eventPlayed = new PlayerEventPlayed()
            {
                PlayerId = CurrentPlayerId, EventCard = eventCard, City = city
            };

            PlayEventCard(eventPlayed);
        }
Beispiel #2
0
        public void PlayEventCard(EventCard eventCard, int playerId, City?city = null)
        {
            var eventPlayed = new PlayerEventPlayed()
            {
                EventCard = eventCard, PlayerId = playerId, City = city
            };

            PlayEventCard(eventPlayed);
        }
Beispiel #3
0
        private void PlayEventCard(PlayerEventPlayed eventPlayed)
        {
            var validationFailures = _validator.ValidatePlayerEventPlayed(CurrentPlayerId, State, eventPlayed).ToList();

            if (validationFailures.Any())
            {
                throw new CardboardException(validationFailures[0]);
            }

            EventCardsPlayed = new PlayerEventPlayed[] { eventPlayed };
        }
        public IEnumerable <string> ValidatePlayerEventPlayed(int playerId, IPandemicState state, PlayerEventPlayed newEventCard)
        {
            var validationFailures = new List <string>();
            var playerState        = state.PlayerStates[playerId];

            if (!playerState.PlayerHand.Any(c => c.PlayerCardType == PlayerCardType.Event && (EventCard)c.Value == newEventCard.EventCard))
            {
                validationFailures.Add($"Player doesn't have event card {newEventCard.EventCard}");
            }

            return(validationFailures);
        }