コード例 #1
0
    def new(self):
        """
        Create new event
        """
        parser = reqparse.RequestParser()
        parser.add_argument('event_type', required=True)
        parser.add_argument('description', required=True)
        parser.add_argument('event_date', required=True)
        parser.add_argument('data', required=False)
        parse_result = parser.parse_args(req=self.request)

        Event.from_json(dumps(parse_result)).save()

        return parse_result
コード例 #2
0
def state_from_json(json) -> GameState:
    state: GameState = GameState()
    state.round = json['round']
    state.outcome = json['outcome']
    state.points = json['points']
    for cityJson in json['cities'].values():
        city = City.from_json(cityJson)
        state.cities.append(city)

    for eventJson in json['events']:
        event: Event = Event.from_json(eventJson)
        state.global_events.append(event)

        if event.event_type == 'pathogenEncountered':
            state.pathogens.append(event.pathogen)
        elif event.event_type == 'vaccineInDevelopment':
            state.pathogens_with_vaccination_in_development.append(
                event.pathogen)
        elif event.event_type == 'vaccineAvailable':
            state.pathogens_with_vaccination.append(event.pathogen)
        elif event.event_type == 'medicationAvailable':
            state.pathogens_with_medication.append(event.pathogen)
        elif event.event_type == 'medicationInDevelopment':
            state.pathogens_with_medication_in_development.append(
                event.pathogen)

    return state