From 15ddb734e2ec92c44ae60a3d668e59ff6cdc8e8e Mon Sep 17 00:00:00 2001 From: Arkerthan <arkerthan@gmail.com> Date: Thu, 14 Jan 2021 22:34:18 +0100 Subject: [PATCH] static typing for limbs --- devTools/types/FC/medicine.d.ts | 4 ++++ js/003-data/slaveProstheticsData.js | 27 +++++++++++---------------- src/interaction/prostheticConfig.js | 18 ++++++++++++++++++ 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/devTools/types/FC/medicine.d.ts b/devTools/types/FC/medicine.d.ts index e69de29bb2d..e3972630faf 100644 --- a/devTools/types/FC/medicine.d.ts +++ b/devTools/types/FC/medicine.d.ts @@ -0,0 +1,4 @@ +declare namespace FC { + type prostheticID = "interfaceP1" | "interfaceP2" | "basicL" | "sexL" | "beautyL" | "combatL" | "cyberneticL" | + "ocular" | "cochlear" | "electrolarynx" | "interfaceTail" | "modT" | "sexT" | "combatT" | "erectile"; +} diff --git a/js/003-data/slaveProstheticsData.js b/js/003-data/slaveProstheticsData.js index a212d2ce486..80b89c1a22a 100644 --- a/js/003-data/slaveProstheticsData.js +++ b/js/003-data/slaveProstheticsData.js @@ -1,7 +1,7 @@ /** * do not change order, order = display order * - * @type {string[]} + * @type {FC.prostheticID[]} */ App.Data.prostheticIDs = ["interfaceP1", "interfaceP2", "basicL", "sexL", "beautyL", "combatL", "cyberneticL", "ocular", "cochlear", @@ -20,7 +20,7 @@ App.Data.prostheticIDs = */ /** - * @type {Object<string, prosthetics>} + * @type {Object<FC.prostheticID, prosthetics>} */ App.Data.prosthetics = { interfaceP1: { @@ -161,21 +161,16 @@ App.Data.modTails = new Map([ ]); /** - * TODO expand with beauty stats and similar - * - * @type {Map<number, {minimumInterface: number, prostheticKey: string, short: string}>} + * @typedef {object} prostheticLimb + * @property {string} short + * @property {FC.prostheticID} prostheticKey + * @property {number} minimumInterface */ -App.Data.limbs = new Map([ - /* TODO think about how to include these - [0, { - short: "None", - isProsthetic: false, - }], - [0, { - short: "Human", - isProsthetic: false, - }], - */ + +/** + * @type {Map<number, prostheticLimb>} + */ +App.Data.prostheticLimbs = new Map([ [2, { short: "basic prosthetic", prostheticKey: "basicL", diff --git a/src/interaction/prostheticConfig.js b/src/interaction/prostheticConfig.js index 01c07dcecca..fb3772027ce 100644 --- a/src/interaction/prostheticConfig.js +++ b/src/interaction/prostheticConfig.js @@ -39,6 +39,9 @@ App.UI.prostheticsConfig = function(slave) { return fragment; + /** + * @returns {DocumentFragment} + */ function eyes() { const f = document.createDocumentFragment(); @@ -144,6 +147,9 @@ App.UI.prostheticsConfig = function(slave) { return f; } + /** + * @returns {DocumentFragment} + */ function ears() { const f = document.createDocumentFragment(); if (slave.earImplant === 1) { @@ -185,6 +191,9 @@ App.UI.prostheticsConfig = function(slave) { return f; } + /** + * @returns {DocumentFragment} + */ function voice() { const f = document.createDocumentFragment(); @@ -234,6 +243,9 @@ App.UI.prostheticsConfig = function(slave) { return f; } + /** + * @returns {DocumentFragment} + */ function limbs() { const f = document.createDocumentFragment(); App.UI.DOM.appendNewElement("h2", f, "Limbs"); @@ -243,6 +255,9 @@ App.UI.prostheticsConfig = function(slave) { return f; } + /** + * @returns {DocumentFragment} + */ function tail() { const f = document.createDocumentFragment(); App.UI.DOM.appendNewElement("h2", f, "Tail"); @@ -315,6 +330,9 @@ App.UI.prostheticsConfig = function(slave) { return f; } + /** + * @returns {DocumentFragment} + */ function buyScreen() { const f = document.createDocumentFragment(); App.UI.DOM.appendNewElement("h2", f, "Prosthetics"); -- GitLab