idCheckers.py (13233B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\common\script\sys\idCheckers.py 2 import eve.common.lib.appConst as appConst 3 from eve.common.lib.appConst import ALSCActionAssemble, ALSCActionRepackage, ALSCActionSetName, ALSCActionMove, ALSCActionSetPassword, ALSCActionAdd, ALSCActionLock, ALSCActionUnlock, ALSCActionEnterPassword, ALSCActionConfigure, locationCharacterGraveyard, locationCorporationGraveyard, locationStructureGraveyard 4 from eveprefs import boot 5 from eveuniverse.security import is_zero_sec_solar_system, is_low_sec_solar_system 6 from inventorycommon.const import * 7 minDustUser = 1000000000 8 9 def IsRegion(itemID): 10 return minRegion <= itemID <= maxRegion 11 12 13 def IsConstellation(itemID): 14 return minConstellation <= itemID <= maxConstellation 15 16 17 def IsSolarSystem(itemID): 18 return minSolarSystem <= itemID <= maxSolarSystem 19 20 21 def IsCelestial(itemID): 22 return minUniverseCelestial <= itemID <= maxUniverseCelestial 23 24 25 def IsStation(itemID): 26 return minStation <= itemID <= maxStation 27 28 29 def IsUniverseCelestial(itemID): 30 return minUniverseCelestial <= itemID <= maxUniverseCelestial 31 32 33 def IsDistrict(itemID): 34 return minDistrict <= itemID <= maxDistrict 35 36 37 def IsStargate(itemID): 38 return minStargate <= itemID <= maxStargate 39 40 41 def IsTrading(itemID): 42 return minTrading <= itemID <= maxTrading 43 44 45 def IsOfficeFolder(itemID): 46 return minOfficeFolder <= itemID <= maxOfficeFolder 47 48 49 def IsFactoryFolder(itemID): 50 return minFactoryFolder <= itemID <= maxFactoryFolder 51 52 53 def IsUniverseAsteroid(itemID): 54 return minUniverseAsteroid <= itemID <= maxUniverseAsteroid 55 56 57 def IsControlBunker(itemID): 58 return minControlBunker <= itemID <= maxControlBunker 59 60 61 def IsFakeItem(itemID): 62 return itemID > minFakeItem 63 64 65 def IsPlayerItem(itemID): 66 return minPlayerItem <= itemID < minFakeItem 67 68 69 def IsKnownSpaceSystem(itemID): 70 return mapKnownSpaceSystemMin <= itemID <= mapKnownSpaceSystemMax 71 72 73 def IsKnownSpaceConstellation(itemID): 74 return mapKnownSpaceConstellationMin <= itemID <= mapKnownSpaceConstellationMax 75 76 77 def IsKnownSpaceRegion(itemID): 78 return mapKnownSpaceRegionMin <= itemID <= mapKnownSpaceRegionMax 79 80 81 def IsWormholeSystem(itemID): 82 return mapWormholeSystemMin <= itemID <= mapWormholeSystemMax 83 84 85 def IsWormholeConstellation(itemID): 86 return mapWormholeConstellationMin <= itemID <= mapWormholeConstellationMax 87 88 89 def IsWormholeRegion(itemID): 90 return mapWormholeRegionMin <= itemID <= mapWormholeRegionMax 91 92 93 def IsZarzakh(itemID): 94 return itemID == solarSystemZarzakh 95 96 97 def IsAbyssalSpaceSystem(itemID): 98 return mapAbyssalSystemMin <= itemID <= mapAbyssalSystemMax 99 100 101 def IsAbyssalSpaceRegion(itemID): 102 return mapAbyssalRegionMin <= itemID <= mapAbyssalRegionMax 103 104 105 def IsVoidSpaceRegion(itemID): 106 return mapVoidRegionMin <= itemID <= mapVoidRegionMax 107 108 109 def IsStarterSpaceRegion(itemID): 110 return regionExordium == itemID 111 112 113 def IsStarterSpaceSystem(itemID): 114 region = cfg.mapSystemCache.get(itemID, None) 115 if not region: 116 return False 117 return IsStarterSpaceRegion(region.regionID) 118 119 120 def IsVoidSpaceConstellation(itemID): 121 return mapVoidConstellationMin <= itemID <= mapVoidConstellationMax 122 123 124 def IsVoidSpaceSystem(itemID): 125 return mapVoidSystemMin <= itemID <= mapVoidSystemMax 126 127 128 def IsHiddenSpaceSystem(itemID): 129 return mapHiddenSystemMin <= itemID <= mapHiddenSystemMax 130 131 132 def IsLocalIdentity(itemID): 133 return IsSystemOrNPC(itemID) 134 135 136 def IsTriglavianSystem(solarSystemID): 137 solarSystem = cfg.mapSystemCache.get(solarSystemID, None) 138 if solarSystem: 139 return getattr(solarSystem, 'factionID', None) == appConst.factionTriglavian 140 return False 141 142 143 def IsStationInTriglavianSystem(stationID): 144 if not IsStation(stationID): 145 return False 146 return IsTriglavianSystem(cfg.evelocations.Get(stationID).solarSystemID) 147 148 149 def IsJoveSystem(solarSystemID): 150 if solarSystemID: 151 region = cfg.mapSystemCache.get(solarSystemID, None).regionID 152 if region in (10000017, 10000019, 10000004): 153 return True 154 return False 155 156 157 def IsStationInJoveSystem(stationID): 158 if not IsStation(stationID): 159 return False 160 return IsJoveSystem(cfg.evelocations.Get(stationID).solarSystemID) 161 162 163 def IsNewbieSystem(solarsystemID): 164 default = [30002547, 165 30001392, 166 30002715, 167 30003489, 168 30005305, 169 30004971, 170 30001672, 171 30002505, 172 30000141, 173 30003410, 174 30005042, 175 30001407] 176 return solarsystemID in default 177 178 179 def IsCareerAgentSystem(solarsystemID): 180 return solarsystemID in (30013489, 30021672, 30045042, 30030141, 30011392, 30011407, 30014971, 30045305, 30042715, 30012547, 30012505, 30023410) 181 182 183 def IsCharacter(ownerID): 184 if ownerID is None: 185 return 0 186 if IsNPCCharacter(ownerID): 187 return 1 188 if IsEvePlayerCharacter(ownerID): 189 return 1 190 return 0 191 192 193 def IsBiomassedCorporation(corporationID): 194 return corporationID == appConst.corpDoomheim 195 196 197 class CharacterNotFoundError(Exception): 198 199 def __init__(self, characterID): 200 self.characterID = characterID 201 202 def __str__(self): 203 return 'Failed to find character with ID %s' % self.characterID 204 205 206 def RaiseIfNotACharacter(characterID): 207 if not IsCharacter(characterID): 208 raise CharacterNotFoundError(characterID) 209 210 211 def IsCorporation(ownerID): 212 if IsNPCCorporation(ownerID): 213 return 1 214 if IsPlayerCorporation(ownerID): 215 return 1 216 return 0 217 218 219 def IsAlliance(ownerID): 220 if minPlayerAlliance <= ownerID <= maxPlayerAlliance: 221 return 1 222 if minPreInv64Items <= ownerID <= maxPreInv64Items: 223 if boot.role == 'server' and sm.GetService('standingMgr').IsKnownToBeAPlayerCorp(ownerID): 224 return 0 225 try: 226 return cfg.eveowners.Get(ownerID).IsAlliance() 227 except KeyError: 228 return 0 229 230 return 0 231 232 233 def IsOwner(ownerID): 234 if IsFaction(ownerID): 235 return 1 236 if IsNPCCorporation(ownerID): 237 return 1 238 if IsNPCCharacter(ownerID): 239 return 1 240 if IsNPC(ownerID): 241 return 0 242 if IsEvePlayerCharacter(ownerID): 243 return 1 244 if IsPlayerCorporation(ownerID): 245 return 1 246 if IsAlliance(ownerID): 247 return 1 248 return 0 249 250 251 def IsNPC(ownerID): 252 return maxSystemItem < ownerID < minPlayerOwner 253 254 255 def IsSystem(ownerID): 256 return ownerID <= maxSystemItem 257 258 259 def IsNPCCharacter(ownerID): 260 return minAgent <= ownerID <= maxAgent 261 262 263 def IsSystemOrNPC(ownerID): 264 return ownerID < minPlayerOwner 265 266 267 def IsFaction(ownerID): 268 return minFaction <= ownerID < maxFaction 269 270 271 def IsEvePlayerCharacter(ownerID): 272 if minPlayerCharacterGen3 <= ownerID <= maxPlayerCharacterGen3: 273 return 1 274 if minPlayerCharacterGen2 <= ownerID <= maxPlayerCharacterGen2: 275 return 1 276 if minPreInv64Items <= ownerID <= maxPreInv64Items: 277 if boot.role == 'server' and sm.GetService('standingMgr').IsKnownToBeAPlayerCorp(ownerID): 278 return 0 279 try: 280 return cfg.eveowners.Get(ownerID).IsCharacter() 281 except KeyError: 282 return 0 283 284 return 0 285 286 287 def IsPlayerOwner(ownerID): 288 return minPlayerOwner <= ownerID <= maxPlayerOwner 289 290 291 def IsNPCCorporation(ownerID): 292 return minNPCCorporation <= ownerID <= maxNPCCorporation 293 294 295 def IsStarterNPCCorporation(ownerID): 296 return ownerID in (1000166, 1000165, 1000077, 1000167, 1000045, 1000044, 1000168, 1000115, 1000169, 1000170, 1000172, 1000171) 297 298 299 def IsPlayerCorporation(ownerID): 300 if minPlayerCorporation <= ownerID <= maxPlayerCorporation: 301 return 1 302 if minPreInv64Items <= ownerID <= maxPreInv64Items: 303 if boot.role == 'server' and sm.GetService('standingMgr').IsKnownToBeAPlayerCorp(ownerID): 304 return 1 305 try: 306 return cfg.eveowners.Get(ownerID).IsCorporation() 307 except KeyError: 308 return 0 309 310 return 0 311 312 313 def IsEveUser(userID): 314 return userID < minDustUser 315 316 317 def IsDustUser(userID): 318 return userID > minDustUser 319 320 321 def IsJunkLocation(locationID): 322 if locationID >= 2000: 323 return 0 324 elif locationID in (6, 8, 10, 23, 25): 325 return 1 326 elif 1000 < locationID < 2000: 327 return 1 328 elif locationID == doomheimStationID: 329 return 1 330 else: 331 return 0 332 333 334 def GetLootChanceByAreaOfspace(locationID): 335 if IsWormholeSystem(locationID): 336 return 0.9 337 if IsTriglavianSystem(locationID): 338 return 0.9 339 if is_zero_sec_solar_system(locationID): 340 return 0.9 341 if is_low_sec_solar_system(locationID): 342 return 0.9 343 return 0.5 344 345 346 def IsDustType(typeID): 347 return typeID > minDustTypeID 348 349 350 def IsOrbital(categoryID): 351 return categoryID == categoryOrbital 352 353 354 def IsStarbase(categoryID): 355 return categoryID == categoryStarbase 356 357 358 def IsShip(categoryID): 359 return categoryID == categoryShip 360 361 362 def IsShipType(typeID): 363 from evetypes import GetCategoryID 364 return IsShip(GetCategoryID(typeID)) 365 366 367 def IsDrone(categoryID): 368 return categoryID == categoryDrone 369 370 371 def IsDroneType(typeID): 372 from evetypes import GetCategoryID 373 return IsDrone(GetCategoryID(typeID)) 374 375 376 def IsFighter(categoryID): 377 return categoryID == categoryFighter 378 379 380 def IsFighterType(typeID): 381 from evetypes import GetCategoryID 382 return IsFighter(GetCategoryID(typeID)) 383 384 385 def IsDroneOrFighter(categoryID): 386 return categoryID in [categoryDrone, categoryFighter] 387 388 389 def IsDroneOrFighterType(typeID): 390 from evetypes import GetCategoryID 391 return IsDroneOrFighter(GetCategoryID(typeID)) 392 393 394 def IsLogisticDrone(typeID): 395 from evetypes import GetGroupID 396 return GetGroupID(typeID) == groupLogisticDrone 397 398 399 def IsSkinType(typeID): 400 from evetypes import GetCategoryID, Exists 401 if not Exists(typeID): 402 return False 403 return GetCategoryID(typeID) == categoryShipSkin 404 405 406 def IsStructure(categoryID): 407 return categoryID == categoryStructure 408 409 410 def IsStructureType(typeID): 411 from evetypes import GetCategoryID 412 return IsStructure(GetCategoryID(typeID)) 413 414 415 def IsWarpVectorType(typeID): 416 from evetypes import GetGroupID 417 return GetGroupID(typeID) == groupWarpVectorItems 418 419 420 def IsDockableStructure(typeID): 421 from evetypes import GetCategoryID 422 from structures.types import IsFlexStructure 423 return IsStructure(GetCategoryID(typeID)) and not IsFlexStructure(typeID) 424 425 426 def IsDockableLocationType(typeID): 427 from evetypes import GetGroupID, GetCategoryID 428 from structures.types import IsFlexStructure 429 if GetGroupID(typeID) == groupStation: 430 return True 431 if GetCategoryID(typeID) == categoryStructure: 432 if IsFlexStructure(typeID): 433 return False 434 return True 435 return False 436 437 438 def IsDeprecatedStation(stationTypeID): 439 return stationTypeID in [typeCaldariResearchOutpost, 440 typeAmarrFactoryOutpost, 441 typeGallenteAdministrativeOutpost, 442 typeMinmatarServiceOutpost, 443 typeStationConquerableOne, 444 typeStationConquerableTwo, 445 typeStationConquerableThree] 446 447 448 def IsCharge(categoryID): 449 return categoryID in [categoryCharge, groupFrequencyCrystal] 450 451 452 def IsChargeType(typeID): 453 from evetypes import GetCategoryID 454 return IsCharge(GetCategoryID(typeID)) 455 456 457 def IsModule(categoryID): 458 return categoryID == categoryModule 459 460 461 def IsModuleType(typeID): 462 from evetypes import GetCategoryID 463 return IsModule(GetCategoryID(typeID)) 464 465 466 def IsCapsule(groupID): 467 return groupID == groupCapsule 468 469 470 def IsNormalCapsule(typeID): 471 return typeID == typeCapsule 472 473 474 def IsGoldenCapsule(typeID): 475 return typeID == typeCapsuleGolden 476 477 478 def IsNewbieShip(groupID): 479 return groupID == groupCorvette 480 481 482 def IsPlex(typeID): 483 return typeID == typePlex 484 485 486 def IsSkyhook(typeID): 487 return typeID == typeSkyhook 488 489 490 def IsAutoMoonMiner(typeID): 491 return typeID == typeUpwellAutoMoonMiner 492 493 494 def IsMercenaryDen(groupID): 495 return groupID == groupMercenaryDen 496 497 498 def IsAssembledShip(categoryID, singleton): 499 return singleton and categoryID == categoryShip 500 501 502 def IsALSCActionAssemble(id): 503 return id == ALSCActionAssemble 504 505 506 def IsALSCActionRepackage(id): 507 return id == ALSCActionRepackage 508 509 510 def IsALSCActionSetName(id): 511 return id == ALSCActionSetName 512 513 514 def IsALSCActionMove(id): 515 return id == ALSCActionMove 516 517 518 def IsALSCActionSetPassword(id): 519 return id == ALSCActionSetPassword 520 521 522 def IsALSCActionAdd(id): 523 return id == ALSCActionAdd 524 525 526 def IsALSCActionLock(id): 527 return id == ALSCActionLock 528 529 530 def IsALSCActionUnlock(id): 531 return id == ALSCActionUnlock 532 533 534 def IsALSCActionEnterPassword(id): 535 return id == ALSCActionEnterPassword 536 537 538 def IsALSCActionConfigure(id): 539 return id == ALSCActionConfigure 540 541 542 def IsLocationCharacterGraveyard(id): 543 return id == locationCharacterGraveyard 544 545 546 def IsLocationCorporationGraveyard(id): 547 return id == locationCorporationGraveyard 548 549 550 def IsLocationStructureGraveyard(id): 551 return id == locationStructureGraveyard 552 553 554 def IsAssetSafetyWrap(item): 555 return item.typeID == typeAssetSafetyWrap 556 557 558 def IsSkinDesignComponent(groupID): 559 return groupID == groupShipSkinDesignComponents 560 561 562 def IsSequenceBinder(groupID): 563 return groupID == groupSequenceBinders 564 565 566 def IsWreck(groupID): 567 return groupID == groupWreck