Skip to content

Commit

Permalink
refactor: simplify code and use table for transformations (opentibiab…
Browse files Browse the repository at this point in the history
…r#2196)

Refactored the code to make it more modular and understandable, using a
table to store transformation IDs in a more compact manner.

---------

Co-authored-by: GitHub Actions <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
omarcopires and github-actions[bot] authored Feb 8, 2024
1 parent a61ba58 commit 9169b01
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 62 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
local transformations = {
[31509] = 31500,
[31500] = 31505,
[31505] = 31513,
[31513] = 31509,
[31510] = 31502,
[31502] = 31506,
[31506] = 31514,
[31514] = 31510,
[31511] = 31503,
[31503] = 31507,
[31507] = 31515,
[31515] = 31511,
[31512] = 31504,
[31504] = 31508,
[31508] = 31516,
[31516] = 31512,
}

local goldenOutfitDisplay = Action()

function goldenOutfitDisplay.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local newItemID = transformations[item:getId()]
if not newItemID then
return true
end

if player:getStorageValue(Storage.OutfitQuest.GoldenOutfit) == 3 then
item:transform(newItemID)
item:getPosition():sendMagicEffect(CONST_ME_EARLY_THUNDER)
else
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need Full Golden Outfit to use it.")
item:getPosition():sendMagicEffect(CONST_ME_POFF)
end
return true
end

for index, value in pairs(transformDisplay) do
goldenOutfitDisplay:id(index)
end

goldenOutfitDisplay:register()

This file was deleted.

0 comments on commit 9169b01

Please sign in to comment.