Implement disc memory recollection properly

This commit is contained in:
Melledy
2025-11-07 21:20:31 -08:00
parent f1a95b77e9
commit 8cc08df65c
2 changed files with 27 additions and 9 deletions
@@ -36,7 +36,9 @@ public class GameDisc implements GameDatabaseObject {
private int exp; private int exp;
private int phase; private int phase;
private int star; private int star;
private boolean read; private boolean read;
private boolean avg;
private long createTime; private long createTime;
@@ -233,15 +235,23 @@ public class GameDisc implements GameDatabaseObject {
return change.setSuccess(true); return change.setSuccess(true);
} }
public PlayerChangeInfo receiveReadReward() { public PlayerChangeInfo receiveReadReward(int readType) {
// Sanity check
if (readType == 1) {
if (this.isRead()) {
return null;
}
} else if (readType == 2) {
if (this.isAvg()) {
return null;
}
} else {
return null;
}
// Create change info // Create change info
var change = new PlayerChangeInfo(); var change = new PlayerChangeInfo();
// Sanity check
if (this.isRead()) {
return change;
}
// Add reward // Add reward
if (this.getData().getReadReward() != null) { if (this.getData().getReadReward() != null) {
int id = getData().getReadReward()[0]; int id = getData().getReadReward()[0];
@@ -250,8 +260,14 @@ public class GameDisc implements GameDatabaseObject {
this.getPlayer().getInventory().addItem(id, count, change); this.getPlayer().getInventory().addItem(id, count, change);
} }
// Set read flag // Set flag
if (readType == 1) {
this.read = true; this.read = true;
} else if (readType == 2) {
this.avg = true;
}
// Save to database
this.save(); this.save();
// Success // Success
@@ -268,6 +284,7 @@ public class GameDisc implements GameDatabaseObject {
.setPhase(this.getPhase()) .setPhase(this.getPhase())
.setStar(this.getStar()) .setStar(this.getStar())
.setRead(this.isRead()) .setRead(this.isRead())
.setAvg(this.isAvg())
.setCreateTime(this.getCreateTime()); .setCreateTime(this.getCreateTime());
return proto; return proto;
@@ -21,7 +21,8 @@ public class HandlerDiscReadRewardReceiveReq extends NetHandler {
} }
// Set read reward // Set read reward
var change = disc.receiveReadReward(); var change = disc.receiveReadReward(req.getReadTypeValue());
if (change == null) { if (change == null) {
return session.encodeMsg(NetMsgId.disc_read_reward_receive_failed_ack); return session.encodeMsg(NetMsgId.disc_read_reward_receive_failed_ack);
} }