mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-14 13:24:43 +01:00
Fix records not displaying main character correctly
This commit is contained in:
@@ -5,6 +5,7 @@ import dev.morphia.annotations.Id;
|
|||||||
import dev.morphia.annotations.Indexed;
|
import dev.morphia.annotations.Indexed;
|
||||||
import emu.nebula.data.GameData;
|
import emu.nebula.data.GameData;
|
||||||
import emu.nebula.database.GameDatabaseObject;
|
import emu.nebula.database.GameDatabaseObject;
|
||||||
|
import emu.nebula.proto.Public.ItemTpl;
|
||||||
import emu.nebula.proto.PublicStarTower.BuildPotential;
|
import emu.nebula.proto.PublicStarTower.BuildPotential;
|
||||||
import emu.nebula.proto.PublicStarTower.StarTowerBuildBrief;
|
import emu.nebula.proto.PublicStarTower.StarTowerBuildBrief;
|
||||||
import emu.nebula.proto.PublicStarTower.StarTowerBuildDetail;
|
import emu.nebula.proto.PublicStarTower.StarTowerBuildDetail;
|
||||||
@@ -28,9 +29,10 @@ public class StarTowerBuild implements GameDatabaseObject {
|
|||||||
private boolean preference;
|
private boolean preference;
|
||||||
private int score;
|
private int score;
|
||||||
|
|
||||||
private Int2IntMap chars;
|
private int[] charIds;
|
||||||
private int[] discIds;
|
private int[] discIds;
|
||||||
|
|
||||||
|
private Int2IntMap charPots;
|
||||||
private Int2IntMap potentials;
|
private Int2IntMap potentials;
|
||||||
private Int2IntMap subNoteSkills;
|
private Int2IntMap subNoteSkills;
|
||||||
|
|
||||||
@@ -43,21 +45,22 @@ public class StarTowerBuild implements GameDatabaseObject {
|
|||||||
this.uid = Snowflake.newUid();
|
this.uid = Snowflake.newUid();
|
||||||
this.playerUid = instance.getPlayer().getUid();
|
this.playerUid = instance.getPlayer().getUid();
|
||||||
this.name = "";
|
this.name = "";
|
||||||
|
this.charPots = new Int2IntOpenHashMap();
|
||||||
this.potentials = new Int2IntOpenHashMap();
|
this.potentials = new Int2IntOpenHashMap();
|
||||||
this.subNoteSkills = new Int2IntOpenHashMap();
|
this.subNoteSkills = new Int2IntOpenHashMap();
|
||||||
|
|
||||||
|
// Characters
|
||||||
|
this.charIds = instance.getDiscs().stream()
|
||||||
|
.filter(d -> d.getId() > 0)
|
||||||
|
.mapToInt(d -> d.getId())
|
||||||
|
.toArray();
|
||||||
|
|
||||||
// Discs
|
// Discs
|
||||||
this.discIds = instance.getDiscs().stream()
|
this.discIds = instance.getDiscs().stream()
|
||||||
.filter(d -> d.getId() > 0)
|
.filter(d -> d.getId() > 0)
|
||||||
.mapToInt(d -> d.getId())
|
.mapToInt(d -> d.getId())
|
||||||
.toArray();
|
.toArray();
|
||||||
|
|
||||||
// Characters
|
|
||||||
this.chars = new Int2IntOpenHashMap();
|
|
||||||
|
|
||||||
instance.getChars().stream()
|
|
||||||
.forEach(c -> this.getChars().put(c.getId(), 0));
|
|
||||||
|
|
||||||
// Add potentials
|
// Add potentials
|
||||||
for (int id : instance.getPotentials()) {
|
for (int id : instance.getPotentials()) {
|
||||||
// Add to potential map
|
// Add to potential map
|
||||||
@@ -67,7 +70,7 @@ public class StarTowerBuild implements GameDatabaseObject {
|
|||||||
var potentialData = GameData.getPotentialDataTable().get(id);
|
var potentialData = GameData.getPotentialDataTable().get(id);
|
||||||
if (potentialData != null) {
|
if (potentialData != null) {
|
||||||
int charId = potentialData.getCharId();
|
int charId = potentialData.getCharId();
|
||||||
this.getChars().put(charId, this.getChars().get(charId) + 1);
|
this.getCharPots().put(charId, this.getCharPots().get(charId) + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -92,10 +95,10 @@ public class StarTowerBuild implements GameDatabaseObject {
|
|||||||
.addAllDiscIds(this.getDiscIds());
|
.addAllDiscIds(this.getDiscIds());
|
||||||
|
|
||||||
// Add characters
|
// Add characters
|
||||||
for (var character : this.getChars().int2IntEntrySet()) {
|
for (int charId : this.getCharIds()) {
|
||||||
var charProto = TowerBuildChar.newInstance()
|
var charProto = TowerBuildChar.newInstance()
|
||||||
.setCharId(character.getIntKey())
|
.setCharId(charId)
|
||||||
.setPotentialCnt(character.getIntValue());
|
.setPotentialCnt(this.getCharPots().get(charId));
|
||||||
|
|
||||||
proto.addChars(charProto);
|
proto.addChars(charProto);
|
||||||
}
|
}
|
||||||
@@ -106,6 +109,7 @@ public class StarTowerBuild implements GameDatabaseObject {
|
|||||||
public StarTowerBuildDetail toDetailProto() {
|
public StarTowerBuildDetail toDetailProto() {
|
||||||
var proto = StarTowerBuildDetail.newInstance();
|
var proto = StarTowerBuildDetail.newInstance();
|
||||||
|
|
||||||
|
// Potentials
|
||||||
for (var entry : this.getPotentials().int2IntEntrySet()) {
|
for (var entry : this.getPotentials().int2IntEntrySet()) {
|
||||||
var potential = BuildPotential.newInstance()
|
var potential = BuildPotential.newInstance()
|
||||||
.setPotentialId(entry.getIntKey())
|
.setPotentialId(entry.getIntKey())
|
||||||
@@ -114,6 +118,15 @@ public class StarTowerBuild implements GameDatabaseObject {
|
|||||||
proto.getMutablePotentials().add(potential);
|
proto.getMutablePotentials().add(potential);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sub note skills
|
||||||
|
for (var entry : this.getSubNoteSkills().int2IntEntrySet()) {
|
||||||
|
var skill = ItemTpl.newInstance()
|
||||||
|
.setTid(entry.getIntKey())
|
||||||
|
.setQty(entry.getIntValue());
|
||||||
|
|
||||||
|
proto.addSubNoteSkills(skill);
|
||||||
|
}
|
||||||
|
|
||||||
return proto;
|
return proto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user