From 59abcb28c51d6ec6141727e1542a863cf51203b1 Mon Sep 17 00:00:00 2001 From: DCoded <dcoded@live.com> Date: Thu, 21 Mar 2019 15:28:58 -0400 Subject: [PATCH] endWeek JS --- src/uncategorized/endWeek.tw | 47 ++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/src/uncategorized/endWeek.tw b/src/uncategorized/endWeek.tw index 256a00f8a76..a8f593053d0 100644 --- a/src/uncategorized/endWeek.tw +++ b/src/uncategorized/endWeek.tw @@ -28,17 +28,19 @@ <</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++>> @@ -56,6 +58,18 @@ */ <<if $organs.length > 0>> +<<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--; + } + } +})>> +/* <<for _i = 0; _i < $organs.length; _i++>> <<if $organs[_i].weeksToCompletion > 0>> <<if $organFarmUpgrade == 3>> @@ -71,8 +85,21 @@ <<set $organs.deleteAt(_i)>> <</if>> <</for>> +*/ <</if>> <<if $incubatorOrgans.length > 0>> +<<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--; + } + } +})>> +/* <<for _i = 0; _i < $incubatorOrgans.length; _i++>> <<if $incubatorOrgans[_i].weeksToCompletion > 0>> <<if $organFarmUpgrade == 3>> @@ -84,6 +111,7 @@ <</if>> <</if>> <</for>> +*/ <</if>> /* for future use <<if $nurseryOrgans.length > 0>> @@ -101,6 +129,15 @@ <</if>> */ <<if $limbs.length > 0>> +<<run $limbs.forEach(function(l) { + if ($limbs[l].weeksToCompletion > 0) { + $limbs[l].weeksToCompletion--; + } + if ($limbs[l].weeksToCompletion == 0) { + $limbsCompleted++; + } +})>> +/* <<for _i = 0; _i < $limbs.length; _i++>> <<if $limbs[_i].weeksToCompletion > 0>> <<set $limbs[_i].weeksToCompletion-->> @@ -109,6 +146,7 @@ <<set $limbsCompleted++>> <</if>> <</for>> +*/ <</if>> /% Begin section: ensure minimum age is set (game may have been loaded from a non-modded version). %/ @@ -151,7 +189,6 @@ <</if>> <</if>> -<<run $slaves.forEach(function(s) { s.lastWeeksCashIncome = 0, s.lastWeeksRepIncome = 0, s.lastWeeksRepExpenses = 0; })>> <<set $lastWeeksCashErrors = "Errors: ">> <<set $lastWeeksRepErrors = "Errors: ">> -- GitLab