def parseMoves(self, symbol): """ generated source for method parseMoves """ if isinstance(symbol, (SymbolAtom, )): return None else: while i < len(list_): moves.add(GdlFactory.createTerm(list_.get(i))) i += 1 return moves
def createStart(self, gamer, list_): """ generated source for method createStart """ if len(list_) < 6: raise IllegalArgumentException("Expected at least 5 arguments!") arg1 = list_.get(1) arg2 = list_.get(2) arg3 = list_.get(3) arg4 = list_.get(4) arg5 = list_.get(5) matchId = arg1.getValue() roleName = GdlFactory.createTerm(arg2) theRulesheet = arg3.__str__() startClock = Integer.valueOf(arg4.getValue()) playClock = Integer.valueOf(arg5.getValue()) # For now, there are only five standard arguments. If there are any # new standard arguments added to START, they should be added here. theReceivedGame = Game.createEphemeralGame(theRulesheet) return StartRequest(gamer, matchId, roleName, theReceivedGame, startClock, playClock)
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