From 9d345634282e2182055a0887e287e5f31445df7a Mon Sep 17 00:00:00 2001
From: Braymann <braymann00@gmail.com>
Date: Fri, 22 Jul 2022 21:23:07 -0500
Subject: [PATCH 1/3] Broken hood creation fix

---
 game/base-clothing/clothing-sets.twee | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/game/base-clothing/clothing-sets.twee b/game/base-clothing/clothing-sets.twee
index cf32e758f5..7b9c00aea1 100644
--- a/game/base-clothing/clothing-sets.twee
+++ b/game/base-clothing/clothing-sets.twee
@@ -321,7 +321,7 @@
 							<<run resetClothingState($_outfitslot)>>
 						<</for>>
 
-						<<if $_slot is "upper" and $worn.upper.hoodposition>>
+						<<if $_slot is "upper" and $worn.upper.hoodposition and $worn.upper.outfitPrimary.head isnot "broken">>
 							<<if $worn.upper.hoodposition isnot outfitHoodPosition($outfit[$wear_outfit])>>
 								<<toggleHood>>
 								<<set _equipSkip["head"] to ($worn.upper.hoodposition is "up" ? true : false)>>
@@ -330,7 +330,7 @@
 					<<else>>
 						<<if $worn[$_slot].name is $_incomingItemName>>
 							<<set _notEquipped[$_slot] to {"name": $_incomingItemName, "reason": "not found replacement"}>>
-							<<if $_slot is "upper" and $worn.upper.hoodposition and $worn.upper.hoodposition isnot outfitHoodPosition($outfit[$wear_outfit])>>
+							<<if $_slot is "upper" and $worn.upper.hoodposition and $worn.upper.outfitPrimary.head isnot "broken" and $worn.upper.hoodposition isnot outfitHoodPosition($outfit[$wear_outfit])>>
 								<<toggleHood>>
 							<</if>>
 							<<if $wardrobe_location isnot "wardrobe">>
-- 
GitLab


From de68b028085a16128931e74143f361350f45fdaf Mon Sep 17 00:00:00 2001
From: Braymann <braymann00@gmail.com>
Date: Fri, 22 Jul 2022 21:27:13 -0500
Subject: [PATCH 2/3] hoodie outfit fix comments

---
 game/03-JavaScript/ingame.js          | 4 ++++
 game/base-clothing/clothing-sets.twee | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/game/03-JavaScript/ingame.js b/game/03-JavaScript/ingame.js
index b0477a84ea..026ab3b7e0 100644
--- a/game/03-JavaScript/ingame.js
+++ b/game/03-JavaScript/ingame.js
@@ -1449,6 +1449,10 @@ function playerCanBreedWith(npc) {
 window.playerCanBreedWith = playerCanBreedWith;
 
 function outfitHoodPosition(outfit) {
+	/*This function is used to determine whether a hoodie in a given outfit set should have its hood up or down.
+	 * It does this by comparing the upper and head slots to determine whether they're part of the same clothing item
+	*/
+
 	let hoodie = setup.clothes.upper.find(item => item.name === outfit.upper);
 	if (hoodie.hoodposition === undefined) return "none";
 	if (outfit.head !== hoodie.outfitPrimary.head) return "down";
diff --git a/game/base-clothing/clothing-sets.twee b/game/base-clothing/clothing-sets.twee
index 7b9c00aea1..368ca4c909 100644
--- a/game/base-clothing/clothing-sets.twee
+++ b/game/base-clothing/clothing-sets.twee
@@ -321,6 +321,7 @@
 							<<run resetClothingState($_outfitslot)>>
 						<</for>>
 
+						/*If the worn item was a hoodie, make sure the hood is in the correct position*/
 						<<if $_slot is "upper" and $worn.upper.hoodposition and $worn.upper.outfitPrimary.head isnot "broken">>
 							<<if $worn.upper.hoodposition isnot outfitHoodPosition($outfit[$wear_outfit])>>
 								<<toggleHood>>
@@ -330,6 +331,7 @@
 					<<else>>
 						<<if $worn[$_slot].name is $_incomingItemName>>
 							<<set _notEquipped[$_slot] to {"name": $_incomingItemName, "reason": "not found replacement"}>>
+							/*If the worn item was a hoodie, make sure the hood is in the correct position*/
 							<<if $_slot is "upper" and $worn.upper.hoodposition and $worn.upper.outfitPrimary.head isnot "broken" and $worn.upper.hoodposition isnot outfitHoodPosition($outfit[$wear_outfit])>>
 								<<toggleHood>>
 							<</if>>
-- 
GitLab


From a1aa514d4265232181c013699eee78e3eb959ed0 Mon Sep 17 00:00:00 2001
From: Braymann <braymann00@gmail.com>
Date: Sat, 23 Jul 2022 13:26:05 -0500
Subject: [PATCH 3/3] Hoodie shop fixes

---
 game/base-clothing/wardrobes.twee | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/game/base-clothing/wardrobes.twee b/game/base-clothing/wardrobes.twee
index a5c0670992..dea06bdb7d 100644
--- a/game/base-clothing/wardrobes.twee
+++ b/game/base-clothing/wardrobes.twee
@@ -582,11 +582,23 @@ Type: <label>Everyday <<radiobutton "$outfit_type" 0 checked>></label> | <label>
 		<<else>>
 			<<set $worn.head to clone(setup.clothes.head[0])>>
 		<</if>>
+
+		<<if _args[0] is "shop" and $tryOn.tryingOn.upper is null>>
+			<<updateOwned "upper">>
+			<<updateOwned "head">>
+		<</if>>
 	
 	/* If hood is down, put it back up and remove anything on the head if necessary */
 	<<else>>
 		<<if !$worn.head.cursed>> /* No cursed head items yet, but if one is made, should probably have some popup saying this was prevented */
-			<<if $worn.head.name isnot "naked" and _args[0] isnot "shop">> /*Don't put head accessory back in wardrobe if curently in a shop, might need it back*/
+			<<if _args[0] is "shop">> /*If in a shop, make sure the head item is accounted for first*/
+				<<if $tryOn.tryingOn.head isnot null>>
+					<<shopbuyv2 "head" "return" null>>/*return if trying on*/
+				<</if>>
+				<<if $tryOn.tryingOn.upper is null and $worn.head.name isnot "naked">>
+					<<generalUndress $wardrobe_location "head">>/*send back to wardrobe if already owned*/
+				<</if>>
+			<<elseif $worn.head.name isnot "naked">>
 				<<generalUndress $wardrobe_location "head">>
 			<</if>>
 			<<set $worn.upper.outfitPrimary.head to clone(setup.clothes.upper[$worn.upper.index].outfitPrimary.head)>>
@@ -602,6 +614,10 @@ Type: <label>Everyday <<radiobutton "$outfit_type" 0 checked>></label> | <label>
 			<<if $worn.head.accessory_colour is "custom">>
 				<<set $worn.head.accessory_colourCustom to $worn.upper.accessory_colourCustom>>
 			<</if>>
+			
+			<<if _args[0] is "shop" and $tryOn.tryingOn.upper is null>>
+				<<updateOwned "upper">>
+			<</if>>
 		<</if>>
 	<</if>>
 <</widget>>
-- 
GitLab