Implement gacha guaranteed claim

This commit is contained in:
Melledy
2025-11-15 23:48:18 -08:00
parent 18ffa6bf58
commit c859252ddd
5 changed files with 100 additions and 11 deletions

View File

@@ -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());
}
}

View File

@@ -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