mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-16 22:34:41 +01:00
Implement gacha history
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.GachaHistoriesOuterClass.GachaHistories;
|
||||
import emu.nebula.proto.Public.UI32;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.gacha_histories_req)
|
||||
public class HandlerGachaHistoriesReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
// Parse request
|
||||
var req = UI32.parseFrom(message);
|
||||
|
||||
// Get history log
|
||||
var list = session.getPlayer().getGachaManager().getHistories().get(req.getValue());
|
||||
|
||||
// Build response
|
||||
var rsp = GachaHistories.newInstance();
|
||||
|
||||
if (list != null) {
|
||||
for (var log : list) {
|
||||
rsp.addList(log.toProto());
|
||||
}
|
||||
}
|
||||
|
||||
// Encode and send
|
||||
return session.encodeMsg(NetMsgId.gacha_histories_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user