mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-12 12:24:35 +01:00
Fix weekly boss entry tickets and rewards
This commit is contained in:
@@ -38,6 +38,7 @@ public class GameConstants {
|
||||
public static final int PREM_GEM_ITEM_ID = 3;
|
||||
public static final int ENERGY_BUY_ITEM_ID = GEM_ITEM_ID;
|
||||
public static final int EXP_ITEM_ID = 21;
|
||||
public static final int WEEKLY_ENTRY_ITEM_ID = 28;
|
||||
|
||||
public static final int MAX_ENERGY = 240;
|
||||
public static final int ENERGY_REGEN_TIME = 360; // Seconds
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package emu.nebula.data.resources;
|
||||
|
||||
import emu.nebula.data.BaseDef;
|
||||
import emu.nebula.data.GameData;
|
||||
import emu.nebula.data.ResourceType;
|
||||
import emu.nebula.data.ResourceType.LoadPriority;
|
||||
import emu.nebula.game.instance.InstanceData;
|
||||
import emu.nebula.game.inventory.ItemRewardList;
|
||||
import emu.nebula.game.inventory.ItemRewardParam;
|
||||
@@ -10,9 +12,10 @@ import emu.nebula.util.JsonUtils;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@ResourceType(name = "WeekBossLevel.json")
|
||||
@ResourceType(name = "WeekBossLevel.json", loadPriority = LoadPriority.LOW)
|
||||
public class WeekBossLevelDef extends BaseDef implements InstanceData {
|
||||
private int Id;
|
||||
private int Difficulty;
|
||||
private int PreLevelId;
|
||||
private int NeedWorldClass;
|
||||
private String BaseAwardPreview;
|
||||
@@ -44,14 +47,33 @@ public class WeekBossLevelDef extends BaseDef implements InstanceData {
|
||||
for (int[] award : awards) {
|
||||
int itemId = award[0];
|
||||
int min = award[1];
|
||||
int max = award.length >= 4 ? award[2] : min;
|
||||
int max = award[1];
|
||||
boolean isFirst = award[award.length - 1] == 1;
|
||||
|
||||
// Set reward count based on difficulty
|
||||
if (min == -1) {
|
||||
min = 0;
|
||||
max = 1;
|
||||
min = this.Difficulty;
|
||||
max = this.Difficulty;
|
||||
|
||||
var item = GameData.getItemDataTable().get(itemId);
|
||||
if (item != null) {
|
||||
switch (item.getRarity()) {
|
||||
case 2:
|
||||
max = this.Difficulty * 3;
|
||||
break;
|
||||
case 3:
|
||||
min = this.Difficulty * 2;
|
||||
max = this.Difficulty * 6;
|
||||
break;
|
||||
case 4:
|
||||
min = this.Difficulty * 3;
|
||||
max = this.Difficulty * 9;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create reward param
|
||||
var reward = new ItemRewardParam(itemId, min, max);
|
||||
|
||||
if (isFirst) {
|
||||
|
||||
@@ -138,4 +138,54 @@ public class InstanceManager extends PlayerManager {
|
||||
return change.setSuccess(true);
|
||||
}
|
||||
|
||||
public PlayerChangeInfo settleWeekly(InstanceData data, boolean win) {
|
||||
// Calculate settle data
|
||||
var settleData = new InstanceSettleData();
|
||||
|
||||
settleData.setWin(win);
|
||||
settleData.setFirst(settleData.isWin() && !getProgress().getWeekBossLog().containsKey(data.getId()));
|
||||
|
||||
// Init player change info
|
||||
var change = new PlayerChangeInfo();
|
||||
|
||||
// Handle win
|
||||
if (settleData.isWin()) {
|
||||
// Calculate rewards
|
||||
int entries = this.getPlayer().getInventory().getResourceCount(GameConstants.WEEKLY_ENTRY_ITEM_ID);
|
||||
|
||||
if (entries > 0) {
|
||||
// Generate regular rewards
|
||||
settleData.setRewards(data.getRewards().generate());
|
||||
|
||||
// Add regular rewards
|
||||
getPlayer().getInventory().addItems(settleData.getRewards(), change);
|
||||
|
||||
// Remove weekly entry
|
||||
getPlayer().getInventory().removeItem(GameConstants.WEEKLY_ENTRY_ITEM_ID, 1, change);
|
||||
}
|
||||
|
||||
// Add first clear rewards even if we dont have the entry ticket
|
||||
if (settleData.isFirst()) {
|
||||
// Generate first clear rewards
|
||||
settleData.setRewards(data.getFirstRewards().generate());
|
||||
|
||||
// Add to inventory
|
||||
getPlayer().getInventory().addItems(settleData.getFirstRewards(), change);
|
||||
}
|
||||
|
||||
// Log
|
||||
this.getProgress().saveInstanceLog(getProgress().getWeekBossLog(), "weekBossLog", data.getId(), 1);
|
||||
|
||||
// Quest triggers
|
||||
this.getPlayer().trigger(QuestCondition.WeekBoosClearSpecificDifficultyAndTotal, 1);
|
||||
this.getPlayer().trigger(QuestCondition.BattleTotal, 1);
|
||||
}
|
||||
|
||||
// Set extra data
|
||||
change.setExtraData(settleData);
|
||||
|
||||
// Success
|
||||
return change.setSuccess(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -627,6 +627,12 @@ public class Player implements GameDatabaseObject {
|
||||
// Trigger quest/achievement login
|
||||
this.trigger(QuestCondition.LoginTotal, 1);
|
||||
|
||||
// Add weekly boss entry item
|
||||
int entries = this.getInventory().getResourceCount(GameConstants.WEEKLY_ENTRY_ITEM_ID);
|
||||
if (entries < 3) {
|
||||
this.getInventory().addItem(GameConstants.WEEKLY_ENTRY_ITEM_ID, 3 - entries);
|
||||
}
|
||||
|
||||
// Update last epoch day
|
||||
this.lastEpochDay = Nebula.getGameContext().getEpochDays();
|
||||
Nebula.getGameDatabase().update(this, this.getUid(), "lastEpochDay", this.lastEpochDay);
|
||||
@@ -720,6 +726,11 @@ public class Player implements GameDatabaseObject {
|
||||
this.loaded = true;
|
||||
}
|
||||
|
||||
public void onCreate() {
|
||||
// Send welcome mail
|
||||
this.getMailbox().sendWelcomeMail();
|
||||
}
|
||||
|
||||
public void onLogin() {
|
||||
// See if we need to reset dailies
|
||||
this.checkResetDailies();
|
||||
|
||||
@@ -132,12 +132,13 @@ public class PlayerModule extends GameContextModule {
|
||||
player.onLoad();
|
||||
player.save();
|
||||
|
||||
// Send welcome mail
|
||||
player.getMailbox().sendWelcomeMail();
|
||||
// Handle any player creation events
|
||||
player.onCreate();
|
||||
|
||||
// Put in player cache
|
||||
this.addToCache(player);
|
||||
|
||||
// Complete
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import emu.nebula.proto.WeekBossSettle.WeekBossSettleReq;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.data.GameData;
|
||||
import emu.nebula.game.instance.InstanceSettleData;
|
||||
import emu.nebula.game.quest.QuestCondition;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.week_boss_settle_req)
|
||||
@@ -28,12 +27,9 @@ public class HandlerWeekBossSettleReq extends NetHandler {
|
||||
var req = WeekBossSettleReq.parseFrom(message);
|
||||
|
||||
// Settle instance
|
||||
var changes = player.getInstanceManager().settleInstance(
|
||||
var changes = player.getInstanceManager().settleWeekly(
|
||||
data,
|
||||
QuestCondition.WeekBoosClearSpecificDifficultyAndTotal,
|
||||
player.getProgress().getWeekBossLog(),
|
||||
"weekBossLog",
|
||||
req.getResult() ? 1 : 0
|
||||
req.getResult()
|
||||
);
|
||||
|
||||
var settleData = (InstanceSettleData) changes.getExtraData();
|
||||
|
||||
Reference in New Issue
Block a user