当前位置: 首页>>代码示例>>Python>>正文


Python Module.isValidCharge方法代码示例

本文整理汇总了Python中eos.saveddata.module.Module.isValidCharge方法的典型用法代码示例。如果您正苦于以下问题:Python Module.isValidCharge方法的具体用法?Python Module.isValidCharge怎么用?Python Module.isValidCharge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eos.saveddata.module.Module的用法示例。


在下文中一共展示了Module.isValidCharge方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __makeModule

# 需要导入模块: from eos.saveddata.module import Module [as 别名]
# 或者: from eos.saveddata.module.Module import isValidCharge [as 别名]
    def __makeModule(self, itemSpec):
        # Mutate item if needed
        m = None
        if itemSpec.mutationIdx in self.mutations:
            mutaItem, mutaAttrs = self.mutations[itemSpec.mutationIdx]
            mutaplasmid = getDynamicItem(mutaItem.ID)
            if mutaplasmid:
                try:
                    m = Module(mutaplasmid.resultingItem, itemSpec.item, mutaplasmid)
                except ValueError:
                    pass
                else:
                    for attrID, mutator in m.mutators.items():
                        if attrID in mutaAttrs:
                            mutator.value = mutaAttrs[attrID]
        # If we still don't have item (item is not mutated or we
        # failed to construct mutated item), try to make regular item
        if m is None:
            try:
                m = Module(itemSpec.item)
            except ValueError:
                return None

        if itemSpec.charge is not None and m.isValidCharge(itemSpec.charge):
            m.charge = itemSpec.charge
        if itemSpec.offline and m.isValidState(FittingModuleState.OFFLINE):
            m.state = FittingModuleState.OFFLINE
        elif m.isValidState(FittingModuleState.ACTIVE):
            m.state = activeStateLimit(m.item)
        return m
开发者ID:,项目名称:,代码行数:32,代码来源:

示例2: FitReplaceModuleCommand

# 需要导入模块: from eos.saveddata.module import Module [as 别名]
# 或者: from eos.saveddata.module.Module import isValidCharge [as 别名]
class FitReplaceModuleCommand(wx.Command):
    """"
    Fitting command that changes an existing module into another.

    from sFit.changeModule
    """
    def __init__(self, fitID, position, itemID):
        wx.Command.__init__(self, True, "Change Module")
        self.fitID = fitID
        self.itemID = itemID
        self.position = position
        self.module = None  # the module version of itemID
        self.old_module = None

    def Do(self):
        fit = eos.db.getFit(self.fitID)

        mod = fit.modules[self.position]
        if not mod.isEmpty:
            self.old_module = ModuleInfoCache(mod.modPosition, mod.item.ID, mod.state, mod.charge, mod.baseItemID,
                                              mod.mutaplasmidID)

        return self.change_module(self.fitID, self.position, self.itemID)

    def Undo(self):
        if self.old_module is None:
            fit = eos.db.getFit(self.fitID)
            fit.modules.toDummy(self.position)
            return True
        self.change_module(self.fitID, self.position, self.old_module.itemID)
        self.module.state = self.old_module.state
        self.module.charge = self.old_module.charge
        return True

    def change_module(self, fitID, position, itemID):
        fit = eos.db.getFit(fitID)

        # We're trying to add a charge to a slot, which won't work. Instead, try to add the charge to the module in that slot.
        # todo: evaluate if this is still a thing
        # actually, this seems like it should be handled higher up...
        #
        # if self.isAmmo(itemID):
        #     module = fit.modules[self.position]
        #     if not module.isEmpty:
        #         self.setAmmo(fitID, itemID, [module])
        #     return True

        pyfalog.debug("Changing position of module from position ({0}) for fit ID: {1}", self.position, fitID)

        item = eos.db.getItem(itemID, eager=("attributes", "group.category"))
        mod = fit.modules[self.position]

        try:
            self.module = Module(item)
        except ValueError:
            pyfalog.warning("Invalid item: {0}", itemID)
            return False

        if self.module.slot != mod.slot:
            return False

        # Dummy it out in case the next bit fails
        fit.modules.toDummy(self.position)

        if self.module.fits(fit):
            self.module.owner = fit
            fit.modules.toModule(self.position, self.module)
            if self.module.isValidState(State.ACTIVE):
                self.module.state = State.ACTIVE

            if self.old_module and self.old_module.charge and self.module.isValidCharge(self.old_module.charge):
                self.module.charge = self.old_module.charge

            # Then, check states of all modules and change where needed. This will recalc if needed
            # self.checkStates(fit, m)

            # fit.fill()
            eos.db.commit()
            return True
        return False
开发者ID:bsmr-eve,项目名称:Pyfa,代码行数:82,代码来源:fitReplaceModule.py


注:本文中的eos.saveddata.module.Module.isValidCharge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。