diff --git a/src/markets/specificMarkets/customSlaveMarket.js b/src/markets/specificMarkets/customSlaveMarket.js index 6b9e99dc18de7a3eccc4fc0c627dbc6df49aee4c..225dff20dc8af8674ffcc7a0720bbadbc88c8313 100644 --- a/src/markets/specificMarkets/customSlaveMarket.js +++ b/src/markets/specificMarkets/customSlaveMarket.js @@ -32,6 +32,7 @@ App.Markets["Custom Slave"] = function() { // hears el.append(smells()); el.append(tastes()); + el.append(limbs()); el.append(nationality()); el.append(reset()); el.append(orderControls()); @@ -718,7 +719,68 @@ App.Markets["Custom Slave"] = function() { return el; } - // TODO: limbs + function limbs() { + const el = new DocumentFragment(); + const limbs = new Map([ + ["arm.left", "Left arm"], + ["arm.right", "Right arm"], + ["leg.left", "Left leg"], + ["leg.right", "Right leg"], + ]); + + for (const [value, text] of limbs) { + const div = document.createElement("div"); + div.id = `${value}-text`; + const hasLimb = (_.get(slave, value) !== null); + div.append(description(hasLimb, text)); + if (hasLimb) { + div.append( + App.UI.DOM.link( + "Remove", + () => { + _.set(slave, value, null); + jQuery(`#${div.id}`).empty().append(description(false, text)) + } + ) + ); + } else { + div.append( + App.UI.DOM.link( + "Add", + () => { + _.set(slave, value, new App.Entity.LimbState()); + /*switch (value) { + case "arm.left": + slave.arm.left = new App.Entity.LimbState(); + break; + case "arm.right": + slave.arm.left = new App.Entity.LimbState(); + break; + case "leg.left": + slave.arm.left = new App.Entity.LimbState(); + break; + case "leg.right": + slave.arm.left = new App.Entity.LimbState(); + break; + }*/ + jQuery(`#${div.id}`).empty().append(description(true, text)) + } + ) + ); + } + + el.append(div); + } + + createDescription(el, description, slaveProperty); + el.append(choicesMaker(slaveProperty, choices, description)); + + function description(hasLimb, text) { + return `${text}: ${(hasLimb) ? `Yes` : `No`}`; + } + + return el; + } function nationality() { const el = document.createElement("div");