mirror of
https://github.com/Melledy/Nebula.git
synced 2026-09-20 01:29:54 +02:00
Implement story
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user