mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-12 12:24:35 +01:00
Improve Boss Blitz UI
This commit is contained in:
@@ -27,7 +27,7 @@ public class ScoreBossManager extends PlayerManager {
|
|||||||
return GameData.getScoreBossControlDataTable().get(this.getControlId());
|
return GameData.getScoreBossControlDataTable().get(this.getControlId());
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScoreBossRankEntry getRanking() {
|
public ScoreBossRankEntry getRankEntry() {
|
||||||
if (this.ranking == null && !this.checkedDatabase) {
|
if (this.ranking == null && !this.checkedDatabase) {
|
||||||
this.ranking = Nebula.getGameDatabase().getObjectByUid(ScoreBossRankEntry.class, this.getPlayerUid());
|
this.ranking = Nebula.getGameDatabase().getObjectByUid(ScoreBossRankEntry.class, this.getPlayerUid());
|
||||||
this.checkedDatabase = true;
|
this.checkedDatabase = true;
|
||||||
@@ -57,7 +57,7 @@ public class ScoreBossManager extends PlayerManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean settle(int stars, int score) {
|
public boolean settle(int stars, int score, int skillScore) {
|
||||||
// Get level
|
// Get level
|
||||||
var control = getControlData();
|
var control = getControlData();
|
||||||
if (control == null || !control.getLevelGroup().contains(this.getLevelId())) {
|
if (control == null || !control.getLevelGroup().contains(this.getLevelId())) {
|
||||||
@@ -71,7 +71,7 @@ public class ScoreBossManager extends PlayerManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get ranking from database
|
// Get ranking from database
|
||||||
this.getRanking();
|
this.getRankEntry();
|
||||||
|
|
||||||
// Create ranking if its not in the database
|
// Create ranking if its not in the database
|
||||||
if (this.ranking == null) {
|
if (this.ranking == null) {
|
||||||
@@ -79,7 +79,7 @@ public class ScoreBossManager extends PlayerManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Settle
|
// Settle
|
||||||
this.ranking.settle(this.getPlayer(), build, getControlId(), getLevelId(), stars, score);
|
this.ranking.settle(this.getPlayer(), build, getControlId(), getLevelId(), stars, score, skillScore);
|
||||||
|
|
||||||
// Save ranking
|
// Save ranking
|
||||||
this.ranking.save();
|
this.ranking.save();
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ public class ScoreBossRankEntry implements GameDatabaseObject {
|
|||||||
private int titleSuffix;
|
private int titleSuffix;
|
||||||
private int[] honor;
|
private int[] honor;
|
||||||
private int score;
|
private int score;
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
private int stars;
|
||||||
|
|
||||||
private int controlId;
|
private int controlId;
|
||||||
private Map<Integer, ScoreBossTeamEntry> teams;
|
private Map<Integer, ScoreBossTeamEntry> teams;
|
||||||
@@ -51,6 +53,17 @@ public class ScoreBossRankEntry implements GameDatabaseObject {
|
|||||||
this.teams = new HashMap<>();
|
this.teams = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO replace later
|
||||||
|
public int getStars() {
|
||||||
|
int stars = 0;
|
||||||
|
|
||||||
|
for (var team : this.getTeams().values()) {
|
||||||
|
stars += team.getStars();
|
||||||
|
}
|
||||||
|
|
||||||
|
return stars;
|
||||||
|
}
|
||||||
|
|
||||||
public void update(Player player) {
|
public void update(Player player) {
|
||||||
this.name = player.getName();
|
this.name = player.getName();
|
||||||
this.level = player.getLevel();
|
this.level = player.getLevel();
|
||||||
@@ -60,28 +73,38 @@ public class ScoreBossRankEntry implements GameDatabaseObject {
|
|||||||
this.honor = player.getHonor();
|
this.honor = player.getHonor();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void settle(Player player, StarTowerBuild build, int controlId, int level, int stars, int score) {
|
public void settle(Player player, StarTowerBuild build, int controlId, int level, int stars, int score, int skillScore) {
|
||||||
// Update player data
|
// Update player data
|
||||||
this.update(player);
|
this.update(player);
|
||||||
|
|
||||||
// Reset score entry if control id doesn't match
|
// Reset score entry if control id doesn't match
|
||||||
if (this.controlId != controlId) {
|
if (this.controlId != controlId) {
|
||||||
this.controlId = controlId;
|
this.controlId = controlId;
|
||||||
this.getTeams().clear();
|
this.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set team entry
|
// Set team entry
|
||||||
var team = new ScoreBossTeamEntry(player, build, stars, score);
|
var team = new ScoreBossTeamEntry(player, build, stars, score, skillScore);
|
||||||
|
|
||||||
|
// Put in team map
|
||||||
this.getTeams().put(level, team);
|
this.getTeams().put(level, team);
|
||||||
|
|
||||||
// Calculate score
|
// Calculate score/stars
|
||||||
this.score = 0;
|
this.score = 0;
|
||||||
|
this.stars = 0;
|
||||||
|
|
||||||
for (var t : this.getTeams().values()) {
|
for (var t : this.getTeams().values()) {
|
||||||
this.score += t.getLevelScore();
|
this.score += t.getLevelScore();
|
||||||
|
this.stars += t.getStars();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void reset() {
|
||||||
|
this.score = 0;
|
||||||
|
this.stars = 0;
|
||||||
|
this.getTeams().clear();
|
||||||
|
}
|
||||||
|
|
||||||
// Proto
|
// Proto
|
||||||
|
|
||||||
public ScoreBossRankData toProto() {
|
public ScoreBossRankData toProto() {
|
||||||
@@ -115,6 +138,7 @@ public class ScoreBossRankEntry implements GameDatabaseObject {
|
|||||||
private int buildScore;
|
private int buildScore;
|
||||||
private int stars;
|
private int stars;
|
||||||
private int levelScore;
|
private int levelScore;
|
||||||
|
private int skillScore;
|
||||||
private List<ScoreBossCharEntry> characters;
|
private List<ScoreBossCharEntry> characters;
|
||||||
|
|
||||||
@Deprecated // Morphia only
|
@Deprecated // Morphia only
|
||||||
@@ -122,11 +146,12 @@ public class ScoreBossRankEntry implements GameDatabaseObject {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScoreBossTeamEntry(Player player, StarTowerBuild build, int stars, int score) {
|
public ScoreBossTeamEntry(Player player, StarTowerBuild build, int stars, int score, int skillScore) {
|
||||||
this.buildId = build.getUid();
|
this.buildId = build.getUid();
|
||||||
this.buildScore = build.getScore();
|
this.buildScore = build.getScore();
|
||||||
this.stars = stars;
|
this.stars = stars;
|
||||||
this.levelScore = score;
|
this.levelScore = score;
|
||||||
|
this.skillScore = skillScore;
|
||||||
this.characters = new ArrayList<>();
|
this.characters = new ArrayList<>();
|
||||||
|
|
||||||
for (var charId : build.getCharIds()) {
|
for (var charId : build.getCharIds()) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package emu.nebula.server.handlers;
|
|||||||
|
|
||||||
import emu.nebula.net.NetHandler;
|
import emu.nebula.net.NetHandler;
|
||||||
import emu.nebula.net.NetMsgId;
|
import emu.nebula.net.NetMsgId;
|
||||||
|
import emu.nebula.proto.Public.ScoreBossLevel;
|
||||||
import emu.nebula.proto.ScoreBossInfoOuterClass.ScoreBossInfo;
|
import emu.nebula.proto.ScoreBossInfoOuterClass.ScoreBossInfo;
|
||||||
import emu.nebula.net.HandlerId;
|
import emu.nebula.net.HandlerId;
|
||||||
import emu.nebula.net.GameSession;
|
import emu.nebula.net.GameSession;
|
||||||
@@ -15,6 +16,33 @@ public class HandlerScoreBossInfoReq extends NetHandler {
|
|||||||
var rsp = ScoreBossInfo.newInstance()
|
var rsp = ScoreBossInfo.newInstance()
|
||||||
.setControlId(session.getPlayer().getScoreBossManager().getControlId());
|
.setControlId(session.getPlayer().getScoreBossManager().getControlId());
|
||||||
|
|
||||||
|
// Get rank entry
|
||||||
|
var rankEntry = session.getPlayer().getScoreBossManager().getRankEntry();
|
||||||
|
if (rankEntry != null) {
|
||||||
|
// Set total score
|
||||||
|
rsp.setScore(rankEntry.getScore());
|
||||||
|
rsp.setStar(rankEntry.getStars());
|
||||||
|
|
||||||
|
// Encode team data to proto
|
||||||
|
for (var teamEntry : rankEntry.getTeams().entrySet()) {
|
||||||
|
int id = teamEntry.getKey();
|
||||||
|
var team = teamEntry.getValue();
|
||||||
|
|
||||||
|
var info = ScoreBossLevel.newInstance()
|
||||||
|
.setBuildId(team.getBuildId())
|
||||||
|
.setLevelId(id)
|
||||||
|
.setScore(team.getLevelScore())
|
||||||
|
.setSkillScore(team.getSkillScore())
|
||||||
|
.setStar(team.getStars());
|
||||||
|
|
||||||
|
for (var charEntry : team.getCharacters()) {
|
||||||
|
info.addCharIds(charEntry.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
rsp.addLevels(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Encode and send
|
// Encode and send
|
||||||
return session.encodeMsg(NetMsgId.score_boss_info_succeed_ack, rsp);
|
return session.encodeMsg(NetMsgId.score_boss_info_succeed_ack, rsp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class HandlerScoreBossRankReq extends NetHandler {
|
|||||||
.setLastRefreshTime(Nebula.getCurrentTime());
|
.setLastRefreshTime(Nebula.getCurrentTime());
|
||||||
|
|
||||||
// Get self
|
// Get self
|
||||||
var self = session.getPlayer().getScoreBossManager().getRanking();
|
var self = session.getPlayer().getScoreBossManager().getRankEntry();
|
||||||
|
|
||||||
if (self != null) {
|
if (self != null) {
|
||||||
rsp.setSelf(self.toProto());
|
rsp.setSelf(self.toProto());
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class HandlerScoreBossSettleReq extends NetHandler {
|
|||||||
var req = ScoreBossSettleReq.parseFrom(message);
|
var req = ScoreBossSettleReq.parseFrom(message);
|
||||||
|
|
||||||
// Settle
|
// Settle
|
||||||
boolean success = session.getPlayer().getScoreBossManager().settle(req.getStar(), req.getScore());
|
boolean success = session.getPlayer().getScoreBossManager().settle(req.getStar(), req.getScore(), req.getSkillScore());
|
||||||
|
|
||||||
if (success == false) {
|
if (success == false) {
|
||||||
return session.encodeMsg(NetMsgId.score_boss_settle_failed_ack);
|
return session.encodeMsg(NetMsgId.score_boss_settle_failed_ack);
|
||||||
|
|||||||
Reference in New Issue
Block a user