Save Monolith and Menace Arena progress to the database

This commit is contained in:
Melledy
2025-11-11 04:42:41 -08:00
parent d9bd61c50d
commit b106541f44
6 changed files with 121 additions and 29 deletions

View File

@@ -3,9 +3,14 @@ package emu.nebula.server.handlers;
import emu.nebula.net.NetHandler;
import emu.nebula.net.NetMsgId;
import emu.nebula.proto.InfinityTowerInfo.InfinityTowerInfoResp;
import emu.nebula.proto.Public.InfinityTowerLevelInfo;
import emu.nebula.net.HandlerId;
import emu.nebula.Nebula;
import emu.nebula.data.GameData;
import emu.nebula.net.GameSession;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
@HandlerId(NetMsgId.infinity_tower_info_req)
public class HandlerInfinityTowerInfoReq extends NetHandler {
@@ -15,6 +20,38 @@ public class HandlerInfinityTowerInfoReq extends NetHandler {
var rsp = InfinityTowerInfoResp.newInstance()
.setBountyLevel(0);
// Add unlocked levels
if (Nebula.getConfig().getServerOptions().unlockInstances) {
// Force unlock every level
var levels = new Int2ObjectOpenHashMap<InfinityTowerLevelInfo>();
for (var data : GameData.getInfinityTowerLevelDataTable()) {
int id = (int) Math.floor(data.getId() / 10000D);
var info = levels.computeIfAbsent(
id,
diff -> InfinityTowerLevelInfo.newInstance().setId(id)
);
if (data.getId() > info.getLevelId()) {
info.setLevelId(data.getId());
}
}
for (var info : levels.values()) {
rsp.addInfos(info);
}
} else {
// Get infinite arena log from player progress
for (var entry : session.getPlayer().getProgress().getInfinityArenaLog().int2IntEntrySet()) {
var info = InfinityTowerLevelInfo.newInstance()
.setId(entry.getIntKey())
.setLevelId(entry.getIntValue());
rsp.addInfos(info);
}
}
// Encode and send
return session.encodeMsg(NetMsgId.infinity_tower_info_succeed_ack, rsp);
}