示例#1
0
 def draw_games(self, stage_players, stage):
     game_uids = []
     for (p1_uid, p2_uid) in stage_players:
         name = "{}:{}-vs-{}".format(stage, p1_uid, p2_uid)
         game = Game(name, p1_uid, p2_uid, self.championship_uid, stage)
         game.save()
         game_uids.append(game.uid)
     return game_uids
示例#2
0
def start_game(game_uid, championship, stage):
    game = Game.fetch(uid=game_uid)
    log.debug("Starting Game: {}".format(game.name))
    ga = GameActor(game, championship, stage)
    ga.start()
    game_actor_map[game.uuid] = ga
    ga.join()
示例#3
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))
示例#4
0
 def get_game_results(self, stage):
     return Game.fetch_all(championship_uid=self.championship_uid, stage=stage)