diff options
Diffstat (limited to 'resources/js/classes')
-rw-r--r-- | resources/js/classes/InventoryItem.js | 40 | ||||
-rw-r--r-- | resources/js/classes/Item.js | 22 | ||||
-rw-r--r-- | resources/js/classes/State.js | 2 |
3 files changed, 62 insertions, 2 deletions
diff --git a/resources/js/classes/InventoryItem.js b/resources/js/classes/InventoryItem.js new file mode 100644 index 0000000..9dfdbcc --- /dev/null +++ b/resources/js/classes/InventoryItem.js @@ -0,0 +1,40 @@ +class InventoryItem { + /** + * @type {Item} + */ + item = null; + + /** + * @type {number} + */ + quantity = 1; + + /** + * @param {Item} item + */ + constructor (item) { + this.item = item; + } + + /* Item */ + + get slug () { + return this.item.slug; + } + + get name () { + return this.item.name; + } + + get category () { + return this.item.category; + } + + get type () { + return this.item.type; + } + + get sprite () { + return this.item.sprite; + } +} diff --git a/resources/js/classes/Item.js b/resources/js/classes/Item.js index e274a20..6207cc2 100644 --- a/resources/js/classes/Item.js +++ b/resources/js/classes/Item.js @@ -1 +1,21 @@ -class Item {} +class Item { + constructor (slug) { + this.slug = slug; + } + + get name () { + return slugToName(this.slug); + } + + get category () { + return DB.items[this.slug].category; + } + + get type () { + return DB.items[this.slug].type; + } + + get sprite () { + return DB.items[this.slug].sprite; + } +} diff --git a/resources/js/classes/State.js b/resources/js/classes/State.js index 2384a85..c0065d1 100644 --- a/resources/js/classes/State.js +++ b/resources/js/classes/State.js @@ -10,7 +10,7 @@ class State { monsters = []; /** - * @type {Item[]} + * @type {InventoryItem[]} */ inventory = []; |