diff --git a/src/facilities/wardrobe/wardrobeShopping.js b/src/facilities/wardrobe/wardrobeShopping.js index 4678d395345bb548d91942c84338161cce9b24c2..41036df161fcce64d110d31769fbd5d994118c60 100644 --- a/src/facilities/wardrobe/wardrobeShopping.js +++ b/src/facilities/wardrobe/wardrobeShopping.js @@ -61,16 +61,21 @@ App.UI.WardrobeShopping = function() { const el = document.createElement("p"); el.classList.add("wardrobe-shopping-block"); el.id = `id${category}`; - Object.keys(data).forEach((clothing) => el.append(createCell(clothing))); + Object.keys(data).forEach( + (clothing) => { + const cell = document.createElement("span"); + cell.id = clothing; + cell.append(createCell(clothing)); + el.append(cell); + }); return el; /** * * @param {string} clothing */ - function createCell(clothing) { + function createCell(clothing, oldOutfit = "") { const el = document.createElement("div"); - el.id = clothing; el.classList.add("wardrobe-shopping-cell"); /** @type {wardrobeItem} */ const clothingObj = App.Data.WardrobeShopping[category][clothing]; @@ -78,11 +83,17 @@ App.UI.WardrobeShopping = function() { let div; if (V.seeImages === 1) { + // If we have more than one possible outfit to showcase, make sure not to show the outfit we did last time. + const clothesArray = clothingObj.contains.length > 1 ? clothingObj.contains.filter(item => item !== oldOutfit) : clothingObj.contains; + // Get a randomly chosen piece of clothing from the set to display: - model.clothes = clothingObj.contains[Math.floor(Math.random() * clothingObj.contains.length)]; + model.clothes = clothesArray[Math.floor(Math.random() * clothesArray.length)]; + + // Some clothing is weird (looking at you, Egyptian necklace) if (clothingObj.hasOwnProperty("modelUpdate")) { Object.assign(model, clothingObj.modelUpdate); } + App.UI.DOM.appendNewElement("div", el, App.Art.SlaveArtElement(model, 1, 0), ["imageRef", "smlImg"]); // Clean up clothing @@ -91,7 +102,7 @@ App.UI.WardrobeShopping = function() { model[prop] = "none"; } } - el.onclick = () => jQuery(`#${clothing}`).empty().append(createCell(clothing)); + el.onclick = () => jQuery(`#${clothing}`).empty().append(createCell(clothing, model.clothes)); } if (!V.boughtItem.clothing[clothing]) { if (cost < V.cash) {