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