mirror of
https://github.com/Melledy/Nebula.git
synced 2026-09-19 17:19:58 +02: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 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
|
||||||
this.read = true;
|
if (readType == 1) {
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user