コード例 #1
0
 def GetOutputVolumePerHour(self):
     cycleTime = self.GetCycleTime()
     if not self.IsProducer() or not cycleTime:
         return 0.0
     volumePerCycle = planetCommon.GetCommodityTotalVolume(self.GetProducts())
     volumePerHour = planetCommon.GetBandwidth(volumePerCycle, cycleTime)
     return volumePerHour
コード例 #2
0
def GetSchematicData(processorTypeID):
    schematicsData = cfg.schematicsByPin[processorTypeID]
    if len(schematicsData) == 0:
        log.LogTraceback(
            'Authoring error: No schematics found for processor pin with typeID %s'
            % processorTypeID)
    schematics = []
    for s in schematicsData:
        try:
            schematic = cfg.schematics.Get(s.schematicID)
        except:
            log.LogTraceback('Authoring error: No schematic found with id=%s' %
                             s.schematicID)
            raise

        inputs, outputs = _GetSchematicInputsAndOutputs(schematic.schematicID)
        outputsDict = {}
        for o in outputs:
            outputsDict[o.typeID] = o.quantity

        volumePerCycle = planetCommon.GetCommodityTotalVolume(outputsDict)
        volumePerHour = planetCommon.GetBandwidth(
            volumePerCycle, schematic.cycleTime * const.SEC)
        sData = util.KeyVal(name=schematic.schematicName,
                            schematicID=schematic.schematicID,
                            cycleTime=schematic.cycleTime,
                            outputs=outputs,
                            inputs=inputs,
                            outputVolume=volumePerHour)
        schematics.append((sData.name, sData))

    return uiutil.SortListOfTuples(schematics)
コード例 #3
0
 def CanImportCommodities(self, commodities):
     """
         Commodities is a dict of typeID:qty pairs.
         Returns true or false.
     """
     volume = planetCommon.GetCommodityTotalVolume(commodities)
     if self.capacityUsed + volume > self.GetCapacity():
         return False
     return True
コード例 #4
0
    def _ApplyMaxAmountFilter(self, toMove):
        availableVolume = self.destPin.GetCapacity(
        ) - self.destPin.capacityUsed
        availableVolume -= planetCommon.GetCommodityTotalVolume(
            self.transferContents)
        transferVolume = planetCommon.GetCommodityTotalVolume(toMove)
        if transferVolume >= availableVolume:
            newToMove = {}
            if len(toMove) == 1:
                for typeID, quantity in toMove.iteritems():
                    commodityVolume = evetypes.GetVolume(typeID)
                    maxAmount = int(
                        math.floor(availableVolume / commodityVolume))
                    newToMove[typeID] = maxAmount

            eve.Message('ExpeditedTransferNotEnoughSpace')
            return newToMove
        else:
            return toMove
コード例 #5
0
    def _ApplyMaxAmountFilter(self, toMove):
        """
        Make sure that there is enough space at destination before moving stuff to the
        transfer list. If we are only moving one commodity, we move as much as we can.
        If we are moving more than one commodity, we move nothing.
        """
        availableVolume = self.destPin.GetCapacity() - self.destPin.capacityUsed
        availableVolume -= planetCommon.GetCommodityTotalVolume(self.transferContents)
        transferVolume = planetCommon.GetCommodityTotalVolume(toMove)
        if transferVolume >= availableVolume:
            newToMove = {}
            if len(toMove) == 1:
                for typeID, quantity in toMove.iteritems():
                    commodityVolume = cfg.invtypes.Get(typeID).volume
                    maxAmount = int(math.floor(availableVolume / commodityVolume))
                    newToMove[typeID] = maxAmount

            eve.Message('ExpeditedTransferNotEnoughSpace')
            return newToMove
        else:
            return toMove
コード例 #6
0
ファイル: BasePinContainer.py プロジェクト: connoryang/1v1dec
    def OnRouteAmountEditChanged(self, newVal):
        try:
            routeAmount = int(newVal)
        except ValueError:
            return

        if not self.currRouteCycleTime:
            return
        routeAmount = min(routeAmount, self.routeMaxAmount)
        routeAmount = max(routeAmount, 0.0)
        volume = planetCommon.GetCommodityTotalVolume(
            {self.commodityToRoute: routeAmount})
        volumePerHour = planetCommon.GetBandwidth(volume,
                                                  self.currRouteCycleTime)
        sm.GetService('planetUI').myPinManager.OnRouteVolumeChanged(
            volumePerHour)
コード例 #7
0
    def RefreshLists(self, *args):
        pinListItems = []
        for typeID, qty in self.pinContents.iteritems():
            lbl = '<t>%s<t>%d' % (evetypes.GetName(typeID), qty)
            data = util.KeyVal(itemID=None,
                               typeID=typeID,
                               label=lbl,
                               getIcon=1,
                               quantity=qty,
                               OnDropData=self.OnSourceScrollDropData)
            pinListItems.append(listentry.Get('DraggableItem', data=data))

        transferListItems = []
        for typeID, qty in self.transferContents.iteritems():
            lbl = '<t>%s<t>%d' % (evetypes.GetName(typeID), qty)
            data = util.KeyVal(itemID=None,
                               typeID=typeID,
                               label=lbl,
                               getIcon=1,
                               quantity=qty,
                               OnDropData=self.OnTransferScrollDropData)
            transferListItems.append(listentry.Get('DraggableItem', data=data))

        self.sr.sourcePinListScroll.Load(
            contentList=pinListItems,
            noContentHint=localization.GetByLabel(
                'UI/PI/Common/StorehouseIsEmpty'),
            headers=[
                localization.GetByLabel('UI/Common/Type'),
                localization.GetByLabel('UI/Common/Name'),
                localization.GetByLabel('UI/Common/Quantity')
            ])
        self.sr.transferListScroll.Load(
            contentList=transferListItems,
            noContentHint=localization.GetByLabel('UI/PI/Common/NoItemsFound'),
            headers=[
                localization.GetByLabel('UI/Common/Type'),
                localization.GetByLabel('UI/Common/Name'),
                localization.GetByLabel('UI/Common/Quantity')
            ])
        transferVolume = planetCommon.GetCommodityTotalVolume(
            self.transferContents)
        self.sr.volumeText.text = localization.GetByLabel(
            'UI/PI/Common/VolumeAmount', amount=transferVolume)
        self.SetNextTransferText()
        self.SetCooldownTimeText()
コード例 #8
0
def GetSchematicData(processorTypeID):
    """
    Returns an alphabetically sorted list of all schematics that the specified processor pin type can produce
    RETURN: a list of util.KeyVal(
        name [string]
        schematicID [int]
        cycleTime [int] (in seconds)
        outputs [list of util.KeyVal(name, typeID, quantity)]
        inputs [list of util.KeyVal(name, typeID, quantity)]
    ) 
    """
    schematicsData = cfg.schematicsByPin[processorTypeID]
    if len(schematicsData) == 0:
        log.LogTraceback(
            'Authoring error: No schematics found for processor pin with typeID %s'
            % processorTypeID)
    schematics = []
    for s in schematicsData:
        try:
            schematic = cfg.schematics.Get(s.schematicID)
        except:
            log.LogTraceback('Authoring error: No schematic found with id=%s' %
                             s.schematicID)
            raise

        inputs, outputs = _GetSchematicInputsAndOutputs(schematic.schematicID)
        outputsDict = {}
        for o in outputs:
            outputsDict[o.typeID] = o.quantity

        volumePerCycle = planetCommon.GetCommodityTotalVolume(outputsDict)
        volumePerHour = planetCommon.GetBandwidth(
            volumePerCycle, schematic.cycleTime * const.SEC)
        sData = util.KeyVal(name=schematic.schematicName,
                            schematicID=schematic.schematicID,
                            cycleTime=schematic.cycleTime,
                            outputs=outputs,
                            inputs=inputs,
                            outputVolume=volumePerHour)
        schematics.append((sData.name, sData))

    return uiutil.SortListOfTuples(schematics)
コード例 #9
0
ファイル: spaceportPin.py プロジェクト: connoryang/1v1dec
 def CanImportCommodities(self, commodities):
     volume = planetCommon.GetCommodityTotalVolume(commodities)
     if self.capacityUsed + volume > self.GetCapacity():
         return False
     return True