本文整理汇总了Python中ige.IDataHolder.IDataHolder.planets方法的典型用法代码示例。如果您正苦于以下问题:Python IDataHolder.planets方法的具体用法?Python IDataHolder.planets怎么用?Python IDataHolder.planets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ige.IDataHolder.IDataHolder
的用法示例。
在下文中一共展示了IDataHolder.planets方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getScanInfos
# 需要导入模块: from ige.IDataHolder import IDataHolder [as 别名]
# 或者: from ige.IDataHolder.IDataHolder import planets [as 别名]
def getScanInfos(self, tran, obj, scanPwr, player):
result = IDataHolder()
results = [result]
if scanPwr >= Rules.level1InfoScanPwr:
result._type = T_SCAN
result.scanPwr = scanPwr
result.oid = obj.oid
result.x = obj.x
result.y = obj.y
if hasattr(obj, 'destinationOid'):
result.destinationOid = obj.destinationOid
# multiply by 1000 to increase accuracy
#~ result.dist = obj.dist * 1000
#~ result.dAngle = obj.dAngle * 1000
#~ result.sAngle = obj.sAngle * 1000
result.signature = obj.signature
result.type = obj.type
result.compOf = obj.compOf
result.starClass = obj.starClass
if scanPwr >= Rules.level2InfoScanPwr:
result.name = obj.name
result.combatCounter = obj.combatCounter
if scanPwr >= Rules.level3InfoScanPwr:
result.planets = obj.planets
result.owner = obj.owner
for planetID in obj.planets:
planet = tran.db[planetID]
if planet.owner == player: ####### This was player.owner, which made no sense. Hope this change doesn't break something
continue
newPwr = scanPwr * planet.signature / obj.signature
results.extend(self.cmd(planet).getScanInfos(tran, planet, newPwr, player))
if scanPwr >= Rules.level4InfoScanPwr:
result.fleets = obj.fleets
for fleetID in obj.fleets:
fleet = tran.db[fleetID]
if fleet.owner == player:
continue
newPwr = scanPwr * fleet.signature / obj.signature
results.extend(self.cmd(fleet).getScanInfos(tran, fleet, newPwr, player))
result.hasmines = 0 #no
if len(obj.minefield) > 0:
result.hasmines = 1 #yes
result.minefield = self.getMines(obj,player.oid) #only shows mines you own
if len(obj.minefield) > 1 or (len(obj.minefield) == 1 and len(result.minefield) == 0):
result.hasmines = 2 #yes, and some aren't my mines
return results
示例2: getScanInfos
# 需要导入模块: from ige.IDataHolder import IDataHolder [as 别名]
# 或者: from ige.IDataHolder.IDataHolder import planets [as 别名]
def getScanInfos(self, tran, obj, scanPwr, player):
result = IDataHolder()
results = [result]
if scanPwr >= Rules.level1InfoScanPwr:
result._type = Const.T_SCAN
result.scanPwr = scanPwr
result.oid = obj.oid
result.x = obj.x
result.y = obj.y
if hasattr(obj, 'destinationOid'):
result.destinationOid = obj.destinationOid
result.signature = obj.signature
result.type = obj.type
result.compOf = obj.compOf
result.starClass = obj.starClass
if scanPwr >= Rules.level2InfoScanPwr:
result.name = obj.name
result.combatCounter = obj.combatCounter
if scanPwr >= Rules.level3InfoScanPwr:
result.planets = obj.planets
result.owner = obj.owner
for planetID in obj.planets:
planet = tran.db[planetID]
if planet.owner == player: ####### This was player.owner, which made no sense. Hope this change doesn't break something
continue
newPwr = scanPwr * planet.signature / obj.signature
results.extend(self.cmd(planet).getScanInfos(tran, planet, newPwr, player))
if scanPwr >= Rules.level4InfoScanPwr:
result.fleets = obj.fleets
for fleetID in obj.fleets:
fleet = tran.db[fleetID]
if fleet.owner == player:
continue
newPwr = scanPwr * fleet.signature / obj.signature
results.extend(self.cmd(fleet).getScanInfos(tran, fleet, newPwr, player))
result.minefield = self.getMines(obj, player.oid)
ownsMines = 1 if result.minefield else 0
result.hasmines = min(2, len(self.getAllMines(obj))) - ownsMines
return results
示例3: getSystemStructStats
# 需要导入模块: from ige.IDataHolder import IDataHolder [as 别名]
# 或者: from ige.IDataHolder.IDataHolder import planets [as 别名]
def getSystemStructStats(data, client, db, systemID, processQueues=True):
""" It go through all planets and structures, and creates IDataHolder
object, with roster of buildings, surplus of bio and en.
processQueues - if True, it go through all buildQueues and adjust all
statistics as it would be all done already.
Returns IDataHolder with parameters:
.bio - system surplus of biomass
.en - system surplus of en
.planets - dictionary, keys are planetIDs of players or free planets,
and values are dictionaries (huh) with keys being techIDs
and values being number of those structs.
"""
systemStats = IDataHolder()
system = db[systemID]
player = client.getPlayer()
myPlanets = set(system.planets) & data.myPlanets
systemStats.planets = {}
for planetID in myPlanets:
systemStats.planets[planetID] = {}
for planetID in set(system.planets) & data.freePlanets:
systemStats.planets[planetID] = {}
# creation of the .planets dictionary
for planetID in myPlanets:
planet = db[planetID]
for techID, hp, something, eff in planet.slots:
try:
systemStats.planets[planetID][techID] += 1
except KeyError:
systemStats.planets[planetID][techID] = 1
if not processQueues:
# do not look into the queue
continue
for task in getattr(planet, 'prodQueue', []):
if not task.isShip:
techID = task.techID
tech = client.getFullTechInfo(task.techID)
if tech.isStructure:
if task.targetID not in systemStats.planets.keys():
continue
try:
systemStats.planets[task.targetID][techID] += 1
except KeyError:
systemStats.planets[task.targetID][techID] = 1
if task.demolishStruct:
try:
systemStats.planets[task.targetID][task.demolishStruct] -= 1
except KeyError:
systemStats.planets[task.targetID][task.demolishStruct] = -1
# by parsing .planets object, fill the .bio and .en parameters
systemStats.bio = 0
systemStats.en = 0
for planetID in systemStats.planets:
planet = db[planetID]
if planetID not in myPlanets:
continue
for techID in systemStats.planets[planetID]:
quantity = systemStats.planets[planetID][techID]
deltaBio, deltaEn, deltaProd = getSystemStatsChange(client, db, techID, planetID, 0)
tech = client.getFullTechInfo(techID)
systemStats.en += quantity * deltaEn
systemStats.bio += quantity * deltaBio
return systemStats