def start_final_game(): game.setup_finalround(players=True) game.choose_question(game.random_question()) resend_gamestate() game.final_player_thread = True eel.spawn(final_player_thread)
def accept_offer(offer_num): game.current_round.offers[offer_num].accepted = True game.current_player.points = game.current_round.offers[offer_num].amount game.state = GameState.CHASE_QUESTIONING game.choose_question(game.random_question()) resend_gamestate()
def start_final_chaser(): game.final_chaser_thread = True game.state = GameState.FINAL_CHASER game.choose_question(game.random_question()) resend_gamestate() game.current_round.finalTime.append({'start': datetime.datetime.now()}) eel.spawn(final_chaser_thread)
def start_round(): game.new_round() game.choose_question( game.random_question( level=game.current_player.level)) game.fast_thread = True eel.spawn(fastround_timer) resend_gamestate()
def question_answered(answer_id, player_id=0): # TODO: Resturcture Point system # * no player.points! -> will be a param now. if game.state == GameState.FAST_GUESS: game.answer_fast_question(answer_id) game.choose_question(game.random_question()) elif GameState.CHASE_PREPARATION <= game.state <= GameState.CHASE_SOLVE: if player_id == 0: # Player game.current_question.answerPlayer = answer_id already_answered = ( game.current_question.answerChaser is not None) else: # Chaser game.current_question.answerChaser = answer_id already_answered = ( game.current_question.answerPlayer is not None) if not already_answered: starttime = datetime.datetime.now() endtime = starttime + \ datetime.timedelta(seconds=SECONDS_CHASE_TIMEOUT) timedout = False i = 0 while ( game.current_question.answerChaser is None or game.current_question.answerPlayer is None) and not timedout: if i % 10 == 0: timedout = datetime.datetime.now() > endtime seconds_played = ( datetime.datetime.now() - starttime ).seconds seconds_remaining = SECONDS_CHASE_TIMEOUT - seconds_played eel.all_chase_tick(seconds_played, seconds_remaining) i += 1 eel.sleep(0.1) if timedout: eel.all_chase_timeout() else: eel.all_chase_both_answered() game.state = GameState.CHASE_SOLVE elif game.state == GameState.FINAL_PLAYERS: game.current_question.answerPlayer = answer_id game.choose_question(game.random_question()) elif game.state == GameState.FINAL_CHASER: game.current_question.answerChaser = answer_id if answer_id == 0: game.choose_question(game.random_question()) else: game.state = GameState.FINAL_CHASER_WRONG game.final_chaser_thread = False elif game.state == GameState.FINAL_CHASER_WRONG: game.current_question.answerPlayer = answer_id game.choose_question(game.random_question()) game.state = GameState.FINAL_CHASER start_final_chaser() resend_gamestate()
def choose_question(id): game.choose_question(game.get_question_by_id(id)) eel.all_new_question(game.current_question.save()) resend_gamestate()
def random_question(): if GameState.CHASE_PREPARATION <= game.state <= GameState.CHASE_SOLVE: game.check_round_end() game.choose_question(game.random_question()) resend_gamestate()