Beispiel #1
0
    def prepare_next_round(self):
        #clear remaining queue items
        self.inbox_a.queue.clear()
        self.inbox_d.queue.clear()
        self.round_no += 1

        if self.winner_uid == self.defender_uid:
            if Round.number_of_wins(self.game_uid, self.defender_uid) >= 5:
                self.game_over = True
                self.loser_uid = self.attacker_uid
            #switch_roles
            self.attacker_uid, self.defender_uid = self.defender_uid, self.attacker_uid
        else:
            if Round.number_of_wins(self.game_uid, self.attacker_uid) >= 5:
                self.game_over = True
                self.loser_uid = self.defender_uid

        if self.game_over:
            game = Game.fetch(uid=self.game_uid)
            game.winner_uid = self.winner_uid
            game.save()
            game = Game.fetch(uid=self.game_uid)
            log.debug("Winner: {}".format(game.winner_uid))
Beispiel #2
0
 def write_round_results(self):
     r = Round(self.round_no, self.attacker_uid, self.defender_uid,
               self.game_uid, self.championship_uid, self.attacker_data,
               self.defender_data, self.winner_uid)
     r.save()