Implement Finale Echoing (Permanent)

- Sweeps and quests this game mode are not implemented yet
This commit is contained in:
Melledy committed 2026-03-15 02:33:40 -07:00
1 parent e0a6659c38
commit f007b6624f
23 files changed
+989 -7

No files matched your search

@@ -0,0 +1,43 @@
package emu.nebula.server.handlers;
import emu.nebula.net.NetHandler;
import emu.nebula.net.NetMsgId;
import emu.nebula.proto.JointDrill2Apply.JointDrill2ApplyReq;
import emu.nebula.proto.JointDrill2Apply.JointDrill2ApplyResp;
import emu.nebula.net.HandlerId;
import emu.nebula.Nebula;
import emu.nebula.game.activity.type.JointDrillActivity;
import emu.nebula.net.GameSession;
@HandlerId(NetMsgId.joint_drill_2_apply_req)
public class HandlerJointDrill2ApplyReq extends NetHandler {
@Override
public byte[] handle(GameSession session, byte[] message) throws Exception {
// Get joint drill activity
var activity = session.getPlayer().getActivityManager().getFirstActivity(JointDrillActivity.class);
if (activity == null) {
return session.encodeMsg(NetMsgId.joint_drill_2_apply_failed_ack);
}
// Parse request
var req = JointDrill2ApplyReq.parseFrom(message);
// Apply for joint drill stage
var change = activity.apply(req.getLevelId(), req.getBuildId(), req.getSimulate());
if (change == null) {
return session.encodeMsg(NetMsgId.joint_drill_2_apply_failed_ack);
}
// Create response packet
var rsp = JointDrill2ApplyResp.newInstance()
.setStarTime(Nebula.getCurrentServerTime() + activity.getLevel().getBattleTime())
.setChange(change.toProto());
// Encode and send
return session.encodeMsg(NetMsgId.joint_drill_2_apply_succeed_ack, rsp);
}
}
@@ -0,0 +1,37 @@
package emu.nebula.server.handlers;
import emu.nebula.net.NetHandler;
import emu.nebula.net.NetMsgId;
import emu.nebula.proto.JointDrill2Continue.JointDrill2ContinueReq;
import emu.nebula.net.HandlerId;
import emu.nebula.game.activity.type.JointDrillActivity;
import emu.nebula.net.GameSession;
@HandlerId(NetMsgId.joint_drill_2_continue_req)
public class HandlerJointDrill2ContinueReq extends NetHandler {
@Override
public byte[] handle(GameSession session, byte[] message) throws Exception {
// Get joint drill activity
var activity = session.getPlayer().getActivityManager().getFirstActivity(JointDrillActivity.class);
if (activity == null) {
return session.encodeMsg(NetMsgId.joint_drill_2_continue_failed_ack);
}
// Parse request
var req = JointDrill2ContinueReq.parseFrom(message);
// Continue
var success = activity.continueDrill(req.getBuildId());
// Check
if (!success) {
return session.encodeMsg(NetMsgId.joint_drill_2_continue_failed_ack);
}
// Encode and send
return session.encodeMsg(NetMsgId.joint_drill_2_continue_succeed_ack);
}
}
@@ -0,0 +1,40 @@
package emu.nebula.server.handlers;
import emu.nebula.net.NetHandler;
import emu.nebula.net.NetMsgId;
import emu.nebula.proto.PublicJointDrill.JointDrillSettle;
import emu.nebula.net.HandlerId;
import emu.nebula.game.activity.type.JointDrillActivity;
import emu.nebula.net.GameSession;
@HandlerId(NetMsgId.joint_drill_2_game_over_req)
public class HandlerJointDrill2GameOverReq extends NetHandler {
@Override
public byte[] handle(GameSession session, byte[] message) throws Exception {
// Get joint drill activity
var activity = session.getPlayer().getActivityManager().getFirstActivity(JointDrillActivity.class);
if (activity == null) {
return session.encodeMsg(NetMsgId.joint_drill_2_game_over_failed_ack);
}
// Give up
var score = activity.settle(0, 0, false);
if (score == null) {
return session.encodeMsg(NetMsgId.joint_drill_2_game_over_failed_ack);
}
// Build response
var rsp = JointDrillSettle.newInstance()
.setFightScore(score.getFight())
.setDifficultyScore(score.getDifficulty())
.setHpScore(score.getHp())
.setChange(score.getChange().toProto());
// Encode and send
return session.encodeMsg(NetMsgId.joint_drill_2_game_over_succeed_ack, rsp);
}
}
@@ -0,0 +1,44 @@
package emu.nebula.server.handlers;
import emu.nebula.net.NetHandler;
import emu.nebula.net.NetMsgId;
import emu.nebula.proto.JointDrill2GiveUp.JointDrill2GiveUpReq;
import emu.nebula.proto.PublicJointDrill.JointDrillSettle;
import emu.nebula.net.HandlerId;
import emu.nebula.game.activity.type.JointDrillActivity;
import emu.nebula.net.GameSession;
@HandlerId(NetMsgId.joint_drill_2_give_up_req)
public class HandlerJointDrill2GiveUpReq extends NetHandler {
@Override
public byte[] handle(GameSession session, byte[] message) throws Exception {
// Get joint drill activity
var activity = session.getPlayer().getActivityManager().getFirstActivity(JointDrillActivity.class);
if (activity == null) {
return session.encodeMsg(NetMsgId.joint_drill_2_give_up_failed_ack);
}
// Parse request
var req = JointDrill2GiveUpReq.parseFrom(message);
// Give up
var score = activity.giveup(req.getTime(), req.getDamage());
if (score == null) {
return session.encodeMsg(NetMsgId.joint_drill_2_give_up_failed_ack);
}
// Build response
var rsp = JointDrillSettle.newInstance()
.setFightScore(score.getFight())
.setDifficultyScore(score.getDifficulty())
.setHpScore(score.getHp())
.setChange(score.getChange().toProto());
// Encode and send
return session.encodeMsg(NetMsgId.joint_drill_2_give_up_succeed_ack, rsp);
}
}
@@ -0,0 +1,16 @@
package emu.nebula.server.handlers;
import emu.nebula.net.NetHandler;
import emu.nebula.net.NetMsgId;
import emu.nebula.net.HandlerId;
import emu.nebula.net.GameSession;
@HandlerId(NetMsgId.joint_drill_2_retreat_req)
public class HandlerJointDrill2RetreatReq extends NetHandler {
@Override
public byte[] handle(GameSession session, byte[] message) throws Exception {
return session.encodeMsg(NetMsgId.joint_drill_2_retreat_succeed_ack);
}
}
@@ -0,0 +1,49 @@
package emu.nebula.server.handlers;
import emu.nebula.net.NetHandler;
import emu.nebula.net.NetMsgId;
import emu.nebula.proto.JointDrill2Settle.JointDrill2SettleReq;
import emu.nebula.proto.PublicJointDrill.JointDrillSettle;
import emu.nebula.net.HandlerId;
import emu.nebula.game.activity.type.JointDrillActivity;
import emu.nebula.net.GameSession;
@HandlerId(NetMsgId.joint_drill_2_settle_req)
public class HandlerJointDrill2SettleReq extends NetHandler {
@Override
public byte[] handle(GameSession session, byte[] message) throws Exception {
// Get joint drill activity
var activity = session.getPlayer().getActivityManager().getFirstActivity(JointDrillActivity.class);
if (activity == null) {
return session.encodeMsg(NetMsgId.joint_drill_2_settle_failed_ack);
}
// Parse request
var req = JointDrill2SettleReq.parseFrom(message);
// Settle
var score = activity.settle(req.getTime(), req.getDamage(), true);
if (score == null) {
return session.encodeMsg(NetMsgId.joint_drill_2_settle_failed_ack);
}
// Handle client events for achievements
session.getPlayer().getAchievementManager().handleClientEvents(req.getEvents());
// Build response
var rsp = JointDrillSettle.newInstance()
.setFightScore(score.getFight())
.setDifficultyScore(score.getDifficulty())
.setHpScore(score.getHp())
.setChange(score.getChange().toProto());
score.getRewards().toItemTemplateStream().forEach(rsp::addItems);
// Encode and send
return session.encodeMsg(NetMsgId.joint_drill_2_settle_succeed_ack, rsp);
}
}
@@ -0,0 +1,16 @@
package emu.nebula.server.handlers;
import emu.nebula.net.NetHandler;
import emu.nebula.net.NetMsgId;
import emu.nebula.net.HandlerId;
import emu.nebula.net.GameSession;
@HandlerId(NetMsgId.joint_drill_2_sync_req)
public class HandlerJointDrill2SyncReq extends NetHandler {
@Override
public byte[] handle(GameSession session, byte[] message) throws Exception {
return session.encodeMsg(NetMsgId.joint_drill_2_sync_succeed_ack);
}
}
@@ -0,0 +1,54 @@
package emu.nebula.server.handlers;
import emu.nebula.net.NetHandler;
import emu.nebula.net.NetMsgId;
import emu.nebula.proto.JointDrillRank.JointDrillRankInfo;
import emu.nebula.net.HandlerId;
import emu.nebula.Nebula;
import emu.nebula.game.activity.type.JointDrillActivity;
import emu.nebula.net.GameSession;
@HandlerId(NetMsgId.joint_drill_rank_req)
public class HandlerJointDrillRankReq extends NetHandler {
@Override
public byte[] handle(GameSession session, byte[] message) throws Exception {
// Get joint drill activity
var activity = session.getPlayer().getActivityManager().getFirstActivity(JointDrillActivity.class);
if (activity == null) {
return session.encodeMsg(NetMsgId.joint_drill_rank_failed_ack);
}
// Build response
var rsp = JointDrillRankInfo.newInstance()
.setLastRefreshTime(Nebula.getCurrentServerTime());
// Get self
var self = activity.getRankEntry();
if (self != null) {
rsp.setSelf(self.toProto());
}
// Get ranking
var ranking = Nebula.getGameContext().getJointDrillModule().getRanking(activity.getId());
for (var entry : ranking) {
// Check self
if (self != null && self.getPlayerUid() == entry.getId()) {
rsp.getMutableSelf().setRank(entry.getRank());
}
// Add to ranking
rsp.addRank(entry);
}
// Set total
rsp.setTotal(ranking.size());
// Encode and send
return session.encodeMsg(NetMsgId.joint_drill_rank_succeed_ack, rsp);
}
}