-
Notifications
You must be signed in to change notification settings - Fork 11
/
Inventory.java
49 lines (40 loc) · 1.18 KB
/
Inventory.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.util.HashMap;
import java.util.Map;
import java.util.Collection;
/**
* Write a description of class Inventory here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Inventory
{
private static Map<String, InventoryItem> map = new HashMap<String, InventoryItem>();
private String inventorySprite = "";
/**
* Constructor for objects of class InventoryItem
*/
public Inventory()
{
}
public void addItem(InventoryItem item) {
map.put(item.getName(), item);
}
public Collection<InventoryItem> getItems() {
return map.values();
}
public void setInventorySprite(String inventorySprite) {
this.inventorySprite = inventorySprite;
}
public String getInventorySprite() {
return inventorySprite;
}
public void use(InventoryItem item) {
ScriptManager.invokeMethod("scripts", "inventory", "use", item);
}
public void openInventory() {
if(!(SceneManager.getInstance().getCurrentWorld() instanceof InventoryWorld)) {
SceneManager.getInstance().setCurrentWorld(new InventoryWorld());
}
}
}