Beispiel #1
0
 def reset_game(self, data=None):
     BaseExhibit.reset_game(self)
     self.init_game()
     self.sound = None
     self.end_function = None
     self.play_tone()
     self.env.keyboard.find_key(self.st.minus_button).listen(
         strip_params(self.minus_pressed), key_down)
     self.env.keyboard.find_key(self.st.plus_button).listen(
         strip_params(self.plus_pressed), key_down)
Beispiel #2
0
    def reset_game(self, key=None, updown=None):
        BaseExhibit.reset_game(self)
        self.env.keyboard.find_key(self.st.start_bl).listen(strip_params(self.begin_game), key_up)
        self.env.keyboard.find_key(self.st.start_bl).listen(self.reset_game, key_down)
        self.env.keyboard.find_key(self.st.end_bl).listen(strip_params(self.end_game), key_down)
        self.env.keyboard.find_key(self.st.error_bl).listen(self.error_down, key_down)
        self.env.keyboard.find_key(self.st.error_bl).listen(self.error_up, key_up)

        self.penalty_timer = None
        self.infinite_timer = None
        self.playing = False
        self.score = 0
        self.penalty_count = 0
        self.last_penalty = -2*self.st.penalty_timeout

        if not self.is_qr_registered:
            self.qr_register()
Beispiel #3
0
 def reset_game(self, qr_register=False):
     BaseExhibit.reset_game(self, qr_register=qr_register)
     self.light(0)
     self.score = 0
     self.seven_print(texts=self.score%1000, phormats='%d')
     self.html('html_instr')
     self.env.keyboard.listen(self.action_down, key_down)
     self.env.keyboard.listen(strip_params(self.action_up), key_up)
Beispiel #4
0
 def run_reset_timer(self, reset_callback, _time=None):
     """
     use Timer implementation to reset game after `time` seconds of inactivity. After this time,
     reset_callback is invoked.
     """
     if _time is None:
         _time=self.st.default_reset_time
     self.activity_timer=None
     def ecb(self):
         self.stop_reset_timer()
         reset_callback()
     def reset():
         if self.activity_timer != 'cancelled':
             if self.activity_timer:
                 self.activity_timer.cancel()
             self.activity_timer=self.create_timer(_time, end_callback=partial(ecb, self))
             self.activity_timer.start()
     self.activity_keypress_cb=self.env.keyboard.listen(strip_params(reset))
     reset()
Beispiel #5
0
 def update_scores(self, key, updown):
     self.stop_reset_timer()
     for p in self.players:
         if p.io.button_label == key.label:
             p.score += 1
             self.env.light(p.io.led_labels[p.score-1], 1)
             if p.score == len(p.io.led_labels):
                 def blink_winner(self, p):
                     for ll in p.io.led_labels:
                         self.env.light(ll, not self.env.lights[ll])
                 self.create_timer(self.st.flicker_time,
                     self.st.flicker_interval,
                     callback = strip_params(partial(blink_winner, self, p)),
                     end_callback = self.reset_game).start()
             else:
                 self.create_timer(self.st.lighted_wall_time,
                     self.st.lighted_wall_time,
                     end_callback=self.end_round).start()
         else:
             self.env.light(p.io.pyramid_label, 0)
Beispiel #6
0
 def reset_game(self):
     BaseExhibit.reset_game(self)
     for p in self.players:
         p.score = 0
     self.reset_lights()
     self.env.keyboard.listen_once(strip_params(self.prepare_round), key_down)
Beispiel #7
0
 def start_infinite_timer(self):
     self.infinite_timer = self.create_timer(60, self.st.time_tick_interval,
         callback=strip_params(self.check_and_print_score),
         end_callback=self.start_infinite_timer)
     self.infinite_timer.start()
Beispiel #8
0
 def urwid_invoke(self, cb):
     """
     invoke cb in the urwid's mainloop thread
     """
     self.loop.set_alarm_in(0,strip_params(cb))
Beispiel #9
0
 def tick():
     self.loop.set_alarm_in(0.1, strip_params(tick))