diff --git a/src/facilities/wardrobe/wardrobeShopping.js b/src/facilities/wardrobe/wardrobeShopping.js index 93f1d61ec33ab27cb5660494fffda4912337c7ea..7404956fffa0625aa3ab4bae0a4075dc7c9819a0 100644 --- a/src/facilities/wardrobe/wardrobeShopping.js +++ b/src/facilities/wardrobe/wardrobeShopping.js @@ -1,5 +1,6 @@ App.UI.WardrobeShopping = function() { const el = document.createElement("p"); + let p; el.id = "wardrobe-shopping"; App.UI.DOM.appendNewElement("H1", el, `Slave Wardrobe`); @@ -49,7 +50,10 @@ App.UI.WardrobeShopping = function() { App.UI.DOM.appendNewElement("H2", el, `Accessories`); - el.append(accessoryBlock()); + p = document.createElement("p"); + p.id = "accessory-block"; + p.append(accessoryBlock()); + el.append(p); return el; @@ -81,6 +85,12 @@ App.UI.WardrobeShopping = function() { function createCell(clothing, oldOutfit = "") { const el = document.createElement("div"); el.classList.add("wardrobe-shopping-cell"); + el.onclick = () => { + // Randomize devotion and trust a bit, so the model moves their arms and "poses" for the player. + model.devotion = random(-10, 70); + model.trust = random(30, 100); + jQuery(`#${clothing}`).empty().append(createCell(clothing, model.clothes)); + }; /** @type {wardrobeItem} */ const clothingObj = App.Data.WardrobeShopping.Clothing[category][clothing]; const cost = Math.trunc(clothingObj.cost * V.upgradeMultiplierTrade); @@ -107,12 +117,6 @@ App.UI.WardrobeShopping = function() { model[prop] = "none"; } } - el.onclick = () => { - // Randomize devotion and trust a bit, so the model moves their arms and "poses" for the player. - model.devotion = random(-10, 70); - model.trust = random(30, 100); - jQuery(`#${clothing}`).empty().append(createCell(clothing, model.clothes)); - }; } if (!isItemAccessible.entry(model.clothes, "clothing")) { if (cost < V.cash) { @@ -124,7 +128,6 @@ App.UI.WardrobeShopping = function() { () => { cashX(forceNeg(cost), "capEx"); V.boughtItem.clothing[clothing] = 1; - refresh(); } ) ); @@ -177,7 +180,7 @@ App.UI.WardrobeShopping = function() { () => { cashX(forceNeg(cost), "capEx"); _.set(V.boughtItem, name, 1); - refresh(); + jQuery(`#accessory-block`).empty().append(accessoryBlock()); } ) ); @@ -202,8 +205,4 @@ App.UI.WardrobeShopping = function() { return line; } } - - function refresh() { - jQuery(`#wardrobe-shopping`).empty().append(App.UI.WardrobeShopping()); - } };