From 2c7fbc03cf821a2b6fd0c1d0b2f725acee788f1b Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Thu, 17 Jun 2021 11:24:52 -0400 Subject: [PATCH] Remove all uses of any in Gang, Train Combat and Train Hacking are now the best exp gains, gang equipment and augs now give exp boosts --- src/Gang/Gang.ts | 24 ++++------ src/Gang/GangMember.ts | 53 ++++++++++++++-------- src/Gang/GangMemberTask.ts | 21 +-------- src/Gang/Helpers.tsx | 1 + src/Gang/IAscensionResult.ts | 9 ++++ src/Gang/ITaskParams.ts | 20 ++++++++ src/Gang/data/tasks.ts | 7 +-- src/Gang/ui/GangMemberAccordionContent.tsx | 11 +++-- src/Gang/ui/GangMemberList.tsx | 16 +++---- src/Gang/ui/GangMemberUpgradePopup.tsx | 21 +++++---- src/Gang/ui/GangStats.tsx | 16 ++----- src/Gang/ui/ManagementSubpage.tsx | 5 +- src/Gang/ui/Panel1.tsx | 16 +++---- src/Gang/ui/Panel2.tsx | 16 +++---- src/Gang/ui/Panel3.tsx | 12 +---- src/Gang/ui/Root.tsx | 11 ++++- src/Gang/ui/TerritorySubpage.tsx | 10 +--- 17 files changed, 137 insertions(+), 132 deletions(-) create mode 100644 src/Gang/IAscensionResult.ts create mode 100644 src/Gang/ITaskParams.ts diff --git a/src/Gang/Gang.ts b/src/Gang/Gang.ts index d0267b8d0..30b5adf15 100644 --- a/src/Gang/Gang.ts +++ b/src/Gang/Gang.ts @@ -24,6 +24,7 @@ import { GangMemberUpgrade } from "./GangMemberUpgrade"; import { GangConstants } from "./data/Constants"; import { CONSTANTS } from "../Constants"; import { GangMemberTasks } from "./GangMemberTasks"; +import { IAscensionResult } from "./IAscensionResult"; import { AllGangs } from "./AllGangs"; import { GangMember } from "./GangMember"; @@ -53,7 +54,7 @@ export class Gang { notifyMemberDeath: boolean; - constructor(facName: string = "", hacking: boolean = false) { + constructor(facName = "", hacking = false) { this.facName = facName; this.members = []; this.wanted = 1; @@ -87,7 +88,7 @@ export class Gang { return AllGangs[this.facName].territory; } - process(numCycles: number = 1, player: IPlayer): void { + process(numCycles = 1, player: IPlayer): void { const CyclesPerSecond = 1000 / CONSTANTS._idleSpeed; if (isNaN(numCycles)) { @@ -110,7 +111,7 @@ export class Gang { } - processGains(numCycles: number = 1, player: IPlayer): void { + processGains(numCycles = 1, player: IPlayer): void { // Get gains per cycle let moneyGains = 0, respectGains = 0, wantedLevelGains = 0; let justice = 0; @@ -170,7 +171,7 @@ export class Gang { } } - processTerritoryAndPowerGains(numCycles: number = 1): void { + processTerritoryAndPowerGains(numCycles = 1): void { this.storedTerritoryAndPowerCycles += numCycles; if (this.storedTerritoryAndPowerCycles < GangConstants.CyclesPerTerritoryAndPowerUpdate) { return; } this.storedTerritoryAndPowerCycles -= GangConstants.CyclesPerTerritoryAndPowerUpdate; @@ -268,14 +269,14 @@ export class Gang { } } - processExperienceGains(numCycles: number = 1): void { + processExperienceGains(numCycles = 1): void { for (let i = 0; i < this.members.length; ++i) { this.members[i].gainExperience(numCycles); this.members[i].updateSkillLevels(); } } - clash(won: boolean = false): void { + clash(won = false): void { // Determine if a gang member should die let baseDeathChance = 0.01; if (won) { baseDeathChance /= 2; } @@ -370,14 +371,8 @@ export class Gang { } - ascendMember(member: GangMember, workerScript: WorkerScript): void { + ascendMember(member: GangMember, workerScript?: WorkerScript): IAscensionResult { try { - - // res is an object with the following format: - // { - // respect: Amount of respect to deduct - // hack/str/def/dex/agi/cha: Ascension multipliers gained for each stat - // } const res = member.ascend(); this.respect = Math.max(1, this.respect - res.respect); if (workerScript == null) { @@ -399,9 +394,8 @@ export class Gang { } catch(e) { if (workerScript == null) { exceptionAlert(e); - } else { - throw e; // Re-throw, will be caught in the Netscript Function } + throw e; // Re-throw, will be caught in the Netscript Function } } diff --git a/src/Gang/GangMember.ts b/src/Gang/GangMember.ts index 78ebfde8c..8ec426953 100644 --- a/src/Gang/GangMember.ts +++ b/src/Gang/GangMember.ts @@ -2,12 +2,22 @@ import { GangMemberTask } from "./GangMemberTask"; import { GangMemberTasks } from "./GangMemberTasks"; import { GangMemberUpgrade } from "./GangMemberUpgrade"; import { GangMemberUpgrades } from "./GangMemberUpgrades"; +import { IAscensionResult } from "./IAscensionResult"; import { IPlayer } from "../PersonObjects/IPlayer"; import { GangConstants } from "./data/Constants"; import { AllGangs } from "./AllGangs"; import { IGang } from "./IGang"; import { Generic_fromJSON, Generic_toJSON, Reviver } from "../../utils/JSONReviver"; +interface IMults { + hack: number; + str: number; + def: number; + dex: number; + agi: number; + cha: number; +} + export class GangMember { name: string; task = "Unassigned"; @@ -67,13 +77,12 @@ export class GangMember { } assignToTask(taskName: string): boolean { - if (GangMemberTasks.hasOwnProperty(taskName)) { - this.task = taskName; - return true; - } else { + if (!GangMemberTasks.hasOwnProperty(taskName)) { this.task = "Unassigned"; return false; } + this.task = taskName; + return true; } unassignFromTask(): void { @@ -151,25 +160,37 @@ export class GangMember { return 5 * task.baseMoney * statWeight * territoryMult * respectMult; } + expMult(): IMults { + return { + hack: (this.hack_mult-1)/10+1, + str: (this.str_mult-1)/10+1, + def: (this.def_mult-1)/10+1, + dex: (this.dex_mult-1)/10+1, + agi: (this.agi_mult-1)/10+1, + cha: (this.cha_mult-1)/10+1, + }; + } + gainExperience(numCycles = 1): void { const task = this.getTask(); if (task === GangMemberTasks["Unassigned"]) return; const difficultyMult = Math.pow(task.difficulty, 0.9); const difficultyPerCycles = difficultyMult * numCycles; const weightDivisor = 1500; - this.hack_exp += (task.hackWeight / weightDivisor) * difficultyPerCycles; - this.str_exp += (task.strWeight / weightDivisor) * difficultyPerCycles; - this.def_exp += (task.defWeight / weightDivisor) * difficultyPerCycles; - this.dex_exp += (task.dexWeight / weightDivisor) * difficultyPerCycles; - this.agi_exp += (task.agiWeight / weightDivisor) * difficultyPerCycles; - this.cha_exp += (task.chaWeight / weightDivisor) * difficultyPerCycles; + const expMult = this.expMult(); + this.hack_exp += (task.hackWeight / weightDivisor) * difficultyPerCycles * expMult.hack; + this.str_exp += (task.strWeight / weightDivisor) * difficultyPerCycles * expMult.str; + this.def_exp += (task.defWeight / weightDivisor) * difficultyPerCycles * expMult.def; + this.dex_exp += (task.dexWeight / weightDivisor) * difficultyPerCycles * expMult.dex; + this.agi_exp += (task.agiWeight / weightDivisor) * difficultyPerCycles * expMult.agi; + this.cha_exp += (task.chaWeight / weightDivisor) * difficultyPerCycles * expMult.cha; } recordEarnedRespect(numCycles = 1, gang: IGang): void { this.earnedRespect += (this.calculateRespectGain(gang) * numCycles); } - getAscensionResults(): any { + getAscensionResults(): IMults { //Calculate ascension bonus to stat multipliers. //This is based on the current number of multipliers from Non-Augmentation upgrades //+ Ascension Bonus = N% of current bonus from Augmentations @@ -201,7 +222,7 @@ export class GangMember { } } - getAscensionEfficiency(): any { + getAscensionEfficiency(): IMults { function formula(mult: number): number { return 1/(1+Math.log(mult)/Math.log(20)); } @@ -215,7 +236,7 @@ export class GangMember { }; } - ascend(): any { + ascend(): IAscensionResult { const res = this.getAscensionResults(); const hackAscMult = res.hack; const strAscMult = res.str; @@ -275,12 +296,6 @@ export class GangMember { } buyUpgrade(upg: GangMemberUpgrade, player: IPlayer, gang: IGang): boolean { - if (typeof upg === 'string') { - upg = GangMemberUpgrades[upg]; - } - if (!(upg instanceof GangMemberUpgrade)) { - return false; - } // Prevent purchasing of already-owned upgrades if (this.augmentations.includes(upg.name) || this.upgrades.includes(upg.name)) { return false; diff --git a/src/Gang/GangMemberTask.ts b/src/Gang/GangMemberTask.ts index a684a09cb..053fe0777 100644 --- a/src/Gang/GangMemberTask.ts +++ b/src/Gang/GangMemberTask.ts @@ -1,23 +1,4 @@ - -interface ITerritory { - money: number; - respect: number; - wanted: number; -} - -export interface ITaskParams { - baseRespect?: number; - baseWanted?: number; - baseMoney?: number; - hackWeight?: number; - strWeight?: number; - defWeight?: number; - dexWeight?: number; - agiWeight?: number; - chaWeight?: number; - difficulty?: number; - territory?: ITerritory; -} +import { ITaskParams, ITerritory } from "./ITaskParams"; export class GangMemberTask { name: string; diff --git a/src/Gang/Helpers.tsx b/src/Gang/Helpers.tsx index bf7de1029..0d7091a52 100644 --- a/src/Gang/Helpers.tsx +++ b/src/Gang/Helpers.tsx @@ -34,6 +34,7 @@ export function displayGangContent(engine: IEngine, gang: Gang, player: IPlayer) } export function clearGangUI(): void { + if(UIElems.gangContainer) UIElems.gangContainer.style.display = 'none'; if (UIElems.gangContainer instanceof Element) ReactDOM.unmountComponentAtNode(UIElems.gangContainer); UIElems.gangContainer = null; UIElems.gangContentCreated = false; diff --git a/src/Gang/IAscensionResult.ts b/src/Gang/IAscensionResult.ts new file mode 100644 index 000000000..f42f7c603 --- /dev/null +++ b/src/Gang/IAscensionResult.ts @@ -0,0 +1,9 @@ +export interface IAscensionResult { + respect: number; + hack: number; + str: number; + def: number; + dex: number; + agi: number; + cha: number; +}; \ No newline at end of file diff --git a/src/Gang/ITaskParams.ts b/src/Gang/ITaskParams.ts new file mode 100644 index 000000000..44178e42f --- /dev/null +++ b/src/Gang/ITaskParams.ts @@ -0,0 +1,20 @@ + +export interface ITerritory { + money: number; + respect: number; + wanted: number; +} + +export interface ITaskParams { + baseRespect?: number; + baseWanted?: number; + baseMoney?: number; + hackWeight?: number; + strWeight?: number; + defWeight?: number; + dexWeight?: number; + agiWeight?: number; + chaWeight?: number; + difficulty?: number; + territory?: ITerritory; +} \ No newline at end of file diff --git a/src/Gang/data/tasks.ts b/src/Gang/data/tasks.ts index 60c5a6662..c5d83e7c8 100644 --- a/src/Gang/data/tasks.ts +++ b/src/Gang/data/tasks.ts @@ -1,3 +1,4 @@ +import { ITaskParams } from "../ITaskParams"; /* tslint:disable:max-line-length */ /** @@ -29,7 +30,7 @@ export interface IGangMemberTaskMetadata { * An object containing weighting parameters for the task. These parameters are used for * various calculations (respect gain, wanted gain, etc.) */ - params?: any; + params: ITaskParams; } /** @@ -254,7 +255,7 @@ export const gangMemberTasksMetadata: IGangMemberTaskMetadata[] = [ name: "Train Combat", params: { strWeight: 25, defWeight: 25, dexWeight: 25, agiWeight: 25, - difficulty: 5, + difficulty: 200, }, }, { @@ -262,7 +263,7 @@ export const gangMemberTasksMetadata: IGangMemberTaskMetadata[] = [ isCombat: true, isHacking: true, name: "Train Hacking", - params: {hackWeight: 100, difficulty: 8}, + params: {hackWeight: 100, difficulty: 45}, }, { desc: "Assign this gang member to train their charisma", diff --git a/src/Gang/ui/GangMemberAccordionContent.tsx b/src/Gang/ui/GangMemberAccordionContent.tsx index 882a0149f..573f95738 100644 --- a/src/Gang/ui/GangMemberAccordionContent.tsx +++ b/src/Gang/ui/GangMemberAccordionContent.tsx @@ -1,20 +1,23 @@ -import * as React from "react"; +import React, { useState } from "react"; import { Panel1 } from "./Panel1"; import { Panel2 } from "./Panel2"; import { Panel3 } from "./Panel3"; +import { Gang } from "../Gang"; +import { GangMember } from "../GangMember"; interface IProps { - gang: any; - member: any; + gang: Gang; + member: GangMember; } export function GangMemberAccordionContent(props: IProps): React.ReactElement { + const setRerender = useState(false)[1]; return (<>
- + setRerender(old => !old)} gang={props.gang} member={props.member} />
diff --git a/src/Gang/ui/GangMemberList.tsx b/src/Gang/ui/GangMemberList.tsx index 44fffdfa8..3accc7163 100644 --- a/src/Gang/ui/GangMemberList.tsx +++ b/src/Gang/ui/GangMemberList.tsx @@ -4,21 +4,17 @@ import { GangMemberAccordionContent } from "./GangMemberAccordionContent" import { GangMemberUpgradePopup } from "./GangMemberUpgradePopup" import { createPopup } from "../../ui/React/createPopup"; import { IPlayer } from "../../PersonObjects/IPlayer"; +import { Gang } from "../Gang"; +import { GangMember } from "../GangMember"; interface IProps { - gang: any; + gang: Gang; player: IPlayer; } export function GangMemberList(props: IProps): React.ReactElement { - const setRerender = useState(false)[1]; const [filter, setFilter] = useState(""); - useEffect(() => { - const id = setInterval(() => setRerender(old => !old), 1000); - return () => clearInterval(id); - }, []); - function openUpgradePopup(): void { const popupId = `gang-upgrade-popup`; createPopup(popupId, GangMemberUpgradePopup, { @@ -32,15 +28,15 @@ export function GangMemberList(props: IProps): React.ReactElement { setFilter(event.target.value); } - function members(): any { - return props.gang.members.filter((member: any) => member.name.indexOf(filter) > -1 || member.task.indexOf(filter) > -1) + function members(): GangMember[] { + return props.gang.members.filter((member: GangMember) => member.name.indexOf(filter) > -1 || member.task.indexOf(filter) > -1) } return (<> Manage Equipment
    - {members().map((member: any) =>
  • + {members().map((member: GangMember) =>
  • {member.name}} diff --git a/src/Gang/ui/GangMemberUpgradePopup.tsx b/src/Gang/ui/GangMemberUpgradePopup.tsx index 999605d6e..bd7b80128 100644 --- a/src/Gang/ui/GangMemberUpgradePopup.tsx +++ b/src/Gang/ui/GangMemberUpgradePopup.tsx @@ -6,10 +6,12 @@ import { GangMemberUpgrade } from "../GangMemberUpgrade"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { Money } from "../../ui/React/Money"; import { removePopup } from "../../ui/React/createPopup"; +import { GangMember } from "../GangMember"; +import { Gang } from "../Gang"; interface IPanelProps { - member: any; - gang: any; + member: GangMember; + gang: Gang; player: IPlayer; } @@ -79,8 +81,8 @@ Agi: {props.member.agi} (x{formatNumber(props.member.agi_mult * props.member.ag Cha: {props.member.cha} (x{formatNumber(props.member.cha_mult * props.member.cha_asc_mult, 2)})
    - Purchased Upgrades: {props.member.upgrades.map((upg: any) => purchased(upg))} - {props.member.augmentations.map((upg: any) => purchased(upg))} + Purchased Upgrades: {props.member.upgrades.map((upg: string) => purchased(upg))} + {props.member.augmentations.map((upg: string) => purchased(upg))}

    Weapons

    @@ -106,7 +108,7 @@ Cha: {props.member.cha} (x{formatNumber(props.member.cha_mult * props.member.ch } interface IProps { - gang: any; + gang: Gang; player: IPlayer; popupId: string; } @@ -115,16 +117,17 @@ export function GangMemberUpgradePopup(props: IProps): React.ReactElement { const setRerender = useState(false)[1]; const [filter, setFilter] = useState(""); - function closePopup(): void { + function closePopup(this: Window, ev: KeyboardEvent): void { + if(ev.keyCode !== 27) return; removePopup(props.popupId); } useEffect(() => { - window.addEventListener('keydown', closePopup); + window.addEventListener<'keydown'>('keydown', closePopup); const id = setInterval(() => setRerender(old => !old), 1000); return () => { clearInterval(id); - window.removeEventListener('keydown', closePopup); + window.removeEventListener<'keydown'>('keydown', closePopup); } }, []); @@ -134,6 +137,6 @@ export function GangMemberUpgradePopup(props: IProps): React.ReactElement { Discount: -{numeralWrapper.formatPercentage(1 - 1 / props.gang.getDiscount())} You get a discount on equipment and upgrades based on your gang's respect and power. More respect and power leads to more discounts.

    - {props.gang.members.map((member: any) => )} + {props.gang.members.map((member: GangMember) => )} ); } diff --git a/src/Gang/ui/GangStats.tsx b/src/Gang/ui/GangStats.tsx index 7ed4eee09..e3d96db23 100644 --- a/src/Gang/ui/GangStats.tsx +++ b/src/Gang/ui/GangStats.tsx @@ -1,5 +1,6 @@ import React, { useState, useEffect } from "react"; import { Factions } from "../../Faction/Factions"; +import { Gang } from "../Gang"; import { formatNumber, @@ -14,7 +15,7 @@ import { createPopup, removePopup } from "../../ui/React/createPopup"; import { dialogBoxCreate } from "../../../utils/DialogBox"; interface IRecruitPopupProps { - gang: any; + gang: Gang; popupId: string; } @@ -45,12 +46,12 @@ function recruitPopup(props: IRecruitPopupProps): React.ReactElement { removePopup(props.popupId); } - function onKeyUp(event: any): void { + function onKeyUp(event: React.KeyboardEvent): void { if(event.keyCode === 13) recruit(); if(event.keyCode === 27) cancel(); } - function onChange(event: any): void { + function onChange(event: React.ChangeEvent): void { setName(event.target.value); } @@ -68,7 +69,7 @@ function recruitPopup(props: IRecruitPopupProps): React.ReactElement { } interface IProps { - gang: any; + gang: Gang; } function Recruitment(props: IProps): React.ReactElement { @@ -120,13 +121,6 @@ function BonusTime(props: IProps): React.ReactElement { } export function GangStats(props: IProps): React.ReactElement { - const setRerender = useState(false)[1]; - - useEffect(() => { - const id = setInterval(() => setRerender(old => !old), 1000); - return () => clearInterval(id); - }, []); - const territoryMult = AllGangs[props.gang.facName].territory * 100; let territoryStr; if (territoryMult <= 0) { diff --git a/src/Gang/ui/ManagementSubpage.tsx b/src/Gang/ui/ManagementSubpage.tsx index 528fd6515..b79c0979a 100644 --- a/src/Gang/ui/ManagementSubpage.tsx +++ b/src/Gang/ui/ManagementSubpage.tsx @@ -1,10 +1,11 @@ -import * as React from "react"; +import React, { useState, useEffect } from "react"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { GangStats } from "./GangStats"; +import { Gang } from "../Gang"; import { GangMemberList } from "./GangMemberList"; interface IProps { - gang: any; + gang: Gang; player: IPlayer; } diff --git a/src/Gang/ui/Panel1.tsx b/src/Gang/ui/Panel1.tsx index d08b03335..dcb6d5601 100644 --- a/src/Gang/ui/Panel1.tsx +++ b/src/Gang/ui/Panel1.tsx @@ -3,10 +3,12 @@ import { dialogBoxCreate } from "../../../utils/DialogBox"; import { formatNumber } from "../../../utils/StringHelperFunctions"; import { numeralWrapper } from "../../ui/numeralFormat"; import { createPopup, removePopup } from "../../ui/React/createPopup"; +import { Gang } from "../Gang"; +import { GangMember } from "../GangMember"; interface IAscendProps { - member: any; - gang: any; + member: GangMember; + gang: Gang; popupId: string; } @@ -43,17 +45,11 @@ Charisma: +{numeralWrapper.formatPercentage(ascendBenefits.cha/100)}
    } interface IProps { - member: any; - gang: any; + member: GangMember; + gang: Gang; } export function Panel1(props: IProps): React.ReactElement { - const setRerender = useState(false)[1]; - - useEffect(() => { - const id = setInterval(() => setRerender(old => !old), 1000); - return () => clearInterval(id); - }, []); function ascend(): void { const popupId = `gang-management-ascend-member ${props.member.name}`; diff --git a/src/Gang/ui/Panel2.tsx b/src/Gang/ui/Panel2.tsx index c08144ea4..d87e1f73c 100644 --- a/src/Gang/ui/Panel2.tsx +++ b/src/Gang/ui/Panel2.tsx @@ -2,25 +2,23 @@ import React, { useState, useEffect } from "react"; import { numeralWrapper } from "../../ui/numeralFormat"; import { StatsTable } from "../../ui/React/StatsTable"; import { MoneyRate } from "../../ui/React/MoneyRate"; +import { Gang } from "../Gang"; +import { GangMember } from "../GangMember"; interface IProps { - member: any; - gang: any; + member: GangMember; + gang: Gang; + onTaskChange: () => void; } export function Panel2(props: IProps): React.ReactElement { - const setRerender = useState(false)[1]; const [currentTask, setCurrentTask] = useState(props.member.task); - useEffect(() => { - const id = setInterval(() => setRerender(old => !old), 1000); - return () => clearInterval(id); - }, []); - function onChange(event: React.ChangeEvent): void { const task = event.target.value; props.member.assignToTask(task); setCurrentTask(task); + props.onTaskChange(); } const tasks = props.gang.getAllTaskNames(); @@ -39,7 +37,7 @@ export function Panel2(props: IProps): React.ReactElement { id={`${props.member.name}-gang-member-task-selector`} value={currentTask}> - {tasks.map((task: any, i: number) => )} + {tasks.map((task: string, i: number) => )}
    {StatsTable(data, null)}
    ); diff --git a/src/Gang/ui/Panel3.tsx b/src/Gang/ui/Panel3.tsx index cd889b100..b7e33e742 100644 --- a/src/Gang/ui/Panel3.tsx +++ b/src/Gang/ui/Panel3.tsx @@ -1,20 +1,12 @@ import React, { useState, useEffect } from "react"; import { GangMemberTasks } from "../GangMemberTasks"; +import { GangMember } from "../GangMember"; interface IProps { - member: any; + member: GangMember; } export function Panel3(props: IProps): React.ReactElement { - const setRerender = useState(false)[1]; - - useEffect(() => { - const id = setInterval(() => { - setRerender(old => !old); - }, 1000); - return () => clearInterval(id); - }, []); - const task = GangMemberTasks[props.member.task]; const desc = task ? task.desc: GangMemberTasks["Unassigned"].desc; diff --git a/src/Gang/ui/Root.tsx b/src/Gang/ui/Root.tsx index 02296884a..2859b41cf 100644 --- a/src/Gang/ui/Root.tsx +++ b/src/Gang/ui/Root.tsx @@ -1,18 +1,25 @@ -import React, { useState } from "react"; +import React, { useState, useEffect } from "react"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { ManagementSubpage } from "./ManagementSubpage"; import { TerritorySubpage } from "./TerritorySubpage"; import { IEngine } from "../../IEngine"; +import { Gang } from "../Gang"; import { displayFactionContent } from "../../Faction/FactionHelpers"; interface IProps { - gang: any; + gang: Gang; player: IPlayer; engine: IEngine; } export function Root(props: IProps): React.ReactElement { const [management, setManagement] = useState(true); + const setRerender = useState(false)[1]; + + useEffect(() => { + const id = setInterval(() => setRerender(old => !old), 1000); + return () => clearInterval(id); + }, []); function back(): void { props.engine.loadFactionContent(); diff --git a/src/Gang/ui/TerritorySubpage.tsx b/src/Gang/ui/TerritorySubpage.tsx index cecbe0c26..f6af15d30 100644 --- a/src/Gang/ui/TerritorySubpage.tsx +++ b/src/Gang/ui/TerritorySubpage.tsx @@ -3,19 +3,13 @@ import { numeralWrapper } from "../../ui/numeralFormat"; import { dialogBoxCreate } from "../../../utils/DialogBox"; import { formatNumber } from "../../../utils/StringHelperFunctions"; import { AllGangs } from "../AllGangs"; +import { Gang } from "../Gang"; interface IProps { - gang: any; + gang: Gang; } export function TerritorySubpage(props: IProps): React.ReactElement { - const setRerender = useState(false)[1]; - - useEffect(() => { - const id = setInterval(() => setRerender(old => !old), 1000); - return () => clearInterval(id); - }, []); - function openWarfareHelp(): void { dialogBoxCreate("This percentage represents the chance you have of 'clashing' with " + "with another gang. If you do not wish to gain/lose territory, " +