Update to the latest version, also implement daily mall gift

This commit is contained in:
Melledy
2026-02-23 21:06:26 -08:00
parent 300a838e06
commit 8809b1646e
6 changed files with 76 additions and 20 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ import emu.nebula.game.inventory.ItemParam;
import emu.nebula.util.WeightedList; import emu.nebula.util.WeightedList;
public class GameConstants { public class GameConstants {
public static final String VERSION = "1.6.0"; public static final String VERSION = "1.7.0";
public static int DATA_VERSION = 0; public static int DATA_VERSION = 0;
public static final ZoneId UTC_ZONE = ZoneId.of("UTC"); public static final ZoneId UTC_ZONE = ZoneId.of("UTC");
@@ -35,9 +35,14 @@ public class ActivityModule extends GameContextModule {
//this.activities.add(1010304); //this.activities.add(1010304);
// Springseek Festival // Springseek Festival
this.activities.add(1010401); //this.activities.add(1010401);
this.activities.add(1010403); //this.activities.add(1010403);
this.activities.add(1010404); //this.activities.add(1010404);
// Winter Requiem and the Trigger of Dawn
this.activities.add(1010501);
this.activities.add(1010503);
this.activities.add(1010504);
// ===== Etc Events ===== // ===== Etc Events =====
@@ -887,7 +887,8 @@ public class Player implements GameDatabaseObject {
.setServerTs(Nebula.getCurrentServerTime()) .setServerTs(Nebula.getCurrentServerTime())
.setSigninIndex(this.getSignInIndex()) .setSigninIndex(this.getSignInIndex())
.setTowerTicket(this.getProgress().getTowerTickets()) .setTowerTicket(this.getProgress().getTowerTickets())
.setDailyShopRewardStatus(this.getQuestManager().hasDailyReward()) .setDailyShopRewardStatus(this.getQuestManager().hasDailyShopReward())
.setDailyMallRewardStatus(this.getQuestManager().hasDailyMallReward())
.setMusicInfo(this.getMusic()) .setMusicInfo(this.getMusic())
.setAchievements(new byte[64]); .setAchievements(new byte[64]);
@@ -43,8 +43,9 @@ public class QuestManager extends PlayerManager implements GameDatabaseObject {
// Level rewards // Level rewards
private Bitset levelRewards; private Bitset levelRewards;
@Getter(AccessLevel.NONE) // Claimed daily rewards
private boolean hasDailyReward; @Getter(AccessLevel.NONE) private boolean dailyShopReward;
@Getter(AccessLevel.NONE) private boolean dailyMallReward;
@Deprecated // Morphia only @Deprecated // Morphia only
public QuestManager() { public QuestManager() {
@@ -58,7 +59,6 @@ public class QuestManager extends PlayerManager implements GameDatabaseObject {
this.claimedWeeklyIds = new IntOpenHashSet(); this.claimedWeeklyIds = new IntOpenHashSet();
this.list = new HashMap<>(); this.list = new HashMap<>();
this.levelRewards = new Bitset(); this.levelRewards = new Bitset();
this.hasDailyReward = true;
this.resetDailyQuests(true); this.resetDailyQuests(true);
@@ -79,8 +79,12 @@ public class QuestManager extends PlayerManager implements GameDatabaseObject {
return this.getList().values(); return this.getList().values();
} }
public boolean hasDailyReward() { public boolean hasDailyShopReward() {
return this.hasDailyReward; return !this.dailyShopReward;
}
public boolean hasDailyMallReward() {
return !this.dailyMallReward;
} }
public void saveLevelRewards() { public void saveLevelRewards() {
@@ -128,8 +132,9 @@ public class QuestManager extends PlayerManager implements GameDatabaseObject {
// Reset activity // Reset activity
this.claimedActiveIds.clear(); this.claimedActiveIds.clear();
// Reset daily shop reward // Reset daily shop rewards
this.hasDailyReward = true; this.dailyShopReward = false;
this.dailyMallReward = false;
// Persist to database // Persist to database
this.save(); this.save();
@@ -466,7 +471,7 @@ public class QuestManager extends PlayerManager implements GameDatabaseObject {
public PlayerChangeInfo claimDailyShopGift() { public PlayerChangeInfo claimDailyShopGift() {
// Sanity check // Sanity check
if (!this.hasDailyReward) { if (!this.hasDailyShopReward()) {
return null; return null;
} }
@@ -475,8 +480,29 @@ public class QuestManager extends PlayerManager implements GameDatabaseObject {
var change = this.getPlayer().getInventory().addItem(reward.getId(), reward.getCount()); var change = this.getPlayer().getInventory().addItem(reward.getId(), reward.getCount());
// Set and update in database // Set and update in database
this.hasDailyReward = false; this.dailyShopReward = true;
Nebula.getGameDatabase().update(this, this.getUid(), "hasDailyReward", this.hasDailyReward); Nebula.getGameDatabase().update(this, this.getUid(), "dailyShopReward", this.dailyShopReward);
// Trigger quest
this.getPlayer().trigger(QuestCondition.DailyShopReceiveShopTotal, 1);
// Success
return change.setSuccess(true);
}
public PlayerChangeInfo claimDailyMallGift() {
// Sanity check
if (!this.hasDailyMallReward()) {
return null;
}
// Daily mall reward
var reward = GameConstants.DAILY_GIFTS.next();
var change = this.getPlayer().getInventory().addItem(reward.getId(), reward.getCount());
// Set and update in database
this.dailyMallReward = true;
Nebula.getGameDatabase().update(this, this.getUid(), "dailyMallReward", this.dailyMallReward);
// Trigger quest // Trigger quest
this.getPlayer().trigger(QuestCondition.DailyShopReceiveShopTotal, 1); this.getPlayer().trigger(QuestCondition.DailyShopReceiveShopTotal, 1);
@@ -0,0 +1,24 @@
package emu.nebula.server.handlers;
import emu.nebula.net.NetHandler;
import emu.nebula.net.NetMsgId;
import emu.nebula.net.HandlerId;
import emu.nebula.net.GameSession;
@HandlerId(NetMsgId.daily_mall_reward_receive_req)
public class HandlerDailyMallRewardReceiveReq extends NetHandler {
@Override
public byte[] handle(GameSession session, byte[] message) throws Exception {
// Claim daily reward
var change = session.getPlayer().getQuestManager().claimDailyMallGift();
if (change == null) {
return session.encodeMsg(NetMsgId.daily_mall_reward_receive_failed_ack);
}
// Encode and send
return session.encodeMsg(NetMsgId.daily_mall_reward_receive_succeed_ack, change.toProto());
}
}
+5 -5
View File
@@ -1,7 +1,7 @@
{ {
"global": 86, "global": 87,
"kr": 93, "kr": 94,
"jp": 90, "jp": 91,
"tw": 96, "tw": 97,
"cn": 89 "cn": 90
} }