diff --git a/src/uncategorized/endWeek.tw b/src/uncategorized/endWeek.tw index 256a00f8a76833581097622b605f1431a88e665f..e66d3f0d7e8aaeb6516cfe47f3bcc8e958fcf7c6 100644 --- a/src/uncategorized/endWeek.tw +++ b/src/uncategorized/endWeek.tw @@ -28,87 +28,74 @@ <</if>> <<run $slaves.forEach(function(s) { - const V = State.variables; if (s.inflationMethod == 1 || s.inflationMethod == 2) { if (s.inflationType == "milk") { - V.inflatedSlavesMilk++; + $inflatedSlavesMilk++; } else if (s.inflationType == "cum") { - V.inflatedSlavesCum++; + $inflatedSlavesCum++; } } if (s.assignment == "be a subordinate slave" && s.subTarget == 0) { - V.subSlaves++; + $subSlaves++; } + s.lastWeeksCashIncome = 0; + s.lastWeeksRepIncome = 0; + s.lastWeeksRepExpenses = 0; })>> -/* -<<for _i = 0; _i < $slaves.length; _i++>> - <<if $slaves[_i].inflationMethod == 1 || $slaves[_i].inflationMethod == 2>> - <<if $slaves[_i].inflationType == "milk">> - <<set $inflatedSlavesMilk++>> - <<elseif $slaves[_i].inflationType == "cum">> - <<set $inflatedSlavesCum++>> - <</if>> - <</if>> - <<if $slaves[_i].assignment == "be a subordinate slave" && $slaves[_i].subTarget == 0>> - <<set $subSlaves++>> - <</if>> -<</for>> -*/ <<if $organs.length > 0>> -<<for _i = 0; _i < $organs.length; _i++>> - <<if $organs[_i].weeksToCompletion > 0>> - <<if $organFarmUpgrade == 3>> - <<set $organs[_i].weeksToCompletion -= 4>> - <<elseif $organFarmUpgrade == 2>> - <<set $organs[_i].weeksToCompletion -= 2>> - <<else>> - <<set $organs[_i].weeksToCompletion-->> - <</if>> - <</if>> - <<if $organs[_i].weeksToCompletion <= 0>> - <<set $completedOrgans.push($organs[_i])>> - <<set $organs.deleteAt(_i)>> - <</if>> -<</for>> +<<run $organs.forEach(function(o) { + if ($organs[o].weeksToCompletion > 0) { + if ($organFarmUpgrade == 3) { + $organs[o].weeksToCompletion -= 4; + } else if ($organFarmUpgrade == 2) { + $organs[o].weeksToCompletion -= 2; + } else { + $organs[o].weeksToCompletion--; + } + } +})>> <</if>> + <<if $incubatorOrgans.length > 0>> -<<for _i = 0; _i < $incubatorOrgans.length; _i++>> - <<if $incubatorOrgans[_i].weeksToCompletion > 0>> - <<if $organFarmUpgrade == 3>> - <<set $incubatorOrgans[_i].weeksToCompletion -= 4>> - <<elseif $organFarmUpgrade == 2>> - <<set $incubatorOrgans[_i].weeksToCompletion -= 2>> - <<else>> - <<set $incubatorOrgans[_i].weeksToCompletion-->> - <</if>> - <</if>> -<</for>> +<<run $incubatorOrgans.forEach(function(io) { + if ($incubatorOrgans[io].weeksToCompletion > 0) { + if ($organFarmUpgrade == 3) { + $incubatorOrgans[io].weeksToCompletion -= 4; + } else if ($organFarmUpgrade == 2) { + $incubatorOrgans[io].weeksToCompletion -= 2; + } else { + $incubatorOrgans[io].weeksToCompletion--; + } + } +})>> <</if>> -/* for future use + +/* for potential future use <<if $nurseryOrgans.length > 0>> -<<for _i = 0; _i < $nurseryOrgans.length; _i++>> - <<if $nurseryOrgans[_i].weeksToCompletion > 0>> - <<if $organFarmUpgrade == 3>> - <<set $nurseryOrgans[_i].weeksToCompletion -= 4>> - <<elseif $organFarmUpgrade == 2>> - <<set $nurseryOrgans[_i].weeksToCompletion -= 2>> - <<else>> - <<set $nurseryOrgans[_i].weeksToCompletion-->> - <</if>> - <</if>> -<</for>> +<<run $nurseryOrgans.forEach(function(no) { + if ($nurseryOrgans[no].weeksToCompletion > 0) { + if ($organFarmUpgrade == 3) { + $nurseryOrgans[no].weeksToCompletion -= 4; + } else if ($organFarmUpgrade == 2) { + $nurseryOrgans[no].weeksToCompletion -= 2; + } else { + $nurseryOrgans[no].weeksToCompletion--; + } + } +})>> <</if>> */ + <<if $limbs.length > 0>> -<<for _i = 0; _i < $limbs.length; _i++>> - <<if $limbs[_i].weeksToCompletion > 0>> - <<set $limbs[_i].weeksToCompletion-->> - <</if>> - <<if $limbs[_i].weeksToCompletion == 0>> - <<set $limbsCompleted++>> - <</if>> -<</for>> +<<run $limbs.forEach(function(l) { + if ($limbs[l].weeksToCompletion > 0) { + $limbs[l].weeksToCompletion--; + } + if ($limbs[l].weeksToCompletion == 0) { + $limbsCompleted++; + } +})>> <</if>> /% Begin section: ensure minimum age is set (game may have been loaded from a non-modded version). %/ @@ -151,7 +138,6 @@ <</if>> <</if>> -<<run $slaves.forEach(function(s) { s.lastWeeksCashIncome = 0, s.lastWeeksRepIncome = 0, s.lastWeeksRepExpenses = 0; })>> <<set $lastWeeksCashErrors = "Errors: ">> <<set $lastWeeksRepErrors = "Errors: ">>