minor refactor

This commit is contained in:
Olivier Gagnon 2021-06-14 17:34:07 -04:00
parent 25f546c691
commit 5863797b03
2 changed files with 39 additions and 145 deletions

@ -1635,7 +1635,7 @@ Gang.prototype.createGangMemberDisplayElement = function(memberObj) {
// Gang member content divided into 3 panels: // Gang member content divided into 3 panels:
// Panel 1 - Shows member's stats & Ascension stuff // Panel 1 - Shows member's stats & Ascension stuff
const statsDiv = createElement("div", { const statsDiv = createElement("div", {
class: "gang-member-info-div", class: "gang-member-info-div tooltip",
id: name + "gang-member-stats", id: name + "gang-member-stats",
tooltipsmall: [`Hk: x${numeralWrapper.formatMultiplier(memberObj.hack_mult * memberObj.hack_asc_mult)}(x${numeralWrapper.formatMultiplier(memberObj.hack_mult)} Eq, x${numeralWrapper.formatMultiplier(memberObj.hack_asc_mult)} Asc)`, tooltipsmall: [`Hk: x${numeralWrapper.formatMultiplier(memberObj.hack_mult * memberObj.hack_asc_mult)}(x${numeralWrapper.formatMultiplier(memberObj.hack_mult)} Eq, x${numeralWrapper.formatMultiplier(memberObj.hack_asc_mult)} Asc)`,
`St: x${numeralWrapper.formatMultiplier(memberObj.str_mult * memberObj.str_asc_mult)}(x${numeralWrapper.formatMultiplier(memberObj.str_mult)} Eq, x${numeralWrapper.formatMultiplier(memberObj.str_asc_mult)} Asc)`, `St: x${numeralWrapper.formatMultiplier(memberObj.str_mult * memberObj.str_asc_mult)}(x${numeralWrapper.formatMultiplier(memberObj.str_mult)} Eq, x${numeralWrapper.formatMultiplier(memberObj.str_asc_mult)} Asc)`,
@ -1645,70 +1645,7 @@ Gang.prototype.createGangMemberDisplayElement = function(memberObj) {
`Ch: x${numeralWrapper.formatMultiplier(memberObj.cha_mult * memberObj.cha_asc_mult)}(x${numeralWrapper.formatMultiplier(memberObj.cha_mult)} Eq, x${numeralWrapper.formatMultiplier(memberObj.cha_asc_mult)} Asc)`].join("<br>"), `Ch: x${numeralWrapper.formatMultiplier(memberObj.cha_mult * memberObj.cha_asc_mult)}(x${numeralWrapper.formatMultiplier(memberObj.cha_mult)} Eq, x${numeralWrapper.formatMultiplier(memberObj.cha_asc_mult)} Asc)`].join("<br>"),
}); });
UIElems.gangMemberPanels[name]["statsDiv"] = statsDiv; UIElems.gangMemberPanels[name]["statsDiv"] = statsDiv;
const statsP = createElement("pre", { ReactDOM.render(<Panel1 gang={this} member={memberObj} />, statsDiv);
display: "inline",
id: name + "gang-member-stats-text",
});
const brElement = createElement("br");
const ascendButton = createElement("button", {
class: "accordion-button",
innerText: "Ascend",
clickListener: () => {
const popupId = `gang-management-ascend-member ${memberObj.name}`;
const ascendBenefits = memberObj.getAscensionResults();
const txt = createElement("pre", {
innerText: ["Are you sure you want to ascend this member? They will lose all of",
"their non-Augmentation upgrades and their stats will reset back to 1.",
"",
`Furthermore, your gang will lose ${numeralWrapper.formatRespect(memberObj.earnedRespect)} respect`,
"",
"In return, they will gain the following permanent boost to stat multipliers:\n",
`Hacking: +${numeralWrapper.formatPercentage(ascendBenefits.hack)}`,
`Strength: +${numeralWrapper.formatPercentage(ascendBenefits.str)}`,
`Defense: +${numeralWrapper.formatPercentage(ascendBenefits.def)}`,
`Dexterity: +${numeralWrapper.formatPercentage(ascendBenefits.dex)}`,
`Agility: +${numeralWrapper.formatPercentage(ascendBenefits.agi)}`,
`Charisma: +${numeralWrapper.formatPercentage(ascendBenefits.cha)}`].join("\n"),
});
const confirmBtn = createElement("button", {
class: "std-button",
clickListener: () => {
this.ascendMember(memberObj);
this.updateGangMemberDisplayElement(memberObj);
removeElementById(popupId);
return false;
},
innerText: "Ascend",
});
const cancelBtn = createElement("button", {
class: "std-button",
clickListener: () => {
removeElementById(popupId);
return false;
},
innerText: "Cancel",
});
createPopup(popupId, [txt, confirmBtn, cancelBtn]);
},
});
const ascendHelpTip = createElement("div", {
class: "help-tip",
clickListener: () => {
dialogBoxCreate(["Ascending a Gang Member resets the member's progress and stats in exchange",
"for a permanent boost to their stat multipliers.",
"<br><br>The additional stat multiplier that the Gang Member gains upon ascension",
"is based on the amount of multipliers the member has from non-Augmentation Equipment.",
"<br><br>Upon ascension, the member will lose all of its non-Augmentation Equipment and your",
"gang will lose respect equal to the total respect earned by the member."].join(" "));
},
innerText: "?",
marginTop: "5px",
});
statsDiv.appendChild(statsP);
statsDiv.appendChild(brElement);
statsDiv.appendChild(ascendButton);
statsDiv.appendChild(ascendHelpTip);
// Panel 2 - Task Selection & Info // Panel 2 - Task Selection & Info
const taskDiv = createElement("div", { const taskDiv = createElement("div", {

@ -28,18 +28,18 @@ function ascendPopup(props: IAscendProps): React.ReactElement {
return (<> return (<>
<pre> <pre>
Are you sure you want to ascend this member? They will lose all of Are you sure you want to ascend this member? They will lose all of<br />
their non-Augmentation upgrades and their stats will reset back to 1. their non-Augmentation upgrades and their stats will reset back to 1.<br />
<br />
Furthermore, your gang will lose {numeralWrapper.formatRespect(props.member.earnedRespect)} respect Furthermore, your gang will lose {numeralWrapper.formatRespect(props.member.earnedRespect)} respect<br />
<br />
In return, they will gain the following permanent boost to stat multipliers: In return, they will gain the following permanent boost to stat multipliers:<br />
Hacking: +{numeralWrapper.formatPercentage(ascendBenefits.hack)} Hacking: +{numeralWrapper.formatPercentage(ascendBenefits.hack)}<br />
Strength: +{numeralWrapper.formatPercentage(ascendBenefits.str)} Strength: +{numeralWrapper.formatPercentage(ascendBenefits.str)}<br />
Defense: +{numeralWrapper.formatPercentage(ascendBenefits.def)} Defense: +{numeralWrapper.formatPercentage(ascendBenefits.def)}<br />
Dexterity: +{numeralWrapper.formatPercentage(ascendBenefits.dex)} Dexterity: +{numeralWrapper.formatPercentage(ascendBenefits.dex)}<br />
Agility: +{numeralWrapper.formatPercentage(ascendBenefits.agi)} Agility: +{numeralWrapper.formatPercentage(ascendBenefits.agi)}<br />
Charisma: +{numeralWrapper.formatPercentage(ascendBenefits.cha)} Charisma: +{numeralWrapper.formatPercentage(ascendBenefits.cha)}<br />
</pre> </pre>
<button className="std-button" onClick={confirm}>Ascend</button> <button className="std-button" onClick={confirm}>Ascend</button>
<button className="std-button" onClick={cancel}>Cancel</button> <button className="std-button" onClick={cancel}>Cancel</button>
@ -61,8 +61,31 @@ export function Panel1(props: IProps): React.ReactElement {
}); });
} }
function openAscensionHelp(): void {
dialogBoxCreate(<>
Ascending a Gang Member resets the member's progress and stats in
exchange for a permanent boost to their stat multipliers.
<br /><br />
The additional stat multiplier that the Gang Member gains upon
ascension is based on the amount of multipliers the member has from
non-Augmentation Equipment.
<br /><br />
Upon ascension, the member will lose all of its non-Augmentation
Equipment and your gang will lose respect equal to the total respect
earned by the member.
</>);
}
return (<> return (<>
<pre> <span className="tooltiptext smallfont">
Hk: x{numeralWrapper.formatMultiplier(props.member.hack_mult * props.member.hack_asc_mult)}(x{numeralWrapper.formatMultiplier(props.member.hack_mult)} Eq, x{numeralWrapper.formatMultiplier(props.member.hack_asc_mult)} Asc)<br />
St: x{numeralWrapper.formatMultiplier(props.member.str_mult * props.member.str_asc_mult)}(x{numeralWrapper.formatMultiplier(props.member.str_mult)} Eq, x{numeralWrapper.formatMultiplier(props.member.str_asc_mult)} Asc)<br />
Df: x{numeralWrapper.formatMultiplier(props.member.def_mult * props.member.def_asc_mult)}(x{numeralWrapper.formatMultiplier(props.member.def_mult)} Eq, x{numeralWrapper.formatMultiplier(props.member.def_asc_mult)} Asc)<br />
Dx: x{numeralWrapper.formatMultiplier(props.member.dex_mult * props.member.dex_asc_mult)}(x{numeralWrapper.formatMultiplier(props.member.dex_mult)} Eq, x{numeralWrapper.formatMultiplier(props.member.dex_asc_mult)} Asc)<br />
Ag: x{numeralWrapper.formatMultiplier(props.member.agi_mult * props.member.agi_asc_mult)}(x{numeralWrapper.formatMultiplier(props.member.agi_mult)} Eq, x{numeralWrapper.formatMultiplier(props.member.agi_asc_mult)} Asc)<br />
Ch: x{numeralWrapper.formatMultiplier(props.member.cha_mult * props.member.cha_asc_mult)}(x{numeralWrapper.formatMultiplier(props.member.cha_mult)} Eq, x{numeralWrapper.formatMultiplier(props.member.cha_asc_mult)} Asc)
</span>
<pre id={`${props.member.name}gang-member-stats-text`}>
Hacking: {formatNumber(props.member.hack, 0)} ({numeralWrapper.formatExp(props.member.hack_exp)} exp)<br /> Hacking: {formatNumber(props.member.hack, 0)} ({numeralWrapper.formatExp(props.member.hack_exp)} exp)<br />
Strength: {formatNumber(props.member.str, 0)} ({numeralWrapper.formatExp(props.member.str_exp)} exp)<br /> Strength: {formatNumber(props.member.str, 0)} ({numeralWrapper.formatExp(props.member.str_exp)} exp)<br />
Defense: {formatNumber(props.member.def, 0)} ({numeralWrapper.formatExp(props.member.def_exp)} exp)<br /> Defense: {formatNumber(props.member.def, 0)} ({numeralWrapper.formatExp(props.member.def_exp)} exp)<br />
@ -72,72 +95,6 @@ export function Panel1(props: IProps): React.ReactElement {
</pre> </pre>
<br /> <br />
<button className="accordion-button" onClick={ascend}>Ascend</button> <button className="accordion-button" onClick={ascend}>Ascend</button>
<div className="help-tip" style={{marginTop: "5px"}} onClick={openAscensionHelp}>?</div>
</>); </>);
} }
/*
const ascendButton = createElement("button", {
class: "accordion-button",
innerText: "Ascend",
clickListener: () => {
const popupId = `gang-management-ascend-member ${memberObj.name}`;
const ascendBenefits = memberObj.getAscensionResults();
const txt = createElement("pre", {
innerText: ["Are you sure you want to ascend this member? They will lose all of",
"their non-Augmentation upgrades and their stats will reset back to 1.",
"",
`Furthermore, your gang will lose ${numeralWrapper.formatRespect(memberObj.earnedRespect)} respect`,
"",
"In return, they will gain the following permanent boost to stat multipliers:\n",
`Hacking: +${numeralWrapper.formatPercentage(ascendBenefits.hack)}`,
`Strength: +${numeralWrapper.formatPercentage(ascendBenefits.str)}`,
`Defense: +${numeralWrapper.formatPercentage(ascendBenefits.def)}`,
`Dexterity: +${numeralWrapper.formatPercentage(ascendBenefits.dex)}`,
`Agility: +${numeralWrapper.formatPercentage(ascendBenefits.agi)}`,
`Charisma: +${numeralWrapper.formatPercentage(ascendBenefits.cha)}`].join("\n"),
});
const confirmBtn = createElement("button", {
class: "std-button",
clickListener: () => {
this.ascendMember(memberObj);
this.updateGangMemberDisplayElement(memberObj);
removePopup(popupId);
return false;
},
innerText: "Ascend",
});
const cancelBtn = createElement("button", {
class: "std-button",
clickListener: () => {
removePopup(popupId);
return false;
},
innerText: "Cancel",
});
createPopup(popupId, [txt, confirmBtn, cancelBtn]);
},
});
const ascendHelpTip = createElement("div", {
class: "help-tip",
clickListener: () => {
dialogBoxCreate(["Ascending a Gang Member resets the member's progress and stats in exchange",
"for a permanent boost to their stat multipliers.",
"<br><br>The additional stat multiplier that the Gang Member gains upon ascension",
"is based on the amount of multipliers the member has from non-Augmentation Equipment.",
"<br><br>Upon ascension, the member will lose all of its non-Augmentation Equipment and your",
"gang will lose respect equal to the total respect earned by the member."].join(" "));
},
innerText: "?",
marginTop: "5px",
});
statsDiv.appendChild(statsP);
statsDiv.appendChild(brElement);
statsDiv.appendChild(ascendButton);
statsDiv.appendChild(ascendHelpTip);
*/