-
-
Notifications
You must be signed in to change notification settings - Fork 632
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: achievement migration and highscore categories (#2260)
Fix initialization of vector and map from category and others small things. --------- Co-authored-by: Elson Costa <elsongabriel@hotmail.com> Co-authored-by: GitHub Actions <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
2be1f89
commit 530595a
Showing
9 changed files
with
77 additions
and
29 deletions.
There are no files selected for viewing
File renamed without changes.
39 changes: 39 additions & 0 deletions
39
data-otservbr-global/scripts/game_migrations/20241708000535_move_achievement_to_kv.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
local achievementProgressStorage = 20000 | ||
local achievementStorage = 30000 | ||
|
||
local function migrateAchievementProgress(player) | ||
for id, achievement in pairs(ACHIEVEMENTS) do | ||
local oldStorageKey = achievementProgressStorage + id | ||
local progressNumber = player:getStorageValue(oldStorageKey) | ||
if progressNumber > 0 then | ||
local achievScopeName = tostring(achievement.name .. "-progress") | ||
player:kv():scoped(achievScopeName, progressNumber) | ||
player:setStorageValue(oldStorageKey, -1) | ||
end | ||
local oldAchievement = player:getStorageValue(achievementStorage + id) | ||
if oldAchievement > 0 then | ||
player:addAchievement(achievement.name) | ||
player:setStorageValue(achievementStorage + id, -1) | ||
end | ||
end | ||
local points = 0 | ||
local list = player:getAchievements() | ||
if #list > 0 then | ||
for i = 1, #list do | ||
local a = Game.getAchievementInfoById(list[i]) | ||
if a.points > 0 then | ||
points = points + a.points | ||
end | ||
end | ||
end | ||
|
||
player:addAchievementPoints(points) | ||
end | ||
|
||
local migration = Migration("20241708000535_move_achievement_to_kv") | ||
|
||
function migration:onExecute() | ||
self:forEachPlayer(migrateAchievementProgress) | ||
end | ||
|
||
migration:register() |
File renamed without changes.
24 changes: 24 additions & 0 deletions
24
data-otservbr-global/scripts/game_migrations/20241708485868_move_some_storages_to_kv.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
local oldAutolootStorage = 30063 | ||
local flasksStorage = "talkaction.potions.flask" | ||
|
||
local function migrate(player) | ||
local isAutoLoot = player:getStorageValue(oldAutolootStorage) | ||
if isAutoLoot > 0 then | ||
player:setFeature(Features.AutoLoot, 1) | ||
player:setStorageValue(oldAutolootStorage, -1) | ||
end | ||
|
||
local getOldFlasksStorage = player:getStorageValueByName(flasksStorage) | ||
if getOldFlasksStorage > 0 then | ||
player:kv():set("talkaction.potions.flask", true) | ||
player:setStorageValueByName(flasksStorage, -1) | ||
end | ||
end | ||
|
||
local migration = Migration("20241708485868_move_some_storages_to_kv") | ||
|
||
function migration:onExecute() | ||
self:forEachPlayer(migrate) | ||
end | ||
|
||
migration:register() |
20 changes: 0 additions & 20 deletions
20
...vbr-global/scripts/globalevents/game_migrations/20241708000535_move_achievement_to_kv.lua
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters