From 0b57334780ef85f9f40e388d2b6798adf13a5b4e Mon Sep 17 00:00:00 2001
From: lowercasedonkey <lowercasedonkey@gmail.com>
Date: Wed, 19 Aug 2020 21:01:23 -0400
Subject: [PATCH] clothing cycling

---
 src/facilities/wardrobe/wardrobeShopping.js | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/facilities/wardrobe/wardrobeShopping.js b/src/facilities/wardrobe/wardrobeShopping.js
index 4678d395345..41036df161f 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) {
-- 
GitLab