def _readGame(self, debug): playerCountChar = self.stream.read(1) if len(playerCountChar) == 0: return False players = [] teams = [] playerNames = [] # Read the game header. (playerCount,) = struct.unpack("!B", playerCountChar) for i in xrange(playerCount): (teamNo, playerNameLen) = struct.unpack("!BH", self.stream.read(3)) playerNames.append(self.stream.read(playerNameLen)) player = Player() player.number = i player.teamNumber = teamNo players.append(player) for teamNo in set(map(lambda player: player.teamNumber, players)): team = Team(number = teamNo) team.playerNumbers = [player.number for player in players if player.teamNumber == teamNo] teams.append(team) self.game = Game(None, teams = teams, players = players, debug = debug) self.gameStartFn(self.game, playerNames) return True
"Transcript move: %d drew %s %s\n" % (player, Cards.cardToString(drawnCard) if drawnCard else "nothing", move)), lambda *args: stdout.write("Transcript hand end!\n"), lambda game: stdout.write("Transcript game end! Scores: %s\n" % ( " ".join(map(lambda team: "%d" % team.totalScore, game.teams))))) reader.read(debug=True) exit(0) players = [] competitor = 0 for i in range(numPlayers): players.append(competitors[competitor]()) competitor += 1 if competitor >= len(competitors): competitor = 0 scores = {} transcriptWriter = None for i in range(games): g = Game(players, debug) if writeTranscript: transcriptWriter = TranscriptWriter(writeTranscript, g) winners = g.play() for winner in winners: if not scores.has_key(winner): scores[winner] = 0 scores[winner] += 1 print scores