This commit is contained in:
Mohamad Alkotob
2017-01-04 19:23:14 +02:00
committed by GitHub
parent f61ba8bd06
commit 7936a223f5

View File

@@ -19,13 +19,20 @@ import java.util.Map;
public final class Inventory extends ItemContainer {
public static enum WearSlot {
weapon, shield, head, body, hand, feet, neck, leftring, rightring;
public static WearSlot fromString(String s, WearSlot default_) {
if (s == null) return default_;
return valueOf(s);
weapon
,shield
,head
,body
,hand
,feet
,neck
,leftring
,rightring;
public static WearSlot fromString(String s, WearSlot default_) {
if (s == null) return default_;
return valueOf(s);
}
}
}
public int gold = 0;
private static final int NUM_WORN_SLOTS = WearSlot.values().length;
@@ -46,6 +53,7 @@ public final class Inventory extends ItemContainer {
this.gold += loot.gold;
this.add(loot.items);
}
public boolean isEmptySlot(WearSlot slot) {
return wear[slot.ordinal()] == null;
}
@@ -53,7 +61,6 @@ public final class Inventory extends ItemContainer {
public ItemType getItemTypeInWearSlot(WearSlot slot) {
return wear[slot.ordinal()];
}
public void setItemTypeInWearSlot(WearSlot slot, ItemType type) {
wear[slot.ordinal()] = type;
}