mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-15 05:44:36 +01:00
Implement story
This commit is contained in:
@@ -8,6 +8,7 @@ import emu.nebula.proto.Public.ActivityTrial;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@HandlerId(NetMsgId.activity_detail_req)
|
||||
public class HandlerActivityDetailReq extends NetHandler {
|
||||
|
||||
@@ -15,11 +16,13 @@ public class HandlerActivityDetailReq extends NetHandler {
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
var rsp = ActivityResp.newInstance();
|
||||
|
||||
/*
|
||||
var activity = ActivityMsg.newInstance()
|
||||
.setId(700101)
|
||||
.setTrial(ActivityTrial.newInstance());
|
||||
|
||||
rsp.addList(activity);
|
||||
*/
|
||||
|
||||
return this.encodeMsg(NetMsgId.activity_detail_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.story_apply_req)
|
||||
public class HandlerStoryApplyReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
return this.encodeMsg(NetMsgId.story_apply_succeed_ack);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.StorySetInfo.StorySetChapter;
|
||||
import emu.nebula.proto.StorySetInfo.StorySetInfoResp;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.data.resources.StorySetSectionDef;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.story_set_info_req)
|
||||
public class HandlerStorySetInfoReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
var rsp = StorySetInfoResp.newInstance();
|
||||
|
||||
for (int chapterId : StorySetSectionDef.getChapterIds()) {
|
||||
var chapter = StorySetChapter.newInstance()
|
||||
.setChapterId(chapterId);
|
||||
|
||||
rsp.addChapters(chapter);
|
||||
}
|
||||
|
||||
return this.encodeMsg(NetMsgId.story_set_info_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.StorySett.StorySettleReq;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.story_settle_req)
|
||||
public class HandlerStorySettleReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
// Parse request
|
||||
var req = StorySettleReq.parseFrom(message);
|
||||
|
||||
// Get list of settled story ids
|
||||
var list = new IntArrayList();
|
||||
|
||||
for (var settle : req.getList()) {
|
||||
list.add(settle.getIdx());
|
||||
}
|
||||
|
||||
// Settle
|
||||
var changes = session.getPlayer().getStoryManager().settle(list);
|
||||
|
||||
// Finish
|
||||
return this.encodeMsg(NetMsgId.story_settle_succeed_ack, changes.toProto());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user