Beispiel #1
0
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
Beispiel #2
0
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
Beispiel #3
0
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)
Beispiel #4
0
def throw_card_action(state: State, action: DiscardCard):
    assert isinstance(action, DiscardCard)
    state.play_card(action.player, action.card)