def addPlayer(self, playerId): # Validate player ID (since this is crucial later throughout the game) validatePlayerId(playerId) # Add player if playerId in self.players: raise DuplicatePlayerException( "playerId {} is already in players".format(playerId)) self.players.append(playerId) # Initialize infiltration values for n in self.nodes.values(): n.infiltration[playerId] = 0 # Assign starting node freeNodes = self.getNodesOfType( "Large City") # TODO make this "fairer" freeNodes = [x for x in freeNodes if x.ownerId == -1] startNode = random.choice(freeNodes) startNode.own(playerId) startNode.isIPSed = True # Done! return
def addPlayer(self, playerId): # Validate player ID (since this is crucial later throughout the game) validatePlayerId(playerId) # Add player if playerId in self.players: raise DuplicatePlayerException("playerId {} is already in players".format(playerId)) self.players.append(playerId) # Initialize infiltration values for n in self.nodes.values(): n.infiltration[playerId] = 0 # Assign starting node freeNodes = self.getNodesOfType("Large City") # TODO make this "fairer" freeNodes = [x for x in freeNodes if x.ownerId == -1] startNode = random.choice(freeNodes) startNode.own(playerId) startNode.isIPSed = True # Done! return
def getPlayerNodes(self, playerId): validatePlayerId(playerId) return [x for x in self.nodes.values() if x.ownerId == playerId]