Implement story

This commit is contained in:
Melledy
2025-10-27 21:39:12 -07:00
parent 08feedc766
commit f618486ced
11 changed files with 227 additions and 2 deletions
@@ -1,5 +1,7 @@
package emu.nebula.game.inventory;
import com.google.gson.annotations.SerializedName;
import dev.morphia.annotations.Entity;
import emu.nebula.proto.Public.ItemTpl;
import lombok.Getter;
@@ -7,7 +9,10 @@ import lombok.Getter;
@Getter
@Entity(useDiscriminator = false)
public class ItemParam {
@SerializedName("Tid")
public int id;
@SerializedName("Qty")
public int count;
@Deprecated // Morphia only
@@ -76,7 +76,7 @@ public class ItemParamMap extends Int2IntOpenHashMap {
.map(e -> ItemTpl.newInstance().setTid(e.getIntKey()).setQty(e.getIntValue()));
}
// Proto
// Helpers
public static ItemParamMap fromTemplates(RepeatedMessage<ItemTpl> items) {
var map = new ItemParamMap();
@@ -97,4 +97,14 @@ public class ItemParamMap extends Int2IntOpenHashMap {
return map;
}
public static ItemParamMap fromItemParams(List<ItemParam> items) {
var map = new ItemParamMap();
for (var template : items) {
map.add(template.getId(), template.getCount());
}
return map;
}
}