Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: problem with casks items in the charge loop and adjustment without code #2505

Merged
merged 9 commits into from
Apr 4, 2024
35 changes: 23 additions & 12 deletions data/modules/scripts/gamestore/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ function parseBuyStoreOffer(playerId, msg)

-- All guarding conditions under which the offer should not be processed must be included here
if
(table.contains(GameStore.OfferTypes, offer.type) == false) -- we've got an invalid offer type
(not table.contains(GameStore.OfferTypes, offer.type)) -- we've got an invalid offer type
luanluciano93 marked this conversation as resolved.
Show resolved Hide resolved
or not player
or (player:getVocation():getId() == 0) and (not GameStore.haveOfferRook(id)) -- we don't have such offer
or not offer
Expand Down Expand Up @@ -620,7 +620,7 @@ end
function Player.canBuyOffer(self, offer)
local playerId = self:getId()
local disabled, disabledReason = 0, ""
if offer.disabled == true or not offer.type then
if offer.disabled or not offer.type then
disabled = 1
end

Expand Down Expand Up @@ -693,7 +693,7 @@ function Player.canBuyOffer(self, offer)
end
elseif offer.type == GameStore.OfferTypes.OFFER_TYPE_MOUNT then
local hasMount = self:hasMount(offer.id)
if hasMount == true then
if hasMount then
luanluciano93 marked this conversation as resolved.
Show resolved Hide resolved
disabled = 1
disabledReason = "You already have this mount."
end
Expand Down Expand Up @@ -1183,7 +1183,7 @@ function sendStoreBalanceUpdating(playerId, updating)
msg:addByte(0x00)
msg:sendToPlayer(player)

if updating == true then
if updating then
sendUpdatedStoreBalances(playerId)
end
end
Expand Down Expand Up @@ -1346,7 +1346,7 @@ end

GameStore.retrieveHistoryTotalPages = function(accountId)
local resultId = db.storeQuery("SELECT count(id) as total FROM store_history WHERE account_id = " .. accountId)
if resultId == false then
if not resultId then
return 0
end

Expand Down Expand Up @@ -1602,7 +1602,7 @@ function GameStore.processStackablePurchase(player, offerId, offerCount, offerNa
local countToAdd = math.min(remainingCount, stackSize)
local inboxItem = inbox:addItem(offerId, countToAdd)
if inboxItem then
if movable ~= true then
if not movable then
inboxItem:setAttribute(ITEM_ATTRIBUTE_STORE, systemTime())
end
else
Expand Down Expand Up @@ -1631,21 +1631,32 @@ function GameStore.processHouseRelatedPurchase(player, offer)
local inbox = player:getStoreInbox()
if inbox then
for _, itemId in ipairs(itemIds) do
for i = 1, offer.count do
if isCaskItem(itemId) then
local decoKit = inbox:addItem(ITEM_DECORATION_KIT, 1)
if decoKit then
decoKit:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "You bought this item in the Store.\nUnwrap it in your own house to create a <" .. ItemType(itemId):getName() .. ">.")
decoKit:setCustomAttribute("unWrapId", itemId)
if isCaskItem(itemId) then
decoKit:setAttribute(ITEM_ATTRIBUTE_DATE, offer.count)
end
decoKit:setAttribute(ITEM_ATTRIBUTE_DATE, offer.count)

if offer.movable ~= true then
if not offer.movable then
decoKit:setAttribute(ITEM_ATTRIBUTE_STORE, systemTime())
end
end
player:sendUpdateContainer(inbox)
else
for i = 1, offer.count do
local decoKit = inbox:addItem(ITEM_DECORATION_KIT, 1)
if decoKit then
decoKit:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "You bought this item in the Store.\nUnwrap it in your own house to create a <" .. ItemType(itemId):getName() .. ">.")
decoKit:setCustomAttribute("unWrapId", itemId)

if not offer.movable then
decoKit:setAttribute(ITEM_ATTRIBUTE_STORE, systemTime())
end
end
player:sendUpdateContainer(inbox)
end
end
player:sendUpdateContainer(inbox)
end
end
end
Expand Down
Loading