-
-
Notifications
You must be signed in to change notification settings - Fork 647
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.
- Loading branch information
Showing
7 changed files
with
53 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("20241708275600_move_achievement_to_kv") | ||
|
||
function migration:onExecute() | ||
self:forEachPlayer(migrateAchievementProgress) | ||
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