From 72bb7e224cc8e3bea11937e106b3ccf7e096a349 Mon Sep 17 00:00:00 2001 From: Arkerthan <arkerthan@gmail.com> Date: Tue, 17 Sep 2019 21:07:59 +0200 Subject: [PATCH] add addProsthetic() --- src/interaction/prostheticConfig.tw | 2 +- src/js/itemAvailability.js | 10 ++++++++++ src/uncategorized/BackwardsCompatibility.tw | 10 +++++----- src/uncategorized/labReport.tw | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/interaction/prostheticConfig.tw b/src/interaction/prostheticConfig.tw index 48c23339cde..a14223ae11c 100644 --- a/src/interaction/prostheticConfig.tw +++ b/src/interaction/prostheticConfig.tw @@ -8,7 +8,7 @@ <<if $adjustProstheticsCompleted > 0>> <<set $adjustProsthetics = $adjustProsthetics.filter(function(p) { if (p.workLeft <= 0 && p.slaveID == $activeSlave.ID) { - $activeSlave.readyProsthetics.push({id: p.id}); + addProsthetic($activeSlave, p.id); $adjustProstheticsCompleted--; return false; } diff --git a/src/js/itemAvailability.js b/src/js/itemAvailability.js index 36923b4fe5a..3550d090ca4 100644 --- a/src/js/itemAvailability.js +++ b/src/js/itemAvailability.js @@ -173,3 +173,13 @@ window.isItemAccessible = function(string) { window.isProstheticAvailable = function(slave, prosthetic) { return slave.readyProsthetics.findIndex(function(p) { return p.id === prosthetic; }) !== -1; }; + +/** + * @param {App.Entity.SlaveState} slave + * @param {string} prosthetic + */ +window.addProsthetic = function(slave, prosthetic) { + if (!isProstheticAvailable(slave, prosthetic)) { + slave.readyProsthetics.push({id: prosthetic}); + } +}; diff --git a/src/uncategorized/BackwardsCompatibility.tw b/src/uncategorized/BackwardsCompatibility.tw index 0b116f26af6..98c46e1fd57 100644 --- a/src/uncategorized/BackwardsCompatibility.tw +++ b/src/uncategorized/BackwardsCompatibility.tw @@ -3518,15 +3518,15 @@ Setting missing slave variables: <<for _k = 0; _k < _Slave.readyLimbs.length; _k++>> <<switch _Slave.readyLimbs[_k].type>> <<case -1>> - <<set _Slave.readyProsthetics.push({id: "basicL"})>> + <<run addProsthetic(_Slave, "basicL")>> <<case -2>> - <<set _Slave.readyProsthetics.push({id: "sexL"})>> + <<run addProsthetic(_Slave, "sexL")>> <<case -3>> - <<set _Slave.readyProsthetics.push({id: "beautyL"})>> + <<run addProsthetic(_Slave, "beautyL")>> <<case -4>> - <<set _Slave.readyProsthetics.push({id: "combatL"})>> + <<run addProsthetic(_Slave, "combatL")>> <<case -5>> - <<set _Slave.readyProsthetics.push({id: "cyberneticL"})>> + <<run addProsthetic(_Slave, "cyberneticL")>> <</switch>> <</for>> <</if>> diff --git a/src/uncategorized/labReport.tw b/src/uncategorized/labReport.tw index a3ccf00a85c..1521e662663 100644 --- a/src/uncategorized/labReport.tw +++ b/src/uncategorized/labReport.tw @@ -25,7 +25,7 @@ <<= setup.prosthetics[_task.id].name>> construction project. <<set $prosthetics[_task.id].amount += 1>> <<case "craftFit">> - <<set _i = $slaves.findIndex(function(s) {return s.ID == _task.slaveID}), $slaves[_i].readyProsthetics.push({id: _task.id})>> + <<set_i = $slaves.findIndex(function(s) {return s.ID == _task.slaveID}), addProsthetic($slaves[_i], _task.id)>> project to construct <<= addA(setup.prosthetics[_task.id].name)>> for <<= SlaveFullName($slaves[_i])>>. <</switch>> <<set $researchLab.tasks.shift(), _task = $researchLab.tasks[0]>> -- GitLab