mirror of
https://github.com/Melledy/Nebula.git
synced 2026-09-19 17:19:58 +02:00
Update to the latest version, also implement daily mall gift
This commit is contained in:
@@ -6,7 +6,7 @@ import emu.nebula.game.inventory.ItemParam;
|
||||
import emu.nebula.util.WeightedList;
|
||||
|
||||
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 final ZoneId UTC_ZONE = ZoneId.of("UTC");
|
||||
|
||||
@@ -35,9 +35,14 @@ public class ActivityModule extends GameContextModule {
|
||||
//this.activities.add(1010304);
|
||||
|
||||
// Springseek Festival
|
||||
this.activities.add(1010401);
|
||||
this.activities.add(1010403);
|
||||
this.activities.add(1010404);
|
||||
//this.activities.add(1010401);
|
||||
//this.activities.add(1010403);
|
||||
//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 =====
|
||||
|
||||
|
||||
@@ -887,7 +887,8 @@ public class Player implements GameDatabaseObject {
|
||||
.setServerTs(Nebula.getCurrentServerTime())
|
||||
.setSigninIndex(this.getSignInIndex())
|
||||
.setTowerTicket(this.getProgress().getTowerTickets())
|
||||
.setDailyShopRewardStatus(this.getQuestManager().hasDailyReward())
|
||||
.setDailyShopRewardStatus(this.getQuestManager().hasDailyShopReward())
|
||||
.setDailyMallRewardStatus(this.getQuestManager().hasDailyMallReward())
|
||||
.setMusicInfo(this.getMusic())
|
||||
.setAchievements(new byte[64]);
|
||||
|
||||
|
||||
@@ -43,8 +43,9 @@ public class QuestManager extends PlayerManager implements GameDatabaseObject {
|
||||
// Level rewards
|
||||
private Bitset levelRewards;
|
||||
|
||||
@Getter(AccessLevel.NONE)
|
||||
private boolean hasDailyReward;
|
||||
// Claimed daily rewards
|
||||
@Getter(AccessLevel.NONE) private boolean dailyShopReward;
|
||||
@Getter(AccessLevel.NONE) private boolean dailyMallReward;
|
||||
|
||||
@Deprecated // Morphia only
|
||||
public QuestManager() {
|
||||
@@ -58,7 +59,6 @@ public class QuestManager extends PlayerManager implements GameDatabaseObject {
|
||||
this.claimedWeeklyIds = new IntOpenHashSet();
|
||||
this.list = new HashMap<>();
|
||||
this.levelRewards = new Bitset();
|
||||
this.hasDailyReward = true;
|
||||
|
||||
this.resetDailyQuests(true);
|
||||
|
||||
@@ -79,8 +79,12 @@ public class QuestManager extends PlayerManager implements GameDatabaseObject {
|
||||
return this.getList().values();
|
||||
}
|
||||
|
||||
public boolean hasDailyReward() {
|
||||
return this.hasDailyReward;
|
||||
public boolean hasDailyShopReward() {
|
||||
return !this.dailyShopReward;
|
||||
}
|
||||
|
||||
public boolean hasDailyMallReward() {
|
||||
return !this.dailyMallReward;
|
||||
}
|
||||
|
||||
public void saveLevelRewards() {
|
||||
@@ -128,8 +132,9 @@ public class QuestManager extends PlayerManager implements GameDatabaseObject {
|
||||
// Reset activity
|
||||
this.claimedActiveIds.clear();
|
||||
|
||||
// Reset daily shop reward
|
||||
this.hasDailyReward = true;
|
||||
// Reset daily shop rewards
|
||||
this.dailyShopReward = false;
|
||||
this.dailyMallReward = false;
|
||||
|
||||
// Persist to database
|
||||
this.save();
|
||||
@@ -466,7 +471,7 @@ public class QuestManager extends PlayerManager implements GameDatabaseObject {
|
||||
|
||||
public PlayerChangeInfo claimDailyShopGift() {
|
||||
// Sanity check
|
||||
if (!this.hasDailyReward) {
|
||||
if (!this.hasDailyShopReward()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -475,8 +480,29 @@ public class QuestManager extends PlayerManager implements GameDatabaseObject {
|
||||
var change = this.getPlayer().getInventory().addItem(reward.getId(), reward.getCount());
|
||||
|
||||
// Set and update in database
|
||||
this.hasDailyReward = false;
|
||||
Nebula.getGameDatabase().update(this, this.getUid(), "hasDailyReward", this.hasDailyReward);
|
||||
this.dailyShopReward = true;
|
||||
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
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"global": 86,
|
||||
"kr": 93,
|
||||
"jp": 90,
|
||||
"tw": 96,
|
||||
"cn": 89
|
||||
"global": 87,
|
||||
"kr": 94,
|
||||
"jp": 91,
|
||||
"tw": 97,
|
||||
"cn": 90
|
||||
}
|
||||
Reference in New Issue
Block a user