Basic implementation of character emblems

This commit is contained in:
Melledy
2025-11-16 10:16:07 -08:00
parent f2656903e5
commit 6b699d97ee
15 changed files with 739 additions and 19 deletions

View File

@@ -0,0 +1,58 @@
package emu.nebula.game.character;
import dev.morphia.annotations.Entity;
import emu.nebula.proto.Public.CharGemPreset;
import lombok.Getter;
@Getter
@Entity(useDiscriminator = false)
public class CharacterGemPreset {
private String name;
private int[] gems;
@Deprecated // Morphia only
public CharacterGemPreset() {
}
public CharacterGemPreset(Character character) {
this.gems = new int[] {-1, -1, -1};
}
public int getLength() {
return this.getGems().length;
}
public int getGemIndex(int slotIndex) {
if (slotIndex < 0 || slotIndex >= this.getLength()) {
return -1;
}
return this.getGems()[slotIndex];
}
public boolean setGemIndex(int slotId, int gemIndex) {
int slotIndex = slotId - 1;
if (slotIndex < 0 || slotIndex >= this.getLength()) {
return false;
}
this.getGems()[slotIndex] = gemIndex;
return true;
}
// Proto
public CharGemPreset toProto() {
var proto = CharGemPreset.newInstance()
.addAllSlotGem(this.getGems());
if (this.getName() != null) {
proto.setName(this.getName());
}
return proto;
}
}