From 68c34636b4df0f38cc4ed73203bf30f551278ae4 Mon Sep 17 00:00:00 2001 From: fcanon <fcanon@nowhere.na> Date: Fri, 23 Feb 2018 10:54:52 -0500 Subject: [PATCH] fix ValidateFacilityDecoration widget pass by name/pass by reference issue --- src/uncategorized/futureSocities.tw | 20 ++-- src/utility/miscWidgets.tw | 165 ++++++++++++++++++---------- 2 files changed, 116 insertions(+), 69 deletions(-) diff --git a/src/uncategorized/futureSocities.tw b/src/uncategorized/futureSocities.tw index ce513bd1b96..3e5b683ce73 100644 --- a/src/uncategorized/futureSocities.tw +++ b/src/uncategorized/futureSocities.tw @@ -1891,7 +1891,7 @@ You are spending <<print cashFormat($FSSpending)>> each week to support your soc /* FACILITY REDECORATION */ <<if $brothel > 0>> -<<ValidateFacilityDecoration $brothelDecoration>> +<<ValidateFacilityDecoration "brothelDecoration">> <br>$brothelNameCaps is decorated in $brothelDecoration style. <<if ($arcologies[0].FSSupremacist >= 20) && ($brothelDecoration != "Supremacist")>> <br> [[Supremacist redecoration|Future Society][$brothelDecoration = "Supremacist", $cash -= 5000]] @@ -1963,7 +1963,7 @@ You are spending <<print cashFormat($FSSpending)>> each week to support your soc <</if>> <<if $club > 0>> -<<ValidateFacilityDecoration $clubDecoration>> +<<ValidateFacilityDecoration "clubDecoration">> <br>$clubNameCaps is decorated in $clubDecoration style. <<if ($arcologies[0].FSSupremacist >= 20) && ($clubDecoration != "Supremacist")>> <br> [[Supremacist redecoration|Future Society][$clubDecoration = "Supremacist", $cash -= 5000]] @@ -2035,7 +2035,7 @@ You are spending <<print cashFormat($FSSpending)>> each week to support your soc <</if>> <<if $dairy > 0>> -<<ValidateFacilityDecoration $dairyDecoration>> +<<ValidateFacilityDecoration "dairyDecoration">> <br>$dairyNameCaps is decorated in $dairyDecoration style. <<if ($arcologies[0].FSSupremacist >= 20) && ($dairyDecoration != "Supremacist")>> <br> [[Supremacist redecoration|Future Society][$dairyDecoration = "Supremacist", $cash -= 5000]] @@ -2107,7 +2107,7 @@ You are spending <<print cashFormat($FSSpending)>> each week to support your soc <</if>> <<if $spa > 0>> -<<ValidateFacilityDecoration $spaDecoration>> +<<ValidateFacilityDecoration "spaDecoration">> <br>$spaNameCaps is decorated in $spaDecoration style. <<if ($arcologies[0].FSSupremacist >= 20) && ($spaDecoration != "Supremacist")>> <br> [[Supremacist redecoration|Future Society][$spaDecoration = "Supremacist", $cash -= 5000]] @@ -2179,7 +2179,7 @@ You are spending <<print cashFormat($FSSpending)>> each week to support your soc <</if>> <<if $clinic > 0>> -<<ValidateFacilityDecoration $clinicDecoration>> +<<ValidateFacilityDecoration "clinicDecoration">> <br>$clinicNameCaps is decorated in $clinicDecoration style. <<if ($arcologies[0].FSSupremacist >= 20) && ($clinicDecoration != "Supremacist")>> <br> [[Supremacist redecoration|Future Society][$clinicDecoration = "Supremacist", $cash -= 5000]] @@ -2251,7 +2251,7 @@ You are spending <<print cashFormat($FSSpending)>> each week to support your soc <</if>> <<if $schoolroom > 0>> -<<ValidateFacilityDecoration $schoolroomDecoration>> +<<ValidateFacilityDecoration "schoolroomDecoration">> <br>$schoolroomNameCaps is decorated in $schoolroomDecoration style. <<if ($arcologies[0].FSSupremacist >= 20) && ($schoolroomDecoration != "Supremacist")>> <br> [[Supremacist redecoration|Future Society][$schoolroomDecoration = "Supremacist", $cash -= 5000]] @@ -2323,7 +2323,7 @@ You are spending <<print cashFormat($FSSpending)>> each week to support your soc <</if>> <<if $cellblock > 0>> -<<ValidateFacilityDecoration $cellblockDecoration>> +<<ValidateFacilityDecoration "cellblockDecoration">> <br>$cellblockNameCaps is decorated in $cellblockDecoration style. <<if ($arcologies[0].FSSupremacist >= 20) && ($cellblockDecoration != "Supremacist")>> <br> [[Supremacist redecoration|Future Society][$cellblockDecoration = "Supremacist", $cash -= 5000]] @@ -2395,7 +2395,7 @@ You are spending <<print cashFormat($FSSpending)>> each week to support your soc <</if>> <<if $servantsQuarters > 0>> -<<ValidateFacilityDecoration $servantsQuartersDecoration>> +<<ValidateFacilityDecoration "servantsQuartersDecoration">> <br>$servantsQuartersNameCaps is decorated in $servantsQuartersDecoration style. <<if ($arcologies[0].FSSupremacist >= 20) && ($servantsQuartersDecoration != "Supremacist")>> <br> [[Supremacist redecoration|Future Society][$servantsQuartersDecoration = "Supremacist", $cash -= 5000]] @@ -2467,7 +2467,7 @@ You are spending <<print cashFormat($FSSpending)>> each week to support your soc <</if>> <<if $arcade > 0>> -<<ValidateFacilityDecoration $arcadeDecoration>> +<<ValidateFacilityDecoration "arcadeDecoration">> <br>$arcadeNameCaps is decorated in $arcadeDecoration style. <<if ($arcologies[0].FSSupremacist >= 20) && ($arcadeDecoration != "Supremacist")>> <br> [[Supremacist redecoration|Future Society][$arcadeDecoration = "Supremacist", $cash -= 5000]] @@ -2539,7 +2539,7 @@ You are spending <<print cashFormat($FSSpending)>> each week to support your soc <</if>> <<if $masterSuite > 0>> -<<ValidateFacilityDecoration $masterSuiteDecoration>> +<<ValidateFacilityDecoration "masterSuiteDecoration">> <br>$masterSuiteNameCaps is decorated in $masterSuiteDecoration style. <<if ($arcologies[0].FSSupremacist >= 20) && ($masterSuiteDecoration != "Supremacist")>> <br> [[Supremacist redecoration|Future Society][$masterSuiteDecoration = "Supremacist", $cash -= 5000]] diff --git a/src/utility/miscWidgets.tw b/src/utility/miscWidgets.tw index 5b43b0fb22a..34ed5888290 100644 --- a/src/utility/miscWidgets.tw +++ b/src/utility/miscWidgets.tw @@ -2199,71 +2199,118 @@ This experience <</widget>> <<widget "ValidateFacilityDecoration">> -/* Used by following widget, called with <<ValidateFacilityDecoration var>> where var is for example $spaDecoration */ -<<if $args[0] != "standard">> - <<if !Number.isFinite($arcologies[0].FSSupremacist) && ($args[0] == "Supremacist")>> - <<set $args[0] = "standard">> - <<elseif !Number.isFinite($arcologies[0].FSSubjugationist) && ($args[0] == "Subjugationist")>> - <<set $args[0] = "standard">> - <<elseif !Number.isFinite($arcologies[0].FSGenderRadicalist) && ($args[0] == "Gender Radicalist")>> - <<set $args[0] = "standard">> - <<elseif !Number.isFinite($arcologies[0].FSGenderFundamentalist) && ($args[0] == "Gender Fundamentalist")>> - <<set $args[0] = "standard">> - <<elseif !Number.isFinite($arcologies[0].FSPaternalist) && ($args[0] == "Paternalist")>> - <<set $args[0] = "standard">> - <<elseif !Number.isFinite($arcologies[0].FSBodyPurist) && ($args[0] == "Body Purist")>> - <<set $args[0] = "standard">> - <<elseif !Number.isFinite($arcologies[0].FSTransformationFetishist) && ($args[0] == "Transformation Fetishist")>> - <<set $args[0] = "standard">> - <<elseif !Number.isFinite($arcologies[0].FSYouthPreferentialist) && ($args[0] == "Youth Preferentialist")>> - <<set $args[0] = "standard">> - <<elseif !Number.isFinite($arcologies[0].FSMaturityPreferentialist) && ($args[0] == "Maturity Preferentialist")>> - <<set $args[0] = "standard">> - <<elseif !Number.isFinite($arcologies[0].FSSlimnessEnthusiast) && ($args[0] == "Slimness Enthusiast")>> - <<set $args[0] = "standard">> - <<elseif !Number.isFinite($arcologies[0].FSAssetExpansionist) && ($args[0] == "Asset Expansionist")>> - <<set $args[0] = "standard">> - <<elseif !Number.isFinite($arcologies[0].FSPastoralist) && ($args[0] == "Pastoralist")>> - <<set $args[0] = "standard">> - <<elseif !Number.isFinite($arcologies[0].FSPhysicalIdealist) && ($args[0] == "Physical Idealist")>> - <<set $args[0] = "standard">> - <<elseif !Number.isFinite($arcologies[0].FSChattelReligionist) && ($args[0] == "Chattel Religionist")>> - <<set $args[0] = "standard">> - <<elseif !Number.isFinite($arcologies[0].FSDegradationist) && ($args[0] == "Degradationist")>> - <<set $args[0] = "standard">> - <<elseif !Number.isFinite($arcologies[0].FSRomanRevivalist) && ($args[0] == "Roman Revivalist")>> - <<set $args[0] = "standard">> - <<elseif !Number.isFinite($arcologies[0].FSEgyptianRevivalist) && ($args[0] == "Egyptian Revivalist")>> - <<set $args[0] = "standard">> - <<elseif !Number.isFinite($arcologies[0].FSEdoRevivalist) && ($args[0] == "Edo Revivalist")>> - <<set $args[0] = "standard">> - <<elseif !Number.isFinite($arcologies[0].FSArabianRevivalist) && ($args[0] == "Arabian Revivalist")>> - <<set $args[0] = "standard">> - <<elseif !Number.isFinite($arcologies[0].FSChineseRevivalist) && ($args[0] == "Chinese Revivalist")>> - <<set $args[0] = "standard">> - <<elseif !Number.isFinite($arcologies[0].FSRepopulationFocus) && ($args[0] == "Repopulation Focus")>> - <<set $args[0] = "standard">> - <<elseif !Number.isFinite($arcologies[0].FSRestart) && ($args[0] == "Eugenics")>> - <<set $args[0] = "standard">> - <<elseif !Number.isFinite($arcologies[0].FSHedonisticDecadence) && ($args[0] == "Hedonistic")>> - <<set $args[0] = "standard">> +/* Used by following widget, called with <<ValidateFacilityDecoration "var">> where var is for example "spaDecoration" -- quotes are needed to pass var as reference - DO NOT INCLUDE $ PREFIX! */ +<<switch State.variables[$args[0]]>> /* get value of var name that was provided */ +<<case "standard">> + /* nothing to do */ +<<case "Supremacist">> + <<if !Number.isFinite($arcologies[0].FSSupremacist)>> + <<set State.variables[$args[0]] = "standard">> <</if>> -<</if>> +<<case "Subjugationist">> + <<if !Number.isFinite($arcologies[0].FSSubjugationist)>> + <<set State.variables[$args[0]] = "standard">> + <</if>> +<<case "Gender Radicalist">> + <<if !Number.isFinite($arcologies[0].FSGenderRadicalist)>> + <<set State.variables[$args[0]] = "standard">> + <</if>> +<<case "Gender Fundamentalist">> + <<if !Number.isFinite($arcologies[0].FSGenderFundamentalist)>> + <<set State.variables[$args[0]] = "standard">> + <</if>> +<<case "Paternalist">> + <<if !Number.isFinite($arcologies[0].FSPaternalist)>> + <<set State.variables[$args[0]] = "standard">> + <</if>> +<<case "Body Purist">> + <<if !Number.isFinite($arcologies[0].FSBodyPurist)>> + <<set State.variables[$args[0]] = "standard">> + <</if>> +<<case "Transformation Fetishist">> + <<if !Number.isFinite($arcologies[0].FSTransformationFetishist)>> + <<set State.variables[$args[0]] = "standard">> + <</if>> +<<case "Youth Preferentialist">> + <<if !Number.isFinite($arcologies[0].FSYouthPreferentialist)>> + <<set State.variables[$args[0]] = "standard">> + <</if>> +<<case "Maturity Preferentialist">> + <<if !Number.isFinite($arcologies[0].FSMaturityPreferentialist)>> + <<set State.variables[$args[0]] = "standard">> + <</if>> +<<case "Slimness Enthusiast">> + <<if !Number.isFinite($arcologies[0].FSSlimnessEnthusiast)>> + <<set State.variables[$args[0]] = "standard">> + <</if>> +<<case "Asset Expansionist">> + <<if !Number.isFinite($arcologies[0].FSAssetExpansionist)>> + <<set State.variables[$args[0]] = "standard">> + <</if>> +<<case "Pastoralist">> + <<if !Number.isFinite($arcologies[0].FSPastoralist)>> + <<set State.variables[$args[0]] = "standard">> + <</if>> +<<case "Physical Idealist">> + <<if !Number.isFinite($arcologies[0].FSPhysicalIdealist)>> + <<set State.variables[$args[0]] = "standard">> + <</if>> +<<case "Chattel Religionist">> + <<if !Number.isFinite($arcologies[0].FSChattelReligionist)>> + <<set State.variables[$args[0]] = "standard">> + <</if>> +<<case "Degradationist">> + <<if !Number.isFinite($arcologies[0].FSDegradationist)>> + <<set State.variables[$args[0]] = "standard">> + <</if>> +<<case "Roman Revivalist">> + <<if !Number.isFinite($arcologies[0].FSRomanRevivalist)>> + <<set State.variables[$args[0]] = "standard">> + <</if>> +<<case "Egyptian Revivalist">> + <<if !Number.isFinite($arcologies[0].FSEgyptianRevivalist)>> + <<set State.variables[$args[0]] = "standard">> + <</if>> +<<case "Edo Revivalist">> + <<if !Number.isFinite($arcologies[0].FSEdoRevivalist)>> + <<set State.variables[$args[0]] = "standard">> + <</if>> +<<case "Arabian Revivalist">> + <<if !Number.isFinite($arcologies[0].FSArabianRevivalist)>> + <<set State.variables[$args[0]] = "standard">> + <</if>> +<<case "Chinese Revivalist">> + <<if !Number.isFinite($arcologies[0].FSChineseRevivalist)>> + <<set State.variables[$args[0]] = "standard">> + <</if>> +<<case "Repopulation Focus">> + <<if !Number.isFinite($arcologies[0].FSRepopulationFocus)>> + <<set State.variables[$args[0]] = "standard">> + <</if>> +<<case "Eugenics">> + <<if !Number.isFinite($arcologies[0].FSRestart)>> + <<set State.variables[$args[0]] = "standard">> + <</if>> +<<case "Hedonistic">> + <<if !Number.isFinite($arcologies[0].FSHedonisticDecadence)>> + <<set State.variables[$args[0]] = "standard">> + <</if>> +<</switch>> <</widget>> <<widget "ClearFacilityDecorations">> /* Called when a FS is abandoned or failed out of. */ -<<if $brothel > 0>><<ValidateFacilityDecoration $brothelDecoration>><</if>> -<<if $club > 0>><<ValidateFacilityDecoration $clubDecoration>><</if>> -<<if $dairy > 0>><<ValidateFacilityDecoration $dairyDecoration>><</if>> -<<if $spa > 0>><<ValidateFacilityDecoration $spaDecoration>><</if>> -<<if $clinic > 0>><<ValidateFacilityDecoration $clinicDecoration>><</if>> -<<if $schoolroom > 0>><<ValidateFacilityDecoration $schoolroomDecoration>><</if>> -<<if $cellblock > 0>><<ValidateFacilityDecoration $cellblockDecoration>><</if>> -<<if $servantsQuarters > 0>><<ValidateFacilityDecoration $servantsQuartersDecoration>><</if>> -<<if $arcade > 0>><<ValidateFacilityDecoration $arcadeDecoration>><</if>> -<<if $masterSuite > 0>><<ValidateFacilityDecoration $masterSuiteDecoration>><</if>> +<<if $brothel > 0>><<ValidateFacilityDecoration "brothelDecoration">><</if>> +<<if $club > 0>><<ValidateFacilityDecoration "clubDecoration">><</if>> +<<if $dairy > 0>><<ValidateFacilityDecoration "dairyDecoration">><</if>> +<<if $spa > 0>><<ValidateFacilityDecoration "spaDecoration">><</if>> +<<if $clinic > 0>><<ValidateFacilityDecoration "clinicDecoration">><</if>> +<<if $schoolroom > 0>><<ValidateFacilityDecoration "schoolroomDecoration">><</if>> +<<if $cellblock > 0>><<ValidateFacilityDecoration "cellblockDecoration">><</if>> +<<if $servantsQuarters > 0>><<ValidateFacilityDecoration "servantsQuartersDecoration">><</if>> +<<if $arcade > 0>><<ValidateFacilityDecoration "arcadeDecoration">><</if>> +<<if $masterSuite > 0>><<ValidateFacilityDecoration "masterSuiteDecoration">><</if>> <</widget>> -- GitLab