Skip to content
Snippets Groups Projects
Commit adf75195 authored by brickode's avatar brickode
Browse files

Disabled LinkList for now, updated JSDocs

parent a30be73c
No related branches found
No related tags found
1 merge request!7685Major Sex Interaction Expansion
...@@ -54,12 +54,12 @@ App.UI.SlaveInteract.useSlave = function(slave) { ...@@ -54,12 +54,12 @@ App.UI.SlaveInteract.useSlave = function(slave) {
class Link { class Link {
/** /**
* @param {string} link The link text. * @param {string} link The link text.
* @param {string|Node} desc The text displayed when link is clicked. * @param {string} desc The text displayed when link is clicked.
* @param {HTMLElement} [parent] The parent node to attach the link to. * @param {HTMLElement} [parent] The parent node to attach the link to.
* @param {string} [type="span"] The type of element to create. * @param {string} [type] The type of element to create.
* @param {HTMLElement|HTMLElement[]} [nodes] Any nodes to attach. * @param {HTMLElement|HTMLElement[]} [nodes] Any nodes to attach.
*/ */
constructor(link, desc, parent, type, nodes) { constructor(link, desc, parent, type, nodes = []) {
this.link = link; this.link = link;
this.desc = desc; this.desc = desc;
this.parent = parent; this.parent = parent;
...@@ -71,17 +71,20 @@ App.UI.SlaveInteract.useSlave = function(slave) { ...@@ -71,17 +71,20 @@ App.UI.SlaveInteract.useSlave = function(slave) {
} }
/** /**
* @param {HTMLElement[]} nodes Any nodes to attach to the link. * @param {HTMLElement|HTMLElement[]} nodes Any nodes to attach to the link.
*/ */
append(...nodes) { append(nodes) {
this.fullLink.append(...nodes); if (Array.isArray(nodes)) {
this.fullLink.append(...nodes);
} else {
this.fullLink.appendChild(nodes);
}
return this; return this;
} }
/** /**
* @template {keyof HTMLElementTagNameMap} K * @param {string} type The type of element the link will be.
* @param {K} type The type of element the link will be.
*/ */
replace(type) { replace(type) {
/** @type {HTMLElement} */ /** @type {HTMLElement} */
...@@ -103,7 +106,14 @@ App.UI.SlaveInteract.useSlave = function(slave) { ...@@ -103,7 +106,14 @@ App.UI.SlaveInteract.useSlave = function(slave) {
return this; return this;
} }
/**
* Generates the full link and appends it to `parent`.
*/
generate() { generate() {
this.append(this.nodes);
this.replace(this.type);
this.appendTo(this.parent);
return this.fullLink; return this.fullLink;
} }
} }
...@@ -133,16 +143,9 @@ App.UI.SlaveInteract.useSlave = function(slave) { ...@@ -133,16 +143,9 @@ App.UI.SlaveInteract.useSlave = function(slave) {
} }
} }
/** A class for creating lists of links. */ class List {
class LinkList { constructor(...args) {
/** this.args = args;
* An array of all options.
* @param {Option[]} options
*/
constructor(options) {
this.options = options;
/** @param {Option[]} filtered An array of all available options. */
this.filtered = [];
} }
/** /**
...@@ -150,10 +153,51 @@ App.UI.SlaveInteract.useSlave = function(slave) { ...@@ -150,10 +153,51 @@ App.UI.SlaveInteract.useSlave = function(slave) {
* @param {Option[]} args A list of Options to add. * @param {Option[]} args A list of Options to add.
*/ */
addOptions(args) { addOptions(args) {
this.options.push(...args); this.args.push(...args);
return this; return this;
} }
}
/** A class for creating lists of links. */
// class LinkList extends List {
// /**
// * @param {Link[]} links An array of all links.
// */
// constructor(links) {
// super(links);
// this.links = links;
// }
// /**
// * Generates and returns a link strip.
// * @param {HTMLElement} div The main div whose text will be replaced.
// * @returns {HTMLElement}
// */
// generateLinks(div) {
// const links = [];
// const linksDiv = document.createElement("div");
// this.links.forEach(link => links.push(App.UI.DOM.link(link.link, () => {
// div.innerHTML = link.desc;
// })));
// linksDiv.appendChild(App.UI.DOM.generateLinksStrip(links));
// return linksDiv;
// }
// }
class OptionList extends List {
/**
* @param {Option[]} options An array of all options.
*/
constructor(options) {
super(options);
this.options = options;
}
/** /**
* Filters out all options whose requirements are not met. * Filters out all options whose requirements are not met.
...@@ -167,8 +211,9 @@ App.UI.SlaveInteract.useSlave = function(slave) { ...@@ -167,8 +211,9 @@ App.UI.SlaveInteract.useSlave = function(slave) {
/** /**
* Generates and returns a link strip. * Generates and returns a link strip.
* @param {HTMLElement} div The main div whose text will be replaced. * @param {HTMLElement} div The main div whose text will be replaced.
* @returns {HTMLElement}
*/ */
generateLinks(div) { generateOptions(div) {
/** @type {HTMLAnchorElement[]} */ /** @type {HTMLAnchorElement[]} */
const links = []; const links = [];
const linksDiv = document.createElement("div"); const linksDiv = document.createElement("div");
...@@ -281,32 +326,18 @@ App.UI.SlaveInteract.useSlave = function(slave) { ...@@ -281,32 +326,18 @@ App.UI.SlaveInteract.useSlave = function(slave) {
const introSpan = App.UI.DOM.makeElement("span", `Use ${him} and take control: `); const introSpan = App.UI.DOM.makeElement("span", `Use ${him} and take control: `);
if (tempSlave.devotion > 50) { if (tempSlave.devotion > 50) {
// const intro = new LinkList( new Link(
// [ `Have sex with ${him}`,
// new Link( `You pull ${tempSlave.slaveName} in close and tell ${him} that you want to make love. With ${
// `Have sex with ${him}`, tempSlave.mouthAccessory === none ?
// `You pull ${tempSlave.slaveName} in close and tell ${him} that you want to make love. With ${ `a ${Beauty(tempSlave) > 150 && tempSlave.face > 10 ? `pretty` : `quick`} smile` :
// tempSlave.mouthAccessory === none ? `as much of a smile as ${his} ${tempSlave.mouthAccessory} will allow`
// `a ${Beauty(tempSlave) > 150 && tempSlave.face > 10 ? `pretty` : `quick`} smile` : }, ${he} makes it clear that your advances are not unwanted.`,
// `as much of a smile as ${his} ${tempSlave.mouthAccessory} will allow` introSpan,
// }, ${he} makes it clear that your advances are not unwanted.`, "span",
// ) generateOptions(),
// ] )
// ) .generate();
// .generateLinks(introSpan);
// if (tempSlave.devotion > 50) {
// const intro = App.UI.DOM.makeElement("div", `You pull ${tempSlave.slaveName} in close and tell ${him} that you want to make love. With ${
// tempSlave.mouthAccessory === none ?
// `a ${Beauty(tempSlave) > 150 && tempSlave.face > 10 ? `pretty` : `quick`} smile` :
// `as much of a smile as ${his} ${tempSlave.mouthAccessory} will allow`
// }, ${he} makes it clear that your advances are not unwanted.`);
// intro.appendChild(generateOptions());
// introSpan.appendChild(App.UI.DOM.linkReplace(
// `Have sex with ${him}`,
// intro
// ));
return introSpan; return introSpan;
} else if (tempSlave.devotion > 20) { } else if (tempSlave.devotion > 20) {
...@@ -341,7 +372,7 @@ App.UI.SlaveInteract.useSlave = function(slave) { ...@@ -341,7 +372,7 @@ App.UI.SlaveInteract.useSlave = function(slave) {
const test = /^[a\s|an\s]/; // any "a" or "an" at the beginning of a string const test = /^[a\s|an\s]/; // any "a" or "an" at the beginning of a string
const face = new LinkList( const face = new OptionList(
[ [
new Option( new Option(
`Kiss ${him}`, `Kiss ${him}`,
...@@ -392,9 +423,9 @@ App.UI.SlaveInteract.useSlave = function(slave) { ...@@ -392,9 +423,9 @@ App.UI.SlaveInteract.useSlave = function(slave) {
) )
] ]
) )
.generateLinks(optionsDiv); .generateOptions(optionsDiv);
const chest = new LinkList( const chest = new OptionList(
[ [
new Option( new Option(
`Grope ${his} chest`, `Grope ${his} chest`,
...@@ -434,9 +465,9 @@ App.UI.SlaveInteract.useSlave = function(slave) { ...@@ -434,9 +465,9 @@ App.UI.SlaveInteract.useSlave = function(slave) {
) )
] ]
) )
.generateLinks(optionsDiv); .generateOptions(optionsDiv);
const crotch = new LinkList( const crotch = new OptionList(
[ [
new Option( new Option(
`Finger ${his} pussy`, `Finger ${his} pussy`,
...@@ -476,9 +507,9 @@ App.UI.SlaveInteract.useSlave = function(slave) { ...@@ -476,9 +507,9 @@ App.UI.SlaveInteract.useSlave = function(slave) {
), ),
] ]
) )
.generateLinks(optionsDiv); .generateOptions(optionsDiv);
const general = new LinkList( const general = new OptionList(
[ [
new Option( new Option(
`Have ${him} dance for you`, `Have ${him} dance for you`,
...@@ -567,9 +598,9 @@ App.UI.SlaveInteract.useSlave = function(slave) { ...@@ -567,9 +598,9 @@ App.UI.SlaveInteract.useSlave = function(slave) {
// }, // },
] ]
) )
.generateLinks(optionsDiv); .generateOptions(optionsDiv);
const clothing = new LinkList( const clothing = new OptionList(
[ [
// new Option( // new Option(
// `Pull up ${his} dress`, // `Pull up ${his} dress`,
...@@ -658,7 +689,7 @@ App.UI.SlaveInteract.useSlave = function(slave) { ...@@ -658,7 +689,7 @@ App.UI.SlaveInteract.useSlave = function(slave) {
), ),
] ]
) )
.generateLinks(optionsDiv); .generateOptions(optionsDiv);
optionsDiv.append(face, chest, crotch, general, clothing); optionsDiv.append(face, chest, crotch, general, clothing);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment