mirror of
https://github.com/Melledy/Nebula.git
synced 2026-09-19 17:19:58 +02:00
Implement bounty trials
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.CharGemInstanceApply.CharGemInstanceApplyReq;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.data.GameData;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.char_gem_instance_apply_req)
|
||||
public class HandlerCharGemInstanceApplyReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
// Parse request
|
||||
var req = CharGemInstanceApplyReq.parseFrom(message);
|
||||
|
||||
var data = GameData.getCharGemInstanceDataTable().get(req.getId());
|
||||
if (data == null) {
|
||||
return this.encodeMsg(NetMsgId.char_gem_instance_apply_failed_ack);
|
||||
}
|
||||
|
||||
// Check player energy
|
||||
if (data.getEnergyConsume() > session.getPlayer().getEnergy()) {
|
||||
return this.encodeMsg(NetMsgId.char_gem_instance_apply_failed_ack);
|
||||
}
|
||||
|
||||
// Set player
|
||||
session.getPlayer().getInstanceManager().setCurInstanceId(req.getId());
|
||||
|
||||
// Template
|
||||
return this.encodeMsg(NetMsgId.char_gem_instance_apply_succeed_ack);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user