Fix challenge rewards not working due to new update behavior

This commit is contained in:
Melledy 2024-02-07 05:01:37 -08:00
parent e6f837c54d
commit 6e52dcdba2
11 changed files with 516 additions and 260 deletions

View File

@ -23,11 +23,6 @@ public final class TakeChallengeRewardCsReqOuterClass {
*/
private int groupId;
/**
* <code>optional uint32 star_count = 10;</code>
*/
private int starCount;
private TakeChallengeRewardCsReq() {
}
@ -75,50 +70,12 @@ public final class TakeChallengeRewardCsReqOuterClass {
return this;
}
/**
* <code>optional uint32 star_count = 10;</code>
* @return whether the starCount field is set
*/
public boolean hasStarCount() {
return (bitField0_ & 0x00000002) != 0;
}
/**
* <code>optional uint32 star_count = 10;</code>
* @return this
*/
public TakeChallengeRewardCsReq clearStarCount() {
bitField0_ &= ~0x00000002;
starCount = 0;
return this;
}
/**
* <code>optional uint32 star_count = 10;</code>
* @return the starCount
*/
public int getStarCount() {
return starCount;
}
/**
* <code>optional uint32 star_count = 10;</code>
* @param value the starCount to set
* @return this
*/
public TakeChallengeRewardCsReq setStarCount(final int value) {
bitField0_ |= 0x00000002;
starCount = value;
return this;
}
@Override
public TakeChallengeRewardCsReq copyFrom(final TakeChallengeRewardCsReq other) {
cachedSize = other.cachedSize;
if ((bitField0_ | other.bitField0_) != 0) {
bitField0_ = other.bitField0_;
groupId = other.groupId;
starCount = other.starCount;
}
return this;
}
@ -132,9 +89,6 @@ public final class TakeChallengeRewardCsReqOuterClass {
if (other.hasGroupId()) {
setGroupId(other.groupId);
}
if (other.hasStarCount()) {
setStarCount(other.starCount);
}
return this;
}
@ -146,7 +100,6 @@ public final class TakeChallengeRewardCsReqOuterClass {
cachedSize = -1;
bitField0_ = 0;
groupId = 0;
starCount = 0;
return this;
}
@ -170,8 +123,7 @@ public final class TakeChallengeRewardCsReqOuterClass {
}
TakeChallengeRewardCsReq other = (TakeChallengeRewardCsReq) o;
return bitField0_ == other.bitField0_
&& (!hasGroupId() || groupId == other.groupId)
&& (!hasStarCount() || starCount == other.starCount);
&& (!hasGroupId() || groupId == other.groupId);
}
@Override
@ -180,10 +132,6 @@ public final class TakeChallengeRewardCsReqOuterClass {
output.writeRawByte((byte) 8);
output.writeUInt32NoTag(groupId);
}
if ((bitField0_ & 0x00000002) != 0) {
output.writeRawByte((byte) 80);
output.writeUInt32NoTag(starCount);
}
}
@Override
@ -192,9 +140,6 @@ public final class TakeChallengeRewardCsReqOuterClass {
if ((bitField0_ & 0x00000001) != 0) {
size += 1 + ProtoSink.computeUInt32SizeNoTag(groupId);
}
if ((bitField0_ & 0x00000002) != 0) {
size += 1 + ProtoSink.computeUInt32SizeNoTag(starCount);
}
return size;
}
@ -210,15 +155,6 @@ public final class TakeChallengeRewardCsReqOuterClass {
groupId = input.readUInt32();
bitField0_ |= 0x00000001;
tag = input.readTag();
if (tag != 80) {
break;
}
}
case 80: {
// starCount
starCount = input.readUInt32();
bitField0_ |= 0x00000002;
tag = input.readTag();
if (tag != 0) {
break;
}
@ -243,9 +179,6 @@ public final class TakeChallengeRewardCsReqOuterClass {
if ((bitField0_ & 0x00000001) != 0) {
output.writeUInt32(FieldNames.groupId, groupId);
}
if ((bitField0_ & 0x00000002) != 0) {
output.writeUInt32(FieldNames.starCount, starCount);
}
output.endObject();
}
@ -268,18 +201,6 @@ public final class TakeChallengeRewardCsReqOuterClass {
}
break;
}
case 2121235933:
case 2124166370: {
if (input.isAtField(FieldNames.starCount)) {
if (!input.trySkipNullValue()) {
starCount = input.readUInt32();
bitField0_ |= 0x00000002;
}
} else {
input.skipUnknownField();
}
break;
}
default: {
input.skipUnknownField();
break;
@ -334,8 +255,6 @@ public final class TakeChallengeRewardCsReqOuterClass {
*/
static class FieldNames {
static final FieldName groupId = FieldName.forField("groupId", "group_id");
static final FieldName starCount = FieldName.forField("starCount", "star_count");
}
}
}

View File

@ -10,6 +10,7 @@ import us.hebi.quickbuf.MessageFactory;
import us.hebi.quickbuf.ProtoMessage;
import us.hebi.quickbuf.ProtoSink;
import us.hebi.quickbuf.ProtoSource;
import us.hebi.quickbuf.RepeatedMessage;
public final class TakeChallengeRewardScRspOuterClass {
/**
@ -18,11 +19,6 @@ public final class TakeChallengeRewardScRspOuterClass {
public static final class TakeChallengeRewardScRsp extends ProtoMessage<TakeChallengeRewardScRsp> implements Cloneable {
private static final long serialVersionUID = 0L;
/**
* <code>optional uint32 star_count = 1;</code>
*/
private int starCount;
/**
* <code>optional uint32 group_id = 6;</code>
*/
@ -34,9 +30,9 @@ public final class TakeChallengeRewardScRspOuterClass {
private int retcode;
/**
* <code>optional .ItemList reward = 15;</code>
* <code>repeated .TakenChallengeRewardInfo taken_reward_list = 10;</code>
*/
private final ItemListOuterClass.ItemList reward = ItemListOuterClass.ItemList.newInstance();
private final RepeatedMessage<TakenChallengeRewardInfoOuterClass.TakenChallengeRewardInfo> takenRewardList = RepeatedMessage.newEmptyInstance(TakenChallengeRewardInfoOuterClass.TakenChallengeRewardInfo.getFactory());
private TakeChallengeRewardScRsp() {
}
@ -48,49 +44,12 @@ public final class TakeChallengeRewardScRspOuterClass {
return new TakeChallengeRewardScRsp();
}
/**
* <code>optional uint32 star_count = 1;</code>
* @return whether the starCount field is set
*/
public boolean hasStarCount() {
return (bitField0_ & 0x00000001) != 0;
}
/**
* <code>optional uint32 star_count = 1;</code>
* @return this
*/
public TakeChallengeRewardScRsp clearStarCount() {
bitField0_ &= ~0x00000001;
starCount = 0;
return this;
}
/**
* <code>optional uint32 star_count = 1;</code>
* @return the starCount
*/
public int getStarCount() {
return starCount;
}
/**
* <code>optional uint32 star_count = 1;</code>
* @param value the starCount to set
* @return this
*/
public TakeChallengeRewardScRsp setStarCount(final int value) {
bitField0_ |= 0x00000001;
starCount = value;
return this;
}
/**
* <code>optional uint32 group_id = 6;</code>
* @return whether the groupId field is set
*/
public boolean hasGroupId() {
return (bitField0_ & 0x00000002) != 0;
return (bitField0_ & 0x00000001) != 0;
}
/**
@ -98,7 +57,7 @@ public final class TakeChallengeRewardScRspOuterClass {
* @return this
*/
public TakeChallengeRewardScRsp clearGroupId() {
bitField0_ &= ~0x00000002;
bitField0_ &= ~0x00000001;
groupId = 0;
return this;
}
@ -117,7 +76,7 @@ public final class TakeChallengeRewardScRspOuterClass {
* @return this
*/
public TakeChallengeRewardScRsp setGroupId(final int value) {
bitField0_ |= 0x00000002;
bitField0_ |= 0x00000001;
groupId = value;
return this;
}
@ -127,7 +86,7 @@ public final class TakeChallengeRewardScRspOuterClass {
* @return whether the retcode field is set
*/
public boolean hasRetcode() {
return (bitField0_ & 0x00000004) != 0;
return (bitField0_ & 0x00000002) != 0;
}
/**
@ -135,7 +94,7 @@ public final class TakeChallengeRewardScRspOuterClass {
* @return this
*/
public TakeChallengeRewardScRsp clearRetcode() {
bitField0_ &= ~0x00000004;
bitField0_ &= ~0x00000002;
retcode = 0;
return this;
}
@ -154,45 +113,46 @@ public final class TakeChallengeRewardScRspOuterClass {
* @return this
*/
public TakeChallengeRewardScRsp setRetcode(final int value) {
bitField0_ |= 0x00000004;
bitField0_ |= 0x00000002;
retcode = value;
return this;
}
/**
* <code>optional .ItemList reward = 15;</code>
* @return whether the reward field is set
* <code>repeated .TakenChallengeRewardInfo taken_reward_list = 10;</code>
* @return whether the takenRewardList field is set
*/
public boolean hasReward() {
return (bitField0_ & 0x00000008) != 0;
public boolean hasTakenRewardList() {
return (bitField0_ & 0x00000004) != 0;
}
/**
* <code>optional .ItemList reward = 15;</code>
* <code>repeated .TakenChallengeRewardInfo taken_reward_list = 10;</code>
* @return this
*/
public TakeChallengeRewardScRsp clearReward() {
bitField0_ &= ~0x00000008;
reward.clear();
public TakeChallengeRewardScRsp clearTakenRewardList() {
bitField0_ &= ~0x00000004;
takenRewardList.clear();
return this;
}
/**
* <code>optional .ItemList reward = 15;</code>
* <code>repeated .TakenChallengeRewardInfo taken_reward_list = 10;</code>
*
* This method returns the internal storage object without modifying any has state.
* The returned object should not be modified and be treated as read-only.
*
* Use {@link #getMutableReward()} if you want to modify it.
* Use {@link #getMutableTakenRewardList()} if you want to modify it.
*
* @return internal storage object for reading
*/
public ItemListOuterClass.ItemList getReward() {
return reward;
public RepeatedMessage<TakenChallengeRewardInfoOuterClass.TakenChallengeRewardInfo> getTakenRewardList(
) {
return takenRewardList;
}
/**
* <code>optional .ItemList reward = 15;</code>
* <code>repeated .TakenChallengeRewardInfo taken_reward_list = 10;</code>
*
* This method returns the internal storage object and sets the corresponding
* has state. The returned object will become part of this message and its
@ -200,19 +160,33 @@ public final class TakeChallengeRewardScRspOuterClass {
*
* @return internal storage object for modifications
*/
public ItemListOuterClass.ItemList getMutableReward() {
bitField0_ |= 0x00000008;
return reward;
public RepeatedMessage<TakenChallengeRewardInfoOuterClass.TakenChallengeRewardInfo> getMutableTakenRewardList(
) {
bitField0_ |= 0x00000004;
return takenRewardList;
}
/**
* <code>optional .ItemList reward = 15;</code>
* @param value the reward to set
* <code>repeated .TakenChallengeRewardInfo taken_reward_list = 10;</code>
* @param value the takenRewardList to add
* @return this
*/
public TakeChallengeRewardScRsp setReward(final ItemListOuterClass.ItemList value) {
bitField0_ |= 0x00000008;
reward.copyFrom(value);
public TakeChallengeRewardScRsp addTakenRewardList(
final TakenChallengeRewardInfoOuterClass.TakenChallengeRewardInfo value) {
bitField0_ |= 0x00000004;
takenRewardList.add(value);
return this;
}
/**
* <code>repeated .TakenChallengeRewardInfo taken_reward_list = 10;</code>
* @param values the takenRewardList to add
* @return this
*/
public TakeChallengeRewardScRsp addAllTakenRewardList(
final TakenChallengeRewardInfoOuterClass.TakenChallengeRewardInfo... values) {
bitField0_ |= 0x00000004;
takenRewardList.addAll(values);
return this;
}
@ -221,10 +195,9 @@ public final class TakeChallengeRewardScRspOuterClass {
cachedSize = other.cachedSize;
if ((bitField0_ | other.bitField0_) != 0) {
bitField0_ = other.bitField0_;
starCount = other.starCount;
groupId = other.groupId;
retcode = other.retcode;
reward.copyFrom(other.reward);
takenRewardList.copyFrom(other.takenRewardList);
}
return this;
}
@ -235,17 +208,14 @@ public final class TakeChallengeRewardScRspOuterClass {
return this;
}
cachedSize = -1;
if (other.hasStarCount()) {
setStarCount(other.starCount);
}
if (other.hasGroupId()) {
setGroupId(other.groupId);
}
if (other.hasRetcode()) {
setRetcode(other.retcode);
}
if (other.hasReward()) {
getMutableReward().mergeFrom(other.reward);
if (other.hasTakenRewardList()) {
getMutableTakenRewardList().addAll(other.takenRewardList);
}
return this;
}
@ -257,10 +227,9 @@ public final class TakeChallengeRewardScRspOuterClass {
}
cachedSize = -1;
bitField0_ = 0;
starCount = 0;
groupId = 0;
retcode = 0;
reward.clear();
takenRewardList.clear();
return this;
}
@ -271,7 +240,7 @@ public final class TakeChallengeRewardScRspOuterClass {
}
cachedSize = -1;
bitField0_ = 0;
reward.clearQuick();
takenRewardList.clearQuick();
return this;
}
@ -285,29 +254,26 @@ public final class TakeChallengeRewardScRspOuterClass {
}
TakeChallengeRewardScRsp other = (TakeChallengeRewardScRsp) o;
return bitField0_ == other.bitField0_
&& (!hasStarCount() || starCount == other.starCount)
&& (!hasGroupId() || groupId == other.groupId)
&& (!hasRetcode() || retcode == other.retcode)
&& (!hasReward() || reward.equals(other.reward));
&& (!hasTakenRewardList() || takenRewardList.equals(other.takenRewardList));
}
@Override
public void writeTo(final ProtoSink output) throws IOException {
if ((bitField0_ & 0x00000001) != 0) {
output.writeRawByte((byte) 8);
output.writeUInt32NoTag(starCount);
}
if ((bitField0_ & 0x00000002) != 0) {
output.writeRawByte((byte) 48);
output.writeUInt32NoTag(groupId);
}
if ((bitField0_ & 0x00000004) != 0) {
if ((bitField0_ & 0x00000002) != 0) {
output.writeRawByte((byte) 112);
output.writeUInt32NoTag(retcode);
}
if ((bitField0_ & 0x00000008) != 0) {
output.writeRawByte((byte) 122);
output.writeMessageNoTag(reward);
if ((bitField0_ & 0x00000004) != 0) {
for (int i = 0; i < takenRewardList.length(); i++) {
output.writeRawByte((byte) 82);
output.writeMessageNoTag(takenRewardList.get(i));
}
}
}
@ -315,16 +281,13 @@ public final class TakeChallengeRewardScRspOuterClass {
protected int computeSerializedSize() {
int size = 0;
if ((bitField0_ & 0x00000001) != 0) {
size += 1 + ProtoSink.computeUInt32SizeNoTag(starCount);
}
if ((bitField0_ & 0x00000002) != 0) {
size += 1 + ProtoSink.computeUInt32SizeNoTag(groupId);
}
if ((bitField0_ & 0x00000004) != 0) {
if ((bitField0_ & 0x00000002) != 0) {
size += 1 + ProtoSink.computeUInt32SizeNoTag(retcode);
}
if ((bitField0_ & 0x00000008) != 0) {
size += 1 + ProtoSink.computeMessageSizeNoTag(reward);
if ((bitField0_ & 0x00000004) != 0) {
size += (1 * takenRewardList.length()) + ProtoSink.computeRepeatedMessageSizeNoTag(takenRewardList);
}
return size;
}
@ -336,19 +299,10 @@ public final class TakeChallengeRewardScRspOuterClass {
int tag = input.readTag();
while (true) {
switch (tag) {
case 8: {
// starCount
starCount = input.readUInt32();
bitField0_ |= 0x00000001;
tag = input.readTag();
if (tag != 48) {
break;
}
}
case 48: {
// groupId
groupId = input.readUInt32();
bitField0_ |= 0x00000002;
bitField0_ |= 0x00000001;
tag = input.readTag();
if (tag != 112) {
break;
@ -357,17 +311,16 @@ public final class TakeChallengeRewardScRspOuterClass {
case 112: {
// retcode
retcode = input.readUInt32();
bitField0_ |= 0x00000004;
bitField0_ |= 0x00000002;
tag = input.readTag();
if (tag != 122) {
if (tag != 82) {
break;
}
}
case 122: {
// reward
input.readMessage(reward);
bitField0_ |= 0x00000008;
tag = input.readTag();
case 82: {
// takenRewardList
tag = input.readRepeatedMessage(takenRewardList, tag);
bitField0_ |= 0x00000004;
if (tag != 0) {
break;
}
@ -390,16 +343,13 @@ public final class TakeChallengeRewardScRspOuterClass {
public void writeTo(final JsonSink output) throws IOException {
output.beginObject();
if ((bitField0_ & 0x00000001) != 0) {
output.writeUInt32(FieldNames.starCount, starCount);
}
if ((bitField0_ & 0x00000002) != 0) {
output.writeUInt32(FieldNames.groupId, groupId);
}
if ((bitField0_ & 0x00000004) != 0) {
if ((bitField0_ & 0x00000002) != 0) {
output.writeUInt32(FieldNames.retcode, retcode);
}
if ((bitField0_ & 0x00000008) != 0) {
output.writeMessage(FieldNames.reward, reward);
if ((bitField0_ & 0x00000004) != 0) {
output.writeRepeatedMessage(FieldNames.takenRewardList, takenRewardList);
}
output.endObject();
}
@ -411,24 +361,12 @@ public final class TakeChallengeRewardScRspOuterClass {
}
while (!input.isAtEnd()) {
switch (input.readFieldHash()) {
case 2121235933:
case 2124166370: {
if (input.isAtField(FieldNames.starCount)) {
if (!input.trySkipNullValue()) {
starCount = input.readUInt32();
bitField0_ |= 0x00000001;
}
} else {
input.skipUnknownField();
}
break;
}
case 293428218:
case 506361563: {
if (input.isAtField(FieldNames.groupId)) {
if (!input.trySkipNullValue()) {
groupId = input.readUInt32();
bitField0_ |= 0x00000002;
bitField0_ |= 0x00000001;
}
} else {
input.skipUnknownField();
@ -439,18 +377,19 @@ public final class TakeChallengeRewardScRspOuterClass {
if (input.isAtField(FieldNames.retcode)) {
if (!input.trySkipNullValue()) {
retcode = input.readUInt32();
bitField0_ |= 0x00000004;
bitField0_ |= 0x00000002;
}
} else {
input.skipUnknownField();
}
break;
}
case -934326481: {
if (input.isAtField(FieldNames.reward)) {
case -600805228:
case 1027082294: {
if (input.isAtField(FieldNames.takenRewardList)) {
if (!input.trySkipNullValue()) {
input.readMessage(reward);
bitField0_ |= 0x00000008;
input.readRepeatedMessage(takenRewardList);
bitField0_ |= 0x00000004;
}
} else {
input.skipUnknownField();
@ -510,13 +449,11 @@ public final class TakeChallengeRewardScRspOuterClass {
* Contains name constants used for serializing JSON
*/
static class FieldNames {
static final FieldName starCount = FieldName.forField("starCount", "star_count");
static final FieldName groupId = FieldName.forField("groupId", "group_id");
static final FieldName retcode = FieldName.forField("retcode");
static final FieldName reward = FieldName.forField("reward");
static final FieldName takenRewardList = FieldName.forField("takenRewardList", "taken_reward_list");
}
}
}

View File

@ -0,0 +1,361 @@
// Code generated by protocol buffer compiler. Do not edit!
package emu.lunarcore.proto;
import java.io.IOException;
import us.hebi.quickbuf.FieldName;
import us.hebi.quickbuf.InvalidProtocolBufferException;
import us.hebi.quickbuf.JsonSink;
import us.hebi.quickbuf.JsonSource;
import us.hebi.quickbuf.MessageFactory;
import us.hebi.quickbuf.ProtoMessage;
import us.hebi.quickbuf.ProtoSink;
import us.hebi.quickbuf.ProtoSource;
public final class TakenChallengeRewardInfoOuterClass {
/**
* Protobuf type {@code TakenChallengeRewardInfo}
*/
public static final class TakenChallengeRewardInfo extends ProtoMessage<TakenChallengeRewardInfo> implements Cloneable {
private static final long serialVersionUID = 0L;
/**
* <code>optional uint32 star_count = 9;</code>
*/
private int starCount;
/**
* <code>optional .ItemList reward = 14;</code>
*/
private final ItemListOuterClass.ItemList reward = ItemListOuterClass.ItemList.newInstance();
private TakenChallengeRewardInfo() {
}
/**
* @return a new empty instance of {@code TakenChallengeRewardInfo}
*/
public static TakenChallengeRewardInfo newInstance() {
return new TakenChallengeRewardInfo();
}
/**
* <code>optional uint32 star_count = 9;</code>
* @return whether the starCount field is set
*/
public boolean hasStarCount() {
return (bitField0_ & 0x00000001) != 0;
}
/**
* <code>optional uint32 star_count = 9;</code>
* @return this
*/
public TakenChallengeRewardInfo clearStarCount() {
bitField0_ &= ~0x00000001;
starCount = 0;
return this;
}
/**
* <code>optional uint32 star_count = 9;</code>
* @return the starCount
*/
public int getStarCount() {
return starCount;
}
/**
* <code>optional uint32 star_count = 9;</code>
* @param value the starCount to set
* @return this
*/
public TakenChallengeRewardInfo setStarCount(final int value) {
bitField0_ |= 0x00000001;
starCount = value;
return this;
}
/**
* <code>optional .ItemList reward = 14;</code>
* @return whether the reward field is set
*/
public boolean hasReward() {
return (bitField0_ & 0x00000002) != 0;
}
/**
* <code>optional .ItemList reward = 14;</code>
* @return this
*/
public TakenChallengeRewardInfo clearReward() {
bitField0_ &= ~0x00000002;
reward.clear();
return this;
}
/**
* <code>optional .ItemList reward = 14;</code>
*
* This method returns the internal storage object without modifying any has state.
* The returned object should not be modified and be treated as read-only.
*
* Use {@link #getMutableReward()} if you want to modify it.
*
* @return internal storage object for reading
*/
public ItemListOuterClass.ItemList getReward() {
return reward;
}
/**
* <code>optional .ItemList reward = 14;</code>
*
* This method returns the internal storage object and sets the corresponding
* has state. The returned object will become part of this message and its
* contents may be modified as long as the has state is not cleared.
*
* @return internal storage object for modifications
*/
public ItemListOuterClass.ItemList getMutableReward() {
bitField0_ |= 0x00000002;
return reward;
}
/**
* <code>optional .ItemList reward = 14;</code>
* @param value the reward to set
* @return this
*/
public TakenChallengeRewardInfo setReward(final ItemListOuterClass.ItemList value) {
bitField0_ |= 0x00000002;
reward.copyFrom(value);
return this;
}
@Override
public TakenChallengeRewardInfo copyFrom(final TakenChallengeRewardInfo other) {
cachedSize = other.cachedSize;
if ((bitField0_ | other.bitField0_) != 0) {
bitField0_ = other.bitField0_;
starCount = other.starCount;
reward.copyFrom(other.reward);
}
return this;
}
@Override
public TakenChallengeRewardInfo mergeFrom(final TakenChallengeRewardInfo other) {
if (other.isEmpty()) {
return this;
}
cachedSize = -1;
if (other.hasStarCount()) {
setStarCount(other.starCount);
}
if (other.hasReward()) {
getMutableReward().mergeFrom(other.reward);
}
return this;
}
@Override
public TakenChallengeRewardInfo clear() {
if (isEmpty()) {
return this;
}
cachedSize = -1;
bitField0_ = 0;
starCount = 0;
reward.clear();
return this;
}
@Override
public TakenChallengeRewardInfo clearQuick() {
if (isEmpty()) {
return this;
}
cachedSize = -1;
bitField0_ = 0;
reward.clearQuick();
return this;
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof TakenChallengeRewardInfo)) {
return false;
}
TakenChallengeRewardInfo other = (TakenChallengeRewardInfo) o;
return bitField0_ == other.bitField0_
&& (!hasStarCount() || starCount == other.starCount)
&& (!hasReward() || reward.equals(other.reward));
}
@Override
public void writeTo(final ProtoSink output) throws IOException {
if ((bitField0_ & 0x00000001) != 0) {
output.writeRawByte((byte) 72);
output.writeUInt32NoTag(starCount);
}
if ((bitField0_ & 0x00000002) != 0) {
output.writeRawByte((byte) 114);
output.writeMessageNoTag(reward);
}
}
@Override
protected int computeSerializedSize() {
int size = 0;
if ((bitField0_ & 0x00000001) != 0) {
size += 1 + ProtoSink.computeUInt32SizeNoTag(starCount);
}
if ((bitField0_ & 0x00000002) != 0) {
size += 1 + ProtoSink.computeMessageSizeNoTag(reward);
}
return size;
}
@Override
@SuppressWarnings("fallthrough")
public TakenChallengeRewardInfo mergeFrom(final ProtoSource input) throws IOException {
// Enabled Fall-Through Optimization (QuickBuffers)
int tag = input.readTag();
while (true) {
switch (tag) {
case 72: {
// starCount
starCount = input.readUInt32();
bitField0_ |= 0x00000001;
tag = input.readTag();
if (tag != 114) {
break;
}
}
case 114: {
// reward
input.readMessage(reward);
bitField0_ |= 0x00000002;
tag = input.readTag();
if (tag != 0) {
break;
}
}
case 0: {
return this;
}
default: {
if (!input.skipField(tag)) {
return this;
}
tag = input.readTag();
break;
}
}
}
}
@Override
public void writeTo(final JsonSink output) throws IOException {
output.beginObject();
if ((bitField0_ & 0x00000001) != 0) {
output.writeUInt32(FieldNames.starCount, starCount);
}
if ((bitField0_ & 0x00000002) != 0) {
output.writeMessage(FieldNames.reward, reward);
}
output.endObject();
}
@Override
public TakenChallengeRewardInfo mergeFrom(final JsonSource input) throws IOException {
if (!input.beginObject()) {
return this;
}
while (!input.isAtEnd()) {
switch (input.readFieldHash()) {
case 2121235933:
case 2124166370: {
if (input.isAtField(FieldNames.starCount)) {
if (!input.trySkipNullValue()) {
starCount = input.readUInt32();
bitField0_ |= 0x00000001;
}
} else {
input.skipUnknownField();
}
break;
}
case -934326481: {
if (input.isAtField(FieldNames.reward)) {
if (!input.trySkipNullValue()) {
input.readMessage(reward);
bitField0_ |= 0x00000002;
}
} else {
input.skipUnknownField();
}
break;
}
default: {
input.skipUnknownField();
break;
}
}
}
input.endObject();
return this;
}
@Override
public TakenChallengeRewardInfo clone() {
return new TakenChallengeRewardInfo().copyFrom(this);
}
@Override
public boolean isEmpty() {
return ((bitField0_) == 0);
}
public static TakenChallengeRewardInfo parseFrom(final byte[] data) throws
InvalidProtocolBufferException {
return ProtoMessage.mergeFrom(new TakenChallengeRewardInfo(), data).checkInitialized();
}
public static TakenChallengeRewardInfo parseFrom(final ProtoSource input) throws IOException {
return ProtoMessage.mergeFrom(new TakenChallengeRewardInfo(), input).checkInitialized();
}
public static TakenChallengeRewardInfo parseFrom(final JsonSource input) throws IOException {
return ProtoMessage.mergeFrom(new TakenChallengeRewardInfo(), input).checkInitialized();
}
/**
* @return factory for creating TakenChallengeRewardInfo messages
*/
public static MessageFactory<TakenChallengeRewardInfo> getFactory() {
return TakenChallengeRewardInfoFactory.INSTANCE;
}
private enum TakenChallengeRewardInfoFactory implements MessageFactory<TakenChallengeRewardInfo> {
INSTANCE;
@Override
public TakenChallengeRewardInfo create() {
return TakenChallengeRewardInfo.newInstance();
}
}
/**
* Contains name constants used for serializing JSON
*/
static class FieldNames {
static final FieldName starCount = FieldName.forField("starCount", "star_count");
static final FieldName reward = FieldName.forField("reward");
}
}
}

View File

@ -46,7 +46,6 @@ public class GameData {
@Getter private static Int2ObjectMap<ChallengeGroupExcel> challengeGroupExcelMap = new Int2ObjectOpenHashMap<>();
@Getter private static Int2ObjectMap<ChallengeExcel> challengeExcelMap = new Int2ObjectOpenHashMap<>();
@Getter private static Int2ObjectMap<ChallengeTargetExcel> challengeTargetExcelMap = new Int2ObjectOpenHashMap<>();
private static Int2ObjectMap<ChallengeRewardExcel> challengeRewardExcelMap = new Int2ObjectOpenHashMap<>();
@Getter private static Int2ObjectMap<RogueManagerExcel> rogueManagerExcelMap = new Int2ObjectOpenHashMap<>();
@Getter private static Int2ObjectMap<RogueTalentExcel> rogueTalentExcelMap = new Int2ObjectOpenHashMap<>();
@ -221,10 +220,6 @@ public class GameData {
return monsterDropExcelMap.get((monsterNpcId << 4) + worldLevel);
}
public static ChallengeRewardExcel getChallengeRewardExcel(int groupId, int starCount) {
return challengeRewardExcelMap.get((groupId << 16) + starCount);
}
public static RogueMapExcel getRogueMapExcel(int rogueMapId, int siteId) {
return rogueMapExcelMap.get((rogueMapId << 8) + siteId);
}

View File

@ -24,6 +24,9 @@ public class GameDepot {
// Relics
private static Int2ObjectMap<List<RelicMainAffixExcel>> relicMainAffixDepot = new Int2ObjectOpenHashMap<>();
private static Int2ObjectMap<List<RelicSubAffixExcel>> relicSubAffixDepot = new Int2ObjectOpenHashMap<>();
// Challenges
@Getter private static Int2ObjectMap<List<ChallengeRewardExcel>> challengeRewardLines = new Int2ObjectOpenHashMap<>();
// Rogue
@Getter private static Int2ObjectMap<int[]> rogueMapGen = new Int2ObjectOpenHashMap<>();

View File

@ -3,6 +3,7 @@ package emu.lunarcore.data.common;
import com.google.gson.annotations.SerializedName;
import emu.lunarcore.proto.ItemCostOuterClass.ItemCost;
import emu.lunarcore.proto.ItemOuterClass.Item;
import lombok.Getter;
@Getter
@ -48,4 +49,10 @@ public class ItemParam {
public static enum ItemParamType {
UNKNOWN, PILE, UNIQUE;
}
public Item toProto() {
return Item.newInstance()
.setItemId(this.getId())
.setNum(this.getCount());
}
}

View File

@ -5,7 +5,7 @@ import emu.lunarcore.data.ResourceType;
import lombok.Getter;
@Getter
@ResourceType(name = {"ChallengeGroupConfig.json"})
@ResourceType(name = {"ChallengeGroupConfig.json", "ChallengeStoryGroupConfig.json"})
public class ChallengeGroupExcel extends GameResource {
private int GroupID;
private int RewardLineGroupID;

View File

@ -1,11 +1,15 @@
package emu.lunarcore.data.excel;
import java.util.ArrayList;
import emu.lunarcore.data.GameDepot;
import emu.lunarcore.data.GameResource;
import emu.lunarcore.data.ResourceType;
import emu.lunarcore.data.ResourceType.LoadPriority;
import lombok.Getter;
@Getter
@ResourceType(name = {"ChallengeMazeRewardLine.json"})
@ResourceType(name = {"ChallengeMazeRewardLine.json", "ChallengeStoryRewardLine.json"}, loadPriority = LoadPriority.LOW)
public class ChallengeRewardExcel extends GameResource {
private int GroupID;
private int StarCount;
@ -15,4 +19,10 @@ public class ChallengeRewardExcel extends GameResource {
public int getId() {
return (GroupID << 16) + StarCount;
}
@Override
public void onLoad() {
var rewardLine = GameDepot.getChallengeRewardLines().computeIfAbsent(GroupID, id -> new ArrayList<>());
rewardLine.add(this);
}
}

View File

@ -1,18 +1,21 @@
package emu.lunarcore.game.challenge;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
import emu.lunarcore.GameConstants;
import emu.lunarcore.LunarCore;
import emu.lunarcore.data.GameData;
import emu.lunarcore.data.GameDepot;
import emu.lunarcore.data.common.ItemParam;
import emu.lunarcore.data.excel.ChallengeExcel;
import emu.lunarcore.game.inventory.GameItem;
import emu.lunarcore.game.player.BasePlayerManager;
import emu.lunarcore.game.player.Player;
import emu.lunarcore.game.player.lineup.PlayerLineup;
import emu.lunarcore.proto.ExtraLineupTypeOuterClass.ExtraLineupType;
import emu.lunarcore.proto.StartChallengeStoryBuffInfoOuterClass.StartChallengeStoryBuffInfo;
import emu.lunarcore.proto.TakenChallengeRewardInfoOuterClass.TakenChallengeRewardInfo;
import emu.lunarcore.server.packet.Retcode;
import emu.lunarcore.server.packet.send.PacketStartChallengeScRsp;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
@ -119,18 +122,15 @@ public class ChallengeManager extends BasePlayerManager {
info.save();
}
public synchronized List<GameItem> takeRewards(int groupId, int starCount) {
public synchronized List<TakenChallengeRewardInfo> takeRewards(int groupId) {
// Get excels
var challengeGroup = GameData.getChallengeGroupExcelMap().get(groupId);
if (challengeGroup == null) return null;
var challengeReward = GameData.getChallengeRewardExcel(challengeGroup.getRewardLineGroupID(), starCount);
if (challengeReward == null) return null;
var challengeRewardLine = GameDepot.getChallengeRewardLines().get(challengeGroup.getRewardLineGroupID());
if (challengeRewardLine == null) return null;
var rewardExcel = GameData.getRewardExcelMap().get(challengeReward.getRewardID());
if (rewardExcel == null) return null;
// Validate
// Get total stars
int totalStars = 0;
for (ChallengeHistory ch : this.getHistory().values()) {
// Legacy compatibility
@ -148,22 +148,47 @@ public class ChallengeManager extends BasePlayerManager {
}
}
// Check if the player has enough stars
if (totalStars < starCount) {
return null;
// Rewards
List<TakenChallengeRewardInfo> rewardInfos = new ArrayList<>();
List<ItemParam> rewardItems = new ArrayList<>();
// Get challenge rewards
for (var challengeReward : challengeRewardLine) {
// Check if we have enough stars to take this reward
if (totalStars < challengeReward.getStarCount()) {
continue;
}
// Get reward info
var reward = this.getTakenRewards().computeIfAbsent(groupId, id -> new ChallengeGroupReward(getPlayer(), groupId));
// Check if reward has been taken
if (reward.hasTakenReward(challengeReward.getStarCount())) {
continue;
}
// Set reward as taken
reward.setTakenReward(challengeReward.getStarCount());
// Get reward excel
var rewardExcel = GameData.getRewardExcelMap().get(challengeReward.getRewardID());
if (rewardExcel == null) continue;
// Add rewards
var proto = TakenChallengeRewardInfo.newInstance()
.setStarCount(challengeReward.getStarCount());
for (ItemParam itemParam : rewardExcel.getRewards()) {
proto.getMutableReward().addItemList(itemParam.toProto());
rewardItems.add(itemParam);
}
rewardInfos.add(proto);
}
// Get reward info
var reward = this.getTakenRewards().computeIfAbsent(groupId, id -> new ChallengeGroupReward(getPlayer(), groupId));
if (reward.hasTakenReward(starCount)) {
return null;
}
reward.setTakenReward(starCount);
// Add items to inventory
return getPlayer().getInventory().addItemParams(rewardExcel.getRewards());
getPlayer().getInventory().addItemParams(rewardItems);
return rewardInfos;
}
public void loadFromDatabase() {

View File

@ -2,8 +2,8 @@ package emu.lunarcore.server.packet.recv;
import java.util.List;
import emu.lunarcore.game.inventory.GameItem;
import emu.lunarcore.proto.TakeChallengeRewardCsReqOuterClass.TakeChallengeRewardCsReq;
import emu.lunarcore.proto.TakenChallengeRewardInfoOuterClass.TakenChallengeRewardInfo;
import emu.lunarcore.server.game.GameSession;
import emu.lunarcore.server.packet.CmdId;
import emu.lunarcore.server.packet.Opcodes;
@ -17,8 +17,8 @@ public class HandlerTakeChallengeRewardCsReq extends PacketHandler {
public void handle(GameSession session, byte[] data) throws Exception {
var req = TakeChallengeRewardCsReq.parseFrom(data);
List<GameItem> rewards = session.getPlayer().getChallengeManager().takeRewards(req.getGroupId(), req.getStarCount());
session.send(new PacketTakeChallengeRewardScRsp(req.getGroupId(), req.getStarCount(), rewards));
List<TakenChallengeRewardInfo> rewardInfos = session.getPlayer().getChallengeManager().takeRewards(req.getGroupId());
session.send(new PacketTakeChallengeRewardScRsp(req.getGroupId(), rewardInfos));
}
}

View File

@ -2,24 +2,23 @@ package emu.lunarcore.server.packet.send;
import java.util.Collection;
import emu.lunarcore.game.inventory.GameItem;
import emu.lunarcore.proto.TakeChallengeRewardScRspOuterClass.TakeChallengeRewardScRsp;
import emu.lunarcore.proto.TakenChallengeRewardInfoOuterClass.TakenChallengeRewardInfo;
import emu.lunarcore.server.packet.BasePacket;
import emu.lunarcore.server.packet.CmdId;
public class PacketTakeChallengeRewardScRsp extends BasePacket {
public PacketTakeChallengeRewardScRsp(int groupId, int starCount, Collection<GameItem> rewards) {
public PacketTakeChallengeRewardScRsp(int groupId, Collection<TakenChallengeRewardInfo> rewards) {
super(CmdId.TakeChallengeRewardScRsp);
var data = TakeChallengeRewardScRsp.newInstance();
if (rewards != null) {
data.setGroupId(groupId)
.setStarCount(starCount);
data.setGroupId(groupId);
for (GameItem item : rewards) {
data.getMutableReward().addItemList(item.toProto());
for (var rewardInfo : rewards) {
data.getMutableTakenRewardList().add(rewardInfo);
}
} else {
data.setRetcode(1);