コード例 #1
0
ファイル: scoretracker.py プロジェクト: Campus77/scoretracker
    def __submit_score_thread(self):
        # submit score to remote server
        (error, elo) = ServerCom.submit_score(self.players, GameData.get_score())
        if error is None:
            self.submit_success = True
            self.elo = elo
            Logger.info('{}'.format(self.elo))

        else:
            self.submit_success = False
            self.elo = 0.0
コード例 #2
0
ファイル: scoretracker.py プロジェクト: Campus77/scoretracker
    def __handle_goal(self, team):
        if team == '1':
            GameData.add_goal(0)
            obj = self.ids.labelHome
        else:
            GameData.add_goal(1)
            obj = self.ids.labelAway

        self.score = GameData.get_score()
        HighlightOverlay(orig_obj=obj, parent=self).animate(font_size=500, color=(1, 1, 1, 0), d=2.0)
        SoundManager.play(Trigger.GOAL)
コード例 #3
0
ファイル: scoretracker.py プロジェクト: Campus77/scoretracker
 def __reset(self):
     self.state = ''
     GameData.reset_match()
     self.score = GameData.get_score()
     self.set_custom_text('00:00')
     self.ids.topbar.customlabel.opacity = 1
     self.ids.btnSubmit.blocking = False
     container = self.ids.kickoff_ball.parent
     self.ids.kickoff_ball.pos = (container.x + container.width / 2.0, container.y + container.height)
     self.score_touch = None
     self.players = [{}] * 4
     self.kickoff_team = -1
     self.elo = 0.0
     Clock.unschedule(self.__update_match_timer)
     Clock.unschedule(self.__animate_kickoff)
コード例 #4
0
 def __submit_score_thread(self):
     # submit score to remote server
     (error, elo) = ServerCom.submit_score(self.players, GameData.get_score())
     if error is None:
         self.submit_success = True
         self.__set_elo(elo)
         # fetch ranking
         ranking_attacker = ServerCom.fetch_ranking('attacker')
         if ranking_attacker:
             PlayerData.set_ranking('attacker', ranking_attacker)
         ranking_defender = ServerCom.fetch_ranking('defender')
         if ranking_defender:
             PlayerData.set_ranking('defender', ranking_defender)
     else:
         self.submit_success = False
コード例 #5
0
 def update_match(self):
     # fetch score from GameData
     self.score = GameData.get_score()
     # update kickoff information
     self.handle_kickoff(False)
     # check max goal during match
     if self.state == 'running':
         if GameData.is_match_finished():
             self.state = 'finished'
             self.stop_time = self.get_time()
             SoundManager.play(Trigger.GAME_END)
     # manual swiping can resume a finished match
     elif self.state == 'finished' and not GameData.is_match_finished():
         self.state = 'running'
         SoundManager.play(Trigger.GAME_RESUME)
コード例 #6
0
    def preprocess_command(self, sound_type):
        ''' special handling for goal sounds'''
        # skip unless goal
        if sound_type != 'goal':
            return sound_type

        # check tie
        new_type = 'goal-tie'
        if GameData.is_tie() and self.has_files_for(new_type) and random.random() < 0.3:
            return new_type
        # check almost tie
        new_type = 'goal-almost-tie'
        if GameData.is_almost_tie() and self.has_files_for(new_type) and random.random() < 0.3:
            return new_type
        # check absolute score
        score = GameData.get_score()
        new_type = 'goal-{}-{}'.format(score[0], score[1])
        if self.has_files_for(new_type) and random.random() < 0.3:
            return new_type
        # default
        return 'goal'
コード例 #7
0
ファイル: scoretracker.py プロジェクト: Campus77/scoretracker
 def handle_score_touch_up(self, event):
     if self.state not in ['running', 'finished']:
         return
     if self.score_touch:
         score_id = self.score_touch['id']
         dist = event.pos[1] - self.score_touch['startPos']
         if abs(dist) > self.MIN_SCORE_MOVE_PX:
             goal_up = dist > 0
             if goal_up:
                 swipe_allowed = GameData.add_goal(score_id)
             else:
                 swipe_allowed = GameData.revoke_goal(score_id)
             if swipe_allowed:
                 self.score = GameData.get_score()
                 HighlightOverlay(orig_obj=self.score_objects[score_id], parent=self).animate(font_size=500, color=(1, 1, 1, 0))
                 if goal_up:
                     SoundManager.play(Trigger.GOAL)
                 else:
                     SoundManager.play(Trigger.OFFSIDE)
             else:
                 # TODO: "Rote Karte"
                 pass
         self.score_objects[score_id].color = (1, 1, 1, 1)
     self.score_touch = None