def prepareGame(self, status, queue) -> (): """Prepare Level 1 Do hardware-preparations :param status: current state of the game, used for web-frontend :param queue: Message-Q for hardware.messages to be launched return list of hardware-processes started here """ kbd = CheckKey(queue) startThreadClass(kbd) timer = Countdown(queue, 16) status.msg = str(_("Level01 starts..")) models.setGameState(self.user_id, status) startThreadClass(timer) glob = tlu_globals.globMgr.tlu_glob() glob.lcdMessagebyline( _("Level: ") + "01", str(_("Easy start ")) + ":)") status.msg = str(_("Level 1 running")) status.level_start = timezone.now() status.level_progress = 0 models.setGameState(self.user_id, status) return ( timer, kbd, )
def test_countdown(self): """ Test countdown display process in general """ queue=TestQueue() cd=Countdown(queue, 1.0) startThreadClass(cd) self.assertNotEqual(cd, None, "Process could not be established") self.stop(cd, "test_countdown")
def test_countdown_timeout(self): """ Test countdown with timeout-event """ queue=TestQueue() cd=Countdown(queue, 0.2) startThreadClass(cd) self.assertNotEqual(cd, None, "Process could not be established") queue.myrun(self) #breaks/terminates once timeout reached self.stop(cd, "test_countdown_timeout")
def test_countdown_reset(self): """ Test countdown with reset-event """ queue=TestQueue() cd=Countdown(queue, 0.1) startThreadClass(cd) self.assertNotEqual(cd, None, "Process could not be established") queueobject=tlu_queueobject(tlu_queue.tlu_queue.MSG_TEST,1) queue.send(queueobject) #forces timer reset queue.myrun(self,cd) #breaks/terminates once timeout reached self.stop(cd, "test_countdown_reset")
def prepareGame(self, status, queue) -> (): """Prepare Test Do hardware-preparations :param status: current state of the game, used for web-frontend :param queue: Message-Q for hardware.messages to be launched return list of hardware-processes started here """ timer = Countdown(queue, 0.5) status.msg = _("Level00 starts..") status.level_start = timezone.now() models.setGameState(self.user_id, status) startProcess(timer) return (timer, )
def prepareGame(self, status, queue) -> (): """ Method to be overwritten by implementation. Would be called before starting the processing of the message queue Use this as a *template* only! return list of started processes (needed to terminate them at the end) :param status: status object of the level :param queue: Message queu for game-messages """ timer = Countdown(queue, 1) status.msg = _("Level00 starts..") status.level_start = timezone.now() models.setGameState(self.user_id, status) startProcess(timer) return (timer, )
def prepareGame(self, status, queue) -> (): """Prepare Level Do hardware-preparations :param status: current state of the game, used for web-frontend :param queue: Message-Q for hardware.messages to be launched return list of hardware-processes started here """ cc = CheckCursor(queue) startThreadClass(cc) timer = Countdown(queue, 4) status.msg = str(_("Level 2 starts..")) models.setGameState(self.user_id, status) startThreadClass(timer) glob = tlu_globals.globMgr.tlu_glob() glob.lcdMessagebyline(_("Level: ") + "02", str(_("Cursorkeys"))) status.msg = str(_("Level 2 running")) status.level_progress = 0 status.level_start = timezone.now() models.setGameState(self.user_id, status) return ( timer, cc, )