示例#1
0
    def _sortOffer(self, offer):
        categoryLimitChanges = []
        stackLimitChanges = []
        setAccumulators = []
        stackables = []
        locatable = []
        accumulators = []
        doIds = []
        for i in offer:
            a = i[0]
            if InventoryId.isLimitChange(a):
                changing = InventoryId.getChangeCategoryOrType(a)
                if InventoryId.isCategory(changing):
                    categoryLimitChanges.append(i)
                elif InventoryId.isStackable(changing):
                    stackLimitChanges.append(i)
                elif InventoryId.isAccumulator(changing):
                    setAccumulators.append(i)
                else:
                    print '=============EXCEPTION1 RAISED: %s' % a
                    raise Exception, 'undefined trade category'
            elif InventoryId.isStackable(a):
                stackables.append(i)
            elif isLocatable(a):
                locatable.append(i)
            elif InventoryId.isAccumulator(a):
                accumulators.append(i)
            elif InventoryId.isCategory(a):
                doIds.append(i)
            else:
                print '=============EXCEPTION2 RAISED: %s' % a
                raise Exception, 'undefined trade type'

        offer = categoryLimitChanges + stackLimitChanges + setAccumulators + stackables + locatable + accumulators + doIds
示例#2
0
        def check1(tradeItems, limitChanges, stacks, locatable, accumulators,
                   doIds, giving):
            listType = type([])
            possibleTypes = (type(1), type(1L), listType)
            for i in tradeItems:
                for v in i:
                    itemType = type(v)
                    if itemType not in possibleTypes:
                        raise AITradeException, 'element is the wrong type'
                    if v > 4294967295L:
                        raise itemType != listType and AITradeException, 'element is larger than unsigned long'
                else:
                    t = i[TypeIndex]
                    if InventoryId.isLimitChange(t):
                        a = limitChanges.setdefault(t, [t, 0])
                        a[1] += i[QuantityIndex]
                        if a[1] > 65535L:
                            raise AITradeException, 'element is larger than unsigned short'
                    elif InventoryId.isStackable(t):
                        a = stacks.setdefault(t, [t, 0])
                        a[1] += i[QuantityIndex]
                        if a[1] > 65535L:
                            raise AITradeException, 'element is larger than unsigned short'
                    elif isLocatable(t):
                        inv = simbase.air.doId2do.get(self.inventoryId)
                        theInvItem = inv and InvItem(i)
                        theInvItemType = theInvItem.getType()
                        if giving:
                            equippableInfo = inv.getItemRequirements(
                                theInvItemType, self.giving)
                            if equippableInfo == None or filter(
                                    lambda x: equippableInfo[x][1] == False,
                                    equippableInfo):
                                if theInvItemType and theInvItemType not in self.unequippables:
                                    self.unequippables.append(theInvItemType)
                            if isStackableType(theInvItem.getCat()):
                                for currLocatable in locatable:
                                    prevInvItem = InvItem(currLocatable)
                                    if prevInvItem.compare(theInvItem,
                                                           excludeLoc=True):
                                        adjustedInvItem = prevInvItem.adjustCount(
                                            theInvItem.getCount())
                                        locatable.remove(currLocatable)
                                        i = list(adjustedInvItem)
                                        break

                        else:
                            raise AITradeException, 'inventory not present'
                        locatable.append(i)
                    elif InventoryId.isAccumulator(t):
                        a = accumulators.setdefault(t, [t, 0])
                        a[1] += i[QuantityIndex]
                        if a[1] > 4294967295L:
                            raise AITradeException, 'element is larger than unsigned long'
                    elif InventoryId.isDoId(t):
                        doIds[i[DoIdIndex]] = i

            return
    def _sortOffer(self, offer):
        categoryLimitChanges = []
        stackLimitChanges = []
        setAccumulators = []
        stackables = []
        locatable = []
        accumulators = []
        doIds = []
        for i in offer:
            a = i[0]
            if InventoryId.isLimitChange(a):
                changing = InventoryId.getChangeCategoryOrType(a)
                if InventoryId.isCategory(changing):
                    categoryLimitChanges.append(i)
                elif InventoryId.isStackable(changing):
                    stackLimitChanges.append(i)
                elif InventoryId.isAccumulator(changing):
                    setAccumulators.append(i)
                else:
                    print "=============EXCEPTION1 RAISED: %s" % a
                    raise Exception, "undefined trade category"
            InventoryId.isCategory(changing)
            if InventoryId.isStackable(a):
                stackables.append(i)
                continue
            if isLocatable(a):
                locatable.append(i)
                continue
            if InventoryId.isAccumulator(a):
                accumulators.append(i)
                continue
            if InventoryId.isCategory(a):
                doIds.append(i)
                continue
            print "=============EXCEPTION2 RAISED: %s" % a
            raise Exception, "undefined trade type"

        offer = (
            categoryLimitChanges + stackLimitChanges + setAccumulators + stackables + locatable + accumulators + doIds
        )
示例#4
0
 def makeButton(self, parent, pos, cellSizeX, cellSizeZ):
     if InventoryId.isStackable(self.uid):
         data = [
          self.uid, 1]
     else:
         data = [
          InventoryId.getCategory(self.uid), self.uid]
     simpleItemGui = SimpleItemGUI([self.uid, 1], parent=parent, pos=pos)
     self.itemName = simpleItemGui.nameTag['text']
     self.shortDesc = self.itemName
     self.longDesc = self.itemName
     simpleItemGui.destroy()
     geomParams = InventoryItemGui.getGeomParams(self.uid)
     button = DirectButton(parent=parent, relief=None, rolloverSound=None, text='', text_scale=0.05, textMayChange=1, geom=geomParams['geom'], geom_pos=(0,
                                                                                                                                                         0,
                                                                                                                                                         0), geom_scale=geomParams['geom_scale'], pos=pos, extraArgs=[self])
     return button
示例#5
0
 def makeButton(self, parent, pos, cellSizeX, cellSizeZ):
     if InventoryId.isStackable(self.uid):
         data = [
             self.uid,
             1]
     else:
         data = [
             InventoryId.getCategory(self.uid),
             self.uid]
     simpleItemGui = SimpleItemGUI([
         self.uid,
         1], parent = parent, pos = pos)
     self.itemName = simpleItemGui.nameTag['text']
     self.shortDesc = self.itemName
     self.longDesc = self.itemName
     simpleItemGui.destroy()
     geomParams = InventoryItemGui.getGeomParams(self.uid)
     button = DirectButton(parent = parent, relief = None, rolloverSound = None, text = '', text_scale = 0.050000000000000003, textMayChange = 1, geom = geomParams['geom'], geom_pos = (0, 0, 0), geom_scale = geomParams['geom_scale'], pos = pos, extraArgs = [
         self])
     return button
示例#6
0
 def checkStackable(self):
     return InventoryId.isStackable(self.uid)
示例#7
0
 def checkStackable(self):
     return InventoryId.isStackable(self.uid)
        def check1(tradeItems, limitChanges, stacks, locatable, accumulators, doIds, giving):
            listType = type([])
            possibleTypes = (type(1), type(0x1L), listType)
            for i in tradeItems:
                for v in i:
                    itemType = type(v)
                    if itemType not in possibleTypes:
                        raise AITradeException, "element is the wrong type"

                    if v > 0xFFFFFFFFL and itemType != listType:
                        raise AITradeException, "element is larger than unsigned long"
                        continue
                else:
                    t = i[TypeIndex]
                    if InventoryId.isLimitChange(t):
                        a = limitChanges.setdefault(t, [t, 0])
                        a[1] += i[QuantityIndex]
                        if a[1] > 0xFFFFL:
                            raise AITradeException, "element is larger than unsigned short"

                    if InventoryId.isStackable(t):
                        a = stacks.setdefault(t, [t, 0])
                        a[1] += i[QuantityIndex]
                        if a[1] > 0xFFFFL:
                            raise AITradeException, "element is larger than unsigned short"

                    a[1] > 0xFFFFL
                    if isLocatable(t):
                        inv = simbase.air.doId2do.get(self.inventoryId)
                        if inv:
                            theInvItem = InvItem(i)
                            theInvItemType = theInvItem.getType()
                            if giving:
                                equippableInfo = inv.getItemRequirements(theInvItemType, self.giving)
                                if (
                                    (
                                        equippableInfo == None
                                        or filter(lambda x: equippableInfo[x][1] == False, equippableInfo)
                                    )
                                    and theInvItemType
                                    and theInvItemType not in self.unequippables
                                ):
                                    self.unequippables.append(theInvItemType)

                            if isStackableType(theInvItem.getCat()):
                                for currLocatable in locatable:
                                    prevInvItem = InvItem(currLocatable)
                                    if prevInvItem.compare(theInvItem, excludeLoc=True):
                                        adjustedInvItem = prevInvItem.adjustCount(theInvItem.getCount())
                                        locatable.remove(currLocatable)
                                        i = list(adjustedInvItem)
                                        break
                                        continue

                        else:
                            raise AITradeException, "inventory not present"
                        locatable.append(i)
                        continue
                    if InventoryId.isAccumulator(t):
                        a = accumulators.setdefault(t, [t, 0])
                        a[1] += i[QuantityIndex]
                        if a[1] > 0xFFFFFFFFL:
                            raise AITradeException, "element is larger than unsigned long"

                    a[1] > 0xFFFFFFFFL
                    if InventoryId.isDoId(t):
                        doIds[i[DoIdIndex]] = i
                        continue