mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-12 12:24:35 +01:00
Implement disc memory recollection properly
This commit is contained in:
@@ -36,7 +36,9 @@ public class GameDisc implements GameDatabaseObject {
|
||||
private int exp;
|
||||
private int phase;
|
||||
private int star;
|
||||
|
||||
private boolean read;
|
||||
private boolean avg;
|
||||
|
||||
private long createTime;
|
||||
|
||||
@@ -233,15 +235,23 @@ public class GameDisc implements GameDatabaseObject {
|
||||
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
|
||||
var change = new PlayerChangeInfo();
|
||||
|
||||
// Sanity check
|
||||
if (this.isRead()) {
|
||||
return change;
|
||||
}
|
||||
|
||||
// Add reward
|
||||
if (this.getData().getReadReward() != null) {
|
||||
int id = getData().getReadReward()[0];
|
||||
@@ -250,8 +260,14 @@ public class GameDisc implements GameDatabaseObject {
|
||||
this.getPlayer().getInventory().addItem(id, count, change);
|
||||
}
|
||||
|
||||
// Set read flag
|
||||
this.read = true;
|
||||
// Set flag
|
||||
if (readType == 1) {
|
||||
this.read = true;
|
||||
} else if (readType == 2) {
|
||||
this.avg = true;
|
||||
}
|
||||
|
||||
// Save to database
|
||||
this.save();
|
||||
|
||||
// Success
|
||||
@@ -268,6 +284,7 @@ public class GameDisc implements GameDatabaseObject {
|
||||
.setPhase(this.getPhase())
|
||||
.setStar(this.getStar())
|
||||
.setRead(this.isRead())
|
||||
.setAvg(this.isAvg())
|
||||
.setCreateTime(this.getCreateTime());
|
||||
|
||||
return proto;
|
||||
|
||||
@@ -21,7 +21,8 @@ public class HandlerDiscReadRewardReceiveReq extends NetHandler {
|
||||
}
|
||||
|
||||
// Set read reward
|
||||
var change = disc.receiveReadReward();
|
||||
var change = disc.receiveReadReward(req.getReadTypeValue());
|
||||
|
||||
if (change == null) {
|
||||
return session.encodeMsg(NetMsgId.disc_read_reward_receive_failed_ack);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user