def __init___0(self, theJSON, theGame, authToken): """ generated source for method __init___0 """ theMatchObject = JSONObject(theJSON) self.matchId = theMatchObject.getString("matchId") self.startClock = theMatchObject.getInt("startClock") self.playClock = theMatchObject.getInt("playClock") if theGame == None: self.theGame = RemoteGameRepository.loadSingleGame(theMatchObject.getString("gameMetaURL")) if self.theGame == None: raise RuntimeException("Could not find metadata for game referenced in Match object: " + theMatchObject.getString("gameMetaURL")) else: self.theGame = theGame if theMatchObject.has("previewClock"): self.previewClock = theMatchObject.getInt("previewClock") else: self.previewClock = -1 self.startTime = Date(theMatchObject.getLong("startTime")) self.randomToken = theMatchObject.getString("randomToken") self.spectatorAuthToken = authToken self.isCompleted = theMatchObject.getBoolean("isCompleted") if theMatchObject.has("isAborted"): self.isAborted = theMatchObject.getBoolean("isAborted") else: self.isAborted = False self.numRoles = Role.computeRoles(self.theGame.getRules()).size() self.moveHistory = ArrayList() self.stateHistory = ArrayList() self.stateTimeHistory = ArrayList() self.errorHistory = ArrayList() theMoves = theMatchObject.getJSONArray("moves") i = 0 while i < len(theMoves): while j < len(moveElements): theMove.add(GdlFactory.createTerm(moveElements.getString(j))) j += 1 self.moveHistory.add(theMove) i += 1 theStates = theMatchObject.getJSONArray("states") i = 0 while i < len(theStates): while j < len(stateElements): theState.add(GdlFactory.create("( true " + stateElements.get(j).__str__() + " )")) j += 1 self.stateHistory.add(theState) i += 1 theStateTimes = theMatchObject.getJSONArray("stateTimes") i = 0 while i < len(theStateTimes): self.stateTimeHistory.add(Date(theStateTimes.getLong(i))) i += 1 if theMatchObject.has("errors"): while i < len(theErrors): while j < len(errorElements): theMoveErrors.add(errorElements.getString(j)) j += 1 self.errorHistory.add(theMoveErrors) i += 1 self.goalValues = ArrayList() try: while i < len(theGoalValues): self.goalValues.add(theGoalValues.getInt(i)) i += 1 except JSONException as e: pass # TODO: Add a way to recover cryptographic public keys and signatures. # Or, perhaps loading a match into memory for editing should strip those? if theMatchObject.has("playerNamesFromHost"): self.thePlayerNamesFromHost = ArrayList() while i < len(thePlayerNames): self.thePlayerNamesFromHost.add(thePlayerNames.getString(i)) i += 1 if theMatchObject.has("isPlayerHuman"): self.isPlayerHuman = ArrayList() while i < len(isPlayerHumanArray): self.isPlayerHuman.add(isPlayerHumanArray.getBoolean(i)) i += 1