mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-16 14:24:57 +01:00
Implement gacha guaranteed claim
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.Public.UI32;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.gacha_guarantee_reward_receive_req)
|
||||
public class HandlerGachaGuaranteeRewardReceiveReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
// Parse req
|
||||
var req = UI32.parseFrom(message);
|
||||
|
||||
// Recieve guaranteed reward
|
||||
var change = session.getPlayer().getGachaManager().recvGuarantee(req.getValue());
|
||||
|
||||
if (change == null) {
|
||||
return session.encodeMsg(NetMsgId.gacha_guarantee_reward_receive_failed_ack);
|
||||
}
|
||||
|
||||
// Encode and send
|
||||
return session.encodeMsg(NetMsgId.gacha_guarantee_reward_receive_succeed_ack, change.toProto());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.GachaInformation.GachaInfo;
|
||||
import emu.nebula.proto.GachaInformation.GachaInformationResp;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.net.GameSession;
|
||||
@@ -16,16 +15,7 @@ public class HandlerGachaInformationReq extends NetHandler {
|
||||
var rsp = GachaInformationResp.newInstance();
|
||||
|
||||
for (var bannerInfo : session.getPlayer().getGachaManager().getBannerInfos()) {
|
||||
var info = GachaInfo.newInstance()
|
||||
.setId(bannerInfo.getBannerId())
|
||||
.setGachaTotalTimes(bannerInfo.getTotal())
|
||||
.setTotalTimes(bannerInfo.getTotal())
|
||||
.setAupMissTimes(bannerInfo.getMissTimesA())
|
||||
.setAMissTimes(bannerInfo.getMissTimesA())
|
||||
.setReveFirstTenReward(true)
|
||||
.setRecvGuaranteeReward(bannerInfo.isUsedGuarantee());
|
||||
|
||||
rsp.addInformation(info);
|
||||
rsp.addInformation(bannerInfo.toProto());
|
||||
}
|
||||
|
||||
// Encode and send
|
||||
|
||||
Reference in New Issue
Block a user