def build_research_station(state: State, city: City): if state.research_stations == 0: state.previous_phase = state.phase state.phase = Phase.MOVE_STATION else: state.research_stations -= 1 state.cities[city].build_research_station() state.last_build_research_station = city
def __init_forecast(state: State): active_player = state.active_player top_cards = set(state.infection_deck[:6]) ccp = ChooseCardsPhase( next_phase=state.previous_phase, cards_to_choose_from=top_cards, count=len(top_cards), player=active_player, after=__forecast_after, ) state.start_choose_cards_phase(ccp)
def create_less_random_simulation( start_player: Character = Character.SCIENTIST): state = State(player_count=2) player_state = PlayerState() player_state.clear_cards() state.players = { start_player: PlayerState(), Character.RESEARCHER if start_player == Character.SCIENTIST else Character.SCIENTIST: PlayerState(), } state.active_player = start_player simulation = Simulation(player_count=2) simulation.state = state return simulation
def __init_cure_virus(state: State): active_player = state.active_player cure_cards = { city for city in state.players[active_player].city_cards if CITY_DATA[city].color == state.virus_to_cure } ccp = ChooseCardsPhase( next_phase=state.previous_phase, cards_to_choose_from=cure_cards, count=num_cards_for_cure(state.active_player), player=active_player, after=__cure_virus_after, ) state.start_choose_cards_phase(ccp)
def __check_oldschool_knowledge_sharing( state: State, character: Character, players_in_city: Dict[Character, PlayerState]) -> List[ActionInterface]: possible_actions: List[ActionInterface] = list() current_city = state.get_player_current_city(character) for c, ps in filter(lambda pst: current_city in pst[1].cards, players_in_city.items()): __add_knowlegde_sharing(c, character, current_city, players_in_city, possible_actions) return possible_actions
def other_action(state: State, action: Other, character: Character = None): if character is None: character = state.active_player if isinstance(action, TreatDisease): state.treat_city(action.city, action.target_virus, times=1 if character != Character.MEDIC else 3) elif isinstance(action, BuildResearchStation): if character != Character.OPERATIONS_EXPERT: state.play_card(character, action.city) build_research_station(state, action.city) elif isinstance(action, DiscoverCure): state.previous_phase = state.phase state.virus_to_cure = action.target_virus state.phase = Phase.CURE_VIRUS elif isinstance(action, ShareKnowledge): state.play_card(action.player, action.card) state.players[action.target_player].add_card(action.card) elif isinstance(action, ReserveCard): state.player_discard_pile.remove(action.card) state.players[character].contingency_planner_card = action.card
def __add_dispatches(moves: List[Movement], from_char: Character, state: State, to_char: Character): moves.append(Dispatch(from_char, state.get_player_current_city(to_char)))
def move_player(state: State, move: Movement): destination_city = move.destination character = move.player if isinstance(move, DriveFerry): assert destination_city in CITY_DATA[state.get_player_current_city( character)].neighbors if isinstance(move, DirectFlight): state.play_card(state.active_player, destination_city) if isinstance(move, CharterFlight): state.play_card(state.active_player, state.get_player_current_city(character)) if isinstance(move, ShuttleFlight): assert (state.cities[state.get_player_current_city( character)].has_research_station() and state.cities[destination_city].has_research_station()) if isinstance(move, OperationsFlight): state.play_card(character, move.discard_card) state.players[character].used_operations_expert_shuttle_move() state.move_player_to_city(character, destination_city)
def event_action(state: State, event: Event): if isinstance(event, Forecast): state.previous_phase = state.phase state.phase = Phase.FORECAST state.play_card(event.player, EventCard.FORECAST) elif isinstance(event, GovernmentGrant): others.build_research_station(state, event.target_city) state.play_card(event.player, EventCard.GOVERNMENT_GRANT) elif isinstance(event, Airlift): state.move_player_to_city(event.target_player, event.destination) state.play_card(event.player, EventCard.AIRLIFT) elif isinstance(event, ResilientPopulation): state.infection_discard_pile.remove(event.discard_city) state.play_card(event.player, EventCard.RESILIENT_POPULATION) elif isinstance(event, OneQuietNight): state.one_quiet_night = True state.play_card(event.player, EventCard.ONE_QUIET_NIGHT) elif isinstance(event, MoveResearchStation): state.cities[event.move_from].remove_research_station() state.phase = state.previous_phase
def throw_card_action(state: State, action: DiscardCard): assert isinstance(action, DiscardCard) state.play_card(action.player, action.card)