mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-02-18 10:53:43 +01:00
Converted GangMember to tsx, only Gang left
This commit is contained in:
@ -7,7 +7,6 @@ import * as React from "react";
|
|||||||
import { Augmentations } from "../../Augmentation/Augmentations";
|
import { Augmentations } from "../../Augmentation/Augmentations";
|
||||||
import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
|
import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
|
||||||
import { Player } from "../../Player";
|
import { Player } from "../../Player";
|
||||||
import { IPlayerOwnedAugmentation } from "../../Augmentation/PlayerOwnedAugmentation";
|
|
||||||
|
|
||||||
import { AugmentationAccordion } from "../../ui/React/AugmentationAccordion";
|
import { AugmentationAccordion } from "../../ui/React/AugmentationAccordion";
|
||||||
|
|
||||||
|
343
src/Gang.jsx
343
src/Gang.jsx
@ -4,15 +4,10 @@
|
|||||||
* balance point to keep them from running out of control
|
* balance point to keep them from running out of control
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { gangMemberTasksMetadata } from "./Gang/data/tasks";
|
|
||||||
import { gangMemberUpgradesMetadata } from "./Gang/data/upgrades";
|
|
||||||
|
|
||||||
import { Engine } from "./engine";
|
import { Engine } from "./engine";
|
||||||
import { Faction } from "./Faction/Faction";
|
import { Faction } from "./Faction/Faction";
|
||||||
import { Factions } from "./Faction/Factions";
|
import { Factions } from "./Faction/Factions";
|
||||||
import { displayFactionContent } from "./Faction/FactionHelpers";
|
|
||||||
|
|
||||||
import { Page, routing } from "./ui/navigationTracking";
|
|
||||||
import { numeralWrapper } from "./ui/numeralFormat";
|
import { numeralWrapper } from "./ui/numeralFormat";
|
||||||
|
|
||||||
import { dialogBoxCreate } from "../utils/DialogBox";
|
import { dialogBoxCreate } from "../utils/DialogBox";
|
||||||
@ -21,53 +16,25 @@ import {
|
|||||||
Generic_toJSON,
|
Generic_toJSON,
|
||||||
Generic_fromJSON,
|
Generic_fromJSON,
|
||||||
} from "../utils/JSONReviver";
|
} from "../utils/JSONReviver";
|
||||||
import {
|
|
||||||
formatNumber,
|
|
||||||
convertTimeMsToTimeElapsedString,
|
|
||||||
} from "../utils/StringHelperFunctions";
|
|
||||||
|
|
||||||
import { exceptionAlert } from "../utils/helpers/exceptionAlert";
|
import { exceptionAlert } from "../utils/helpers/exceptionAlert";
|
||||||
import { getRandomInt } from "../utils/helpers/getRandomInt";
|
import { getRandomInt } from "../utils/helpers/getRandomInt";
|
||||||
import { KEY } from "../utils/helpers/keyCodes";
|
|
||||||
|
|
||||||
import { createAccordionElement } from "../utils/uiHelpers/createAccordionElement";
|
|
||||||
import { createElement } from "../utils/uiHelpers/createElement";
|
import { createElement } from "../utils/uiHelpers/createElement";
|
||||||
import { createPopup } from "../utils/uiHelpers/createPopup";
|
|
||||||
import { removeChildrenFromElement } from "../utils/uiHelpers/removeChildrenFromElement";
|
|
||||||
import { removeElement } from "../utils/uiHelpers/removeElement";
|
import { removeElement } from "../utils/uiHelpers/removeElement";
|
||||||
import { removeElementById } from "../utils/uiHelpers/removeElementById";
|
|
||||||
|
|
||||||
import { StatsTable } from "./ui/React/StatsTable";
|
|
||||||
import { Money } from "./ui/React/Money";
|
|
||||||
import { MoneyRate } from "./ui/React/MoneyRate";
|
|
||||||
import { Reputation } from "./ui/React/Reputation";
|
|
||||||
|
|
||||||
// import { GangMember as GM } from "./Gang/GangMember";
|
|
||||||
import { GangMemberUpgrade } from "./Gang/GangMemberUpgrade";
|
import { GangMemberUpgrade } from "./Gang/GangMemberUpgrade";
|
||||||
import { GangMemberUpgrades } from "./Gang/GangMemberUpgrades";
|
import { GangMemberUpgrades } from "./Gang/GangMemberUpgrades";
|
||||||
import { GangConstants } from "./Gang/data/Constants";
|
import { GangConstants } from "./Gang/data/Constants";
|
||||||
import { GangMemberTasks } from "./Gang/GangMemberTasks";
|
import { GangMemberTasks } from "./Gang/GangMemberTasks";
|
||||||
import { GangMemberTask } from "./Gang/GangMemberTask";
|
import { GangMemberTask } from "./Gang/GangMemberTask";
|
||||||
|
|
||||||
import { ManagementSubpage } from "./Gang/ui/ManagementSubpage";
|
|
||||||
import { TerritorySubpage } from "./Gang/ui/TerritorySubpage";
|
|
||||||
import { GangStats } from "./Gang/ui/GangStats";
|
|
||||||
import { AllGangs } from "./Gang/AllGangs";
|
import { AllGangs } from "./Gang/AllGangs";
|
||||||
import { Root } from "./Gang/ui/Root";
|
import { Root } from "./Gang/ui/Root";
|
||||||
|
import { GangMember } from "./Gang/GangMember";
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import ReactDOM from "react-dom";
|
import ReactDOM from "react-dom";
|
||||||
import { renderToStaticMarkup } from "react-dom/server"
|
|
||||||
|
|
||||||
const GangNames = [
|
|
||||||
"Slum Snakes",
|
|
||||||
"Tetrads",
|
|
||||||
"The Syndicate",
|
|
||||||
"The Dark Army",
|
|
||||||
"Speakers for the Dead",
|
|
||||||
"NiteSec",
|
|
||||||
"The Black Hand",
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param facName {string} Name of corresponding faction
|
* @param facName {string} Name of corresponding faction
|
||||||
@ -189,12 +156,6 @@ Gang.prototype.processGains = function(numCycles=1, player) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function calculateTerritoryGain(winGang, loseGang) {
|
|
||||||
const powerBonus = Math.max(1, 1+Math.log(AllGangs[winGang].power/AllGangs[loseGang].power)/Math.log(50));
|
|
||||||
const gains = Math.min(AllGangs[loseGang].territory, powerBonus*0.0001*(Math.random()+.5))
|
|
||||||
return gains;
|
|
||||||
}
|
|
||||||
|
|
||||||
Gang.prototype.processTerritoryAndPowerGains = function(numCycles=1) {
|
Gang.prototype.processTerritoryAndPowerGains = function(numCycles=1) {
|
||||||
this.storedTerritoryAndPowerCycles += numCycles;
|
this.storedTerritoryAndPowerCycles += numCycles;
|
||||||
if (this.storedTerritoryAndPowerCycles < GangConstants.CyclesPerTerritoryAndPowerUpdate) { return; }
|
if (this.storedTerritoryAndPowerCycles < GangConstants.CyclesPerTerritoryAndPowerUpdate) { return; }
|
||||||
@ -233,13 +194,13 @@ Gang.prototype.processTerritoryAndPowerGains = function(numCycles=1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Then process territory
|
// Then process territory
|
||||||
for (let i = 0; i < GangNames.length; ++i) {
|
for (let i = 0; i < GangConstants.Names.length; ++i) {
|
||||||
const others = GangNames.filter((e) => {
|
const others = GangConstants.Names.filter((e) => {
|
||||||
return e !== GangNames[i];
|
return e !== GangConstants.Names[i];
|
||||||
});
|
});
|
||||||
const other = getRandomInt(0, others.length - 1);
|
const other = getRandomInt(0, others.length - 1);
|
||||||
|
|
||||||
const thisGang = GangNames[i];
|
const thisGang = GangConstants.Names[i];
|
||||||
const otherGang = others[other];
|
const otherGang = others[other];
|
||||||
|
|
||||||
// If either of the gangs involved in this clash is the player, determine
|
// If either of the gangs involved in this clash is the player, determine
|
||||||
@ -496,297 +457,11 @@ Gang.fromJSON = function(value) {
|
|||||||
|
|
||||||
Reviver.constructors.Gang = Gang;
|
Reviver.constructors.Gang = Gang;
|
||||||
|
|
||||||
function GangMember(name) {
|
function calculateTerritoryGain(winGang, loseGang) {
|
||||||
this.name = name;
|
const powerBonus = Math.max(1, 1+Math.log(AllGangs[winGang].power/AllGangs[loseGang].power)/Math.log(50));
|
||||||
this.task = "Unassigned";
|
const gains = Math.min(AllGangs[loseGang].territory, powerBonus*0.0001*(Math.random()+.5))
|
||||||
|
return gains;
|
||||||
this.earnedRespect = 0;
|
|
||||||
|
|
||||||
this.hack = 1;
|
|
||||||
this.str = 1;
|
|
||||||
this.def = 1;
|
|
||||||
this.dex = 1;
|
|
||||||
this.agi = 1;
|
|
||||||
this.cha = 1;
|
|
||||||
|
|
||||||
this.hack_exp = 0;
|
|
||||||
this.str_exp = 0;
|
|
||||||
this.def_exp = 0;
|
|
||||||
this.dex_exp = 0;
|
|
||||||
this.agi_exp = 0;
|
|
||||||
this.cha_exp = 0;
|
|
||||||
|
|
||||||
this.hack_mult = 1;
|
|
||||||
this.str_mult = 1;
|
|
||||||
this.def_mult = 1;
|
|
||||||
this.dex_mult = 1;
|
|
||||||
this.agi_mult = 1;
|
|
||||||
this.cha_mult = 1;
|
|
||||||
|
|
||||||
this.hack_asc_mult = 1;
|
|
||||||
this.str_asc_mult = 1;
|
|
||||||
this.def_asc_mult = 1;
|
|
||||||
this.dex_asc_mult = 1;
|
|
||||||
this.agi_asc_mult = 1;
|
|
||||||
this.cha_asc_mult = 1;
|
|
||||||
|
|
||||||
this.upgrades = []; // Names of upgrades
|
|
||||||
this.augmentations = []; // Names of augmentations only
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same skill calculation formula as Player
|
|
||||||
GangMember.prototype.calculateSkill = function(exp, mult=1) {
|
|
||||||
return Math.max(Math.floor(mult * (32 * Math.log(exp + 534.5) - 200)), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
GangMember.prototype.updateSkillLevels = function() {
|
|
||||||
this.hack = this.calculateSkill(this.hack_exp, this.hack_mult * this.hack_asc_mult);
|
|
||||||
this.str = this.calculateSkill(this.str_exp, this.str_mult * this.str_asc_mult);
|
|
||||||
this.def = this.calculateSkill(this.def_exp, this.def_mult * this.def_asc_mult);
|
|
||||||
this.dex = this.calculateSkill(this.dex_exp, this.dex_mult * this.dex_asc_mult);
|
|
||||||
this.agi = this.calculateSkill(this.agi_exp, this.agi_mult * this.agi_asc_mult);
|
|
||||||
this.cha = this.calculateSkill(this.cha_exp, this.cha_mult * this.cha_asc_mult);
|
|
||||||
}
|
|
||||||
|
|
||||||
GangMember.prototype.calculatePower = function() {
|
|
||||||
return (this.hack + this.str + this.def + this.dex + this.agi + this.cha) / 95;
|
|
||||||
}
|
|
||||||
|
|
||||||
GangMember.prototype.assignToTask = function(taskName) {
|
|
||||||
if (GangMemberTasks.hasOwnProperty(taskName)) {
|
|
||||||
this.task = taskName;
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
this.task = "Unassigned";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GangMember.prototype.unassignFromTask = function() {
|
|
||||||
this.task = "Unassigned";
|
|
||||||
}
|
|
||||||
|
|
||||||
GangMember.prototype.getTask = function() {
|
|
||||||
// Backwards compatibility
|
|
||||||
if (this.task instanceof GangMemberTask) {
|
|
||||||
this.task = this.task.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GangMemberTasks.hasOwnProperty(this.task)) {
|
|
||||||
return GangMemberTasks[this.task];
|
|
||||||
}
|
|
||||||
return GangMemberTasks["Unassigned"];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Gains are per cycle
|
|
||||||
GangMember.prototype.calculateRespectGain = function(gang) {
|
|
||||||
const task = this.getTask();
|
|
||||||
if (task == null || !(task instanceof GangMemberTask) || task.baseRespect === 0) {return 0;}
|
|
||||||
var statWeight = (task.hackWeight/100) * this.hack +
|
|
||||||
(task.strWeight/100) * this.str +
|
|
||||||
(task.defWeight/100) * this.def +
|
|
||||||
(task.dexWeight/100) * this.dex +
|
|
||||||
(task.agiWeight/100) * this.agi +
|
|
||||||
(task.chaWeight/100) * this.cha;
|
|
||||||
statWeight -= (4 * task.difficulty);
|
|
||||||
if (statWeight <= 0) { return 0; }
|
|
||||||
const territoryMult = Math.pow(AllGangs[gang.facName].territory * 100, task.territory.respect) / 100;
|
|
||||||
if (isNaN(territoryMult) || territoryMult <= 0) { return 0; }
|
|
||||||
var respectMult = gang.getWantedPenalty();
|
|
||||||
return 11 * task.baseRespect * statWeight * territoryMult * respectMult;
|
|
||||||
}
|
|
||||||
|
|
||||||
GangMember.prototype.calculateWantedLevelGain = function(gang) {
|
|
||||||
const task = this.getTask();
|
|
||||||
if (task == null || !(task instanceof GangMemberTask) || task.baseWanted === 0) { return 0; }
|
|
||||||
let statWeight = (task.hackWeight / 100) * this.hack +
|
|
||||||
(task.strWeight / 100) * this.str +
|
|
||||||
(task.defWeight / 100) * this.def +
|
|
||||||
(task.dexWeight / 100) * this.dex +
|
|
||||||
(task.agiWeight / 100) * this.agi +
|
|
||||||
(task.chaWeight / 100) * this.cha;
|
|
||||||
statWeight -= (3.5 * task.difficulty);
|
|
||||||
if (statWeight <= 0) { return 0; }
|
|
||||||
const territoryMult = Math.pow(AllGangs[gang.facName].territory * 100, task.territory.wanted) / 100;
|
|
||||||
if (isNaN(territoryMult) || territoryMult <= 0) { return 0; }
|
|
||||||
if (task.baseWanted < 0) {
|
|
||||||
return 0.4 * task.baseWanted * statWeight * territoryMult;
|
|
||||||
} else {
|
|
||||||
const calc = 7 * task.baseWanted / (Math.pow(3 * statWeight * territoryMult, 0.8));
|
|
||||||
|
|
||||||
// Put an arbitrary cap on this to prevent wanted level from rising too fast if the
|
|
||||||
// denominator is very small. Might want to rethink formula later
|
|
||||||
return Math.min(100, calc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GangMember.prototype.calculateMoneyGain = function(gang) {
|
|
||||||
const task = this.getTask();
|
|
||||||
if (task == null || !(task instanceof GangMemberTask) || task.baseMoney === 0) {return 0;}
|
|
||||||
var statWeight = (task.hackWeight/100) * this.hack +
|
|
||||||
(task.strWeight/100) * this.str +
|
|
||||||
(task.defWeight/100) * this.def +
|
|
||||||
(task.dexWeight/100) * this.dex +
|
|
||||||
(task.agiWeight/100) * this.agi +
|
|
||||||
(task.chaWeight/100) * this.cha;
|
|
||||||
statWeight -= (3.2 * task.difficulty);
|
|
||||||
if (statWeight <= 0) { return 0; }
|
|
||||||
const territoryMult = Math.pow(AllGangs[gang.facName].territory * 100, task.territory.money) / 100;
|
|
||||||
if (isNaN(territoryMult) || territoryMult <= 0) { return 0; }
|
|
||||||
var respectMult = gang.getWantedPenalty();
|
|
||||||
return 5 * task.baseMoney * statWeight * territoryMult * respectMult;
|
|
||||||
}
|
|
||||||
|
|
||||||
GangMember.prototype.gainExperience = function(numCycles=1) {
|
|
||||||
const task = this.getTask();
|
|
||||||
if (task == null || !(task instanceof GangMemberTask) || 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
GangMember.prototype.recordEarnedRespect = function(numCycles=1, gang) {
|
|
||||||
this.earnedRespect += (this.calculateRespectGain(gang) * numCycles);
|
|
||||||
}
|
|
||||||
|
|
||||||
GangMember.prototype.ascend = function() {
|
|
||||||
const res = this.getAscensionResults();
|
|
||||||
const hackAscMult = res.hack;
|
|
||||||
const strAscMult = res.str;
|
|
||||||
const defAscMult = res.def;
|
|
||||||
const dexAscMult = res.dex;
|
|
||||||
const agiAscMult = res.agi;
|
|
||||||
const chaAscMult = res.cha;
|
|
||||||
this.hack_asc_mult += hackAscMult;
|
|
||||||
this.str_asc_mult += strAscMult;
|
|
||||||
this.def_asc_mult += defAscMult;
|
|
||||||
this.dex_asc_mult += dexAscMult;
|
|
||||||
this.agi_asc_mult += agiAscMult;
|
|
||||||
this.cha_asc_mult += chaAscMult;
|
|
||||||
|
|
||||||
// Remove upgrades. Then re-calculate multipliers and stats
|
|
||||||
this.upgrades.length = 0;
|
|
||||||
this.hack_mult = 1;
|
|
||||||
this.str_mult = 1;
|
|
||||||
this.def_mult = 1;
|
|
||||||
this.dex_mult = 1;
|
|
||||||
this.agi_mult = 1;
|
|
||||||
this.cha_mult = 1;
|
|
||||||
for (let i = 0; i < this.augmentations.length; ++i) {
|
|
||||||
let aug = GangMemberUpgrades[this.augmentations[i]];
|
|
||||||
aug.apply(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear exp and recalculate stats
|
|
||||||
this.hack_exp = 0;
|
|
||||||
this.str_exp = 0;
|
|
||||||
this.def_exp = 0;
|
|
||||||
this.dex_exp = 0;
|
|
||||||
this.agi_exp = 0;
|
|
||||||
this.cha_exp = 0;
|
|
||||||
this.updateSkillLevels();
|
|
||||||
|
|
||||||
const respectToDeduct = this.earnedRespect;
|
|
||||||
this.earnedRespect = 0;
|
|
||||||
return {
|
|
||||||
respect: respectToDeduct,
|
|
||||||
hack: hackAscMult,
|
|
||||||
str: strAscMult,
|
|
||||||
def: defAscMult,
|
|
||||||
dex: dexAscMult,
|
|
||||||
agi: agiAscMult,
|
|
||||||
cha: chaAscMult,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
GangMember.prototype.getAscensionEfficiency = function() {
|
|
||||||
function formula(mult) {
|
|
||||||
return 1/(1+Math.log(mult)/Math.log(20));
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
hack: formula(this.hack_asc_mult),
|
|
||||||
str: formula(this.str_asc_mult),
|
|
||||||
def: formula(this.def_asc_mult),
|
|
||||||
dex: formula(this.dex_asc_mult),
|
|
||||||
agi: formula(this.agi_asc_mult),
|
|
||||||
cha: formula(this.cha_asc_mult),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns the multipliers that would be gained from ascension
|
|
||||||
GangMember.prototype.getAscensionResults = function() {
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
let hack = 1;
|
|
||||||
let str = 1;
|
|
||||||
let def = 1;
|
|
||||||
let dex = 1;
|
|
||||||
let agi = 1;
|
|
||||||
let cha = 1;
|
|
||||||
for (let i = 0; i < this.upgrades.length; ++i) {
|
|
||||||
let upg = GangMemberUpgrades[this.upgrades[i]];
|
|
||||||
if (upg.mults.hack != null) { hack *= upg.mults.hack; }
|
|
||||||
if (upg.mults.str != null) { str *= upg.mults.str; }
|
|
||||||
if (upg.mults.def != null) { def *= upg.mults.def; }
|
|
||||||
if (upg.mults.dex != null) { dex *= upg.mults.dex; }
|
|
||||||
if (upg.mults.agi != null) { agi *= upg.mults.agi; }
|
|
||||||
if (upg.mults.cha != null) { cha *= upg.mults.cha; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// Subtract 1 because we're only interested in the actual "bonus" part
|
|
||||||
const eff = this.getAscensionEfficiency();
|
|
||||||
return {
|
|
||||||
hack: (Math.max(0, hack - 1) * GangConstants.AscensionMultiplierRatio * eff.hack),
|
|
||||||
str: (Math.max(0, str - 1) * GangConstants.AscensionMultiplierRatio * eff.str),
|
|
||||||
def: (Math.max(0, def - 1) * GangConstants.AscensionMultiplierRatio * eff.def),
|
|
||||||
dex: (Math.max(0, dex - 1) * GangConstants.AscensionMultiplierRatio * eff.dex),
|
|
||||||
agi: (Math.max(0, agi - 1) * GangConstants.AscensionMultiplierRatio * eff.agi),
|
|
||||||
cha: (Math.max(0, cha - 1) * GangConstants.AscensionMultiplierRatio * eff.cha),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GangMember.prototype.buyUpgrade = function(upg, player, gang) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player.money.lt(upg.getCost(gang))) { return false; }
|
|
||||||
player.loseMoney(upg.getCost(gang));
|
|
||||||
if (upg.type === "g") {
|
|
||||||
this.augmentations.push(upg.name);
|
|
||||||
} else {
|
|
||||||
this.upgrades.push(upg.name);
|
|
||||||
}
|
|
||||||
upg.apply(this);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
GangMember.prototype.toJSON = function() {
|
|
||||||
return Generic_toJSON("GangMember", this);
|
|
||||||
}
|
|
||||||
|
|
||||||
GangMember.fromJSON = function(value) {
|
|
||||||
return Generic_fromJSON(GangMember, value.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
Reviver.constructors.GangMember = GangMember;
|
|
||||||
|
|
||||||
// Gang UI Dom Elements
|
// Gang UI Dom Elements
|
||||||
const UIElems = {
|
const UIElems = {
|
||||||
gangContentCreated: false,
|
gangContentCreated: false,
|
||||||
|
@ -38,7 +38,7 @@ export let AllGangs: {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
export function resetGangs() {
|
export function resetGangs(): void {
|
||||||
AllGangs = {
|
AllGangs = {
|
||||||
"Slum Snakes" : {
|
"Slum Snakes" : {
|
||||||
power: 1,
|
power: 1,
|
||||||
@ -71,6 +71,6 @@ export function resetGangs() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function loadAllGangs(saveString: string) {
|
export function loadAllGangs(saveString: string): void {
|
||||||
AllGangs = JSON.parse(saveString, Reviver);
|
AllGangs = JSON.parse(saveString, Reviver);
|
||||||
}
|
}
|
@ -1,294 +1,291 @@
|
|||||||
import { Page, routing } from "../ui/navigationTracking";
|
import { GangMemberTask } from "./GangMemberTask";
|
||||||
|
import { GangMemberTasks } from "./GangMemberTasks";
|
||||||
|
import { GangMemberUpgrade } from "./GangMemberUpgrade";
|
||||||
|
import { GangMemberUpgrades } from "./GangMemberUpgrades";
|
||||||
|
import { IPlayer } from "../PersonObjects/IPlayer";
|
||||||
|
import { GangConstants } from "./data/Constants";
|
||||||
|
import { AllGangs } from "./AllGangs";
|
||||||
import { Generic_fromJSON, Generic_toJSON, Reviver } from "../../utils/JSONReviver";
|
import { Generic_fromJSON, Generic_toJSON, Reviver } from "../../utils/JSONReviver";
|
||||||
|
|
||||||
export class GangMember {
|
export class GangMember {
|
||||||
name: string;
|
name: string;
|
||||||
task: string = "Unassigned";
|
task = "Unassigned";
|
||||||
|
|
||||||
earnedRespect: number = 0;
|
earnedRespect = 0;
|
||||||
|
|
||||||
hack: number = 1;
|
hack = 1;
|
||||||
str: number = 1;
|
str = 1;
|
||||||
def: number = 1;
|
def = 1;
|
||||||
dex: number = 1;
|
dex = 1;
|
||||||
agi: number = 1;
|
agi = 1;
|
||||||
cha: number = 1;
|
cha = 1;
|
||||||
|
|
||||||
hack_exp: number = 0;
|
hack_exp = 0;
|
||||||
str_exp: number = 0;
|
str_exp = 0;
|
||||||
def_exp: number = 0;
|
def_exp = 0;
|
||||||
dex_exp: number = 0;
|
dex_exp = 0;
|
||||||
agi_exp: number = 0;
|
agi_exp = 0;
|
||||||
cha_exp: number = 0;
|
cha_exp = 0;
|
||||||
|
|
||||||
hack_mult: number = 1;
|
hack_mult = 1;
|
||||||
str_mult: number = 1;
|
str_mult = 1;
|
||||||
def_mult: number = 1;
|
def_mult = 1;
|
||||||
dex_mult: number = 1;
|
dex_mult = 1;
|
||||||
agi_mult: number = 1;
|
agi_mult = 1;
|
||||||
cha_mult: number = 1;
|
cha_mult = 1;
|
||||||
|
|
||||||
hack_asc_mult: number = 1;
|
hack_asc_mult = 1;
|
||||||
str_asc_mult: number = 1;
|
str_asc_mult = 1;
|
||||||
def_asc_mult: number = 1;
|
def_asc_mult = 1;
|
||||||
dex_asc_mult: number = 1;
|
dex_asc_mult = 1;
|
||||||
agi_asc_mult: number = 1;
|
agi_asc_mult = 1;
|
||||||
cha_asc_mult: number = 1;
|
cha_asc_mult = 1;
|
||||||
|
|
||||||
upgrades: string[] = []; // Names of upgrades
|
upgrades: string[] = []; // Names of upgrades
|
||||||
augmentations: string[] = []; // Names of augmentations only
|
augmentations: string[] = []; // Names of augmentations only
|
||||||
|
|
||||||
constructor(name: string = "") {
|
constructor(name = "") {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
calculateSkill(exp: number, mult: number = 1): number {
|
||||||
|
return Math.max(Math.floor(mult * (32 * Math.log(exp + 534.5) - 200)), 1);
|
||||||
|
}
|
||||||
|
|
||||||
// // Same skill calculation formula as Player
|
updateSkillLevels(): void {
|
||||||
// calculateSkill(exp: number, mult: number = 1): number {
|
this.hack = this.calculateSkill(this.hack_exp, this.hack_mult * this.hack_asc_mult);
|
||||||
// return Math.max(Math.floor(mult * (32 * Math.log(exp + 534.5) - 200)), 1);
|
this.str = this.calculateSkill(this.str_exp, this.str_mult * this.str_asc_mult);
|
||||||
// }
|
this.def = this.calculateSkill(this.def_exp, this.def_mult * this.def_asc_mult);
|
||||||
|
this.dex = this.calculateSkill(this.dex_exp, this.dex_mult * this.dex_asc_mult);
|
||||||
|
this.agi = this.calculateSkill(this.agi_exp, this.agi_mult * this.agi_asc_mult);
|
||||||
|
this.cha = this.calculateSkill(this.cha_exp, this.cha_mult * this.cha_asc_mult);
|
||||||
|
}
|
||||||
|
|
||||||
// updateSkillLevels(): void {
|
calculatePower(): number {
|
||||||
// this.hack = this.calculateSkill(this.hack_exp, this.hack_mult * this.hack_asc_mult);
|
return (this.hack + this.str + this.def + this.dex + this.agi + this.cha) / 95;
|
||||||
// this.str = this.calculateSkill(this.str_exp, this.str_mult * this.str_asc_mult);
|
}
|
||||||
// this.def = this.calculateSkill(this.def_exp, this.def_mult * this.def_asc_mult);
|
|
||||||
// this.dex = this.calculateSkill(this.dex_exp, this.dex_mult * this.dex_asc_mult);
|
|
||||||
// this.agi = this.calculateSkill(this.agi_exp, this.agi_mult * this.agi_asc_mult);
|
|
||||||
// this.cha = this.calculateSkill(this.cha_exp, this.cha_mult * this.cha_asc_mult);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// calculatePower(): number {
|
assignToTask(taskName: string): boolean {
|
||||||
// return (this.hack + this.str + this.def + this.dex + this.agi + this.cha) / 95;
|
if (GangMemberTasks.hasOwnProperty(taskName)) {
|
||||||
// }
|
this.task = taskName;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
this.task = "Unassigned";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// assignToTask(taskName: string): boolean {
|
unassignFromTask(): void {
|
||||||
// if (GangMemberTasks.hasOwnProperty(taskName)) {
|
this.task = "Unassigned";
|
||||||
// this.task = taskName;
|
}
|
||||||
// return true;
|
|
||||||
// } else {
|
|
||||||
// this.task = "Unassigned";
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// unassignFromTask(): string {
|
getTask(): GangMemberTask {
|
||||||
// this.task = "Unassigned";
|
// TODO(hydroflame): transfer that to a save file migration function
|
||||||
// }
|
// Backwards compatibility
|
||||||
|
if ((this.task as any) instanceof GangMemberTask) {
|
||||||
|
this.task = (this.task as any).name;
|
||||||
|
}
|
||||||
|
|
||||||
// getTask(): string {
|
if (GangMemberTasks.hasOwnProperty(this.task)) {
|
||||||
// // Backwards compatibility
|
return GangMemberTasks[this.task];
|
||||||
// if (this.task instanceof GangMemberTask) {
|
}
|
||||||
// this.task = this.task.name;
|
return GangMemberTasks["Unassigned"];
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if (GangMemberTasks.hasOwnProperty(this.task)) {
|
calculateRespectGain(gang: any): number {
|
||||||
// return GangMemberTasks[this.task];
|
const task = this.getTask();
|
||||||
// }
|
if (task.baseRespect === 0) return 0;
|
||||||
// return GangMemberTasks["Unassigned"];
|
var statWeight = (task.hackWeight/100) * this.hack +
|
||||||
// }
|
(task.strWeight/100) * this.str +
|
||||||
|
(task.defWeight/100) * this.def +
|
||||||
|
(task.dexWeight/100) * this.dex +
|
||||||
|
(task.agiWeight/100) * this.agi +
|
||||||
|
(task.chaWeight/100) * this.cha;
|
||||||
|
statWeight -= (4 * task.difficulty);
|
||||||
|
if (statWeight <= 0) return 0;
|
||||||
|
const territoryMult = Math.pow(AllGangs[gang.facName].territory * 100, task.territory.respect) / 100;
|
||||||
|
if (isNaN(territoryMult) || territoryMult <= 0) return 0;
|
||||||
|
const respectMult = gang.getWantedPenalty();
|
||||||
|
return 11 * task.baseRespect * statWeight * territoryMult * respectMult;
|
||||||
|
}
|
||||||
|
|
||||||
// // Gains are per cycle
|
calculateWantedLevelGain(gang: any): number {
|
||||||
// calculateRespectGain(gang: any): number {
|
const task = this.getTask();
|
||||||
// const task = this.getTask();
|
if (task.baseWanted === 0) return 0;
|
||||||
// if (task == null || !(task instanceof GangMemberTask) || task.baseRespect === 0) {return 0;}
|
let statWeight = (task.hackWeight / 100) * this.hack +
|
||||||
// let statWeight = (task.hackWeight/100) * this.hack +
|
(task.strWeight / 100) * this.str +
|
||||||
// (task.strWeight/100) * this.str +
|
(task.defWeight / 100) * this.def +
|
||||||
// (task.defWeight/100) * this.def +
|
(task.dexWeight / 100) * this.dex +
|
||||||
// (task.dexWeight/100) * this.dex +
|
(task.agiWeight / 100) * this.agi +
|
||||||
// (task.agiWeight/100) * this.agi +
|
(task.chaWeight / 100) * this.cha;
|
||||||
// (task.chaWeight/100) * this.cha;
|
statWeight -= (3.5 * task.difficulty);
|
||||||
// statWeight -= (4 * task.difficulty);
|
if (statWeight <= 0) return 0;
|
||||||
// if (statWeight <= 0) { return 0; }
|
const territoryMult = Math.pow(AllGangs[gang.facName].territory * 100, task.territory.wanted) / 100;
|
||||||
// const territoryMult = Math.pow(AllGangs[gang.facName].territory * 100, task.territory.respect) / 100;
|
if (isNaN(territoryMult) || territoryMult <= 0) return 0;
|
||||||
// if (isNaN(territoryMult) || territoryMult <= 0) { return 0; }
|
if (task.baseWanted < 0) {
|
||||||
// const respectMult = gang.getWantedPenalty();
|
return 0.4 * task.baseWanted * statWeight * territoryMult;
|
||||||
// return 11 * task.baseRespect * statWeight * territoryMult * respectMult;
|
} else {
|
||||||
// }
|
const calc = 7 * task.baseWanted / (Math.pow(3 * statWeight * territoryMult, 0.8));
|
||||||
|
|
||||||
// calculateWantedLevelGain(gang: any): number {
|
// Put an arbitrary cap on this to prevent wanted level from rising too fast if the
|
||||||
// const task = this.getTask();
|
// denominator is very small. Might want to rethink formula later
|
||||||
// if (task == null || !(task instanceof GangMemberTask) || task.baseWanted === 0) { return 0; }
|
return Math.min(100, calc);
|
||||||
// let statWeight = (task.hackWeight / 100) * this.hack +
|
}
|
||||||
// (task.strWeight / 100) * this.str +
|
}
|
||||||
// (task.defWeight / 100) * this.def +
|
|
||||||
// (task.dexWeight / 100) * this.dex +
|
|
||||||
// (task.agiWeight / 100) * this.agi +
|
|
||||||
// (task.chaWeight / 100) * this.cha;
|
|
||||||
// statWeight -= (3.5 * task.difficulty);
|
|
||||||
// if (statWeight <= 0) { return 0; }
|
|
||||||
// const territoryMult = Math.pow(AllGangs[gang.facName].territory * 100, task.territory.wanted) / 100;
|
|
||||||
// if (isNaN(territoryMult) || territoryMult <= 0) { return 0; }
|
|
||||||
// if (task.baseWanted < 0) {
|
|
||||||
// return 0.4 * task.baseWanted * statWeight * territoryMult;
|
|
||||||
// } else {
|
|
||||||
// const calc = 7 * task.baseWanted / (Math.pow(3 * statWeight * territoryMult, 0.8));
|
|
||||||
|
|
||||||
// // Put an arbitrary cap on this to prevent wanted level from rising too fast if the
|
calculateMoneyGain(gang: any): number {
|
||||||
// // denominator is very small. Might want to rethink formula later
|
const task = this.getTask();
|
||||||
// return Math.min(100, calc);
|
if (task.baseMoney === 0) return 0;
|
||||||
// }
|
let statWeight = (task.hackWeight/100) * this.hack +
|
||||||
// }
|
(task.strWeight/100) * this.str +
|
||||||
|
(task.defWeight/100) * this.def +
|
||||||
|
(task.dexWeight/100) * this.dex +
|
||||||
|
(task.agiWeight/100) * this.agi +
|
||||||
|
(task.chaWeight/100) * this.cha;
|
||||||
|
statWeight -= (3.2 * task.difficulty);
|
||||||
|
if (statWeight <= 0) return 0;
|
||||||
|
const territoryMult = Math.pow(AllGangs[gang.facName].territory * 100, task.territory.money) / 100;
|
||||||
|
if (isNaN(territoryMult) || territoryMult <= 0) return 0;
|
||||||
|
const respectMult = gang.getWantedPenalty();
|
||||||
|
return 5 * task.baseMoney * statWeight * territoryMult * respectMult;
|
||||||
|
}
|
||||||
|
|
||||||
// calculateMoneyGain(gang: any): number {
|
gainExperience(numCycles: number = 1): void {
|
||||||
// const task = this.getTask();
|
const task = this.getTask();
|
||||||
// if (task == null || !(task instanceof GangMemberTask) || task.baseMoney === 0) {return 0;}
|
if (task === GangMemberTasks["Unassigned"]) return;
|
||||||
// let statWeight = (task.hackWeight/100) * this.hack +
|
const difficultyMult = Math.pow(task.difficulty, 0.9);
|
||||||
// (task.strWeight/100) * this.str +
|
const difficultyPerCycles = difficultyMult * numCycles;
|
||||||
// (task.defWeight/100) * this.def +
|
const weightDivisor = 1500;
|
||||||
// (task.dexWeight/100) * this.dex +
|
this.hack_exp += (task.hackWeight / weightDivisor) * difficultyPerCycles;
|
||||||
// (task.agiWeight/100) * this.agi +
|
this.str_exp += (task.strWeight / weightDivisor) * difficultyPerCycles;
|
||||||
// (task.chaWeight/100) * this.cha;
|
this.def_exp += (task.defWeight / weightDivisor) * difficultyPerCycles;
|
||||||
// statWeight -= (3.2 * task.difficulty);
|
this.dex_exp += (task.dexWeight / weightDivisor) * difficultyPerCycles;
|
||||||
// if (statWeight <= 0) { return 0; }
|
this.agi_exp += (task.agiWeight / weightDivisor) * difficultyPerCycles;
|
||||||
// const territoryMult = Math.pow(AllGangs[gang.facName].territory * 100, task.territory.money) / 100;
|
this.cha_exp += (task.chaWeight / weightDivisor) * difficultyPerCycles;
|
||||||
// if (isNaN(territoryMult) || territoryMult <= 0) { return 0; }
|
}
|
||||||
// const respectMult = gang.getWantedPenalty();
|
|
||||||
// return 5 * task.baseMoney * statWeight * territoryMult * respectMult;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// gainExperience(numCycles: number = 1): void {
|
recordEarnedRespect(numCycles: number = 1, gang: any): void {
|
||||||
// const task = this.getTask();
|
this.earnedRespect += (this.calculateRespectGain(gang) * numCycles);
|
||||||
// if (task == null || !(task instanceof GangMemberTask) || 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;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// recordEarnedRespect(numCycles: number = 1, gang: any): void {
|
getAscensionResults(): any {
|
||||||
// this.earnedRespect += (this.calculateRespectGain(gang) * numCycles);
|
//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
|
||||||
|
let hack = 1;
|
||||||
|
let str = 1;
|
||||||
|
let def = 1;
|
||||||
|
let dex = 1;
|
||||||
|
let agi = 1;
|
||||||
|
let cha = 1;
|
||||||
|
for (let i = 0; i < this.upgrades.length; ++i) {
|
||||||
|
let upg = GangMemberUpgrades[this.upgrades[i]];
|
||||||
|
if (upg.mults.hack != null) { hack *= upg.mults.hack; }
|
||||||
|
if (upg.mults.str != null) { str *= upg.mults.str; }
|
||||||
|
if (upg.mults.def != null) { def *= upg.mults.def; }
|
||||||
|
if (upg.mults.dex != null) { dex *= upg.mults.dex; }
|
||||||
|
if (upg.mults.agi != null) { agi *= upg.mults.agi; }
|
||||||
|
if (upg.mults.cha != null) { cha *= upg.mults.cha; }
|
||||||
|
}
|
||||||
|
|
||||||
// ascend(): any {
|
// Subtract 1 because we're only interested in the actual "bonus" part
|
||||||
// const res = this.getAscensionResults();
|
const eff = this.getAscensionEfficiency();
|
||||||
// const hackAscMult = res.hack;
|
return {
|
||||||
// const strAscMult = res.str;
|
hack: (Math.max(0, hack - 1) * GangConstants.AscensionMultiplierRatio * eff.hack),
|
||||||
// const defAscMult = res.def;
|
str: (Math.max(0, str - 1) * GangConstants.AscensionMultiplierRatio * eff.str),
|
||||||
// const dexAscMult = res.dex;
|
def: (Math.max(0, def - 1) * GangConstants.AscensionMultiplierRatio * eff.def),
|
||||||
// const agiAscMult = res.agi;
|
dex: (Math.max(0, dex - 1) * GangConstants.AscensionMultiplierRatio * eff.dex),
|
||||||
// const chaAscMult = res.cha;
|
agi: (Math.max(0, agi - 1) * GangConstants.AscensionMultiplierRatio * eff.agi),
|
||||||
// this.hack_asc_mult += hackAscMult;
|
cha: (Math.max(0, cha - 1) * GangConstants.AscensionMultiplierRatio * eff.cha),
|
||||||
// this.str_asc_mult += strAscMult;
|
}
|
||||||
// this.def_asc_mult += defAscMult;
|
}
|
||||||
// this.dex_asc_mult += dexAscMult;
|
|
||||||
// this.agi_asc_mult += agiAscMult;
|
|
||||||
// this.cha_asc_mult += chaAscMult;
|
|
||||||
|
|
||||||
// // Remove upgrades. Then re-calculate multipliers and stats
|
getAscensionEfficiency(): any {
|
||||||
// this.upgrades.length = 0;
|
function formula(mult: number): number {
|
||||||
// this.hack_mult = 1;
|
return 1/(1+Math.log(mult)/Math.log(20));
|
||||||
// this.str_mult = 1;
|
}
|
||||||
// this.def_mult = 1;
|
return {
|
||||||
// this.dex_mult = 1;
|
hack: formula(this.hack_asc_mult),
|
||||||
// this.agi_mult = 1;
|
str: formula(this.str_asc_mult),
|
||||||
// this.cha_mult = 1;
|
def: formula(this.def_asc_mult),
|
||||||
// for (let i = 0; i < this.augmentations.length; ++i) {
|
dex: formula(this.dex_asc_mult),
|
||||||
// let aug = GangMemberUpgrades[this.augmentations[i]];
|
agi: formula(this.agi_asc_mult),
|
||||||
// aug.apply(this);
|
cha: formula(this.cha_asc_mult),
|
||||||
// }
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// // Clear exp and recalculate stats
|
ascend(): any {
|
||||||
// this.hack_exp = 0;
|
const res = this.getAscensionResults();
|
||||||
// this.str_exp = 0;
|
const hackAscMult = res.hack;
|
||||||
// this.def_exp = 0;
|
const strAscMult = res.str;
|
||||||
// this.dex_exp = 0;
|
const defAscMult = res.def;
|
||||||
// this.agi_exp = 0;
|
const dexAscMult = res.dex;
|
||||||
// this.cha_exp = 0;
|
const agiAscMult = res.agi;
|
||||||
// this.updateSkillLevels();
|
const chaAscMult = res.cha;
|
||||||
|
this.hack_asc_mult += hackAscMult;
|
||||||
|
this.str_asc_mult += strAscMult;
|
||||||
|
this.def_asc_mult += defAscMult;
|
||||||
|
this.dex_asc_mult += dexAscMult;
|
||||||
|
this.agi_asc_mult += agiAscMult;
|
||||||
|
this.cha_asc_mult += chaAscMult;
|
||||||
|
|
||||||
// const respectToDeduct = this.earnedRespect;
|
// Remove upgrades. Then re-calculate multipliers and stats
|
||||||
// this.earnedRespect = 0;
|
this.upgrades.length = 0;
|
||||||
// return {
|
this.hack_mult = 1;
|
||||||
// respect: respectToDeduct,
|
this.str_mult = 1;
|
||||||
// hack: hackAscMult,
|
this.def_mult = 1;
|
||||||
// str: strAscMult,
|
this.dex_mult = 1;
|
||||||
// def: defAscMult,
|
this.agi_mult = 1;
|
||||||
// dex: dexAscMult,
|
this.cha_mult = 1;
|
||||||
// agi: agiAscMult,
|
for (let i = 0; i < this.augmentations.length; ++i) {
|
||||||
// cha: chaAscMult,
|
let aug = GangMemberUpgrades[this.augmentations[i]];
|
||||||
// };
|
aug.apply(this);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// getAscensionEfficiency(): any {
|
// Clear exp and recalculate stats
|
||||||
// function formula(mult) {
|
this.hack_exp = 0;
|
||||||
// return 1/(1+Math.log(mult)/Math.log(20));
|
this.str_exp = 0;
|
||||||
// }
|
this.def_exp = 0;
|
||||||
// return {
|
this.dex_exp = 0;
|
||||||
// hack: formula(this.hack_asc_mult),
|
this.agi_exp = 0;
|
||||||
// str: formula(this.str_asc_mult),
|
this.cha_exp = 0;
|
||||||
// def: formula(this.def_asc_mult),
|
this.updateSkillLevels();
|
||||||
// dex: formula(this.dex_asc_mult),
|
|
||||||
// agi: formula(this.agi_asc_mult),
|
|
||||||
// cha: formula(this.cha_asc_mult),
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Returns the multipliers that would be gained from ascension
|
const respectToDeduct = this.earnedRespect;
|
||||||
// getAscensionResults(): any {
|
this.earnedRespect = 0;
|
||||||
// /**
|
return {
|
||||||
// * Calculate ascension bonus to stat multipliers.
|
respect: respectToDeduct,
|
||||||
// * This is based on the current number of multipliers from Non-Augmentation upgrades
|
hack: hackAscMult,
|
||||||
// * + Ascension Bonus = N% of current bonus from Augmentations
|
str: strAscMult,
|
||||||
// */
|
def: defAscMult,
|
||||||
// let hack = 1;
|
dex: dexAscMult,
|
||||||
// let str = 1;
|
agi: agiAscMult,
|
||||||
// let def = 1;
|
cha: chaAscMult,
|
||||||
// let dex = 1;
|
};
|
||||||
// let agi = 1;
|
}
|
||||||
// let cha = 1;
|
|
||||||
// for (let i = 0; i < this.upgrades.length; ++i) {
|
|
||||||
// const upg = GangMemberUpgrades[this.upgrades[i]];
|
|
||||||
// if (upg.mults.hack != null) { hack *= upg.mults.hack; }
|
|
||||||
// if (upg.mults.str != null) { str *= upg.mults.str; }
|
|
||||||
// if (upg.mults.def != null) { def *= upg.mults.def; }
|
|
||||||
// if (upg.mults.dex != null) { dex *= upg.mults.dex; }
|
|
||||||
// if (upg.mults.agi != null) { agi *= upg.mults.agi; }
|
|
||||||
// if (upg.mults.cha != null) { cha *= upg.mults.cha; }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // Subtract 1 because we're only interested in the actual "bonus" part
|
buyUpgrade(upg: GangMemberUpgrade, player: IPlayer, gang: any): boolean {
|
||||||
// const eff = this.getAscensionEfficiency();
|
if (typeof upg === 'string') {
|
||||||
// return {
|
upg = GangMemberUpgrades[upg];
|
||||||
// hack: (Math.max(0, hack - 1) * AscensionMultiplierRatio * eff.hack),
|
}
|
||||||
// str: (Math.max(0, str - 1) * AscensionMultiplierRatio * eff.str),
|
if (!(upg instanceof GangMemberUpgrade)) {
|
||||||
// def: (Math.max(0, def - 1) * AscensionMultiplierRatio * eff.def),
|
return false;
|
||||||
// dex: (Math.max(0, dex - 1) * AscensionMultiplierRatio * eff.dex),
|
}
|
||||||
// agi: (Math.max(0, agi - 1) * AscensionMultiplierRatio * eff.agi),
|
// Prevent purchasing of already-owned upgrades
|
||||||
// cha: (Math.max(0, cha - 1) * AscensionMultiplierRatio * eff.cha),
|
if (this.augmentations.includes(upg.name) || this.upgrades.includes(upg.name)) {
|
||||||
// }
|
return false;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// buyUpgrade(upg: any, player: any, gang: any): boolean {
|
if (player.money.lt(upg.getCost(gang))) { return false; }
|
||||||
// if (typeof upg === 'string') {
|
player.loseMoney(upg.getCost(gang));
|
||||||
// upg = GangMemberUpgrades[upg];
|
if (upg.type === "g") {
|
||||||
// }
|
this.augmentations.push(upg.name);
|
||||||
// if (!(upg instanceof GangMemberUpgrade)) {
|
} else {
|
||||||
// return false;
|
this.upgrades.push(upg.name);
|
||||||
// }
|
}
|
||||||
// // Prevent purchasing of already-owned upgrades
|
upg.apply(this);
|
||||||
// if (this.augmentations.includes(upg.name) || this.upgrades.includes(upg.name)) {
|
return true;
|
||||||
// return false;
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
// if (player.money.lt(upg.getCost(gang))) { return false; }
|
|
||||||
// player.loseMoney(upg.getCost(gang));
|
|
||||||
// if (upg.type === "g") {
|
|
||||||
// this.augmentations.push(upg.name);
|
|
||||||
// } else {
|
|
||||||
// this.upgrades.push(upg.name);
|
|
||||||
// }
|
|
||||||
// upg.apply(this);
|
|
||||||
// if (routing.isOn(Page.Gang) && UIElems.gangMemberUpgradeBoxOpened) {
|
|
||||||
// var initFilterValue = UIElems.gangMemberUpgradeBoxFilter.value.toString();
|
|
||||||
// gang.createGangMemberUpgradeBox(player, initFilterValue);
|
|
||||||
// }
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serialize the current object to a JSON save state.
|
* Serialize the current object to a JSON save state.
|
||||||
|
@ -7,7 +7,7 @@ export class GangMemberUpgrade {
|
|||||||
desc: string;
|
desc: string;
|
||||||
mults: IMults;
|
mults: IMults;
|
||||||
|
|
||||||
constructor(name: string = "", cost: number = 0, type: string = "w", mults: IMults = {}) {
|
constructor(name = "", cost = 0, type = "w", mults: IMults = {}) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.cost = cost;
|
this.cost = cost;
|
||||||
//w = weapon, a = armor, v = vehicle, r = rootkit, g = Aug
|
//w = weapon, a = armor, v = vehicle, r = rootkit, g = Aug
|
||||||
@ -17,7 +17,7 @@ export class GangMemberUpgrade {
|
|||||||
this.desc = this.createDescription();
|
this.desc = this.createDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
getCost(gang: any) {
|
getCost(gang: any): number {
|
||||||
return this.cost / gang.getDiscount();
|
return this.cost / gang.getDiscount();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ export class GangMemberUpgrade {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Passes in a GangMember object
|
// Passes in a GangMember object
|
||||||
apply(member: any) {
|
apply(member: any): void {
|
||||||
if (this.mults.str != null) { member.str_mult *= this.mults.str; }
|
if (this.mults.str != null) { member.str_mult *= this.mults.str; }
|
||||||
if (this.mults.def != null) { member.def_mult *= this.mults.def; }
|
if (this.mults.def != null) { member.def_mult *= this.mults.def; }
|
||||||
if (this.mults.dex != null) { member.dex_mult *= this.mults.dex; }
|
if (this.mults.dex != null) { member.dex_mult *= this.mults.dex; }
|
||||||
|
@ -3,11 +3,22 @@ export const GangConstants: {
|
|||||||
MaximumGangMembers: number;
|
MaximumGangMembers: number;
|
||||||
CyclesPerTerritoryAndPowerUpdate: number;
|
CyclesPerTerritoryAndPowerUpdate: number;
|
||||||
AscensionMultiplierRatio: number;
|
AscensionMultiplierRatio: number;
|
||||||
|
Names: string[];
|
||||||
} = {
|
} = {
|
||||||
// Respect is divided by this to get rep gain
|
// Respect is divided by this to get rep gain
|
||||||
GangRespectToReputationRatio: 5,
|
GangRespectToReputationRatio: 5,
|
||||||
MaximumGangMembers: 30,
|
MaximumGangMembers: 30,
|
||||||
CyclesPerTerritoryAndPowerUpdate: 100,
|
CyclesPerTerritoryAndPowerUpdate: 100,
|
||||||
// Portion of upgrade multiplier that is kept after ascending
|
// Portion of upgrade multiplier that is kept after ascending
|
||||||
AscensionMultiplierRatio : 15,
|
AscensionMultiplierRatio: 15,
|
||||||
|
// Names of possible Gangs
|
||||||
|
Names: [
|
||||||
|
"Slum Snakes",
|
||||||
|
"Tetrads",
|
||||||
|
"The Syndicate",
|
||||||
|
"The Dark Army",
|
||||||
|
"Speakers for the Dead",
|
||||||
|
"NiteSec",
|
||||||
|
"The Black Hand",
|
||||||
|
],
|
||||||
};
|
};
|
@ -5,7 +5,7 @@ export interface IMults {
|
|||||||
dex?: number;
|
dex?: number;
|
||||||
agi?: number;
|
agi?: number;
|
||||||
cha?: number;
|
cha?: number;
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the parameters that can be used to initialize and describe a GangMemberUpgrade
|
* Defines the parameters that can be used to initialize and describe a GangMemberUpgrade
|
||||||
|
@ -11,7 +11,7 @@ interface IProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function GangMemberList(props: IProps): React.ReactElement {
|
export function GangMemberList(props: IProps): React.ReactElement {
|
||||||
const [rerender, setRerender] = useState(false);
|
const setRerender = useState(false)[1];
|
||||||
const [filter, setFilter] = useState("");
|
const [filter, setFilter] = useState("");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -40,7 +40,7 @@ export function GangMemberList(props: IProps): React.ReactElement {
|
|||||||
<input className="text-input" placeholder="Filter gang member" style={{margin: "5px", padding: "5px"}} value={filter} onChange={onChange} />
|
<input className="text-input" placeholder="Filter gang member" style={{margin: "5px", padding: "5px"}} value={filter} onChange={onChange} />
|
||||||
<a className="a-link-button" style={{display: 'inline-block'}} onClick={openUpgradePopup}>Manage Equipment</a>
|
<a className="a-link-button" style={{display: 'inline-block'}} onClick={openUpgradePopup}>Manage Equipment</a>
|
||||||
<ul>
|
<ul>
|
||||||
{members().map((member: any, i : number) => <li key={member.name}>
|
{members().map((member: any) => <li key={member.name}>
|
||||||
<Accordion
|
<Accordion
|
||||||
panelInitiallyOpened={true}
|
panelInitiallyOpened={true}
|
||||||
headerContent={<>{member.name}</>}
|
headerContent={<>{member.name}</>}
|
||||||
|
@ -14,7 +14,7 @@ interface IPanelProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function GangMemberUpgradePanel(props: IPanelProps): React.ReactElement {
|
function GangMemberUpgradePanel(props: IPanelProps): React.ReactElement {
|
||||||
const [rerender, setRerender] = useState(false);
|
const setRerender = useState(false)[1];
|
||||||
// Upgrade buttons. Only show upgrades that can be afforded
|
// Upgrade buttons. Only show upgrades that can be afforded
|
||||||
const weaponUpgrades: GangMemberUpgrade[] = [];
|
const weaponUpgrades: GangMemberUpgrade[] = [];
|
||||||
const armorUpgrades: GangMemberUpgrade[] = [];
|
const armorUpgrades: GangMemberUpgrade[] = [];
|
||||||
@ -57,7 +57,7 @@ function GangMemberUpgradePanel(props: IPanelProps): React.ReactElement {
|
|||||||
</div>);
|
</div>);
|
||||||
}
|
}
|
||||||
|
|
||||||
function upgradeButton(upg: GangMemberUpgrade, left: boolean = false): React.ReactElement {
|
function upgradeButton(upg: GangMemberUpgrade, left = false): React.ReactElement {
|
||||||
function onClick(): void {
|
function onClick(): void {
|
||||||
props.member.buyUpgrade(upg, props.player, props.gang);
|
props.member.buyUpgrade(upg, props.player, props.gang);
|
||||||
setRerender(old => !old);
|
setRerender(old => !old);
|
||||||
@ -112,7 +112,7 @@ interface IProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function GangMemberUpgradePopup(props: IProps): React.ReactElement {
|
export function GangMemberUpgradePopup(props: IProps): React.ReactElement {
|
||||||
const [rerender, setRerender] = useState(false);
|
const setRerender = useState(false)[1];
|
||||||
const [filter, setFilter] = useState("");
|
const [filter, setFilter] = useState("");
|
||||||
|
|
||||||
function closePopup(): void {
|
function closePopup(): void {
|
||||||
@ -137,39 +137,3 @@ export function GangMemberUpgradePopup(props: IProps): React.ReactElement {
|
|||||||
{props.gang.members.map((member: any) => <GangMemberUpgradePanel key={member.name} player={props.player} gang={props.gang} member={member} />)}
|
{props.gang.members.map((member: any) => <GangMemberUpgradePanel key={member.name} player={props.player} gang={props.gang} member={member} />)}
|
||||||
</>);
|
</>);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
// Add buttons to purchase each upgrade
|
|
||||||
const upgrades = [weaponUpgrades, armorUpgrades, vehicleUpgrades, rootkitUpgrades, augUpgrades];
|
|
||||||
const divs = [weaponDiv, armorDiv, vehicleDiv, rootkitDiv, augDiv];
|
|
||||||
for (let i = 0; i < upgrades.length; ++i) {
|
|
||||||
let upgradeArray = upgrades[i];
|
|
||||||
let div = divs[i];
|
|
||||||
for (let j = 0; j < upgradeArray.length; ++j) {
|
|
||||||
let upg = upgradeArray[j];
|
|
||||||
(function (upg, div, memberObj, i, gang) {
|
|
||||||
let createElementParams = {
|
|
||||||
innerHTML: `${upg.name} - ${renderToStaticMarkup(Money(upg.getCost(gang)))}`,
|
|
||||||
class: "a-link-button", margin:"2px", padding:"2px", display:"block",
|
|
||||||
fontSize:"11px",
|
|
||||||
clickListener:() => {
|
|
||||||
memberObj.buyUpgrade(upg, player, gangObj);
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
// For the last two divs, tooltip should be on the left
|
|
||||||
if (i >= 3) {
|
|
||||||
createElementParams.tooltipleft = upg.desc;
|
|
||||||
} else {
|
|
||||||
createElementParams.tooltip = upg.desc;
|
|
||||||
}
|
|
||||||
div.appendChild(createElement("a", createElementParams));
|
|
||||||
})(upg, div, this, i, gangObj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
createPopup(boxId, UIElems.gangMemberUpgradeBoxElements)
|
|
||||||
|
|
||||||
*/
|
|
@ -79,7 +79,7 @@ function Recruitment(props: IProps): React.ReactElement {
|
|||||||
if (numMembers >= GangConstants.MaximumGangMembers) {
|
if (numMembers >= GangConstants.MaximumGangMembers) {
|
||||||
return (<></>);
|
return (<></>);
|
||||||
} else if (props.gang.canRecruitMember()) {
|
} else if (props.gang.canRecruitMember()) {
|
||||||
function onClick() {
|
function onClick(): void {
|
||||||
const popupId = "recruit-gang-member-popup";
|
const popupId = "recruit-gang-member-popup";
|
||||||
createPopup(popupId, recruitPopup, {
|
createPopup(popupId, recruitPopup, {
|
||||||
gang: props.gang,
|
gang: props.gang,
|
||||||
@ -120,7 +120,7 @@ function BonusTime(props: IProps): React.ReactElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function GangStats(props: IProps): React.ReactElement {
|
export function GangStats(props: IProps): React.ReactElement {
|
||||||
const [rerender, setRerender] = useState(false);
|
const setRerender = useState(false)[1];
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const id = setInterval(() => setRerender(old => !old), 1000);
|
const id = setInterval(() => setRerender(old => !old), 1000);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import * as React from "react";
|
||||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||||
import { GangStats } from "./GangStats";
|
import { GangStats } from "./GangStats";
|
||||||
import { GangMemberList } from "./GangMemberList";
|
import { GangMemberList } from "./GangMemberList";
|
||||||
|
@ -11,15 +11,13 @@ interface IAscendProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function ascendPopup(props: IAscendProps): React.ReactElement {
|
function ascendPopup(props: IAscendProps): React.ReactElement {
|
||||||
function confirm() {
|
function confirm(): void {
|
||||||
props.gang.ascendMember(props.member);
|
props.gang.ascendMember(props.member);
|
||||||
removePopup(props.popupId);
|
removePopup(props.popupId);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancel() {
|
function cancel(): void {
|
||||||
removePopup(props.popupId);
|
removePopup(props.popupId);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const ascendBenefits = props.member.getAscensionResults();
|
const ascendBenefits = props.member.getAscensionResults();
|
||||||
@ -32,12 +30,12 @@ their non-Augmentation upgrades and their stats will reset back to 1.<br />
|
|||||||
Furthermore, your gang will lose {numeralWrapper.formatRespect(props.member.earnedRespect)} respect<br />
|
Furthermore, your gang will lose {numeralWrapper.formatRespect(props.member.earnedRespect)} respect<br />
|
||||||
<br />
|
<br />
|
||||||
In return, they will gain the following permanent boost to stat multipliers:<br />
|
In return, they will gain the following permanent boost to stat multipliers:<br />
|
||||||
Hacking: +{numeralWrapper.formatPercentage(ascendBenefits.hack)}<br />
|
Hacking: +{numeralWrapper.formatPercentage(ascendBenefits.hack/100)}<br />
|
||||||
Strength: +{numeralWrapper.formatPercentage(ascendBenefits.str)}<br />
|
Strength: +{numeralWrapper.formatPercentage(ascendBenefits.str/100)}<br />
|
||||||
Defense: +{numeralWrapper.formatPercentage(ascendBenefits.def)}<br />
|
Defense: +{numeralWrapper.formatPercentage(ascendBenefits.def/100)}<br />
|
||||||
Dexterity: +{numeralWrapper.formatPercentage(ascendBenefits.dex)}<br />
|
Dexterity: +{numeralWrapper.formatPercentage(ascendBenefits.dex/100)}<br />
|
||||||
Agility: +{numeralWrapper.formatPercentage(ascendBenefits.agi)}<br />
|
Agility: +{numeralWrapper.formatPercentage(ascendBenefits.agi/100)}<br />
|
||||||
Charisma: +{numeralWrapper.formatPercentage(ascendBenefits.cha)}<br />
|
Charisma: +{numeralWrapper.formatPercentage(ascendBenefits.cha/100)}<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>
|
||||||
@ -50,14 +48,14 @@ interface IProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function Panel1(props: IProps): React.ReactElement {
|
export function Panel1(props: IProps): React.ReactElement {
|
||||||
const [rerender, setRerender] = useState(false);
|
const setRerender = useState(false)[1];
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const id = setInterval(() => setRerender(old => !old), 1000);
|
const id = setInterval(() => setRerender(old => !old), 1000);
|
||||||
return () => clearInterval(id);
|
return () => clearInterval(id);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
function ascend() {
|
function ascend(): void {
|
||||||
const popupId = `gang-management-ascend-member ${props.member.name}`;
|
const popupId = `gang-management-ascend-member ${props.member.name}`;
|
||||||
createPopup(popupId, ascendPopup, {
|
createPopup(popupId, ascendPopup, {
|
||||||
member: props.member,
|
member: props.member,
|
||||||
|
@ -9,7 +9,7 @@ interface IProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function Panel2(props: IProps): React.ReactElement {
|
export function Panel2(props: IProps): React.ReactElement {
|
||||||
const [rerender, setRerender] = useState(false);
|
const setRerender = useState(false)[1];
|
||||||
const [currentTask, setCurrentTask] = useState(props.member.task);
|
const [currentTask, setCurrentTask] = useState(props.member.task);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -6,7 +6,7 @@ interface IProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function Panel3(props: IProps): React.ReactElement {
|
export function Panel3(props: IProps): React.ReactElement {
|
||||||
const [rerender, setRerender] = useState(false);
|
const setRerender = useState(false)[1];
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const id = setInterval(() => {
|
const id = setInterval(() => {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React, { useState } from "react";
|
||||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||||
import { ManagementSubpage } from "./ManagementSubpage";
|
import { ManagementSubpage } from "./ManagementSubpage";
|
||||||
import { TerritorySubpage } from "./TerritorySubpage";
|
import { TerritorySubpage } from "./TerritorySubpage";
|
||||||
|
@ -9,7 +9,7 @@ interface IProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function TerritorySubpage(props: IProps): React.ReactElement {
|
export function TerritorySubpage(props: IProps): React.ReactElement {
|
||||||
const [rerender, setRerender] = useState(false);
|
const setRerender = useState(false)[1];
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const id = setInterval(() => setRerender(old => !old), 1000);
|
const id = setInterval(() => setRerender(old => !old), 1000);
|
||||||
@ -25,13 +25,12 @@ export function TerritorySubpage(props: IProps): React.ReactElement {
|
|||||||
|
|
||||||
function formatTerritoryP(n: number): string {
|
function formatTerritoryP(n: number): string {
|
||||||
const v = n * 100;
|
const v = n * 100;
|
||||||
let displayNumber;
|
if (v <= 0) {
|
||||||
if (n <= 0) {
|
|
||||||
return formatNumber(0, 2);
|
return formatNumber(0, 2);
|
||||||
} else if (n >= 100) {
|
} else if (v >= 100) {
|
||||||
return formatNumber(100, 2);
|
return formatNumber(100, 2);
|
||||||
} else {
|
} else {
|
||||||
return formatNumber(n, 2);
|
return formatNumber(v, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,37 +115,3 @@ export function TerritorySubpage(props: IProps): React.ReactElement {
|
|||||||
</div>);
|
</div>);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
let gangNames = Object.keys(AllGangs).filter(g => g != this.facName);
|
|
||||||
gangNames.unshift(this.facName);
|
|
||||||
for (const gangname of gangNames) {
|
|
||||||
if (AllGangs.hasOwnProperty(gangname)) {
|
|
||||||
const gangTerritoryInfo = AllGangs[gangname];
|
|
||||||
let territory = gangTerritoryInfo.territory * 100;
|
|
||||||
|
|
||||||
//Fix some rounding issues graphically
|
|
||||||
let displayNumber;
|
|
||||||
if (territory <= 0) {
|
|
||||||
displayNumber = formatNumber(0, 2);
|
|
||||||
} else if (territory >= 100) {
|
|
||||||
displayNumber = formatNumber(100, 2);
|
|
||||||
} else {
|
|
||||||
displayNumber = formatNumber(territory, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gangname === this.facName) {
|
|
||||||
let newHTML = `<b><u>${gangname}</u></b><br>Power: ${formatNumber(gangTerritoryInfo.power, 6)}<br>`;
|
|
||||||
newHTML += `Territory: ${displayNumber}%<br><br>`;
|
|
||||||
UIElems.gangTerritoryInfoText.innerHTML += newHTML;
|
|
||||||
} else {
|
|
||||||
const clashVictoryChance = playerPower / (gangTerritoryInfo.power + playerPower);
|
|
||||||
let newHTML = `<u>${gangname}</u><br>Power: ${formatNumber(gangTerritoryInfo.power, 6)}<br>`;
|
|
||||||
newHTML += `Territory: ${displayNumber}%<br>`;
|
|
||||||
newHTML += `Chance to win clash with this gang: ${numeralWrapper.formatPercentage(clashVictoryChance, 3)}<br><br>`;
|
|
||||||
UIElems.gangTerritoryInfoText.innerHTML += newHTML;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
@ -27,7 +27,7 @@ export class Accordion extends React.Component<IProps, IState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleHeaderClick(e: React.MouseEvent<HTMLButtonElement>): void {
|
handleHeaderClick(): void {
|
||||||
this.setState({
|
this.setState({
|
||||||
panelOpened: !this.state.panelOpened,
|
panelOpened: !this.state.panelOpened,
|
||||||
});
|
});
|
||||||
|
@ -12,10 +12,6 @@ type IProps = {
|
|||||||
onAttempt: (answer: string) => void;
|
onAttempt: (answer: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
type IState = {
|
|
||||||
answer: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function CodingContractPopup(props: IProps): React.ReactElement {
|
export function CodingContractPopup(props: IProps): React.ReactElement {
|
||||||
const [answer, setAnswer] = useState("");
|
const [answer, setAnswer] = useState("");
|
||||||
|
|
||||||
|
@ -14,8 +14,6 @@ import { Popup } from "./Popup";
|
|||||||
import { createElement } from "../../../utils/uiHelpers/createElement";
|
import { createElement } from "../../../utils/uiHelpers/createElement";
|
||||||
import { removeElementById } from "../../../utils/uiHelpers/removeElementById";
|
import { removeElementById } from "../../../utils/uiHelpers/removeElementById";
|
||||||
|
|
||||||
type ReactComponent = new(...args: any[]) => React.Component<any, any>;
|
|
||||||
|
|
||||||
let gameContainer: HTMLElement;
|
let gameContainer: HTMLElement;
|
||||||
|
|
||||||
function getGameContainer(): void {
|
function getGameContainer(): void {
|
||||||
|
Reference in New Issue
Block a user