mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-23 09:45:06 +01:00
Basic implementation of character emblems
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user