Ejemplo n.º 1
0
 def step_back(self, step: int) -> Snapshot:
     self.history = self.history[:-step]
     players = []
     snapshot = self.history[-1]
     snapshot.print()
     for player_id, player_data in enumerate(snapshot.players):
         player = Player(player_id)
         player.load(player_data)
         players.append(player)
     self.round.players = players
     self.round.trace = self.round.trace[:snapshot.step_trace]
     self.round.player_id = snapshot.player_id
     self.dealer.jump(snapshot.step_deck)
     return snapshot
Ejemplo n.º 2
0
    def load_game(self, uuid, step) -> Snapshot:
        with open(f'logs/{uuid}_history.pickle', 'rb') as handle:
            self.history = pickle.load(handle)
        self.history = self.history[:step]
        self.dealer = Dealer(self.rand_seed)
        players = []
        snapshot = self.history[-1]

        for player_id, player_data in enumerate(snapshot.players):
            player = Player(player_id)
            player.load(player_data)
            players.append(player)

        self.round = Round(self.dealer, players, self.config)

        with open(f'logs/{uuid}_trace.pickle', 'rb') as handle:
            self.round.trace = pickle.load(handle)[:snapshot.step_trace]

        self.round.player_id = snapshot.player_id
        self.dealer.jump(snapshot.step_deck)
        return snapshot