public bool ShouldPlayAirLift(IPandemicState state) { var bestCityOnBoard = _routeHelper.GetBestLocationOnBoard(state.Cities); var valueOfBestCity = _routeHelper.GetLocationValue(state, bestCityOnBoard); var playerLocationValues = state.PlayerStates.Select(s => _routeHelper.GetLocationValue(state, s.Value.Location)); return(playerLocationValues.Any(lv => valueOfBestCity - lv > 3)); }
private void GetEventCardsToPlay(IPandemicTurn turn) { var currentPlayerId = turn.CurrentPlayerId; var currentPlayerState = turn.State.PlayerStates[currentPlayerId]; // One Quiet Night var oneQuietNightCard = currentPlayerState.PlayerHand.SingleOrDefault(c => c.PlayerCardType == PlayerCardType.Event && (EventCard)c.Value == EventCard.OneQuietNight); if (oneQuietNightCard != null && !_eventCardHelper.ShouldPlayOneQuietNight(turn.State)) { BroadCastThought("I should play One Quiet Night"); turn.PlayEventCard(EventCard.OneQuietNight); } // Government Grant var governmentGrantCard = currentPlayerState.PlayerHand.SingleOrDefault(c => c.PlayerCardType == PlayerCardType.Event && (EventCard)c.Value == EventCard.GovernmentGrant); if (governmentGrantCard != null && _eventCardHelper.ShouldPlayGovernmentGrant(turn.State)) { var locationForNewResearchStation = _routeHelper.GetBestLocationForNewResearchStation(turn.State); if (locationForNewResearchStation.HasValue) { BroadCastThought($"I should play government grant in {locationForNewResearchStation}"); turn.PlayEventCard(EventCard.GovernmentGrant, locationForNewResearchStation.Value); } } // Airlift var airliftCard = currentPlayerState.PlayerHand.SingleOrDefault(c => c.PlayerCardType == PlayerCardType.Event && (EventCard)c.Value == EventCard.Airlift); if (airliftCard != null && _eventCardHelper.ShouldPlayAirLift(turn.State)) { var locationToAirliftTo = _routeHelper.GetBestLocationOnBoard(turn.State.Cities); var playerToAirlift = turn.State.PlayerStates .OrderBy(p => _routeHelper.GetLocationValue(turn.State, p.Value.Location)) .Select(ps => ps.Key).First(); BroadCastThought($"I should play airlift on {playerToAirlift} and move them to {locationToAirliftTo}"); turn.PlayEventCard(EventCard.Airlift, playerToAirlift, locationToAirliftTo); } }