コード例 #1
0
 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
0
	def getScanInfos(self, tran, obj, scanPwr, player):
		if obj.owner == player.oid:
			return []
		if scanPwr >= Rules.level1InfoScanPwr:
			result = IDataHolder()
			result._type = T_SCAN
			result.scanPwr = scanPwr
			result.oid = obj.oid
			result.x = obj.x
			result.y = obj.y
			result.oldX = obj.oldX
			result.oldY = obj.oldY
			result.eta = obj.eta
			result.signature = obj.signature
			result.type = obj.type
			result.orbiting = obj.orbiting
			if obj.orbiting == OID_NONE and obj.actionIndex < len(obj.actions):
				target = obj.actions[obj.actionIndex][1]
				targetObj = tran.db[target]
				if targetObj.type == T_PLANET:
					result.target = targetObj.compOf
				else:
					result.target = target
		else:
			return []
		if scanPwr >= Rules.level2InfoScanPwr:
			result.owner = obj.owner
			if obj.customname:
				result.name = obj.customname
			else:
				result.name = obj.name
		if scanPwr >= Rules.level3InfoScanPwr:
			result.isMilitary = obj.isMilitary
			result.combatPwr = obj.combatPwr
		if scanPwr >= Rules.level4InfoScanPwr:
			# provide less information
			result.shipScan = {}
			owner = tran.db[obj.owner]
			for designID, hp, shield, exp in obj.ships:
				tech = owner.shipDesigns[designID]
				key = tech.name, tech.combatClass, tech.isMilitary
				result.shipScan[key] = result.shipScan.get(key, 0) + 1
		if scanPwr >= Rules.partnerScanPwr:
			result.scannerPwr = obj.scannerPwr
			result.allowmerge = obj.allowmerge
			result.customname = obj.customname
			result.name = obj.name
		return [result]
コード例 #3
0
ファイル: IPlanet.py プロジェクト: Lukc/ospace-lukc
	def getScanInfos(self, tran, obj, scanPwr, player):
		if scanPwr >= Rules.level1InfoScanPwr:
			result = IDataHolder()
			result._type = T_SCAN
			result.scanPwr = scanPwr
			result.oid = obj.oid
			result.signature = obj.signature
			result.type = obj.type
			result.orbit = obj.orbit
			result.compOf = obj.compOf
			result.x = obj.x
			result.y = obj.y
			result.plType = obj.plType
		if scanPwr >= Rules.level2InfoScanPwr:
			result.plDiameter = obj.plDiameter
			if getattr(obj, "plType", 'X') != 'G':
				result.plMin = obj.plMin
			result.plBio = obj.plBio
			result.plEn = obj.plEn
			result.plSlots = obj.plSlots
			result.plStratRes = obj.plStratRes
			result.plMaxSlots = obj.plMaxSlots
		if scanPwr >= Rules.level3InfoScanPwr:
			result.name = obj.name
			result.storPop = obj.storPop
			result.owner = obj.owner
			#XXX result.plMaxMoonsSlots = obj.plMaxMoonsSlots
		if scanPwr >= Rules.level4InfoScanPwr:
			# TODO provide less information
			result.hasRefuel = (obj.refuelInc > 0) #simple detect if docks exist for problems dialog
			result.slots = obj.slots
			#XXX result.plMoonsSlots = obj.plMoonsSlots
			result.shield = obj.shield
			result.prevShield = -1
			result.maxShield = -1
		if scanPwr >= Rules.partnerScanPwr:
			result.maxShield = obj.maxShield
			result.prevShield = obj.prevShield
			result.refuelMax = obj.refuelMax
			result.refuelInc = obj.refuelInc
			result.scannerPwr = obj.scannerPwr
			result.trainShipInc = obj.trainShipInc
			result.trainShipMax = obj.trainShipMax
			result.upgradeShip = obj.upgradeShip
			result.repairShip = obj.repairShip
			result.fleetSpeedBoost = obj.fleetSpeedBoost
		return [result]
コード例 #4
0
ファイル: ISystem.py プロジェクト: mozts2005/OuterSpace
 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
コード例 #5
0
ファイル: ISystem.py プロジェクト: WittsEnd2/Space-Scanner
    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
コード例 #6
0
ファイル: ISystem.py プロジェクト: ospaceteam/outerspace
    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
コード例 #7
0
 def getScanInfo(self, tran, obj, scanPwr):
     result = IDataHolder()
     result._type = Const.T_SCAN
     result.scanPwr = scanPwr
     if scanPwr > Rules.level1InfoScanPwr:
         result.oid = obj.oid
         result.x = obj.x
         result.y = obj.y
         result.oldX = obj.oldX
         result.oldY = obj.oldY
         result.signature = obj.signature
         result.type = obj.type
         result.orbiting = obj.orbiting
         result.speed = obj.speed
         result.eta = obj.eta
     if scanPwr > Rules.level2InfoScanPwr:
         result.name = obj.name
     if scanPwr > Rules.level3InfoScanPwr:
         result.asDiameter = obj.asDiameter
         result.asHP = obj.asHP
     if scanPwr > Rules.level4InfoScanPwr:
         pass
     return result
コード例 #8
0
 def getScanInfo(self, tran, obj, scanPwr):
     result = IDataHolder()
     result._type = T_SCAN
     result.scanPwr = scanPwr
     if scanPwr > Rules.level1InfoScanPwr:
         result.oid = obj.oid
         result.x = obj.x
         result.y = obj.y
         result.oldX = obj.oldX
         result.oldY = obj.oldY
         result.signature = obj.signature
         result.type = obj.type
         result.orbiting = obj.orbiting
         result.speed = obj.speed
         result.eta = obj.eta
     if scanPwr > Rules.level2InfoScanPwr:
         result.name = obj.name
     if scanPwr > Rules.level3InfoScanPwr:
         result.asDiameter = obj.asDiameter
         result.asHP = obj.asHP
     if scanPwr > Rules.level4InfoScanPwr:
         pass
     return result