MCPcopy Index your code
hub / github.com/pyfa-org/Pyfa / getTestSet

Method getTestSet

service/port/efs.py:476–558  ·  view source on GitHub ↗
(setType)

Source from the content-addressed store, hash-verified

474
475 @staticmethod
476 def getTestSet(setType):
477 def getT2ItemsWhere(additionalFilter, mustBeOffensive=False, category="Module"):
478 # Used to obtain a smaller subset of items while still containing examples of each group.
479 T2_META_LEVEL = 5
480 categoryID = getCategory(category).categoryID
481 result = gamedata_session.query(Item).join(ItemEffect, Group, Attribute).\
482 filter(
483 additionalFilter,
484 Item.metaLevel == T2_META_LEVEL,
485 Group.categoryID == categoryID,
486 ).all()
487 if mustBeOffensive:
488 result = filter(lambda t: t.offensive is True, result)
489 return list(result)
490
491 def getChargeType(item, setType):
492 if setType == "turret":
493 return str(item.attributes["chargeGroup1"].value) + "-" + str(item.attributes["chargeSize"].value)
494 return str(item.attributes["chargeGroup1"].value)
495
496 if setType in EfsPort.wepTestSet.keys():
497 return EfsPort.wepTestSet[setType]
498 else:
499 EfsPort.wepTestSet[setType] = []
500 modSet = EfsPort.wepTestSet[setType]
501
502 if setType == "drone":
503 ilist = getT2ItemsWhere(True, True, "Drone")
504 for item in ilist:
505 drone = Drone(item)
506 drone.amount = 1
507 drone.amountActive = 1
508 drone.itemModifiedAttributes.parent = drone
509 modSet.append(drone)
510 return modSet
511
512 turretFittedEffectID = gamedata_session.query(Effect).filter(Effect.name == "turretFitted").first().effectID
513 launcherFittedEffectID = gamedata_session.query(Effect).filter(Effect.name == "launcherFitted").first().effectID
514 if setType == "launcher":
515 effectFilter = ItemEffect.effectID == launcherFittedEffectID
516 reqOff = False
517 else:
518 effectFilter = ItemEffect.effectID == turretFittedEffectID
519 reqOff = True
520 ilist = getT2ItemsWhere(effectFilter, reqOff)
521 previousChargeTypes = []
522 # Get modules from item list
523 for item in ilist:
524 chargeType = getChargeType(item, setType)
525 # Only add turrets if we don"t already have one with the same size and ammo type.
526 if setType == "launcher" or chargeType not in previousChargeTypes:
527 previousChargeTypes.append(chargeType)
528 mod = Module(item)
529 modSet.append(mod)
530
531 sMkt = Market.getInstance()
532 # Due to typed missile damage bonuses we"ll need to add extra launchers to cover all four types.
533 additionalLaunchers = []

Callers 1

Calls 7

DroneClass · 0.90
ModuleClass · 0.90
getVariationsByItemsMethod · 0.80
keysMethod · 0.45
appendMethod · 0.45
getInstanceMethod · 0.45
getModifiedItemAttrMethod · 0.45

Tested by

no test coverage detected