def processINITPhase(self, tran, obj, data): IPlayer.processINITPhase(self, tran, obj, data) # TODO -- remove following lines obj.lastLogin = time.time() # delete itself if there are no fleets and planets if not obj.fleets and not obj.planets: self.cmd(obj).delete(tran, obj)
def processINITPhase(self, tran, obj, data): IPlayer.processINITPhase(self, tran, obj, data) # TODO -- remove following lines obj.lastLogin = time.time() # delete itself if there are no fleets and planets if not obj.fleets and not obj.planets: self.cmd(obj).delete(tran, obj)
def processINITPhase(self, tran, obj, data): IPlayer.processINITPhase(self, tran, obj, data) obj.lastLogin = time.time() # delete itself if there are no fleets and planets # delete the account as well # unregister it from the AI system if not obj.fleets and not obj.planets: self.cmd(obj).delete(tran, obj)
def processINITPhase(self, tran, obj, data): IPlayer.processINITPhase(self, tran, obj, data) obj.lastLogin = time.time() # delete itself if there are no fleets and planets # delete the account as well # unregister it from the AI system if not obj.fleets and not obj.planets: self.cmd(obj).delete(tran, obj)
def processINITPhase(self, tran, obj, data): IPlayer.processINITPhase(self, tran, obj, data) if (len(obj.techs) == 0): log.warning('Renegade player in INIT phase without techs; granting again') self.cmd(obj).update(tran, obj) #grant the techs because something screwed up obj.lastLogin = time.time() # delete itself if there are no fleets and planets if not obj.fleets and not obj.planets: self.cmd(obj).delete(tran, obj)
def processINITPhase(self, tran, obj, data): IPlayer.processINITPhase(self, tran, obj, data) if (len(obj.techs) == 0): log.warning( 'Renegade player in INIT phase without techs; granting again') self.cmd(obj).update( tran, obj) #grant the techs because something screwed up obj.lastLogin = time.time() # delete itself if there are no fleets and planets if not obj.fleets and not obj.planets: self.cmd(obj).delete(tran, obj)
def processINITPhase(self, tran, obj, data): IPlayer.processINITPhase(self, tran, obj, data) obj.lastLogin = time.time() log.debug("NATURE - asteroids", len(obj.fleets), obj.fleets)
def processINITPhase(self, tran, obj, data): IPlayer.processINITPhase(self, tran, obj, data) # TODO -- remove following lines obj.lastLogin = time.time() # delete itself if there are no fleets and planets if not obj.fleets and not obj.planets: self.cmd(obj).delete(tran, obj) # "AI" behavior -> construct pirate bases on system AI owns for planetID in obj.planets: planet = tran.db[planetID] #@log.debug(obj.oid, "PIRATEAI - scanning", planetID, len(planet.prodQueue), len(planet.slots), planet.plSlots, planet.plMaxSlots) if planet.prodQueue: # something is in production queue continue if not Rules.Tech.PIRATEBREWERY in obj.techs: log.warning( 'Pirate player in INIT phase without techs; granting again' ) self.cmd(obj).update( tran, obj) #grant the techs because something screwed up if planet.plSlots > len(planet.slots): # build PIRBASE log.debug(obj.oid, "PIRATEAI - building pirate base", planet.oid) self.cmd(planet).startConstruction(tran, planet, Rules.Tech.PIRATEBASE, 1, planet.oid, False, False, OID_NONE) continue else: # no room # try to build on another planets system = tran.db[planet.compOf] build = False for targetID in system.planets: target = tran.db[targetID] if target.owner == OID_NONE and target.plSlots > 0: log.debug(obj.oid, "PIRATEAI - colonizing planet", target.oid) self.cmd(planet).startConstruction( tran, planet, Rules.Tech.PIRATEBASE, 1, targetID, False, False, OID_NONE) build = True if build: break if build: continue # try to expand slots if Rules.Tech.ADDSLOT3 in obj.techs and planet.plSlots < planet.plMaxSlots: log.debug(obj.oid, "PIRATEAI - building surface expansion", planet.oid) self.cmd(planet).startConstruction(tran, planet, Rules.Tech.ADDSLOT3, 1, planet.oid, False, False, OID_NONE) build = True if build: continue #try to assemble/condense planets if Rules.Tech.PLASSEMBL5 in obj.techs or Rules.Tech.PLCOND5 in obj.techs: for targetID in system.planets: target = tran.db[targetID] if target.plType == 'A' and Rules.Tech.PLASSEMBL5 in obj.techs: log.debug(obj.oid, "PIRATEAI - assembling asteroid", target.oid) self.cmd(planet).startConstruction( tran, planet, Rules.Tech.PLASSEMBL5, 1, planet.oid, False, False, OID_NONE) build = True elif target.plType == 'G' and Rules.Tech.PLCOND5 in obj.techs: log.debug(obj.oid, "PIRATEAI - assembling asteroid", target.oid) self.cmd(planet).startConstruction( tran, planet, Rules.Tech.PLCOND5, 1, planet.oid, False, False, OID_NONE) build = True if build: break continue #grant time based techs as needed: if obj.galaxies: if not (Rules.Tech.ADDSLOT3 in obj.techs and Rules.Tech.PLASSEMBL5 in obj.techs and Rules.Tech.PLCOND5 in obj.techs): galaxy = tran.db[obj.galaxies[0]] if galaxy.creationTime + Rules.pirateGrantHSE < time.time( ) and not Rules.Tech.ADDSLOT3 in obj.techs: obj.techs[Rules.Tech.ADDSLOT3] = Rules.techMaxImprovement if galaxy.creationTime + Rules.pirateGrantASSEM < time.time( ) and not Rules.Tech.PLASSEMBL5 in obj.techs: obj.techs[Rules.Tech.PLASSEMBL5] = Rules.techMaxImprovement if galaxy.creationTime + Rules.pirateGrantCOND < time.time( ) and not Rules.Tech.PLCOND5 in obj.techs: obj.techs[Rules.Tech.PLCOND5] = Rules.techMaxImprovement
def processINITPhase(self, tran, obj, data): IPlayer.processINITPhase(self, tran, obj, data) obj.lastLogin = time.time() log.debug("NATURE - asteroids", len(obj.fleets), obj.fleets)
def processINITPhase(self, tran, obj, data): IPlayer.processINITPhase(self, tran, obj, data) obj.lastLogin = time.time()
def processINITPhase(self, tran, obj, data): IPlayer.processINITPhase(self, tran, obj, data) # TODO -- remove following lines obj.lastLogin = time.time() # delete itself if there are no fleets and planets if not obj.fleets and not obj.planets: self.cmd(obj).delete(tran, obj) # "AI" behavior -> construct pirate bases on system AI owns for planetID in obj.planets: planet = tran.db[planetID] #@log.debug(obj.oid, "PIRATEAI - scanning", planetID, len(planet.prodQueue), len(planet.slots), planet.plSlots, planet.plMaxSlots) if planet.prodQueue: # something is in production queue continue if not Rules.Tech.PIRATEBREWERY in obj.techs: log.warning('Pirate player in INIT phase without techs; granting again') self.cmd(obj).update(tran, obj) #grant the techs because something screwed up if planet.plSlots > len(planet.slots): # build PIRBASE log.debug(obj.oid, "PIRATEAI - building pirate base", planet.oid) self.cmd(planet).startConstruction(tran, planet, Rules.Tech.PIRATEBASE, 1, planet.oid, False, False, OID_NONE) continue else: # no room # try to build on another planets system = tran.db[planet.compOf] build = False for targetID in system.planets: target = tran.db[targetID] if target.owner == OID_NONE and target.plSlots > 0: log.debug(obj.oid, "PIRATEAI - colonizing planet", target.oid) self.cmd(planet).startConstruction(tran, planet, Rules.Tech.PIRATEBASE, 1, targetID, False, False, OID_NONE) build = True if build: break if build: continue # try to expand slots if Rules.Tech.ADDSLOT3 in obj.techs and planet.plSlots < planet.plMaxSlots: log.debug(obj.oid, "PIRATEAI - building surface expansion", planet.oid) self.cmd(planet).startConstruction(tran, planet, Rules.Tech.ADDSLOT3, 1, planet.oid, False, False, OID_NONE) build = True if build: continue #try to assemble/condense planets if Rules.Tech.PLASSEMBL5 in obj.techs or Rules.Tech.PLCOND5 in obj.techs: for targetID in system.planets: target = tran.db[targetID] if target.plType == 'A' and Rules.Tech.PLASSEMBL5 in obj.techs: log.debug(obj.oid, "PIRATEAI - assembling asteroid", target.oid) self.cmd(planet).startConstruction(tran, planet, Rules.Tech.PLASSEMBL5, 1, planet.oid, False, False, OID_NONE) build = True elif target.plType == 'G' and Rules.Tech.PLCOND5 in obj.techs: log.debug(obj.oid, "PIRATEAI - assembling asteroid", target.oid) self.cmd(planet).startConstruction(tran, planet, Rules.Tech.PLCOND5, 1, planet.oid, False, False, OID_NONE) build = True if build: break continue #grant time based techs as needed: if obj.galaxies: if not (Rules.Tech.ADDSLOT3 in obj.techs and Rules.Tech.PLASSEMBL5 in obj.techs and Rules.Tech.PLCOND5 in obj.techs): galaxy = tran.db[obj.galaxies[0]] if galaxy.creationTime + Rules.pirateGrantHSE < time.time() and not Rules.Tech.ADDSLOT3 in obj.techs: obj.techs[Rules.Tech.ADDSLOT3] = Rules.techMaxImprovement if galaxy.creationTime + Rules.pirateGrantASSEM < time.time() and not Rules.Tech.PLASSEMBL5 in obj.techs: obj.techs[Rules.Tech.PLASSEMBL5] = Rules.techMaxImprovement if galaxy.creationTime + Rules.pirateGrantCOND < time.time() and not Rules.Tech.PLCOND5 in obj.techs: obj.techs[Rules.Tech.PLCOND5] = Rules.techMaxImprovement