Ejemplo n.º 1
0
    def __bpfDecoder(cls, blueprintData):
        if blueprintData is None:
            return
        else:
            vehicleFragments = {}
            nationalFragments = {}
            intelligenceData = defaultdict(int)
            for fragmentCD, count in blueprintData.iteritems():
                fragmentType = getFragmentType(fragmentCD)
                if fragmentType == BlueprintTypes.VEHICLE:
                    vehicleCD = getVehicleCD(fragmentCD)
                    layout = Layout.fromInt(count)
                    vehicleFragments[vehicleCD] = layout
                if fragmentType == BlueprintTypes.NATIONAL:
                    vehicleCD = getVehicleCDForNational(fragmentCD)
                    nationID = getFragmentNationID(fragmentCD)
                    if nationID in nationalFragments:
                        nationalFragments[nationID].update({vehicleCD: count})
                    else:
                        nationalFragments[nationID] = {vehicleCD: count}
                if fragmentType == BlueprintTypes.INTELLIGENCE_DATA:
                    vehicleCD = getVehicleCDForIntelligence(fragmentCD)
                    intelligenceData[vehicleCD] += count

            return (vehicleFragments, nationalFragments, intelligenceData)
Ejemplo n.º 2
0
 def __proccesRawBlueprints(self, blueprintsRaw):
     for blueprintCD in blueprintsRaw:
         fragmentType = getFragmentType(blueprintCD)
         if fragmentType == BlueprintTypes.INTELLIGENCE_DATA:
             self.__universalBlueprints += blueprintsRaw[blueprintCD]
         if fragmentType == BlueprintTypes.NATIONAL:
             nationID = getFragmentNationID(blueprintCD)
             nationName = nations.MAP.get(nationID, nations.NONE_INDEX)
             self.__nationalBlueprints[nationName] += blueprintsRaw[
                 blueprintCD]
Ejemplo n.º 3
0
 def getTypeAndNation(self, fragmentCD=None):
     if fragmentCD is None and self.__blueprintCD is None:
         return
     else:
         fragmentCD = self.__blueprintCD if fragmentCD is None else fragmentCD
         fragmentType = getFragmentType(fragmentCD)
         nation = nations.NAMES[getFragmentNationID(
             fragmentCD
         )] if fragmentType == BlueprintTypes.NATIONAL else None
         return (fragmentType, nation)
Ejemplo n.º 4
0
def _blueprintResourceFactory(resourceType, resources):
    result = []
    for resource in resources:
        fragmentCD = int(resource.name)
        fragmentType = getFragmentType(fragmentCD)
        if fragmentType == BlueprintTypes.INTELLIGENCE_DATA:
            result.append(IntelligenceBlueprintResource(fragmentCD, resource.rate, resource.limit, resourceType))
        if fragmentType == BlueprintTypes.NATIONAL:
            result.append(NationalBlueprintResource(fragmentCD, resource.rate, resource.limit, resourceType))

    return result
Ejemplo n.º 5
0
 def getFragmentData(self, fragmentCD=None):
     if fragmentCD is None and self.__blueprintCD is None:
         return
     else:
         fragmentCD = self.__blueprintCD if fragmentCD is None else fragmentCD
         fragmentType = getFragmentType(fragmentCD)
         nation = None
         alliance = None
         if fragmentType in (BlueprintTypes.NATIONAL, BlueprintTypes.VEHICLE):
             nation = nations.NAMES[getFragmentNationID(fragmentCD)]
             alliance = nations.ALLIANCES_TAGS_ORDER[nations.NATION_TO_ALLIANCE_IDS_MAP[nations.INDICES[nation]]]
         return (fragmentType, nation, alliance)
Ejemplo n.º 6
0
def getUniqueBlueprints(blueprints, isFullNationCD=False):
    vehicleFragments = defaultdict(int)
    nationalFragments = defaultdict(int)
    intelligenceData = 0
    for fragmentCD, count in blueprints.iteritems():
        fragmentType = getFragmentType(fragmentCD)
        if fragmentType == BlueprintTypes.VEHICLE:
            vehicleFragments[getVehicleCD(fragmentCD)] += count
        if fragmentType == BlueprintTypes.NATIONAL:
            nationID = fragmentCD & 255 if isFullNationCD else getFragmentNationID(
                fragmentCD)
            nationalFragments[nationID] += count
        if fragmentType == BlueprintTypes.INTELLIGENCE_DATA:
            intelligenceData += count

    return (vehicleFragments, nationalFragments, intelligenceData)
Ejemplo n.º 7
0
def blueprintsOfferBonusFactory(name, value, isCompensation=False, ctx=None):
    blueprintBonuses = []
    for fragmentCD, fragmentCount in sorted(value.iteritems(),
                                            key=itemgetter(0)):
        fragmentType = getFragmentType(fragmentCD)
        if fragmentType == BlueprintTypes.VEHICLE:
            blueprintBonuses.append(
                VehicleBlueprintOfferBonus(name, (fragmentCD, fragmentCount),
                                           isCompensation, ctx))
        if fragmentType == BlueprintTypes.INTELLIGENCE_DATA:
            vehicleCD = getVehicleCDForIntelligence(fragmentCD)
            blueprintBonuses.append(
                IntelligenceBlueprintOfferBonus(name,
                                                (vehicleCD, fragmentCount),
                                                isCompensation, ctx))
        if fragmentType == BlueprintTypes.NATIONAL:
            vehicleCD = getVehicleCDForNational(fragmentCD)
            blueprintBonuses.append(
                NationalBlueprintOfferBonus(name, (vehicleCD, fragmentCount),
                                            isCompensation, ctx))

    return blueprintBonuses