Skip to content
Snippets Groups Projects
Commit 13c9c32c authored by Pregmodder's avatar Pregmodder
Browse files

Merge branch 'pm-ra-setassignment-fix' into 'pregmod-master'

RA setAssignment merge fix

Closes #44

See merge request !1431
parents a7a349ed 22dd1b78
No related branches found
No related tags found
1 merge request!1431RA setAssignment merge fix
...@@ -1027,10 +1027,6 @@ window.mergeRules = function(rules) { ...@@ -1027,10 +1027,6 @@ window.mergeRules = function(rules) {
for (var i = 0; i < rules.length; i++) { for (var i = 0; i < rules.length; i++) {
for (var prop in rules[i]) { for (var prop in rules[i]) {
// we don't manage setAssignment here, we do it in <<DefaultRules>>
if (prop === "setAssignment")
continue;
// A rule overrides any preceding ones if, // A rule overrides any preceding ones if,
// * there are no preceding ones, // * there are no preceding ones,
// * or it sets autoBrand, // * or it sets autoBrand,
...@@ -1044,11 +1040,11 @@ window.mergeRules = function(rules) { ...@@ -1044,11 +1040,11 @@ window.mergeRules = function(rules) {
if (applies) if (applies)
{ {
//Objects in JS in operaions "=" pass by reference, so we need completly new object to avoid mess up previous rules. //Objects in JS in operations "=" pass by reference, so we need a completely new object to avoid messing up previous rules.
if ("object" == typeof rules[i][prop] && "object" != typeof combinedRule[prop]) if ("object" == typeof rules[i][prop] && "object" != typeof combinedRule[prop])
combinedRule[prop] = new Object(); combinedRule[prop] = new Object();
//If we already have object - now we will process it's properties, but object itself should be skiped. //If we already have object - now we will process its properties, but object itself should be skipped.
if ("object" != typeof combinedRule[prop]) if ("object" != typeof combinedRule[prop])
combinedRule[prop] = rules[i][prop]; combinedRule[prop] = rules[i][prop];
......
...@@ -2951,63 +2951,59 @@ Your brand design is ''$brandDesign.'' ...@@ -2951,63 +2951,59 @@ Your brand design is ''$brandDesign.''
<<continue>> <<continue>>
<</if>> <</if>>
<<set _temp = _combinedRule.setAssignment>> /% Before merging rules, we process assignments for each rule separately so we can remove slaves from facilities when they no longer qualify, even if the final "winning" rule assigns them elsewhere %/
<<set _combinedRule = mergeRules([_combinedRule, _currentRule])>> /% We also ignore inapplicable assignments for the current slave, so we only merge assignments that are valid %/
<<set _combinedRule.setAssignment = _temp>>
/% We merge assignments here %/
<<if _currentRule.setAssignment == "no default setting">>
<<continue>>
<</if>>
<<switch _currentRule.setAssignment>> <<switch _currentRule.setAssignment>>
<<case "no default setting">>
<<run delete _currentRule.setAssignment>>
<<case "live with your Head Girl">> <<case "live with your Head Girl">>
<<if ($HGSuiteSlaves < 1 && $args[0].indentureRestrictions <= 0)>> <<if ($HGSuiteSlaves < 1 && $args[0].indentureRestrictions <= 0)>>
<<set _combinedRule.setAssignment = _currentRule.setAssignment>>
<<else>> <<else>>
<<RAFacilityRemove $args[0] _currentRule>> <<RAFacilityRemove $args[0] _currentRule>> /% before deleting _currentRule.setAssignment %/
<<run delete _currentRule.setAssignment>>
<</if>> <</if>>
<<case "be confined in the arcade">> <<case "be confined in the arcade">>
<<if ($arcadeSlaves < $arcade && $args[0].indentureRestrictions <= 0 && $args[0].breedingMark != 1)>> <<if ($arcadeSlaves < $arcade && $args[0].indentureRestrictions <= 0 && $args[0].breedingMark != 1)>>
<<set _combinedRule.setAssignment = _currentRule.setAssignment>>
<<else>> <<else>>
<<RAFacilityRemove $args[0] _currentRule>> <<RAFacilityRemove $args[0] _currentRule>> /% before deleting _currentRule.setAssignment %/
<<run delete _currentRule.setAssignment>>
<</if>> <</if>>
<<case "serve in the master suite">> <<case "serve in the master suite">>
<<if ($masterSuiteSlaves < $masterSuite && ($args[0].devotion > 20 || $args[0].trust < -50 || ($args[0].devotion >= -50 && $args[0].trust < -20)))>> <<if ($masterSuiteSlaves < $masterSuite && ($args[0].devotion > 20 || $args[0].trust < -50 || ($args[0].devotion >= -50 && $args[0].trust < -20)))>>
<<set _combinedRule.setAssignment = _currentRule.setAssignment>>
<<else>> <<else>>
<<RAFacilityRemove $args[0] _currentRule>> <<RAFacilityRemove $args[0] _currentRule>> /% before deleting _currentRule.setAssignment %/
<<run delete _currentRule.setAssignment>>
<</if>> <</if>>
<<case "get treatment in the clinic">> <<case "get treatment in the clinic">>
<<if ($clinicSlaves < $clinic && ($args[0].health < 20 || ($args[0].chem > 15 && $Nurse != 0 && $clinicUpgradeFilters == 1)) || (($args[0].bellyImplant > -1) && ($bellyImplants == 1)) || $args[0].preg > 1)>> <<if ($clinicSlaves < $clinic && ($args[0].health < 20 || ($args[0].chem > 15 && $Nurse != 0 && $clinicUpgradeFilters == 1)) || (($args[0].bellyImplant > -1) && ($bellyImplants == 1)) || $args[0].preg > 1)>>
<<set _combinedRule.setAssignment = _currentRule.setAssignment>>
<<else>> <<else>>
<<RAFacilityRemove $args[0] _currentRule>> <<RAFacilityRemove $args[0] _currentRule>> /% before deleting _currentRule.setAssignment %/
<<run delete _currentRule.setAssignment>>
<</if>> <</if>>
<<case "rest in the spa">> <<case "rest in the spa">>
<<if ($spaSlaves < $spa) && ($args[0].health < 20) || ($args[0].trust < 60) || ($args[0].devotion <= 60) || ($args[0].fetish == "mindbroken") && ($args[0].devotion >= -20)>> <<if ($spaSlaves < $spa) && ($args[0].health < 20) || ($args[0].trust < 60) || ($args[0].devotion <= 60) || ($args[0].fetish == "mindbroken") && ($args[0].devotion >= -20)>>
<<set _combinedRule.setAssignment = _currentRule.setAssignment>>
<<else>> <<else>>
<<RAFacilityRemove $args[0] _currentRule>> <<RAFacilityRemove $args[0] _currentRule>> /% before deleting _currentRule.setAssignment %/
<<run delete _currentRule.setAssignment>>
<</if>> <</if>>
<<case "work in the brothel">> <<case "work in the brothel">>
<<if ($brothelSlaves < $brothel && ($args[0].devotion > 50 || $args[0].trust > 50 || $args[0].trust < -50 || ($args[0].devotion >= -50 && $args[0].trust < -20)) && $args[0].breedingMark != 1)>> <<if ($brothelSlaves < $brothel && ($args[0].devotion > 50 || $args[0].trust > 50 || $args[0].trust < -50 || ($args[0].devotion >= -50 && $args[0].trust < -20)) && $args[0].breedingMark != 1)>>
<<set _combinedRule.setAssignment = _currentRule.setAssignment>>
<<else>> <<else>>
<<RAFacilityRemove $args[0] _currentRule>> <<RAFacilityRemove $args[0] _currentRule>> /% before deleting _currentRule.setAssignment %/
<<run delete _currentRule.setAssignment>>
<</if>> <</if>>
<<case "serve in the club">> <<case "serve in the club">>
<<if ($clubSlaves < $club && ($args[0].devotion > 50 || $args[0].trust > 50 || $args[0].trust < -50 || ($args[0].devotion >= -50 && $args[0].trust < -20)) && $args[0].breedingMark != 1)>> <<if ($clubSlaves < $club && ($args[0].devotion > 50 || $args[0].trust > 50 || $args[0].trust < -50 || ($args[0].devotion >= -50 && $args[0].trust < -20)) && $args[0].breedingMark != 1)>>
<<set _combinedRule.setAssignment = _currentRule.setAssignment>>
<<else>> <<else>>
<<RAFacilityRemove $args[0] _currentRule>> <<RAFacilityRemove $args[0] _currentRule>> /% before deleting _currentRule.setAssignment %/
<<run delete _currentRule.setAssignment>>
<</if>> <</if>>
<<case "work in the dairy">> <<case "work in the dairy">>
...@@ -3019,81 +3015,95 @@ Your brand design is ''$brandDesign.'' ...@@ -3019,81 +3015,95 @@ Your brand design is ''$brandDesign.''
<<if ($args[0].devotion > 20) || (($args[0].devotion >= -50) && ($args[0].trust < -20)) || ($args[0].trust < -50) || ($args[0].amp == 1) || ($dairyRestraintsUpgrade == 1)>> <<if ($args[0].devotion > 20) || (($args[0].devotion >= -50) && ($args[0].trust < -20)) || ($args[0].trust < -50) || ($args[0].amp == 1) || ($dairyRestraintsUpgrade == 1)>>
<<if ($dairyStimulatorsSetting < 2) || ($args[0].anus > 2) || ($dairyPrepUpgrade == 1)>> <<if ($dairyStimulatorsSetting < 2) || ($args[0].anus > 2) || ($dairyPrepUpgrade == 1)>>
<<if ($dairyPregSetting < 2) || ($args[0].vagina > 2) || ($args[0].ovaries == 0) || ($dairyPrepUpgrade == 1)>> <<if ($dairyPregSetting < 2) || ($args[0].vagina > 2) || ($args[0].ovaries == 0) || ($dairyPrepUpgrade == 1)>>
<<set _combinedRule.setAssignment = _currentRule.setAssignment>>
<<else>> <<else>>
<<RAFacilityRemove $args[0] _currentRule>> <<RAFacilityRemove $args[0] _currentRule>> /% before deleting _currentRule.setAssignment %/
<<run delete _currentRule.setAssignment>>
<</if>> <</if>>
<<else>> <<else>>
<<RAFacilityRemove $args[0] _currentRule>> <<RAFacilityRemove $args[0] _currentRule>> /% before deleting _currentRule.setAssignment %/
<<run delete _currentRule.setAssignment>>
<</if>> <</if>>
<<else>> <<else>>
<<RAFacilityRemove $args[0] _currentRule>> <<RAFacilityRemove $args[0] _currentRule>> /% before deleting _currentRule.setAssignment %/
<<run delete _currentRule.setAssignment>>
<</if>> <</if>>
<<else>> <<else>>
<<RAFacilityRemove $args[0] _currentRule>> <<RAFacilityRemove $args[0] _currentRule>> /% before deleting _currentRule.setAssignment %/
<<run delete _currentRule.setAssignment>>
<</if>> <</if>>
<</if>> <</if>>
<</if>> <</if>>
<<case "work as a servant">> <<case "work as a servant">>
<<if ($servantsQuartersSlaves < $servantsQuarters && canSee($args[0]) && canWalk($args[0]) && ($args[0].devotion >= -20 || $args[0].trust < -20 || ($args[0].devotion >= -50 && $args[0].trust <= 20)))>> <<if ($servantsQuartersSlaves < $servantsQuarters && canSee($args[0]) && canWalk($args[0]) && ($args[0].devotion >= -20 || $args[0].trust < -20 || ($args[0].devotion >= -50 && $args[0].trust <= 20)))>>
<<set _combinedRule.setAssignment = _currentRule.setAssignment>>
<<else>> <<else>>
<<RAFacilityRemove $args[0] _currentRule>> <<RAFacilityRemove $args[0] _currentRule>> /% before deleting _currentRule.setAssignment %/
<<run delete _currentRule.setAssignment>>
<</if>> <</if>>
<<case "learn in the schoolroom">> <<case "learn in the schoolroom">>
<<if ($schoolroomSlaves < $schoolroom && $args[0].fetish != "mindbroken" && ($args[0].devotion >= -20 || $args[0].trust < -50 || ($args[0].devotion >= -50 && $args[0].trust < -20)))>> <<if ($schoolroomSlaves < $schoolroom && $args[0].fetish != "mindbroken" && ($args[0].devotion >= -20 || $args[0].trust < -50 || ($args[0].devotion >= -50 && $args[0].trust < -20)))>>
<<if ($args[0].intelligenceImplant < 1) || ($args[0].voice != 0 && $args[0].accent+$schoolroomUpgradeLanguage > 2) || ($args[0].oralSkill <= 10+$schoolroomUpgradeSkills*20) || ($args[0].whoreSkill <= 10+$schoolroomUpgradeSkills*20) || ($args[0].entertainSkill <= 10+$schoolroomUpgradeSkills*20) || ($args[0].analSkill < 10+$schoolroomUpgradeSkills*20) || (($args[0].vagina >= 0) && ($args[0].vaginalSkill < 10+$schoolroomUpgradeSkills*20))>> <<if ($args[0].intelligenceImplant < 1) || ($args[0].voice != 0 && $args[0].accent+$schoolroomUpgradeLanguage > 2) || ($args[0].oralSkill <= 10+$schoolroomUpgradeSkills*20) || ($args[0].whoreSkill <= 10+$schoolroomUpgradeSkills*20) || ($args[0].entertainSkill <= 10+$schoolroomUpgradeSkills*20) || ($args[0].analSkill < 10+$schoolroomUpgradeSkills*20) || (($args[0].vagina >= 0) && ($args[0].vaginalSkill < 10+$schoolroomUpgradeSkills*20))>>
<<set _combinedRule.setAssignment = _currentRule.setAssignment>>
<<else>> <<else>>
<<RAFacilityRemove $args[0] _currentRule>> <<RAFacilityRemove $args[0] _currentRule>> /% before deleting _currentRule.setAssignment %/
<<run delete _currentRule.setAssignment>>
<</if>> <</if>>
<<else>> <<else>>
<<RAFacilityRemove $args[0] _currentRule>> <<RAFacilityRemove $args[0] _currentRule>> /% before deleting _currentRule.setAssignment %/
<<run delete _currentRule.setAssignment>>
<</if>> <</if>>
<<case "be confined in the cellblock">> <<case "be confined in the cellblock">>
<<if ($cellblockSlaves < $cellblock && (($args[0].devotion < -20 && $args[0].trust >= -20) || ($args[0].devotion < -50 && $args[0].trust >= -50)))>> <<if ($cellblockSlaves < $cellblock && (($args[0].devotion < -20 && $args[0].trust >= -20) || ($args[0].devotion < -50 && $args[0].trust >= -50)))>>
<<set _combinedRule.setAssignment = _currentRule.setAssignment>>
<<else>> <<else>>
<<RAFacilityRemove $args[0] _currentRule>> <<RAFacilityRemove $args[0] _currentRule>> /% before deleting _currentRule.setAssignment %/
<<run delete _currentRule.setAssignment>>
<</if>> <</if>>
<<case "take classes">> <<case "take classes">>
<<if (!$args[0].intelligenceImplant && $args[0].fetish != "mindbroken" && ($args[0].devotion >= -20 || $args[0].trust < -50 || ($args[0].trust < -20 && $args[0].devotion >= -50)))>> <<if (!$args[0].intelligenceImplant && $args[0].fetish != "mindbroken" && ($args[0].devotion >= -20 || $args[0].trust < -50 || ($args[0].trust < -20 && $args[0].devotion >= -50)))>>
<<set _combinedRule.setAssignment = _currentRule.setAssignment>> <<else>>
<<run delete _currentRule.setAssignment>>
<</if>> <</if>>
<<case "choose her own job">> <<case "choose her own job">>
<<if ($args[0].fetish != "mindbroken")>> <<if ($args[0].fetish != "mindbroken")>>
<<set _combinedRule.setAssignment = _currentRule.setAssignment>> <<else>>
<<run delete _currentRule.setAssignment>>
<</if>> <</if>>
<<case "get milked">> <<case "get milked">>
<<if ($args[0].lactation > 0 || $args[0].balls > 0)>> <<if ($args[0].lactation > 0 || $args[0].balls > 0)>>
<<set _combinedRule.setAssignment = _currentRule.setAssignment>> <<else>>
<<run delete _currentRule.setAssignment>>
<</if>> <</if>>
<<case "be a servant">> <<case "be a servant">>
<<if (canWalk($args[0]) && canSee($args[0]) && ($args[0].devotion >= -20 || $args[0].trust < -50 || ($args[0].trust < -20 && $args[0].devotion >= -50)))>> <<if (canWalk($args[0]) && canSee($args[0]) && ($args[0].devotion >= -20 || $args[0].trust < -50 || ($args[0].trust < -20 && $args[0].devotion >= -50)))>>
<<set _combinedRule.setAssignment = _currentRule.setAssignment>> <<else>>
<<run delete _currentRule.setAssignment>>
<</if>> <</if>>
<<case "work a glory hole">> <<case "work a glory hole">>
<<if $args[0].indentureRestrictions <= 0 && $args[0].breedingMark != 1>> <<if $args[0].indentureRestrictions <= 0 && $args[0].breedingMark != 1>>
<<set _combinedRule.setAssignment = _currentRule.setAssignment>> <<else>>
<<run delete _currentRule.setAssignment>>
<</if>> <</if>>
<<case "whore" "serve the public" "stay confined">> <<case "whore" "serve the public" "stay confined">>
<<if ($args[0].fuckdoll == 0) && $args[0].breedingMark != 1>> <<if ($args[0].fuckdoll == 0) && $args[0].breedingMark != 1>>
<<set _combinedRule.setAssignment = _currentRule.setAssignment>> <<else>>
<<run delete _currentRule.setAssignment>>
<</if>> <</if>>
<<default>> <<default>>
<<set _combinedRule.setAssignment = _currentRule.setAssignment>> @@.red;raWidgets missing case for assignment '<<print _currentRule.setAssignment>>'@@.
<</switch>> <</switch>>
/% merge the current rule (possibly modified by the code above) into the combined rule %/
<<set _combinedRule = mergeRules([_combinedRule, _currentRule])>>
<</for>> /* done merging rules; from here onwards, we should only use _combinedRule */ <</for>> /* done merging rules; from here onwards, we should only use _combinedRule */
/% If a slave has no rules applying to them, _combinedRule would (should) be an /% If a slave has no rules applying to them, _combinedRule would (should) be an
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment