mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-22 17:51:53 +00:00
fix McoinExchangeHcoinRsp packet structure
This commit is contained in:
parent
b9e27828b8
commit
677aa2d2c4
@ -4,6 +4,7 @@ import emu.grasscutter.net.packet.Opcodes;
|
||||
import emu.grasscutter.net.packet.PacketHandler;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.McoinExchangeHcoinReqOuterClass;
|
||||
import emu.grasscutter.net.proto.RetcodeOuterClass;
|
||||
import emu.grasscutter.server.game.GameSession;
|
||||
import emu.grasscutter.server.packet.send.PacketMcoinExchangeHcoinRsp;
|
||||
|
||||
@ -15,13 +16,13 @@ public class HandlerMcoinExchangeHcoinReq extends PacketHandler {
|
||||
McoinExchangeHcoinReqOuterClass.McoinExchangeHcoinReq exchangeReq = McoinExchangeHcoinReqOuterClass.McoinExchangeHcoinReq.parseFrom(payload);
|
||||
|
||||
if (session.getPlayer().getCrystals() < exchangeReq.getMCoinNum() && exchangeReq.getMCoinNum() == exchangeReq.getHCoinNum()) {
|
||||
session.send(new PacketMcoinExchangeHcoinRsp(RetcodeOuterClass.Retcode.RET_UNKNOWN_ERROR_VALUE));
|
||||
return;
|
||||
}
|
||||
|
||||
session.getPlayer().setCrystals(session.getPlayer().getCrystals() - exchangeReq.getMCoinNum());
|
||||
session.getPlayer().setPrimogems(session.getPlayer().getPrimogems() + exchangeReq.getHCoinNum());
|
||||
session.getPlayer().save();
|
||||
|
||||
session.send(new PacketMcoinExchangeHcoinRsp(session.getPlayer().getCrystals(), session.getPlayer().getPrimogems()));
|
||||
session.send(new PacketMcoinExchangeHcoinRsp(RetcodeOuterClass.Retcode.RET_SUCC_VALUE));
|
||||
}
|
||||
}
|
||||
|
@ -6,13 +6,13 @@ import emu.grasscutter.net.proto.McoinExchangeHcoinRspOuterClass;
|
||||
|
||||
public class PacketMcoinExchangeHcoinRsp extends BasePacket {
|
||||
|
||||
public PacketMcoinExchangeHcoinRsp(int mcoin, int hcoin) {
|
||||
public PacketMcoinExchangeHcoinRsp(int retCode) {
|
||||
super(PacketOpcodes.McoinExchangeHcoinRsp);
|
||||
|
||||
McoinExchangeHcoinRspOuterClass.McoinExchangeHcoinRsp mcoinExchangeHcoinRsp = McoinExchangeHcoinRspOuterClass.McoinExchangeHcoinRsp.newBuilder()
|
||||
.setMCoinNum(mcoin)
|
||||
.setHCoinNum(hcoin).build();
|
||||
McoinExchangeHcoinRspOuterClass.McoinExchangeHcoinRsp proto = McoinExchangeHcoinRspOuterClass.McoinExchangeHcoinRsp.newBuilder()
|
||||
.setRetcode(retCode)
|
||||
.build();
|
||||
|
||||
this.setData(mcoinExchangeHcoinRsp);
|
||||
this.setData(proto);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user