Ejemplo n.º 1
0
    async def action_answer_question(
        cls, msg, client: Client
    ) -> Optional[AbstractState]:
        if "answer_index" not in msg or not isinstance(msg["answer_index"], int):
            return None
        if client.current_game is None:
            logging.error(
                "Tried to enter %s state without being in a game???", cls.__name__
            )
            return
        current_question = client.current_game.round_three_module.current_question
        if msg["answer_index"] == current_question.correct_index:
            client.current_game.round_three_module.add_chaser_correct_answer()
        client.current_answer_index = msg["answer_index"]

        other_state_transitions = [
            c.change_state(RoundThreeStateChaserDidNotAnswer())
            for c in client.current_game.round_three_module.chased_clients
            if c is not client
        ]
        if other_state_transitions:
            asyncio.wait(other_state_transitions)
        # Think this fixes some of the races idk
        if not client.current_game.round_three_module.timer_expired:
            return RoundThreeStateChaserAnswered()
Ejemplo n.º 2
0
 async def action_answer_question(
         cls, msg, client: Client) -> Optional[AbstractState]:
     if "answer_index" not in msg or not isinstance(msg["answer_index"],
                                                    int):
         return None
     if client.current_game is None:
         logging.error("Tried to enter %s state without being in a game???",
                       cls.__name__)
         return
     current_question = client.current_game.round_one_module.client_question[
         client]
     if msg["answer_index"] == current_question.correct_index:
         client.current_game.round_one_module.add_correct_answer(client)
     client.current_answer_index = msg["answer_index"]
     return RoundOneStateAnswered()
Ejemplo n.º 3
0
 async def action_answer_question(
         cls, msg, client: Client) -> Optional[AbstractState]:
     if "answer_index" not in msg:
         return None
     if client.current_game is None:
         logging.error("Tried to enter %s state without being in a game???",
                       cls.__name__)
         return
     round_two_module = client.current_game.round_two_module
     current_question = round_two_module.client_question[client]
     if msg["answer_index"] == current_question.correct_index or True:
         round_two_module.add_correct_answer(client)
     else:
         round_two_module.add_incorrect_answer(client)
     client.current_answer_index = msg["answer_index"]
     return RoundTwoStateAnswered()