From 5863797b03d96a1911e4c61183e17f03f4f016b5 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Mon, 14 Jun 2021 17:34:07 -0400 Subject: [PATCH] minor refactor --- src/Gang.jsx | 67 +---------------------- src/Gang/ui/Panel1.tsx | 117 +++++++++++++---------------------------- 2 files changed, 39 insertions(+), 145 deletions(-) diff --git a/src/Gang.jsx b/src/Gang.jsx index 69b362bae..2f3f4287d 100644 --- a/src/Gang.jsx +++ b/src/Gang.jsx @@ -1635,7 +1635,7 @@ Gang.prototype.createGangMemberDisplayElement = function(memberObj) { // Gang member content divided into 3 panels: // Panel 1 - Shows member's stats & Ascension stuff const statsDiv = createElement("div", { - class: "gang-member-info-div", + class: "gang-member-info-div tooltip", 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)`, `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("
"), }); UIElems.gangMemberPanels[name]["statsDiv"] = statsDiv; - const statsP = createElement("pre", { - 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.", - "

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.", - "

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); + ReactDOM.render(, statsDiv); // Panel 2 - Task Selection & Info const taskDiv = createElement("div", { diff --git a/src/Gang/ui/Panel1.tsx b/src/Gang/ui/Panel1.tsx index 3de4ddc5e..6f3762983 100644 --- a/src/Gang/ui/Panel1.tsx +++ b/src/Gang/ui/Panel1.tsx @@ -28,18 +28,18 @@ function ascendPopup(props: IAscendProps): React.ReactElement { return (<>
-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(props.member.earnedRespect)} respect
-
-In return, they will gain the following permanent boost to stat multipliers:
-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)}
+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(props.member.earnedRespect)} respect
+
+In return, they will gain the following permanent boost to stat multipliers:
+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)}
@@ -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. +

+ 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. +

+ 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 (<> -
+        
+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)
+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)
+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)
+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)
+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)
+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) +
+
         Hacking: {formatNumber(props.member.hack, 0)} ({numeralWrapper.formatExp(props.member.hack_exp)} exp)
Strength: {formatNumber(props.member.str, 0)} ({numeralWrapper.formatExp(props.member.str_exp)} exp)
Defense: {formatNumber(props.member.def, 0)} ({numeralWrapper.formatExp(props.member.def_exp)} exp)
@@ -72,72 +95,6 @@ export function Panel1(props: IProps): React.ReactElement {

+
?
); } - - -/* - -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.", - "

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.", - "

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); - -*/ \ No newline at end of file