mirror of
https://github.com/Melledy/Nebula.git
synced 2026-09-20 01:29:54 +02:00
Players now get shadow siege requests/permits from spending energy
This commit is contained in:
@@ -591,32 +591,10 @@ public class Inventory extends PlayerManager implements GameDatabaseObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case TraceRequest -> {
|
case TraceRequest -> {
|
||||||
int oldAmount = this.getPlayer().getTraceHuntManager().getTraceRequests();
|
this.getPlayer().getTraceHuntManager().addTraceRequests(amount, change, true);
|
||||||
int newAmount = oldAmount;
|
|
||||||
int diff = 0;
|
|
||||||
|
|
||||||
newAmount = this.getPlayer().getTraceHuntManager().addTraceRequests(amount);
|
|
||||||
diff = newAmount - oldAmount;
|
|
||||||
|
|
||||||
var proto = TraceHuntItem.newInstance()
|
|
||||||
.setTid(id)
|
|
||||||
.setGrantQty(diff);
|
|
||||||
|
|
||||||
change.add(proto);
|
|
||||||
}
|
}
|
||||||
case HuntPermit -> {
|
case HuntPermit -> {
|
||||||
int oldAmount = this.getPlayer().getTraceHuntManager().getHuntPermits();
|
this.getPlayer().getTraceHuntManager().addHuntPermits(amount, change, true);
|
||||||
int newAmount = oldAmount;
|
|
||||||
int diff = 0;
|
|
||||||
|
|
||||||
newAmount = this.getPlayer().getTraceHuntManager().addHuntPermits(amount);
|
|
||||||
diff = newAmount - oldAmount;
|
|
||||||
|
|
||||||
var proto = TraceHuntItem.newInstance()
|
|
||||||
.setTid(id)
|
|
||||||
.setGrantQty(diff);
|
|
||||||
|
|
||||||
change.add(proto);
|
|
||||||
}
|
}
|
||||||
default -> {
|
default -> {
|
||||||
// Not implemented
|
// Not implemented
|
||||||
|
|||||||
@@ -609,6 +609,9 @@ public class Player implements GameDatabaseObject {
|
|||||||
// Trigger quest
|
// Trigger quest
|
||||||
this.trigger(QuestCondition.EnergyDeplete, amount);
|
this.trigger(QuestCondition.EnergyDeplete, amount);
|
||||||
|
|
||||||
|
// Trigger trace hunt
|
||||||
|
this.getTraceHuntManager().onSpendEnergy(amount, change);
|
||||||
|
|
||||||
// Complete
|
// Complete
|
||||||
return change;
|
return change;
|
||||||
}
|
}
|
||||||
@@ -727,6 +730,9 @@ public class Player implements GameDatabaseObject {
|
|||||||
this.getInventory().addItem(GameConstants.JOINT_DRILL_TICKET_ID, 3 - tickets);
|
this.getInventory().addItem(GameConstants.JOINT_DRILL_TICKET_ID, 3 - tickets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset daily trace hunt items
|
||||||
|
this.getTraceHuntManager().resetDailyQuota();
|
||||||
|
|
||||||
// Check to reset weeklies
|
// Check to reset weeklies
|
||||||
if (resetWeekly) {
|
if (resetWeekly) {
|
||||||
// Add weekly boss entry item
|
// Add weekly boss entry item
|
||||||
@@ -1312,10 +1318,12 @@ public class Player implements GameDatabaseObject {
|
|||||||
// Trace hunt
|
// Trace hunt
|
||||||
proto.getMutableHuntPermit()
|
proto.getMutableHuntPermit()
|
||||||
.setTid(GameConstants.TRACE_HUNT_PERMIT_ITEM_ID)
|
.setTid(GameConstants.TRACE_HUNT_PERMIT_ITEM_ID)
|
||||||
|
.setDailyCount(this.getTraceHuntManager().getDailyPermits())
|
||||||
.setGrantedCount(this.getTraceHuntManager().getHuntPermits());
|
.setGrantedCount(this.getTraceHuntManager().getHuntPermits());
|
||||||
|
|
||||||
proto.getMutableTraceRequest()
|
proto.getMutableTraceRequest()
|
||||||
.setTid(GameConstants.TRACE_HUNT_REQUEST_ITEM_ID)
|
.setTid(GameConstants.TRACE_HUNT_REQUEST_ITEM_ID)
|
||||||
|
.setDailyCount(this.getTraceHuntManager().getDailyRequests())
|
||||||
.setGrantedCount(this.getTraceHuntManager().getTraceRequests());
|
.setGrantedCount(this.getTraceHuntManager().getTraceRequests());
|
||||||
|
|
||||||
// Complete
|
// Complete
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import emu.nebula.database.GameDatabaseObject;
|
|||||||
import emu.nebula.game.player.Player;
|
import emu.nebula.game.player.Player;
|
||||||
import emu.nebula.game.player.PlayerChangeInfo;
|
import emu.nebula.game.player.PlayerChangeInfo;
|
||||||
import emu.nebula.game.player.PlayerManager;
|
import emu.nebula.game.player.PlayerManager;
|
||||||
|
import emu.nebula.proto.Public.TraceHuntItem;
|
||||||
import emu.nebula.proto.TraceHuntInfoOuterClass.TraceHuntInfo;
|
import emu.nebula.proto.TraceHuntInfoOuterClass.TraceHuntInfo;
|
||||||
import emu.nebula.util.Utils;
|
import emu.nebula.util.Utils;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -32,9 +33,12 @@ public class TraceHuntManager extends PlayerManager implements GameDatabaseObjec
|
|||||||
|
|
||||||
// Requests/Hunt items
|
// Requests/Hunt items
|
||||||
private int traceRequests;
|
private int traceRequests;
|
||||||
|
private int dailyRequestProgress; // Every 10 energy used = +1 trace request
|
||||||
private int dailyRequests; // Max of 20 daily
|
private int dailyRequests; // Max of 20 daily
|
||||||
|
|
||||||
private int huntPermits;
|
private int huntPermits;
|
||||||
|
private int dailyPermitProgress; // Every 50 energy used = +1 hunting permit
|
||||||
|
private int dailyPermits; // Max of 4 daily
|
||||||
|
|
||||||
// Current boss
|
// Current boss
|
||||||
private int bossId;
|
private int bossId;
|
||||||
@@ -91,26 +95,98 @@ public class TraceHuntManager extends PlayerManager implements GameDatabaseObjec
|
|||||||
return (int) (medals * rate);
|
return (int) (medals * rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int addTraceRequests(int amount) {
|
public void onSpendEnergy(int amount, PlayerChangeInfo change) {
|
||||||
|
// Save flag
|
||||||
|
boolean save = true;
|
||||||
|
|
||||||
|
// Calculate daily request/permits to add
|
||||||
|
this.dailyRequestProgress += amount;
|
||||||
|
this.dailyPermitProgress += amount;
|
||||||
|
|
||||||
|
int newRequests = (int) Math.floor(this.dailyRequestProgress / 10D);
|
||||||
|
this.dailyRequestProgress = this.dailyRequestProgress % 10;
|
||||||
|
|
||||||
|
int newPermits = (int) Math.floor(this.dailyPermitProgress / 50D);
|
||||||
|
this.dailyPermitProgress = this.dailyPermitProgress % 50;
|
||||||
|
|
||||||
|
// Add
|
||||||
|
if (newRequests > 0) {
|
||||||
|
int max = Math.max(Math.min(60 - this.getTraceRequests(), 20 - this.getDailyRequests()), 0);
|
||||||
|
int add = Math.min(newRequests, max);
|
||||||
|
|
||||||
|
if (add > 0) {
|
||||||
|
this.dailyRequests += add;
|
||||||
|
this.addTraceRequests(add, change, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newPermits > 0) {
|
||||||
|
int max = Math.max(Math.min(12 - this.getHuntPermits(), 4 - this.getDailyPermits()), 0);
|
||||||
|
int add = Math.min(newPermits, max);
|
||||||
|
|
||||||
|
if (add > 0) {
|
||||||
|
this.dailyPermits += add;
|
||||||
|
this.addHuntPermits(add, change, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save to database
|
||||||
|
if (save) {
|
||||||
|
this.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetDailyQuota() {
|
||||||
|
// Reset progress and limits
|
||||||
|
this.dailyRequestProgress = 0;
|
||||||
|
this.dailyRequests = 0;
|
||||||
|
this.dailyPermitProgress = 0;
|
||||||
|
this.dailyPermits = 0;
|
||||||
|
|
||||||
|
// Save to database
|
||||||
|
this.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addTraceRequests(int amount, PlayerChangeInfo change, boolean shouldSave) {
|
||||||
|
// Save old value to check if we need to save this to the database
|
||||||
|
int oldValue = this.traceRequests;
|
||||||
|
|
||||||
// Add/remove requests
|
// Add/remove requests
|
||||||
this.traceRequests = Math.max(Math.min(this.traceRequests + amount, 60), 0);
|
this.traceRequests = Math.max(Math.min(this.traceRequests + amount, 60), 0);
|
||||||
|
|
||||||
// Save to database
|
// Save to database
|
||||||
|
if (shouldSave && oldValue != this.traceRequests) {
|
||||||
this.save();
|
this.save();
|
||||||
|
|
||||||
// Return amount
|
|
||||||
return this.traceRequests;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int addHuntPermits(int amount) {
|
// Add to change info
|
||||||
|
var proto = TraceHuntItem.newInstance()
|
||||||
|
.setTid(GameConstants.TRACE_HUNT_REQUEST_ITEM_ID)
|
||||||
|
.setGrantQty(this.getTraceRequests() - oldValue)
|
||||||
|
.setDailyCount(this.getDailyRequests());
|
||||||
|
|
||||||
|
change.add(proto);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addHuntPermits(int amount, PlayerChangeInfo change, boolean shouldSave) {
|
||||||
|
// Save old value to check if we need to save this to the database
|
||||||
|
int oldValue = this.huntPermits;
|
||||||
|
|
||||||
// Add/remove permits
|
// Add/remove permits
|
||||||
this.huntPermits = Math.max(this.huntPermits + amount, 0);
|
this.huntPermits = Math.max(Math.min(this.huntPermits + amount, 12), 0);
|
||||||
|
|
||||||
// Save to database
|
// Save to database
|
||||||
|
if (shouldSave && oldValue != this.huntPermits) {
|
||||||
this.save();
|
this.save();
|
||||||
|
}
|
||||||
|
|
||||||
// Return amount
|
// Add to change info
|
||||||
return this.huntPermits;
|
var proto = TraceHuntItem.newInstance()
|
||||||
|
.setTid(GameConstants.TRACE_HUNT_PERMIT_ITEM_ID)
|
||||||
|
.setGrantQty(this.getHuntPermits() - oldValue)
|
||||||
|
.setDailyCount(this.getDailyPermits());
|
||||||
|
|
||||||
|
change.add(proto);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxGainableExp() {
|
public int getMaxGainableExp() {
|
||||||
|
|||||||
Reference in New Issue
Block a user