mirror of
https://github.com/Melledy/Nebula.git
synced 2026-09-19 09:09:54 +02:00
Implement honor affinity levels for leaderboards
This commit is contained in:
@@ -21,6 +21,14 @@ public class HonorDef extends BaseDef {
|
||||
return Id;
|
||||
}
|
||||
|
||||
public boolean isCharacterHonor() {
|
||||
return this.Type == 2 && this.Params.length > 0;
|
||||
}
|
||||
|
||||
public int getCharacterId() {
|
||||
return this.Params[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
// Run AFTER character data has been loaded
|
||||
|
||||
@@ -300,8 +300,8 @@ public class Inventory extends PlayerManager implements GameDatabaseObject {
|
||||
if (honor == null) return false;
|
||||
|
||||
// Check if honor title is a trekker affinity title
|
||||
if (honor.getType() == 2 && honor.getParams().length >= 1) {
|
||||
int charId = honor.getParams()[0];
|
||||
if (honor.isCharacterHonor()) {
|
||||
int charId = honor.getCharacterId();
|
||||
var character = this.getPlayer().getCharacters().getCharacterById(charId);
|
||||
|
||||
if (character != null && character.getAffinityLevel() >= GameConstants.AFFINITY_HONOR_UNLOCK_LEVEL) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.util.List;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import dev.morphia.annotations.Id;
|
||||
|
||||
import emu.nebula.data.GameData;
|
||||
import emu.nebula.database.GameDatabaseObject;
|
||||
import emu.nebula.game.player.Player;
|
||||
import emu.nebula.game.tower.StarTowerBuild;
|
||||
@@ -31,6 +31,7 @@ public class JointDrillRankEntry implements GameDatabaseObject {
|
||||
private int titlePrefix;
|
||||
private int titleSuffix;
|
||||
private int[] honor;
|
||||
private int[] honorAff;
|
||||
private int score;
|
||||
private IntSet claimedRewards;
|
||||
|
||||
@@ -66,6 +67,19 @@ public class JointDrillRankEntry implements GameDatabaseObject {
|
||||
this.titlePrefix = player.getTitlePrefix();
|
||||
this.titleSuffix = player.getTitleSuffix();
|
||||
this.honor = player.getHonor();
|
||||
this.honorAff = new int[this.honor.length];
|
||||
|
||||
for (int i = 0; i < this.honor.length; i++) {
|
||||
var honor = GameData.getHonorDataTable().get(this.honor[i]);
|
||||
if (honor == null || !honor.isCharacterHonor()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var character = player.getCharacters().getCharacterById(honor.getCharacterId());
|
||||
if (character != null) {
|
||||
this.honorAff[i] = character.getAffinityLevel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void settle(Player player, List<JointDrillBuild> builds, int activityId, int score) {
|
||||
@@ -107,8 +121,19 @@ public class JointDrillRankEntry implements GameDatabaseObject {
|
||||
.setTitleSuffix(this.getTitleSuffix())
|
||||
.setRank(this.getRank());
|
||||
|
||||
for (int id : this.getHonor()) {
|
||||
proto.addHonors(HonorInfo.newInstance().setId(id));
|
||||
for (int i = 0; i < this.getHonor().length; i++) {
|
||||
int honorId = this.getHonor()[i];
|
||||
int affinityLevel = 0;
|
||||
|
||||
if (this.getHonorAff() != null && i < this.getHonorAff().length) {
|
||||
affinityLevel = this.getHonorAff()[i];
|
||||
}
|
||||
|
||||
var info = HonorInfo.newInstance()
|
||||
.setId(honorId)
|
||||
.setAffinityLV(affinityLevel);
|
||||
|
||||
proto.addHonors(info);
|
||||
}
|
||||
|
||||
for (var team : this.getTeams()) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.Map;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import dev.morphia.annotations.Id;
|
||||
|
||||
import emu.nebula.data.GameData;
|
||||
import emu.nebula.database.GameDatabaseObject;
|
||||
import emu.nebula.game.player.Player;
|
||||
import emu.nebula.game.tower.StarTowerBuild;
|
||||
@@ -33,6 +33,7 @@ public class ScoreBossRankEntry implements GameDatabaseObject {
|
||||
private int titlePrefix;
|
||||
private int titleSuffix;
|
||||
private int[] honor;
|
||||
private int[] honorAff;
|
||||
private int score;
|
||||
@SuppressWarnings("unused")
|
||||
private int stars;
|
||||
@@ -81,6 +82,19 @@ public class ScoreBossRankEntry implements GameDatabaseObject {
|
||||
this.titlePrefix = player.getTitlePrefix();
|
||||
this.titleSuffix = player.getTitleSuffix();
|
||||
this.honor = player.getHonor();
|
||||
this.honorAff = new int[this.honor.length];
|
||||
|
||||
for (int i = 0; i < this.honor.length; i++) {
|
||||
var honor = GameData.getHonorDataTable().get(this.honor[i]);
|
||||
if (honor == null || !honor.isCharacterHonor()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var character = player.getCharacters().getCharacterById(honor.getCharacterId());
|
||||
if (character != null) {
|
||||
this.honorAff[i] = character.getAffinityLevel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void settle(Player player, StarTowerBuild build, int controlId, int level, int stars, int score, int skillScore) {
|
||||
@@ -129,8 +143,19 @@ public class ScoreBossRankEntry implements GameDatabaseObject {
|
||||
.setTitleSuffix(this.getTitleSuffix())
|
||||
.setRank(this.getRank());
|
||||
|
||||
for (int id : this.getHonor()) {
|
||||
proto.addHonors(HonorInfo.newInstance().setId(id));
|
||||
for (int i = 0; i < this.getHonor().length; i++) {
|
||||
int honorId = this.getHonor()[i];
|
||||
int affinityLevel = 0;
|
||||
|
||||
if (this.getHonorAff() != null && i < this.getHonorAff().length) {
|
||||
affinityLevel = this.getHonorAff()[i];
|
||||
}
|
||||
|
||||
var info = HonorInfo.newInstance()
|
||||
.setId(honorId)
|
||||
.setAffinityLV(affinityLevel);
|
||||
|
||||
proto.addHonors(info);
|
||||
}
|
||||
|
||||
for (var entry : this.getTeams().entrySet()) {
|
||||
|
||||
Reference in New Issue
Block a user