def AcceptInputPrice(self):

        if not self.priceInputBoard:
            return True

        text = self.priceInputBoard.GetText()

        if not text:
            return True

        if not text.isdigit():
            return True

        if int(text) <= 0:
            return True

        attachedInvenType = self.priceInputBoard.sourceWindowType
        sourceSlotPos = self.priceInputBoard.sourceSlotPos
        targetSlotPos = self.priceInputBoard.targetSlotPos

        for privatePos, (itemWindowType,
                         itemSlotIndex) in self.itemStock.items():
            if itemWindowType == attachedInvenType and itemSlotIndex == sourceSlotPos:
                shop.DelPrivateShopItemStock(itemWindowType, itemSlotIndex)
                del self.itemStock[privatePos]

        price = int(self.priceInputBoard.GetText())

        if IsPrivateShopItemPriceList():
            SetPrivateShopItemPrice(self.priceInputBoard.itemVNum, price)

        shop.AddPrivateShopItemStock(attachedInvenType, sourceSlotPos,
                                     targetSlotPos, price)
        count = player.GetItemCount(attachedInvenType, sourceSlotPos)
        vnum = player.GetItemIndex(attachedInvenType, sourceSlotPos)
        self.SaveFilePrice(vnum, count, price)
        self.itemStock[targetSlotPos] = (attachedInvenType, sourceSlotPos)
        snd.PlaySound("sound/ui/drop.wav")

        self.Refresh()

        #####

        self.priceInputBoard = None
        return True
Exemple #2
0
    def SetItemPrice(self, slot):
        _id = player.GetItemIndex(slot)
        if _id == 0:
            return

        str_price = self.items_ui[_id]['item_price'].GetText()

        if self.MultiplicationButton.isOn:
            won, yang = OpenLib.ConvertPrice(str_price,
                                             player.GetItemCount(slot))
        else:
            won, yang = OpenLib.ConvertPrice(str_price, 1)

        #Ignore items with price at 0
        if won + yang <= 0.9:
            return

        shop.AddPrivateShopItemStock(player.SLOT_TYPE_INVENTORY, slot, slot,
                                     yang, won)
Exemple #3
0
    def AcceptInputPrice(self):

        if not self.priceInputBoard:
            return True

        if app.ENABLE_OFFLINE_SHOP:
            if self.type:
                text = self.priceInputBoard.GetTextPrice1()
                textpricetwo = self.priceInputBoard.GetTextPrice2()
                textpricethree = self.priceInputBoard.GetTextPrice3()
                textpricefour = self.priceInputBoard.GetTextPrice4()
            else:
                text = self.priceInputBoard.GetText()

            if not text:
                self.PopupMsg("Please input price values")
                return True

            if not text.isdigit():
                self.PopupMsg("Please input only number to prices")
                return True
            if self.type:
                if not textpricetwo.isdigit() or not textpricethree.isdigit(
                ) or not textpricefour.isdigit():
                    self.PopupMsg("Please input price values")
                    return True

            if not self.type and int(text) <= 0:
                self.PopupMsg("Please input just only positive price")
                return True
            if self.type:
                if int(textpricetwo) < 0 or int(textpricethree) < 0 or int(
                        textpricefour) < 0:
                    self.PopupMsg("Please input just positive price")
                    return True

                if int(text) == 0 and int(textpricetwo) == 0 and int(
                        textpricethree) == 0 and int(textpricefour) == 0:
                    self.PopupMsg("Please input price values")
                    return True

                if self.priceInputBoard.itemVNum == 80007 and int(
                        textpricethree) > 0:
                    self.PopupMsg("You cannot sell gold bar with gold bar")
                    return True
        else:
            text = self.priceInputBoard.GetText()

            if not text:
                return True

            if not text.isdigit():
                return True

            if int(text) <= 0:
                return True

        attachedInvenType = self.priceInputBoard.sourceWindowType
        sourceSlotPos = self.priceInputBoard.sourceSlotPos
        targetSlotPos = self.priceInputBoard.targetSlotPos

        for privatePos, (itemWindowType,
                         itemSlotIndex) in self.itemStock.items():
            if itemWindowType == attachedInvenType and itemSlotIndex == sourceSlotPos:
                shop.DelPrivateShopItemStock(itemWindowType, itemSlotIndex)
                del self.itemStock[privatePos]

        if app.ENABLE_OFFLINE_SHOP:
            if self.type:
                price = int(self.priceInputBoard.GetTextPrice1())
                price_two = int(self.priceInputBoard.GetTextPrice2())
                price_three = int(self.priceInputBoard.GetTextPrice3())
                price_four = int(self.priceInputBoard.GetTextPrice4())
            else:
                price = int(self.priceInputBoard.GetText())
        else:
            price = int(self.priceInputBoard.GetText())

        if IsPrivateShopItemPriceList():
            SetPrivateShopItemPrice(self.priceInputBoard.itemVNum, price)

        if app.ENABLE_OFFLINE_SHOP:
            if self.type:
                if not constInfo.SHOP_ALLOW_COIN:
                    price_two = 0
                if not constInfo.SHOP_ALLOW_GOLDBAR:
                    price_three = 0
                if not constInfo.SHOP_ALLOW_WON:
                    price_four = 0

                wonFlag = 0
                try:
                    wonFlag = app.ENABLE_CHEQUE_SYSTEM
                except:
                    pass
                if not wonFlag:
                    price_four = 0

            if self.type:
                shop.AddPrivateShopItemStock(attachedInvenType, sourceSlotPos,
                                             targetSlotPos, price, price_two,
                                             price_three, price_four)
            else:
                shop.AddPrivateShopItemStock(attachedInvenType, sourceSlotPos,
                                             targetSlotPos, price)
        else:
            shop.AddPrivateShopItemStock(attachedInvenType, sourceSlotPos,
                                         targetSlotPos, price)

        self.itemStock[targetSlotPos] = (attachedInvenType, sourceSlotPos)
        snd.PlaySound("sound/ui/drop.wav")

        self.Refresh()

        #####
        if app.ENABLE_OFFLINE_SHOP:
            self.priceInputBoard.Close()
        self.priceInputBoard = None
        return True