diff --git a/src/npc/startingGirls/editFamily.js b/src/npc/startingGirls/editFamily.js index 62fc3f44b4948e4442e8902fdbc89b9ca5d31160..05fb3497ee0fdccdbba705b06c1a1daab1a3ed95 100644 --- a/src/npc/startingGirls/editFamily.js +++ b/src/npc/startingGirls/editFamily.js @@ -1,349 +1,452 @@ App.Intro.editFamily = function(slave) { const el = new DocumentFragment(); + const _allowPCFamily = (V.freshPC === 1 || V.saveImported === 0); + const canBeMom = (s) => (s.vagina > 0 && ((s.mother !== slave.mother) || (slave.mother === 0))); + const canBeDad = (s) => (s.dick > 0 && ((s.father !== slave.father) || (slave.father === 0))); + + const editFamily = makeElWithID("edit-family"); + + const familyTable = makeElWithID("family-table"); + familyTable.append(makeElWithID("dont-be-dumb")); + familyTable.append(mother()); + familyTable.append(father()); + familyTable.append(sameMotherAs()); + familyTable.append(sameFatherAs()); + familyTable.append(motherOfTheChildren()); + familyTable.append(fatherOfTheChildren()); + if (_allowPCFamily) { + familyTable.append(resetAllRelativesOfPC()); + } + editFamily.append(familyTable); + editFamily.append(makeElWithID("family-tree")); - return el; - function mainDisplay() { - const el = new DocumentFragment(); - const _allowPCFamily = (V.freshPC === 1 || V.saveImported === 0); + function mother() { + const div = new DocumentFragment(); + const linkArray = []; - function makeElWithID(id, elType = "div") { - const el = document.createElement(elType); - el.id = id; - return el; + div.append("Mother: "); + + const nameEl = makeElWithID("motherName"); + nameEl.append(parentName("mother")); + div.append(nameEl); + + linkArray.push( + App.UI.DOM.link( + "Reset", + () => { + slave.mother = 0; + refresh(); + } + ) + ); + + if (canBeMom(V.PC) && ((V.PC.actualAge - slave.actualAge) >= V.fertilityAge) && _allowPCFamily) { + linkArray.push( + App.UI.DOM.link( + "You", + () => { + slave.mother = V.PC.ID; + refresh(); + } + ) + ); + } + + for (const potentialRel of V.slaves) { + if (canBeMom(potentialRel) && ((potentialRel.actualAge - slave.actualAge) >= potentialRel.pubertyAgeXX) && potentialRel.newGamePlus === 0) { + linkArray.push( + App.UI.DOM.link( + potentialRel.slaveName, + () => { + slave.mother = potentialRel.ID; + refresh(); + } + ) + ); + } } - el.append() - const editFamily = makeElWithID("edit-family"); + div.append(App.UI.DOM.generateLinksStrip(linkArray)); - const familyTable = makeElWithID("family-table"); - editFamily.append(familyTable); - familyTable.append(makeElWithID("dont-be-dumb")); + return div; + } - function mother() { - const div = new DocumentFragment(); - const linkArray = []; - const requirements = (s) => (s.vagina > 0 && ((s.mother !== slave.mother) || (slave.mother === 0))); + function father() { + const div = new DocumentFragment(); + const linkArray = []; - const nameEl = makeElWithID("motherName") - nameEl.append(parentName("mother")); - div.append(nameEl); + div.append("Father: "); - div.append("Mother: "); + const nameEl = makeElWithID("fatherName"); + nameEl.append(parentName("father")); + div.append(nameEl); + linkArray.push( + App.UI.DOM.link( + "Reset", + () => { + slave.father = 0; + refresh(); + } + ) + ); + + if (canBeDad(V.PC) && ((V.PC.actualAge - slave.actualAge) >= V.potencyAge) && _allowPCFamily) { linkArray.push( App.UI.DOM.link( - "Reset", + "You", () => { - slave.mother = 0; + slave.father = V.PC.ID; refresh(); } ) + ); + } + + for (const potentialRel of V.slaves) { + if (canBeDad(potentialRel) && ((potentialRel.actualAge - slave.actualAge) >= potentialRel.pubertyAgeXY) && potentialRel.newGamePlus === 0) { + linkArray.push( + App.UI.DOM.link( + potentialRel.slaveName, + () => { + slave.father = potentialRel.ID; + refresh(); + } + ) + ); + } + } + + div.append(App.UI.DOM.generateLinksStrip(linkArray)); + + return div; + } + + function sameMotherAs() { + const div = new DocumentFragment(); + const linkArray = []; + + const nameEl = makeElWithID("sameMotherNames"); + nameEl.append(App.StartingGirls.listOfSlavesWithParent('mother', slave.mother)); + div.append(nameEl); + + div.append("Same mother as: "); + + linkArray.push( + App.UI.DOM.link( + "Reset", + () => { + slave.mother = 0; + refresh(); + } ) + ); - if (requirements(V.PC) && ((V.PC.actualAge - slave.actualAge) >= V.fertilityAge) && _allowPCFamily) { + if (canBeMom(V.PC) && _allowPCFamily) { + linkArray.push( + App.UI.DOM.link( + "You", + () => { + setRel(V.PC); + refresh(); + } + ) + ); + } + + for (const potentialRel of V.slaves) { + if (canBeMom(potentialRel) && ((potentialRel.actualAge - slave.actualAge) >= potentialRel.pubertyAgeXX) && potentialRel.newGamePlus === 0) { linkArray.push( App.UI.DOM.link( - "You", + potentialRel.slaveName, () => { - slave.mother = V.PC.ID; + setRel(potentialRel); refresh(); } ) + ); + } + } + + div.append(App.UI.DOM.generateLinksStrip(linkArray)); + + return div; + + function setRel(potentialRel) { + if (potentialRel.mother !== 0) { + slave.mother = potentialRel.mother; + } else if (slave.mother !== 0) { + potentialRel.mother = slave.mother; + } else { + slave.mother = -20 - 2*slave.ID; + potentialRel.mother = slave.mother; + } + } + } + + function sameFatherAs() { + const div = new DocumentFragment(); + const linkArray = []; + + const nameEl = makeElWithID("sameFatherNames"); + nameEl.append(App.StartingGirls.listOfSlavesWithParent('father', slave.father)); + div.append(nameEl); + + div.append("Same father as: "); + + linkArray.push( + App.UI.DOM.link( + "Reset", + () => { + slave.father = 0; + refresh(); + } + ) + ); + + if (canBeDad(V.PC) && _allowPCFamily) { + linkArray.push( + App.UI.DOM.link( + "You", + () => { + setRel(V.PC); + refresh(); + } ) + ); + } + + for (const potentialRel of V.slaves) { + if (canBeDad(potentialRel) && ((potentialRel.actualAge - slave.actualAge) >= potentialRel.pubertyAgeXY) && potentialRel.newGamePlus === 0) { + linkArray.push( + App.UI.DOM.link( + potentialRel.slaveName, + () => { + setRel(potentialRel); + refresh(); + } + ) + ); + } + } + + div.append(App.UI.DOM.generateLinksStrip(linkArray)); + + return div; + + function setRel(potentialRel) { + if (potentialRel.father !== 0) { + slave.father = potentialRel.father; + } else if (slave.father !== 0) { + potentialRel.father = slave.father; + } else { + slave.father = -20 - 2*slave.ID; + potentialRel.father = slave.father; + } + } + } + + function motherOfTheChildren() { + const div = new DocumentFragment(); + const linkArray = []; + + const nameEl = makeElWithID("motheredNames"); + nameEl.append(App.StartingGirls.listOfSlavesWithParent("mother", slave.ID)); + div.append(nameEl); + + div.append("Mother of the children: "); + + linkArray.push( + App.UI.DOM.link( + "Reset", + () => { + for (const s of V.slaves) { + if (s.mother === slave.ID && s.newGamePlus === 0) { + s.mother = 0; + } + } + if (V.PC.mother === slave.ID && _allowPCFamily) { + V.PC.mother = 0; + } + refresh(); + } + ) + ); + + if (slave.vagina >= 0) { + if (canBeMom(V.PC) && (slave.actualAge - V.PC.actualAge) >= V.fertilityAge && _allowPCFamily) { + linkArray.push( + App.UI.DOM.link( + "You", + () => { + setRel(V.PC); + refresh(); + } + ) + ); } for (const potentialRel of V.slaves) { - if (requirements(potentialRel) && ((potentialRel.actualAge - slave.actualAge) >= potentialRel.pubertyAgeXX) && potentialRel.newGamePlus === 0) { + if (canBeMom(potentialRel) && ((potentialRel.actualAge - slave.actualAge) >= potentialRel.pubertyAgeXX) && potentialRel.newGamePlus === 0) { linkArray.push( App.UI.DOM.link( potentialRel.slaveName, () => { - slave.mother = potentialRel.ID + setRel(potentialRel); refresh(); } ) - ) + ); } } + } - div.append(App.UI.DOM.generateLinksStrip(linkArray)); + div.append(App.UI.DOM.generateLinksStrip(linkArray)); - return div; - } - - - - - - <br>''Father:'' <span id="fatherName"> - <<parentName "father">></span> - <<link "Reset">> - slave.father = 0; - <<redisplayFamily>> - <</link>> - if (V.PC.dick > 0) && ((V.PC.actualAge - slave.actualAge) >= V.potencyAge) && ((V.PC.father !== slave.father) || (slave.father === 0)) && _allowPCFamily { - | <<link "You">> - slave.father = V.PC.ID; - <<redisplayFamily>> - <</link>> - } - <<for _efw = 0; _efw < V.slaves.length; _efw++>> - if (V.slaves[_efw].dick > 0) && (((V.slaves[_efw].actualAge - slave.actualAge) >= V.slaves[_efw].pubertyAgeXY)) && ((V.slaves[_efw].father !== slave.father) || (slave.father === 0)) && V.slaves[_efw].newGamePlus === 0 { - | - _id = V.slaves[_efw].ID; - _slaveName = V.slaves[_efw].slaveName; - <<print " - <<link _slaveName>> - slave.father = " + _id + "; - <<redisplayFamily>> - <</link>> - ">> + return div; + + function setRel(potentialRel) { + potentialRel.mother = slave.ID; + if (slave.vagina === 0) { + slave.vagina = 1; } - <</for>> - - <br>''Same mother as:'' <span id="sameMotherNames"> - V.App.StartingGirls.listOfSlavesWithParent('mother', slave.mother)</span> - <<link "Reset">> - slave.mother = 0; - <<redisplayFamily>> - <</link>> - if (slave.mother !== V.PC.ID) && (V.PC.mother !== slave.ID) && _allowPCFamily { - | - <<link "You">> - if (V.PC.mother !== 0) { - slave.mother = V.PC.mother; - } else if (slave.mother !== 0) { - V.PC.mother = slave.mother; - } else { - slave.mother = -20 - 2*slave.ID; - V.PC.mother = slave.mother; - } - <<redisplayFamily>> - <</link>> } - <<for _efw = 0; _efw < V.slaves.length; _efw++>> - if (V.slaves[_efw].newGamePlus === 0) { - if (V.saveImported === 1) {| } - _slaveName = V.slaves[_efw].slaveName; - _slave = V.slaves[_efw]; - if (slave.mother !== _slave.ID) && (_slave.mother !== slave.ID) { - | - <<print " - <<link _slaveName>> - _slave = V.slaves[" + _efw + "]; - if (_slave.mother !== 0) { - slave.mother = _slave.mother; - } else if (slave.mother !== 0) { - _slave.mother = slave.mother; - } else { - slave.mother = -20 - 2*slave.ID; - _slave.mother = slave.mother; - } - <<redisplayFamily>> - <</link>> - ">> + + function fatherOfTheChildren() { + const div = new DocumentFragment(); + const linkArray = []; + + const nameEl = makeElWithID("fatheredNames"); + nameEl.append(App.StartingGirls.listOfSlavesWithParent("father", slave.ID)); + div.append(nameEl); + + div.append("Father of the children: "); + + linkArray.push( + App.UI.DOM.link( + "Reset", + () => { + for (const s of V.slaves) { + if (s.father === slave.ID && s.newGamePlus === 0) { + s.father = 0; + } + } + if (V.PC.father === slave.ID && _allowPCFamily) { + V.PC.father = 0; + } + refresh(); } + ) + ); + + if (slave.dick > 0) { + if (canBeMom(V.PC) && (slave.actualAge - V.PC.actualAge) >= V.potencyAge && _allowPCFamily) { + linkArray.push( + App.UI.DOM.link( + "You", + () => { + V.PC.father = slave.ID; + refresh(); + } + ) + ); } - <</for>> - - <br>''Same father as:'' <span id="sameFatherNames"> - V.App.StartingGirls.listOfSlavesWithParent('father', slave.father)</span> - <<link "Reset">> - slave.father = 0; - <<replace '#fatherName'>> - <</replace>> - <<replace '#sameFatherNames'>> - <</replace>> - <<redisplayFamily>> - <</link>> - if (slave.father !== V.PC.ID) && (V.PC.father !== slave.ID) && _allowPCFamily { - | - <<link "You">> - if (V.PC.father !== 0) { - slave.father = V.PC.father; - } else if (slave.father !== 0) { - V.PC.father = slave.father; - } else { - slave.father = (-20 - 2*slave.ID -1); - V.PC.father = slave.father; + + for (const potentialRel of V.slaves) { + if (canBeMom(potentialRel) && ((potentialRel.actualAge - slave.actualAge) >= potentialRel.pubertyAgeXX) && potentialRel.newGamePlus === 0) { + linkArray.push( + App.UI.DOM.link( + potentialRel.slaveName, + () => { + potentialRel.father = slave.ID; + refresh(); + } + ) + ); } - <<redisplayFamily>> - <</link>> + } } - <<for _efw = 0; _efw < V.slaves.length; _efw++>> - if (V.slaves[_efw].newGamePlus === 0) { - if (V.saveImported === 1) {| + + div.append(App.UI.DOM.generateLinksStrip(linkArray)); + + return div; } - _slaveName = V.slaves[_efw].slaveName; - _slave = V.slaves[_efw]; - if (slave.father !== _slave.ID) && (_slave.father !== slave.ID) { - | - <<print " - <<link _slaveName>> - _slave = V.slaves[" + _efw + "]; - if (_slave.father !== 0) { - slave.father = _slave.father; - } else if (slave.father !== 0) { - _slave.father = slave.father; - } else { - slave.father = (-20 - 2*slave.ID -1); - _slave.father = slave.father; + + function resetAllRelativesOfPC() { + return App.UI.DOM.makeElement( + "div", + App.UI.DOM.link( + "Reset ALL PC Relatives", + () => { + let _sameMother = 0; + let _sameFather = 0; + + for (const s of V.slaves) { + if (s.newGamePlus === 0) { + if (s.mother === V.PC.ID) { + s.mother = 0; } - <<redisplayFamily>> - <</link>> - ">> - } - } - <</for>> - - <br>''Mother of the children:'' <span id="motheredNames"> - V.App.StartingGirls.listOfSlavesWithParent("mother", slave.ID)</span> - <<link "Reset">> - <<for _efw = 0; _efw < V.slaves.length; _efw++>> - if (V.slaves[_efw].mother === slave.ID && V.slaves[_efw].newGamePlus === 0) { - V.slaves[_efw].mother = 0; - } - <</for>> - if (V.PC.mother === slave.ID && _allowPCFamily) { - V.PC.mother = 0; - } - <<redisplayFamily>> - <</link>> - if (slave.vagina >= 0) { - if ((slave.actualAge - V.PC.actualAge) >= V.fertilityAge) && ((V.PC.mother !== slave.mother) || (slave.mother === 0)) && _allowPCFamily { - | - <<link "You">> - V.PC.mother = slave.ID; - if (slave.vagina === 0) { - slave.vagina = 1; - } - <<redisplayFamily>> - <</link>> - } - - <<for _efw = 0; _efw < V.slaves.length; _efw++>> - if (V.slaves[_efw].newGamePlus === 0) { - _slaveName = V.slaves[_efw].slaveName; - _slave = V.slaves[_efw]; - if ((slave.actualAge - _slave.actualAge) >= V.fertilityAge) && ((_slave.mother !== slave.mother) || (slave.mother === 0)) { - | - <<print " - <<link _slaveName>> - _slave = V.slaves[" + _efw + "]; - _slave.mother = slave.ID; - if (slave.vagina === 0) { - slave.vagina = 1; + if (s.father === V.PC.ID) { + s.father = 0; + } + if (s.mother === V.PC.mother) { + _sameMother++; + } + if (s.father === V.PC.father) { + _sameFather++; } - <<redisplayFamily>> - <</link>> - ">> + } } - } - <</for>> - } - - <br>''Father of the children:'' <span id="fatheredNames"> - V.App.StartingGirls.listOfSlavesWithParent("father", slave.ID)</span> - <<link "Reset">> - <<for _efw = 0; _efw < V.slaves.length; _efw++>> - if (V.slaves[_efw].father === slave.ID && V.slaves[_efw].newGamePlus === 0) { - V.slaves[_efw].father = 0; - } - <</for>> - if (V.PC.father === slave.ID && _allowPCFamily) { - V.PC.father = 0; - } - <<redisplayFamily>> - <</link>> - if (slave.dick > 0) { - if ((slave.actualAge - V.PC.actualAge) >= V.potencyAge) && ((V.PC.father !== slave.father) || (slave.father === 0)) && _allowPCFamily { - | - <<link "You">> - V.PC.father = slave.ID; - <<redisplayFamily>> - <</link>> - } - - <<for _efw = 0; _efw < V.slaves.length; _efw++>> - if (V.slaves[_efw].newGamePlus === 0) { - _slaveName = V.slaves[_efw].slaveName; - _slave = V.slaves[_efw]; - if ((slave.actualAge - _slave.actualAge) >= V.potencyAge) && ((_slave.father !== slave.father) || (slave.father === 0)) { - | - <<print " - <<link _slaveName>> - _slave = V.slaves[" + _efw + "]; - _slave.father = slave.ID; - <<redisplayFamily>> - <</link>> - ">> + if (_sameMother === 0 && slave.mother === V.PC.mother) { + slave.mother = 0; } - } - <</for>> - } - - <br> - if (_allowPCFamily) { - <<link "Reset ALL PC Relatives">> - _sameMother = 0, _sameFather = 0; - <<for _efw = 0; _efw < V.slaves.length; _efw++>> - if (V.slaves[_efw].newGamePlus === 0) { - if (V.slaves[_efw].mother === V.PC.ID) { - V.slaves[_efw].mother = 0; - } - if (V.slaves[_efw].father === V.PC.ID) { - V.slaves[_efw].father = 0; - } - if (V.slaves[_efw].mother === V.PC.mother) { - _sameMother++; - } - if (V.slaves[_efw].father === V.PC.father) { - _sameFather++; - } + if (_sameFather === 0 && slave.father === V.PC.father) { + slave.father = 0; } - <</for>> - if (_sameMother === 0 && slave.mother === V.PC.mother) { - slave.mother = 0; - } - if (_sameFather === 0 && slave.father === V.PC.father) { - slave.father = 0; - } - <<for _efw = 0; (_efw < V.slaves.length && (_sameMother === 1 || _sameFather === 1)); _efw++>> - if (V.slaves[_efw].newGamePlus === 0) { - if (V.slaves[_efw].mother === V.PC.mother && _sameMother === 1) { - V.slaves[_efw].mother = 0, _sameMother = 0; - } - if (V.slaves[_efw].father === V.PC.father && _sameFather === 1) { - V.slaves[_efw].father = 0, _sameFather = 0; + for (let _efw = 0; (_efw < V.slaves.length && (_sameMother === 1 || _sameFather === 1)); _efw++) { + if (V.slaves[_efw].newGamePlus === 0) { + if (V.slaves[_efw].mother === V.PC.mother && _sameMother === 1) { + V.slaves[_efw].mother = 0; + _sameMother = 0; + } + if (V.slaves[_efw].father === V.PC.father && _sameFather === 1) { + V.slaves[_efw].father = 0; + _sameFather = 0; + } } } - <</for>> - if (slave.mother === V.PC.ID) { - slave.mother = 0; - } - if (slave.father === V.PC.ID) { - slave.father = 0; + if (slave.mother === V.PC.ID) { + slave.mother = 0; + } + if (slave.father === V.PC.ID) { + slave.father = 0; + } + V.PC.father = 0; + V.PC.mother = 0; + refresh(); } - V.PC.father = 0; - V.PC.mother = 0; - <<redisplayFamily>> - <</link>> - } - - <br> - <span id="familySummary"> - V.App.Desc.family(slave)</span> - <br> - </div> - <div id="family-tree"></div> - </div> - + ) + ); + } + + + function makeElWithID(id, elType = "div") { + const el = document.createElement(elType); + el.id = id; + return el; } + const familySummary = makeElWithID("familySummary"); + familySummary.append(App.Desc.family(slave)); + el.append(familySummary); + + + return el; + /** - * + * * @param {string} rel "mother", etc. Property of slave object. */ function parentName(rel) {