Implement dictionaries

This commit is contained in:
Melledy
2025-10-28 00:41:30 -07:00
parent 1bf87715b5
commit 38d44f7a71
4 changed files with 75 additions and 1 deletions

View File

@@ -37,6 +37,9 @@ public class GameData {
@Getter private static DataTable<MallShopDef> MallShopDataTable = new DataTable<>();
@Getter private static DataTable<MallGemDef> MallGemDataTable = new DataTable<>();
@Getter private static DataTable<DictionaryTabDef> DictionaryTabDataTable = new DataTable<>();
@Getter private static DataTable<DictionaryEntryDef> DictionaryEntryDataTable = new DataTable<>();
@Getter private static DataTable<WorldClassDef> WorldClassDataTable = new DataTable<>();
@Getter private static DataTable<GuideGroupDef> GuideGroupDataTable = new DataTable<>();
@Getter private static DataTable<StoryDef> StoryDataTable = new DataTable<>();

View File

@@ -0,0 +1,28 @@
package emu.nebula.data.resources;
import emu.nebula.data.BaseDef;
import emu.nebula.data.GameData;
import emu.nebula.data.ResourceType;
import emu.nebula.data.ResourceType.LoadPriority;
import lombok.Getter;
@Getter
@ResourceType(name = "DictionaryEntry.json", loadPriority = LoadPriority.LOW)
public class DictionaryEntryDef extends BaseDef {
private int Id;
private int Tab;
private int Index;
@Override
public int getId() {
return Id;
}
@Override
public void onLoad() {
var dictionary = GameData.getDictionaryTabDataTable().get(this.getTab());
if (dictionary != null) {
dictionary.getEntries().add(this);
}
}
}

View File

@@ -0,0 +1,26 @@
package emu.nebula.data.resources;
import java.util.ArrayList;
import java.util.List;
import emu.nebula.data.BaseDef;
import emu.nebula.data.ResourceType;
import lombok.Getter;
@Getter
@ResourceType(name = "DictionaryTab.json")
public class DictionaryTabDef extends BaseDef {
private int Id;
private List<DictionaryEntryDef> entries;
public DictionaryTabDef() {
this.entries = new ArrayList<>();
}
@Override
public int getId() {
return Id;
}
}

View File

@@ -19,6 +19,8 @@ import emu.nebula.game.mail.Mailbox;
import emu.nebula.game.story.StoryManager;
import emu.nebula.game.tower.StarTowerManager;
import emu.nebula.net.GameSession;
import emu.nebula.proto.PlayerData.DictionaryEntry;
import emu.nebula.proto.PlayerData.DictionaryTab;
import emu.nebula.proto.PlayerData.PlayerInfo;
import emu.nebula.proto.Public.NewbieInfo;
import emu.nebula.proto.Public.QuestType;
@@ -333,7 +335,6 @@ public class Player implements GameDatabaseObject {
.setCreateTime(this.getCreateTime());
proto.getMutableWorldClass()
.setStage(3)
.setCur(this.getLevel())
.setLastExp(this.getExp());
@@ -418,6 +419,22 @@ public class Player implements GameDatabaseObject {
for (int boardId : this.getBoards()) {
proto.addBoard(boardId);
}
// Add dictionary tabs
for (var dictionaryData : GameData.getDictionaryTabDataTable()) {
var dictionaryProto = DictionaryTab.newInstance()
.setTabId(dictionaryData.getId());
for (var entry : dictionaryData.getEntries()) {
var entryProto = DictionaryEntry.newInstance()
.setIndex(entry.getIndex())
.setStatus(2); // 2 = complete
dictionaryProto.addEntries(entryProto);
}
proto.addDictionaries(dictionaryProto);
}
// Server timestamp
proto.setServerTs(Nebula.getCurrentTime());