mirror of
https://github.com/Melledy/Nebula.git
synced 2026-09-19 09:09:54 +02:00
Update score boss control id properly
This commit is contained in:
@@ -227,7 +227,7 @@ public class Nebula {
|
|||||||
/**
|
/**
|
||||||
* Returns the current server time in seconds
|
* Returns the current server time in seconds
|
||||||
*/
|
*/
|
||||||
public static long getCurrentTime() {
|
public static long getCurrentServerTime() {
|
||||||
return System.currentTimeMillis() / 1000;
|
return System.currentTimeMillis() / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package emu.nebula.data.resources;
|
|||||||
|
|
||||||
import emu.nebula.data.BaseDef;
|
import emu.nebula.data.BaseDef;
|
||||||
import emu.nebula.data.ResourceType;
|
import emu.nebula.data.ResourceType;
|
||||||
|
import emu.nebula.util.Utils;
|
||||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@@ -9,10 +10,21 @@ import lombok.Getter;
|
|||||||
@ResourceType(name = "ScoreBossControl.json")
|
@ResourceType(name = "ScoreBossControl.json")
|
||||||
public class ScoreBossControlDef extends BaseDef {
|
public class ScoreBossControlDef extends BaseDef {
|
||||||
private int Id;
|
private int Id;
|
||||||
|
private String StartTime;
|
||||||
|
private String EndTime;
|
||||||
private IntOpenHashSet LevelGroup;
|
private IntOpenHashSet LevelGroup;
|
||||||
|
|
||||||
|
private transient long startDate;
|
||||||
|
private transient long endDate;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return Id;
|
return Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoad() {
|
||||||
|
this.startDate = Utils.dateToMilliseconds(this.StartTime) / 1000;
|
||||||
|
this.endDate = Utils.dateToMilliseconds(this.EndTime) / 1000;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,6 +119,9 @@ public class GameContext implements Runnable {
|
|||||||
this.epochWeeks = Utils.getWeeks(this.epochDays);
|
this.epochWeeks = Utils.getWeeks(this.epochDays);
|
||||||
this.epochMonths = Utils.getMonths(this.epochDays);
|
this.epochMonths = Utils.getMonths(this.epochDays);
|
||||||
|
|
||||||
|
// Update score boss season
|
||||||
|
this.getScoreBossModule().updateSeason();
|
||||||
|
|
||||||
// Reset dailies for players
|
// Reset dailies for players
|
||||||
this.resetDailies();
|
this.resetDailies();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public class GameAchievement {
|
|||||||
// Check if completed
|
// Check if completed
|
||||||
if (this.getCurProgress() >= this.getMaxProgress()) {
|
if (this.getCurProgress() >= this.getMaxProgress()) {
|
||||||
this.curProgress = this.getMaxProgress();
|
this.curProgress = this.getMaxProgress();
|
||||||
this.completed = Nebula.getCurrentTime();
|
this.completed = Nebula.getCurrentServerTime();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class Agent {
|
|||||||
|
|
||||||
public Agent(AgentDef data, int duration, int[] charIds) {
|
public Agent(AgentDef data, int duration, int[] charIds) {
|
||||||
this.id = data.getId();
|
this.id = data.getId();
|
||||||
this.start = Nebula.getCurrentTime();
|
this.start = Nebula.getCurrentServerTime();
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
this.charIds = charIds;
|
this.charIds = charIds;
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ public class CharacterContact {
|
|||||||
chat.report(process, options, end);
|
chat.report(process, options, end);
|
||||||
|
|
||||||
// Set trigger time
|
// Set trigger time
|
||||||
this.triggerTime = Nebula.getCurrentTime();
|
this.triggerTime = Nebula.getCurrentServerTime();
|
||||||
|
|
||||||
// Add next chat
|
// Add next chat
|
||||||
this.addNextChat();
|
this.addNextChat();
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public class GameCharacter implements GameDatabaseObject {
|
|||||||
this.talents = new Bitset();
|
this.talents = new Bitset();
|
||||||
this.gemPresets = new ArrayList<>();
|
this.gemPresets = new ArrayList<>();
|
||||||
this.gemSlots = new CharacterGemSlot[GameConstants.CHARACTER_MAX_GEM_SLOTS];
|
this.gemSlots = new CharacterGemSlot[GameConstants.CHARACTER_MAX_GEM_SLOTS];
|
||||||
this.createTime = Nebula.getCurrentTime();
|
this.createTime = Nebula.getCurrentServerTime();
|
||||||
|
|
||||||
this.contact = new CharacterContact(this);
|
this.contact = new CharacterContact(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class GameDisc implements GameDatabaseObject {
|
|||||||
this.data = data;
|
this.data = data;
|
||||||
this.discId = data.getId();
|
this.discId = data.getId();
|
||||||
this.level = 1;
|
this.level = 1;
|
||||||
this.createTime = Nebula.getCurrentTime();
|
this.createTime = Nebula.getCurrentServerTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlayer(Player player) {
|
public void setPlayer(Player player) {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ public class GachaHistoryLog {
|
|||||||
public GachaHistoryLog(int type, int gachaId, IntList results) {
|
public GachaHistoryLog(int type, int gachaId, IntList results) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.gid = gachaId;
|
this.gid = gachaId;
|
||||||
this.time = Nebula.getCurrentTime();
|
this.time = Nebula.getCurrentServerTime();
|
||||||
this.ids = results;
|
this.ids = results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class GameMail {
|
|||||||
this.author = author;
|
this.author = author;
|
||||||
this.subject = subject;
|
this.subject = subject;
|
||||||
this.desc = desc;
|
this.desc = desc;
|
||||||
this.time = Nebula.getCurrentTime();
|
this.time = Nebula.getCurrentServerTime();
|
||||||
this.expiry = this.time + TimeUnit.DAYS.toSeconds(30);
|
this.expiry = this.time + TimeUnit.DAYS.toSeconds(30);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ public class Player implements GameDatabaseObject {
|
|||||||
|
|
||||||
// Set basic info
|
// Set basic info
|
||||||
this.accountUid = account.getUid();
|
this.accountUid = account.getUid();
|
||||||
this.createTime = Nebula.getCurrentTime();
|
this.createTime = Nebula.getCurrentServerTime();
|
||||||
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.signature = "";
|
this.signature = "";
|
||||||
@@ -532,7 +532,7 @@ public class Player implements GameDatabaseObject {
|
|||||||
|
|
||||||
public int getEnergy() {
|
public int getEnergy() {
|
||||||
// Cache time
|
// Cache time
|
||||||
long time = Nebula.getCurrentTime();
|
long time = Nebula.getCurrentServerTime();
|
||||||
|
|
||||||
// Calculate time diff
|
// Calculate time diff
|
||||||
double diff = time - this.energyLastUpdate;
|
double diff = time - this.energyLastUpdate;
|
||||||
@@ -819,7 +819,7 @@ public class Player implements GameDatabaseObject {
|
|||||||
|
|
||||||
public PlayerInfo toProto() {
|
public PlayerInfo toProto() {
|
||||||
PlayerInfo proto = PlayerInfo.newInstance()
|
PlayerInfo proto = PlayerInfo.newInstance()
|
||||||
.setServerTs(Nebula.getCurrentTime())
|
.setServerTs(Nebula.getCurrentServerTime())
|
||||||
.setSigninIndex(this.getSignInIndex())
|
.setSigninIndex(this.getSignInIndex())
|
||||||
.setTowerTicket(this.getProgress().getTowerTickets())
|
.setTowerTicket(this.getProgress().getTowerTickets())
|
||||||
.setDailyShopRewardStatus(this.getQuestManager().hasDailyReward())
|
.setDailyShopRewardStatus(this.getQuestManager().hasDailyReward())
|
||||||
@@ -1023,7 +1023,7 @@ public class Player implements GameDatabaseObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Energy getEnergyProto() {
|
public Energy getEnergyProto() {
|
||||||
long nextDuration = Math.max(GameConstants.ENERGY_REGEN_TIME - (Nebula.getCurrentTime() - getEnergyLastUpdate()), 1);
|
long nextDuration = Math.max(GameConstants.ENERGY_REGEN_TIME - (Nebula.getCurrentServerTime() - getEnergyLastUpdate()), 1);
|
||||||
|
|
||||||
var proto = Energy.newInstance()
|
var proto = Energy.newInstance()
|
||||||
.setUpdateTime(this.getEnergyLastUpdate())
|
.setUpdateTime(this.getEnergyLastUpdate())
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import emu.nebula.Nebula;
|
import emu.nebula.Nebula;
|
||||||
|
import emu.nebula.data.GameData;
|
||||||
import emu.nebula.game.GameContext;
|
import emu.nebula.game.GameContext;
|
||||||
import emu.nebula.game.GameContextModule;
|
import emu.nebula.game.GameContextModule;
|
||||||
import emu.nebula.proto.ScoreBossRank.ScoreBossRankData;
|
import emu.nebula.proto.ScoreBossRank.ScoreBossRankData;
|
||||||
@@ -11,6 +12,8 @@ import lombok.Getter;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class ScoreBossModule extends GameContextModule {
|
public class ScoreBossModule extends GameContextModule {
|
||||||
|
private int seasonId;
|
||||||
|
|
||||||
private long lastUpdate;
|
private long lastUpdate;
|
||||||
private long nextUpdate;
|
private long nextUpdate;
|
||||||
private List<ScoreBossRankData> ranking;
|
private List<ScoreBossRankData> ranking;
|
||||||
@@ -21,9 +24,25 @@ public class ScoreBossModule extends GameContextModule {
|
|||||||
this.ranking = new ArrayList<>();
|
this.ranking = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO calculate from bin data
|
|
||||||
public int getControlId() {
|
public int getControlId() {
|
||||||
return 2;
|
return this.seasonId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateSeason() {
|
||||||
|
int season = 1;
|
||||||
|
long time = Nebula.getCurrentServerTime();
|
||||||
|
|
||||||
|
for (var data : GameData.getScoreBossControlDataTable()) {
|
||||||
|
if (data.getId() <= season) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (time >= data.getStartDate()) {
|
||||||
|
season = data.getId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.seasonId = season;
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getRefreshTime() {
|
private long getRefreshTime() {
|
||||||
@@ -56,6 +75,6 @@ public class ScoreBossModule extends GameContextModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.nextUpdate = System.currentTimeMillis() + this.getRefreshTime();
|
this.nextUpdate = System.currentTimeMillis() + this.getRefreshTime();
|
||||||
this.lastUpdate = Nebula.getCurrentTime();
|
this.lastUpdate = Nebula.getCurrentServerTime();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class HandlerGachaSpinReq extends NetHandler {
|
|||||||
|
|
||||||
// Build response
|
// Build response
|
||||||
var rsp = GachaSpinResp.newInstance()
|
var rsp = GachaSpinResp.newInstance()
|
||||||
.setTime(Nebula.getCurrentTime())
|
.setTime(Nebula.getCurrentServerTime())
|
||||||
.setAMissTimes(result.getInfo().getMissTimesA())
|
.setAMissTimes(result.getInfo().getMissTimesA())
|
||||||
.setAupMissTimes(result.getInfo().getMissTimesA())
|
.setAupMissTimes(result.getInfo().getMissTimesA())
|
||||||
.setTotalTimes(result.getInfo().getTotal())
|
.setTotalTimes(result.getInfo().getTotal())
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class HandlerIkeReq extends NetHandler {
|
|||||||
var rsp = IKEResp.newInstance()
|
var rsp = IKEResp.newInstance()
|
||||||
.setToken(session.getToken())
|
.setToken(session.getToken())
|
||||||
.setCipher(session.getEncryptMethod())
|
.setCipher(session.getEncryptMethod())
|
||||||
.setServerTs(Nebula.getCurrentTime())
|
.setServerTs(Nebula.getCurrentServerTime())
|
||||||
.setPubKey(session.getServerPublicKey());
|
.setPubKey(session.getServerPublicKey());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class HandlerMallShopListReq extends NetHandler {
|
|||||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||||
var rsp = MallShopProductList.newInstance();
|
var rsp = MallShopProductList.newInstance();
|
||||||
|
|
||||||
long refreshTime = Nebula.getCurrentTime() + TimeUnit.DAYS.toSeconds(30);
|
long refreshTime = Nebula.getCurrentServerTime() + TimeUnit.DAYS.toSeconds(30);
|
||||||
|
|
||||||
for (var data : GameData.getMallShopDataTable()) {
|
for (var data : GameData.getMallShopDataTable()) {
|
||||||
if (data.getStock() <= 0) {
|
if (data.getStock() <= 0) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class HandlerPlayerPingReq extends NetHandler {
|
|||||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||||
// Create response
|
// Create response
|
||||||
var rsp = Pong.newInstance()
|
var rsp = Pong.newInstance()
|
||||||
.setServerTs(Nebula.getCurrentTime());
|
.setServerTs(Nebula.getCurrentServerTime());
|
||||||
|
|
||||||
return session.encodeMsg(NetMsgId.player_ping_succeed_ack, rsp);
|
return session.encodeMsg(NetMsgId.player_ping_succeed_ack, rsp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class HandlerScoreBossRankReq extends NetHandler {
|
|||||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||||
// Build response
|
// Build response
|
||||||
var rsp = ScoreBossRankInfo.newInstance()
|
var rsp = ScoreBossRankInfo.newInstance()
|
||||||
.setLastRefreshTime(Nebula.getCurrentTime());
|
.setLastRefreshTime(Nebula.getCurrentServerTime());
|
||||||
|
|
||||||
// Get self
|
// Get self
|
||||||
var self = session.getPlayer().getScoreBossManager().getRankEntry();
|
var self = session.getPlayer().getScoreBossManager().getRankEntry();
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import java.net.InetSocketAddress;
|
|||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.OffsetDateTime;
|
||||||
import java.time.YearMonth;
|
import java.time.YearMonth;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
@@ -88,10 +89,6 @@ public class Utils {
|
|||||||
return new File(path).mkdirs();
|
return new File(path).mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long getCurrentSeconds() {
|
|
||||||
return Math.floorDiv(System.currentTimeMillis(), 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getMinAdvanceForLevel(int level) {
|
public static int getMinAdvanceForLevel(int level) {
|
||||||
return Math.max(Math.min((int) ((level - 1) / 10D), 8), 0);
|
return Math.max(Math.min((int) ((level - 1) / 10D), 8), 0);
|
||||||
}
|
}
|
||||||
@@ -336,4 +333,9 @@ public class Utils {
|
|||||||
.atZone(GameConstants.UTC_ZONE)
|
.atZone(GameConstants.UTC_ZONE)
|
||||||
.format(DateTimeFormatter.ofPattern(pattern));
|
.format(DateTimeFormatter.ofPattern(pattern));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static long dateToMilliseconds(String dateString) {
|
||||||
|
var offsetDateTime = OffsetDateTime.parse(dateString, DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
||||||
|
return offsetDateTime.toInstant().toEpochMilli();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user