mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-12 20:34:36 +01:00
Implement dictionaries
This commit is contained in:
@@ -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<>();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user