From 0305106ce541dc9091de910ff7a04d39caf620f5 Mon Sep 17 00:00:00 2001 From: cha0s Date: Mon, 7 Oct 2019 03:12:41 -0500 Subject: [PATCH] chore: tidy --- common/traits/item.trait.js | 20 +++++++++++--------- server/fixtures/hoe.entity.js | 2 +- server/fixtures/potion.entity.js | 2 +- server/fixtures/rock.entity.js | 2 +- server/fixtures/tomato-seeds.entity.js | 2 +- server/fixtures/watering-can.entity.js | 2 +- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/common/traits/item.trait.js b/common/traits/item.trait.js index 22fb868..3926a02 100644 --- a/common/traits/item.trait.js +++ b/common/traits/item.trait.js @@ -24,7 +24,7 @@ export class Item extends decorate(Trait) { type: 'actions', traversals: [], }, - slotImages: { + slotImageUris: { default: '/question-mark.png', }, }; @@ -44,16 +44,18 @@ export class Item extends decorate(Trait) { super(entity, params, state); const itemActions = this._processedItemActions(); this._itemActions = behaviorItemFromJSON(itemActions); - this._slotImages = {}; + this._slotImageUris = {}; } hydrate() { if (AVOCADO_CLIENT) { const promises = []; - for (const index in this.params.slotImages) { - promises.push(Image.load(this.params.slotImages[index]).then((image) => { - this._slotImages[index] = image; - })); + for (const index in this.params.slotImageUris) { + const imageUri = this.params.slotImageUris[index]; + const promise = Image.load(imageUri).then((image) => { + this._slotImageUris[index] = image; + }); + promises.push(promise); } return Promise.all(promises); } @@ -102,11 +104,11 @@ export class Item extends decorate(Trait) { imageForSlot: () => { const qty = this.entity.qty; - if (this._slotImages[qty]) { - return this._slotImages[qty]; + if (this._slotImageUris[qty]) { + return this._slotImageUris[qty]; } else { - return this._slotImages['default']; + return this._slotImageUris['default']; } }, diff --git a/server/fixtures/hoe.entity.js b/server/fixtures/hoe.entity.js index 9c0e055..839a12f 100644 --- a/server/fixtures/hoe.entity.js +++ b/server/fixtures/hoe.entity.js @@ -21,7 +21,7 @@ export function hoeJSON() { buildInvoke(['item', 'useTool']), ], }, - slotImages: { + slotImageUris: { default: '/hoe.png', }, }, diff --git a/server/fixtures/potion.entity.js b/server/fixtures/potion.entity.js index c9ce43a..8871648 100644 --- a/server/fixtures/potion.entity.js +++ b/server/fixtures/potion.entity.js @@ -38,7 +38,7 @@ export function potionJSON() { decrement, ], }, - slotImages: { + slotImageUris: { default: '/potion.png', }, }, diff --git a/server/fixtures/rock.entity.js b/server/fixtures/rock.entity.js index 66545ec..7633383 100644 --- a/server/fixtures/rock.entity.js +++ b/server/fixtures/rock.entity.js @@ -51,7 +51,7 @@ export function rockJSON() { setProjectileBehaving, ], }, - slotImages: { + slotImageUris: { default: '/rock.png', }, }, diff --git a/server/fixtures/tomato-seeds.entity.js b/server/fixtures/tomato-seeds.entity.js index 126c27e..ec61fe2 100644 --- a/server/fixtures/tomato-seeds.entity.js +++ b/server/fixtures/tomato-seeds.entity.js @@ -20,7 +20,7 @@ export function tomatoSeedsJSON() { buildInvoke(['item', 'useTool']), ], }, - slotImages: { + slotImageUris: { default: '/seeds.png', }, }, diff --git a/server/fixtures/watering-can.entity.js b/server/fixtures/watering-can.entity.js index 1fc8397..3969133 100644 --- a/server/fixtures/watering-can.entity.js +++ b/server/fixtures/watering-can.entity.js @@ -21,7 +21,7 @@ export function wateringCanJSON() { buildInvoke(['item', 'useTool']), ], }, - slotImages: { + slotImageUris: { default: '/watering-can.png', }, },