From 9466017906ab32ea800ca55c36ef1c74ebc6a65c Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Mon, 14 Jun 2021 20:20:07 -0400 Subject: [PATCH] modifying gang stats --- src/Gang.jsx | 5 +- src/Gang/ui/GangStats.tsx | 164 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 src/Gang/ui/GangStats.tsx diff --git a/src/Gang.jsx b/src/Gang.jsx index cbd36bad9..0d47dc13d 100644 --- a/src/Gang.jsx +++ b/src/Gang.jsx @@ -1519,6 +1519,8 @@ Gang.prototype.updateGangContent = function() { } } } else { + // TODO(hydroflame): you're working here + // Update information for overall gang if (UIElems.gangInfo instanceof Element) { var faction = Factions[this.facName]; @@ -1617,12 +1619,13 @@ Gang.prototype.updateGangContent = function() { UIElems.gangRecruitRequirementText.style.display = "inline-block"; UIElems.gangRecruitRequirementText.innerHTML = `${formatNumber(respectCost, 2)} respect needed to recruit next member`; } + + // TODO(hydroflame): TO HERE } } // Takes in a GangMember object Gang.prototype.createGangMemberDisplayElement = function(memberObj) { - // TODO(hydroflame): you're working on this. if (!UIElems.gangContentCreated) { return; } const name = memberObj.name; const id = `${name}-gang-member-accordion`; diff --git a/src/Gang/ui/GangStats.tsx b/src/Gang/ui/GangStats.tsx new file mode 100644 index 000000000..348685008 --- /dev/null +++ b/src/Gang/ui/GangStats.tsx @@ -0,0 +1,164 @@ +import React, { useState, useEffect } from "react"; + +export function GangStats(props: IProps): React.ReactElement { + const [rerender, setRerender] = useState(false); + + useEffect(() => { + const id = setInterval(() => setRerender(old => !old), 1000); + return () => clearInterval(id); + }, []); + + + return (

+

+ Respect: 108.82214 (0.23534 / sec) + + Represents the amount of respect your gang has from other gangs and criminal organizations. Your respect affects the amount of money your gang members will earn, and also determines how much reputation you are earning with your gang's corresponding Faction. + +

+
+

+ Wanted Level: 1.37503 (0.00002 / sec) + + Represents how much the gang is wanted by law enforcement. The higher your gang's wanted level, the harder it will be for your gang members to make money and earn respect. Note that the minimum wanted level is 1. + +

+
+

+ Wanted Level Penalty: -1.25% + + Penalty for respect and money gain rates due to Wanted Level + +

+
+
+

+ Money gain rate: + + $2.571k / sec + +

+
+
+

+ Territory: 14.29% + + The percentage of total territory your Gang controls + +

+
+
+

+ Faction reputation: + + 28.677 + +

+
+
+

+ Bonus time: 1 hours 30 minutes 58 seconds + + You gain bonus time while offline or when the game is inactive (e.g. when the tab is throttled by the browser). Bonus time makes the Gang mechanic progress faster, up to 5x the normal speed + +

+
+

); +} + + + +/* + +var faction = Factions[this.facName]; +var rep; +if (!(faction instanceof Faction)) { + rep = "ERROR"; +} else { + rep = faction.playerReputation; +} +UIElems.gangInfo.appendChild(createElement("p", { + display: "inline-block", + innerText: "Respect: " + numeralWrapper.formatRespect(this.respect) + + " (" + numeralWrapper.formatRespect(5*this.respectGainRate) + " / sec)", + tooltip: "Represents the amount of respect your gang has from other gangs and criminal " + + "organizations. Your respect affects the amount of money " + + "your gang members will earn, and also determines how much " + + "reputation you are earning with your gang's corresponding Faction.", +})); +UIElems.gangInfo.appendChild(createElement("br")); + +UIElems.gangInfo.appendChild(createElement("p", { + display: "inline-block", + innerText: "Wanted Level: " + numeralWrapper.formatWanted(this.wanted) + + " (" + numeralWrapper.formatWanted(5*this.wantedGainRate) + " / sec)", + tooltip: "Represents how much the gang is wanted by law enforcement. The higher " + + "your gang's wanted level, the harder it will be for your gang members " + + "to make money and earn respect. Note that the minimum wanted level is 1.", +})); +UIElems.gangInfo.appendChild(createElement("br")); + +var wantedPenalty = this.getWantedPenalty(); +wantedPenalty = (1 - wantedPenalty) * 100; +UIElems.gangInfo.appendChild(createElement("p", { + display: "inline-block", + innerText: `Wanted Level Penalty: -${formatNumber(wantedPenalty, 2)}%`, + tooltip: "Penalty for respect and money gain rates due to Wanted Level", +})); +UIElems.gangInfo.appendChild(createElement("br")); + +const d0 = createElement("div"); +ReactDOM.render(

Money gain rate: {MoneyRate(5 * this.moneyGainRate)}

, d0); +UIElems.gangInfo.appendChild(d0); +UIElems.gangInfo.appendChild(createElement("br")); + +var territoryMult = AllGangs[this.facName].territory * 100; +let displayNumber; +if (territoryMult <= 0) { + displayNumber = formatNumber(0, 2); +} else if (territoryMult >= 100) { + displayNumber = formatNumber(100, 2); +} else { + displayNumber = formatNumber(territoryMult, 2); +} +UIElems.gangInfo.appendChild(createElement("p", { + display: "inline-block", + innerText: `Territory: ${formatNumber(displayNumber, 3)}%`, + tooltip: "The percentage of total territory your Gang controls", +})); +UIElems.gangInfo.appendChild(createElement("br")); + +const d1 = createElement("div"); +ReactDOM.render(

Faction reputation: {Reputation(rep)}

, d1); +UIElems.gangInfo.appendChild(d1); +UIElems.gangInfo.appendChild(createElement("br")); + +const CyclesPerSecond = 1000 / Engine._idleSpeed; +if (this.storedCycles / CyclesPerSecond*1000 > 5000) { + UIElems.gangInfo.appendChild(createElement("p", { + innerText: `Bonus time: ${convertTimeMsToTimeElapsedString(this.storedCycles / CyclesPerSecond*1000)}`, + display: "inline-block", + tooltip: "You gain bonus time while offline or when the game is inactive (e.g. when the tab is throttled by the browser). " + + "Bonus time makes the Gang mechanic progress faster, up to 5x the normal speed", + })); + UIElems.gangInfo.appendChild(createElement("br")); +} + +const numMembers = this.members.length; +const respectCost = this.getRespectNeededToRecruitMember(); + +const btn = UIElems.gangRecruitMemberButton; +if (numMembers >= GangConstants.MaximumGangMembers) { + btn.className = "a-link-button-inactive"; + UIElems.gangRecruitRequirementText.style.display = "inline-block"; + UIElems.gangRecruitRequirementText.innerHTML = "You have reached the maximum amount of gang members"; +} else if (this.canRecruitMember()) { + btn.className = "a-link-button"; + UIElems.gangRecruitRequirementText.style.display = "none"; +} else { + btn.className = "a-link-button-inactive"; + UIElems.gangRecruitRequirementText.style.display = "inline-block"; + UIElems.gangRecruitRequirementText.innerHTML = `${formatNumber(respectCost, 2)} respect needed to recruit next member`; +} + +*/ \ No newline at end of file