Пример #1
0
    def __init__(self, easy_questions, average_questions, hard_questions):
        super().__init__(is_visible=False)
        self._show_highlight = False
        self._highlighted_index = 0
        self._selected_question = None

        self._choose_question_label = Label("Choose a question difficulty:", 0,
                                            0)
        easy_question_label = Button('Easy', 0, 0,
                                     lambda: self._on_difficulty_clicked(0))
        average_question_label = Button('Average', 0, 0,
                                        lambda: self._on_difficulty_clicked(1))
        hard_question_label = Button('Hard', 0, 0,
                                     lambda: self._on_difficulty_clicked(2))

        total_w = self._choose_question_label.get_size()[0] + 25 + easy_question_label.get_size()[0] + 25 + \
            average_question_label.get_size()[0] + 25 + hard_question_label.get_size()[0]

        self._choose_question_label.x = SCREEN_WIDTH / 2 - total_w / 2
        easy_question_label.x = self._choose_question_label.x + self._choose_question_label.get_size(
        )[0] + 25
        average_question_label.x = easy_question_label.x + easy_question_label.get_size(
        )[0] + 25
        hard_question_label.x = average_question_label.x + average_question_label.get_size(
        )[0] + 25

        self._questions = [easy_questions, average_questions, hard_questions]
        self._buttons = [
            easy_question_label, average_question_label, hard_question_label
        ]

        get_game().register('on_draw', self.on_draw)

        for btn in self._buttons:
            get_game().register_button_mouse_events(btn)
Пример #2
0
 def __init__(self):
     self._share = type(self).START_SHARE
     self._share_diff_sum = 0
     self._last_share_diff = 0
     self._label = Label('', 0, 0, font_size=20)
     self._diff_label = Label('', 0, 0, font_size=20)
     self.update()
     get_game().register('on_draw', self.on_draw)
Пример #3
0
 def contestant_withdrawn_message():
     contestant = get_game().current_contestant
     prize_money = get_game().questions_stages.get_current_prize_money()
     return (
         f'{contestant.name} withdrawn with ${prize_money}!\n'
         f'Total profit this round: {get_game().budget.get_diff_sum()}\n'
         f'Total rating this round: {get_game().audience_share.get_diff_sum()}'
     )
Пример #4
0
 def _on_difficulty_clicked(self, index):
     get_game().pause_gameplay()
     [
         get_game().sound_controller.play_select_easy,
         get_game().sound_controller.play_select_average,
         get_game().sound_controller.play_select_hard
     ][index]()
     self._show_selected_answer(index)
Пример #5
0
 def show(self):
     super().show()
     get_game().disable_all_buttons()
     self._selected_question = None
     self._choose_question_label.y = get_game().on_screen_question_ui.get_question_box_y() - \
         self._choose_question_label.get_size()[1] / 2
     for btn in self._buttons:
         btn.y = self._choose_question_label.y
         btn.enable()
Пример #6
0
    def __init__(self):
        self._theme = arcade.sound.Sound('sound/theme.wav')
        self._select_easy = arcade.sound.Sound('sound/select_easy.wav')
        self._select_average = arcade.sound.Sound('sound/select_average.wav')
        self._select_hard = arcade.sound.Sound('sound/select_hard.wav')
        self._mute_button = Button('Mute',
                                   20,
                                   10,
                                   on_click_callback=self._toggle_mute)
        self._theme_sound = None
        self._is_muted = False

        get_game().register('on_draw', self._mute_button.on_draw)
        get_game().register_button_mouse_events(self._mute_button)
Пример #7
0
    def _calc_share(self, question_difficulty: QuestionDifficulty):
        stage_coeff = (get_game().questions_stages.current_stage_index + 1)
        if stage_coeff <= 2:
            probable_change, possible_shift = {
                QuestionDifficulty.EASY: (1, 0.25),
                QuestionDifficulty.AVERAGE: (2, 1),
                QuestionDifficulty.HARD: (2, 2)
            }[question_difficulty]
        elif stage_coeff <= 5:
            probable_change, possible_shift = {
                QuestionDifficulty.EASY: (0.5, 0.5),
                QuestionDifficulty.AVERAGE: (1, 0.5),
                QuestionDifficulty.HARD: (2, 1)
            }[question_difficulty]
        else:
            probable_change, possible_shift = {
                QuestionDifficulty.EASY: (2, 2),
                QuestionDifficulty.AVERAGE: (2, 1),
                QuestionDifficulty.HARD: (2, 0)
            }[question_difficulty]

        self._last_share_diff = (random() * probable_change) - possible_shift

        if self._last_share_diff + self._share < 0:
            self._last_share_diff = -self._share

        self._update_diff_lbl(self._last_share_diff)
        self._share += self._last_share_diff
        self._share_diff_sum += self._last_share_diff

        if self._share > 100:
            self._share = 100
Пример #8
0
    def update(self, question_answered: typing.Optional[QuestionData] = None):
        if question_answered is None:
            self._share = type(self).START_SHARE
            self._last_share_diff = 0
            self._diff_label.text = ''
            self._share_diff_sum = 0
        else:
            self._calc_share(question_answered.difficulty)
        self._label.text = 'Rating: {}'.format(AudienceShare._share_as_str(self._share))
        self._label.x = 10
        self._label.y = get_game().budget.ui.get_y() - self._label.get_size()[1] - 5
        self._diff_label.x = self._label.x + self._label.get_size()[0] + 10
        self._diff_label.y = self._label.y

        if self._last_share_diff != 0:
            get_game().budget.add_amount(int(self._last_share_diff * 75000))
Пример #9
0
 def contestant_won_message():
     contestant = get_game().current_contestant
     return (
         f'{contestant.name} won the MILLION DOLLARS PRIZE!!!\n'
         'Sadly for you...\n'
         f'Total profit this round: {get_game().budget.get_diff_sum()}\n'
         f'Total rating this round: {get_game().audience_share.get_diff_sum()}'
     )
Пример #10
0
 def should_withdraw(self):
     questions_stages = get_game().questions_stages
     # at present only consider quitting if just hit the exit point, not afterwards
     if questions_stages.is_currently_on_exit_point():
         if random() <= self._prize_to_quit_prob[
                 questions_stages.get_current_prize_money()]:
             return True
     return False
Пример #11
0
 def _show_selected_answer(self, index):
     self._selected_question = random.choice(self._questions[index])
     self.hide()
     get_game().background_controller.show_host()
     get_game().questions_stages.hide()
     get_game().unpause_gameplay()
     add_timer(1, lambda: get_game().background_controller.show_question())
     add_timer(2,
               lambda: get_game().background_controller.show_contestant())
     self._answer_question()
Пример #12
0
    def __init__(self):
        super().__init__(is_visible=True)
        self._text_box = TextBox('',
                                 SCREEN_WIDTH / 4 + 10,
                                 0,
                                 bounds_w=SCREEN_WIDTH / 2 - 20,
                                 font_size=18)
        self._on_continue_callback = None
        self._continue_btn = Button('Continue', 0, 0,
                                    lambda: self._on_click_continue())
        self._continue_btn.x = SCREEN_WIDTH * 0.75 - self._continue_btn.get_size(
        )[0] - 20
        get_game().register('on_draw', self.on_draw)
        get_game().register_button_mouse_events(self._continue_btn)

        self._rect_y = 0
        self._rect_h = 0
        self.set_text(self.new_contestant_message())
Пример #13
0
    def __init__(self):
        super().__init__()
        self._current_stage_index = 0
        self._stages = []
        for stage in STAGES:
            self._stages.append(
                Label('${}'.format(stage.money), 0, 0, stage.color))

        self._horizon_padding = 30
        self._max_width = max([lbl.get_size()[0] for lbl in self._stages])
        height_sum = sum([lbl.get_size()[1]
                          for lbl in self._stages]) + (10 *
                                                       (len(self._stages) - 1))
        current_y = SCREEN_HEIGHT - height_sum - 10
        for i, lbl in enumerate(self._stages):
            lbl.x = SCREEN_WIDTH - self._max_width - self._horizon_padding
            lbl.y = current_y
            current_y += lbl.get_size()[1] + 10
        get_game().register('on_draw', self.on_draw)
Пример #14
0
 def new_contestant_message():
     contestant = get_game().current_contestant
     easy_answer_percent = '{}%'.format(
         int(contestant.answer_prob[QuestionDifficulty.EASY] * 100))
     average_answer_percent = '{}%'.format(
         int(contestant.answer_prob[QuestionDifficulty.AVERAGE] * 100))
     hard_answer_percent = '{}%'.format(
         int(contestant.answer_prob[QuestionDifficulty.HARD] * 100))
     prize_to_quit_percent = {
         16000:
         '{}%'.format(int(contestant.prize_to_quit_prob[16000] * 100)),
         125000:
         '{}%'.format(int(contestant.prize_to_quit_prob[125000] * 100))
     }
     return (
         f'Name: {contestant.name}\n'
         f'Chance of answering easy questions: {easy_answer_percent}\n'
         f'Chance of answering average questions: {average_answer_percent}\n'
         f'Chance of answering hard questions: {hard_answer_percent}\n'
         f'Chances of withdrawal: {prize_to_quit_percent[16000]} on $16000, {prize_to_quit_percent[125000]} on $125000'
     )
Пример #15
0
 def _answer_question(self):
     question = get_game().on_screen_question
     get_game().current_contestant.answer(question)
     question.verify_answered_question()
Пример #16
0
 def show(self, on_continue_callback=None):
     super().show()
     self._on_continue_callback = on_continue_callback
     get_game().disable_all_buttons()
     self._continue_btn.enable()
Пример #17
0
 def verify_answered_question(self):
     correct = self.get_correct_answer()
     correct.mark_as_correct(get_game().next_stage_or_new_contestant)
Пример #18
0
 def __init__(self):
     self._question_data = None
     self._ui = QuestionUI()
     self._answers = [PossibleAnswer(i, self._ui) for i in range(4)]
     self._correct_answer_index = -1
     get_game().register('on_draw', self.on_draw)
Пример #19
0
 def next_stage(self):
     get_game().background_controller.show_select_question()
     self._current_stage_index += 1
     get_game().on_screen_question.reset_data()
     self.show()
     get_game().question_pool.show()