mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 01:23:49 +01:00
Converted GangMember to tsx, only Gang left
This commit is contained in:
parent
4cdd65e96c
commit
99b8dfa0c1
@ -7,7 +7,6 @@ import * as React from "react";
|
||||
import { Augmentations } from "../../Augmentation/Augmentations";
|
||||
import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
|
||||
import { Player } from "../../Player";
|
||||
import { IPlayerOwnedAugmentation } from "../../Augmentation/PlayerOwnedAugmentation";
|
||||
|
||||
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
|
||||
*/
|
||||
|
||||
import { gangMemberTasksMetadata } from "./Gang/data/tasks";
|
||||
import { gangMemberUpgradesMetadata } from "./Gang/data/upgrades";
|
||||
|
||||
import { Engine } from "./engine";
|
||||
import { Faction } from "./Faction/Faction";
|
||||
import { Factions } from "./Faction/Factions";
|
||||
import { displayFactionContent } from "./Faction/FactionHelpers";
|
||||
|
||||
import { Page, routing } from "./ui/navigationTracking";
|
||||
import { numeralWrapper } from "./ui/numeralFormat";
|
||||
|
||||
import { dialogBoxCreate } from "../utils/DialogBox";
|
||||
@ -21,53 +16,25 @@ import {
|
||||
Generic_toJSON,
|
||||
Generic_fromJSON,
|
||||
} from "../utils/JSONReviver";
|
||||
import {
|
||||
formatNumber,
|
||||
convertTimeMsToTimeElapsedString,
|
||||
} from "../utils/StringHelperFunctions";
|
||||
|
||||
import { exceptionAlert } from "../utils/helpers/exceptionAlert";
|
||||
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 { createPopup } from "../utils/uiHelpers/createPopup";
|
||||
import { removeChildrenFromElement } from "../utils/uiHelpers/removeChildrenFromElement";
|
||||
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 { GangMemberUpgrades } from "./Gang/GangMemberUpgrades";
|
||||
import { GangConstants } from "./Gang/data/Constants";
|
||||
import { GangMemberTasks } from "./Gang/GangMemberTasks";
|
||||
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 { Root } from "./Gang/ui/Root";
|
||||
import { GangMember } from "./Gang/GangMember";
|
||||
|
||||
import React from "react";
|
||||
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
|
||||
@ -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) {
|
||||
this.storedTerritoryAndPowerCycles += numCycles;
|
||||
if (this.storedTerritoryAndPowerCycles < GangConstants.CyclesPerTerritoryAndPowerUpdate) { return; }
|
||||
@ -233,13 +194,13 @@ Gang.prototype.processTerritoryAndPowerGains = function(numCycles=1) {
|
||||
}
|
||||
|
||||
// Then process territory
|
||||
for (let i = 0; i < GangNames.length; ++i) {
|
||||
const others = GangNames.filter((e) => {
|
||||
return e !== GangNames[i];
|
||||
for (let i = 0; i < GangConstants.Names.length; ++i) {
|
||||
const others = GangConstants.Names.filter((e) => {
|
||||
return e !== GangConstants.Names[i];
|
||||
});
|
||||
const other = getRandomInt(0, others.length - 1);
|
||||
|
||||
const thisGang = GangNames[i];
|
||||
const thisGang = GangConstants.Names[i];
|
||||
const otherGang = others[other];
|
||||
|
||||
// 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;
|
||||
|
||||
function GangMember(name) {
|
||||
this.name = name;
|
||||
this.task = "Unassigned";
|
||||
|
||||
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
|
||||
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;
|
||||
}
|
||||
|
||||
// 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
|
||||
const UIElems = {
|
||||
gangContentCreated: false,
|
||||
|
@ -38,7 +38,7 @@ export let AllGangs: {
|
||||
},
|
||||
}
|
||||
|
||||
export function resetGangs() {
|
||||
export function resetGangs(): void {
|
||||
AllGangs = {
|
||||
"Slum Snakes" : {
|
||||
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);
|
||||
}
|
@ -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";
|
||||
|
||||
export class GangMember {
|
||||
name: string;
|
||||
task: string = "Unassigned";
|
||||
task = "Unassigned";
|
||||
|
||||
earnedRespect: number = 0;
|
||||
earnedRespect = 0;
|
||||
|
||||
hack: number = 1;
|
||||
str: number = 1;
|
||||
def: number = 1;
|
||||
dex: number = 1;
|
||||
agi: number = 1;
|
||||
cha: number = 1;
|
||||
hack = 1;
|
||||
str = 1;
|
||||
def = 1;
|
||||
dex = 1;
|
||||
agi = 1;
|
||||
cha = 1;
|
||||
|
||||
hack_exp: number = 0;
|
||||
str_exp: number = 0;
|
||||
def_exp: number = 0;
|
||||
dex_exp: number = 0;
|
||||
agi_exp: number = 0;
|
||||
cha_exp: number = 0;
|
||||
hack_exp = 0;
|
||||
str_exp = 0;
|
||||
def_exp = 0;
|
||||
dex_exp = 0;
|
||||
agi_exp = 0;
|
||||
cha_exp = 0;
|
||||
|
||||
hack_mult: number = 1;
|
||||
str_mult: number = 1;
|
||||
def_mult: number = 1;
|
||||
dex_mult: number = 1;
|
||||
agi_mult: number = 1;
|
||||
cha_mult: number = 1;
|
||||
hack_mult = 1;
|
||||
str_mult = 1;
|
||||
def_mult = 1;
|
||||
dex_mult = 1;
|
||||
agi_mult = 1;
|
||||
cha_mult = 1;
|
||||
|
||||
hack_asc_mult: number = 1;
|
||||
str_asc_mult: number = 1;
|
||||
def_asc_mult: number = 1;
|
||||
dex_asc_mult: number = 1;
|
||||
agi_asc_mult: number = 1;
|
||||
cha_asc_mult: number = 1;
|
||||
hack_asc_mult = 1;
|
||||
str_asc_mult = 1;
|
||||
def_asc_mult = 1;
|
||||
dex_asc_mult = 1;
|
||||
agi_asc_mult = 1;
|
||||
cha_asc_mult = 1;
|
||||
|
||||
upgrades: string[] = []; // Names of upgrades
|
||||
augmentations: string[] = []; // Names of augmentations only
|
||||
|
||||
constructor(name: string = "") {
|
||||
constructor(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
|
||||
// calculateSkill(exp: number, mult: number = 1): number {
|
||||
// return Math.max(Math.floor(mult * (32 * Math.log(exp + 534.5) - 200)), 1);
|
||||
// }
|
||||
updateSkillLevels(): void {
|
||||
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);
|
||||
}
|
||||
|
||||
// updateSkillLevels(): void {
|
||||
// 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);
|
||||
// }
|
||||
calculatePower(): number {
|
||||
return (this.hack + this.str + this.def + this.dex + this.agi + this.cha) / 95;
|
||||
}
|
||||
|
||||
// calculatePower(): number {
|
||||
// return (this.hack + this.str + this.def + this.dex + this.agi + this.cha) / 95;
|
||||
// }
|
||||
assignToTask(taskName: string): boolean {
|
||||
if (GangMemberTasks.hasOwnProperty(taskName)) {
|
||||
this.task = taskName;
|
||||
return true;
|
||||
} else {
|
||||
this.task = "Unassigned";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// assignToTask(taskName: string): boolean {
|
||||
// if (GangMemberTasks.hasOwnProperty(taskName)) {
|
||||
// this.task = taskName;
|
||||
// return true;
|
||||
// } else {
|
||||
// this.task = "Unassigned";
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
unassignFromTask(): void {
|
||||
this.task = "Unassigned";
|
||||
}
|
||||
|
||||
// unassignFromTask(): string {
|
||||
// this.task = "Unassigned";
|
||||
// }
|
||||
getTask(): GangMemberTask {
|
||||
// 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 {
|
||||
// // Backwards compatibility
|
||||
// if (this.task instanceof GangMemberTask) {
|
||||
// this.task = this.task.name;
|
||||
// }
|
||||
if (GangMemberTasks.hasOwnProperty(this.task)) {
|
||||
return GangMemberTasks[this.task];
|
||||
}
|
||||
return GangMemberTasks["Unassigned"];
|
||||
}
|
||||
|
||||
// if (GangMemberTasks.hasOwnProperty(this.task)) {
|
||||
// return GangMemberTasks[this.task];
|
||||
// }
|
||||
// return GangMemberTasks["Unassigned"];
|
||||
// }
|
||||
calculateRespectGain(gang: any): number {
|
||||
const task = this.getTask();
|
||||
if (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;
|
||||
const respectMult = gang.getWantedPenalty();
|
||||
return 11 * task.baseRespect * statWeight * territoryMult * respectMult;
|
||||
}
|
||||
|
||||
// // Gains are per cycle
|
||||
// calculateRespectGain(gang: any): number {
|
||||
// const task = this.getTask();
|
||||
// if (task == null || !(task instanceof GangMemberTask) || task.baseRespect === 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 -= (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;
|
||||
// }
|
||||
calculateWantedLevelGain(gang: any): number {
|
||||
const task = this.getTask();
|
||||
if (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));
|
||||
|
||||
// calculateWantedLevelGain(gang: any): number {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
// // 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);
|
||||
// }
|
||||
// }
|
||||
calculateMoneyGain(gang: any): number {
|
||||
const task = this.getTask();
|
||||
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 {
|
||||
// const task = this.getTask();
|
||||
// if (task == null || !(task instanceof GangMemberTask) || 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;
|
||||
// }
|
||||
gainExperience(numCycles: number = 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;
|
||||
}
|
||||
|
||||
// gainExperience(numCycles: number = 1): void {
|
||||
// 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;
|
||||
// }
|
||||
recordEarnedRespect(numCycles: number = 1, gang: any): void {
|
||||
this.earnedRespect += (this.calculateRespectGain(gang) * numCycles);
|
||||
}
|
||||
|
||||
// recordEarnedRespect(numCycles: number = 1, gang: any): void {
|
||||
// this.earnedRespect += (this.calculateRespectGain(gang) * numCycles);
|
||||
// }
|
||||
getAscensionResults(): any {
|
||||
//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 {
|
||||
// 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;
|
||||
// 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),
|
||||
}
|
||||
}
|
||||
|
||||
// // 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);
|
||||
// }
|
||||
getAscensionEfficiency(): any {
|
||||
function formula(mult: number): number {
|
||||
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),
|
||||
};
|
||||
}
|
||||
|
||||
// // 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();
|
||||
ascend(): any {
|
||||
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;
|
||||
|
||||
// const respectToDeduct = this.earnedRespect;
|
||||
// this.earnedRespect = 0;
|
||||
// return {
|
||||
// respect: respectToDeduct,
|
||||
// hack: hackAscMult,
|
||||
// str: strAscMult,
|
||||
// def: defAscMult,
|
||||
// dex: dexAscMult,
|
||||
// agi: agiAscMult,
|
||||
// cha: 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);
|
||||
}
|
||||
|
||||
// getAscensionEfficiency(): any {
|
||||
// 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),
|
||||
// };
|
||||
// }
|
||||
// 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();
|
||||
|
||||
// // Returns the multipliers that would be gained from ascension
|
||||
// getAscensionResults(): any {
|
||||
// /**
|
||||
// * 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) {
|
||||
// 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; }
|
||||
// }
|
||||
const respectToDeduct = this.earnedRespect;
|
||||
this.earnedRespect = 0;
|
||||
return {
|
||||
respect: respectToDeduct,
|
||||
hack: hackAscMult,
|
||||
str: strAscMult,
|
||||
def: defAscMult,
|
||||
dex: dexAscMult,
|
||||
agi: agiAscMult,
|
||||
cha: chaAscMult,
|
||||
};
|
||||
}
|
||||
|
||||
// // Subtract 1 because we're only interested in the actual "bonus" part
|
||||
// const eff = this.getAscensionEfficiency();
|
||||
// return {
|
||||
// hack: (Math.max(0, hack - 1) * AscensionMultiplierRatio * eff.hack),
|
||||
// str: (Math.max(0, str - 1) * AscensionMultiplierRatio * eff.str),
|
||||
// def: (Math.max(0, def - 1) * AscensionMultiplierRatio * eff.def),
|
||||
// dex: (Math.max(0, dex - 1) * AscensionMultiplierRatio * eff.dex),
|
||||
// agi: (Math.max(0, agi - 1) * AscensionMultiplierRatio * eff.agi),
|
||||
// cha: (Math.max(0, cha - 1) * AscensionMultiplierRatio * eff.cha),
|
||||
// }
|
||||
// }
|
||||
buyUpgrade(upg: GangMemberUpgrade, player: IPlayer, gang: any): 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;
|
||||
}
|
||||
|
||||
// buyUpgrade(upg: any, player: any, gang: any): 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;
|
||||
// }
|
||||
|
||||
// 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;
|
||||
// }
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the current object to a JSON save state.
|
||||
|
@ -7,7 +7,7 @@ export class GangMemberUpgrade {
|
||||
desc: string;
|
||||
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.cost = cost;
|
||||
//w = weapon, a = armor, v = vehicle, r = rootkit, g = Aug
|
||||
@ -17,7 +17,7 @@ export class GangMemberUpgrade {
|
||||
this.desc = this.createDescription();
|
||||
}
|
||||
|
||||
getCost(gang: any) {
|
||||
getCost(gang: any): number {
|
||||
return this.cost / gang.getDiscount();
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ export class GangMemberUpgrade {
|
||||
}
|
||||
|
||||
// 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.def != null) { member.def_mult *= this.mults.def; }
|
||||
if (this.mults.dex != null) { member.dex_mult *= this.mults.dex; }
|
||||
|
@ -3,11 +3,22 @@ export const GangConstants: {
|
||||
MaximumGangMembers: number;
|
||||
CyclesPerTerritoryAndPowerUpdate: number;
|
||||
AscensionMultiplierRatio: number;
|
||||
Names: string[];
|
||||
} = {
|
||||
// Respect is divided by this to get rep gain
|
||||
GangRespectToReputationRatio: 5,
|
||||
MaximumGangMembers: 30,
|
||||
CyclesPerTerritoryAndPowerUpdate: 100,
|
||||
// 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;
|
||||
agi?: number;
|
||||
cha?: number;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 {
|
||||
const [rerender, setRerender] = useState(false);
|
||||
const setRerender = useState(false)[1];
|
||||
const [filter, setFilter] = useState("");
|
||||
|
||||
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} />
|
||||
<a className="a-link-button" style={{display: 'inline-block'}} onClick={openUpgradePopup}>Manage Equipment</a>
|
||||
<ul>
|
||||
{members().map((member: any, i : number) => <li key={member.name}>
|
||||
{members().map((member: any) => <li key={member.name}>
|
||||
<Accordion
|
||||
panelInitiallyOpened={true}
|
||||
headerContent={<>{member.name}</>}
|
||||
|
@ -14,7 +14,7 @@ interface IPanelProps {
|
||||
}
|
||||
|
||||
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
|
||||
const weaponUpgrades: GangMemberUpgrade[] = [];
|
||||
const armorUpgrades: GangMemberUpgrade[] = [];
|
||||
@ -57,7 +57,7 @@ function GangMemberUpgradePanel(props: IPanelProps): React.ReactElement {
|
||||
</div>);
|
||||
}
|
||||
|
||||
function upgradeButton(upg: GangMemberUpgrade, left: boolean = false): React.ReactElement {
|
||||
function upgradeButton(upg: GangMemberUpgrade, left = false): React.ReactElement {
|
||||
function onClick(): void {
|
||||
props.member.buyUpgrade(upg, props.player, props.gang);
|
||||
setRerender(old => !old);
|
||||
@ -112,7 +112,7 @@ interface IProps {
|
||||
}
|
||||
|
||||
export function GangMemberUpgradePopup(props: IProps): React.ReactElement {
|
||||
const [rerender, setRerender] = useState(false);
|
||||
const setRerender = useState(false)[1];
|
||||
const [filter, setFilter] = useState("");
|
||||
|
||||
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} />)}
|
||||
</>);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
// 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) {
|
||||
return (<></>);
|
||||
} else if (props.gang.canRecruitMember()) {
|
||||
function onClick() {
|
||||
function onClick(): void {
|
||||
const popupId = "recruit-gang-member-popup";
|
||||
createPopup(popupId, recruitPopup, {
|
||||
gang: props.gang,
|
||||
@ -120,7 +120,7 @@ function BonusTime(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
export function GangStats(props: IProps): React.ReactElement {
|
||||
const [rerender, setRerender] = useState(false);
|
||||
const setRerender = useState(false)[1];
|
||||
|
||||
useEffect(() => {
|
||||
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 { GangStats } from "./GangStats";
|
||||
import { GangMemberList } from "./GangMemberList";
|
||||
|
@ -11,15 +11,13 @@ interface IAscendProps {
|
||||
}
|
||||
|
||||
function ascendPopup(props: IAscendProps): React.ReactElement {
|
||||
function confirm() {
|
||||
function confirm(): void {
|
||||
props.gang.ascendMember(props.member);
|
||||
removePopup(props.popupId);
|
||||
return false;
|
||||
}
|
||||
|
||||
function cancel() {
|
||||
function cancel(): void {
|
||||
removePopup(props.popupId);
|
||||
return false;
|
||||
}
|
||||
|
||||
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 />
|
||||
<br />
|
||||
In return, they will gain the following permanent boost to stat multipliers:<br />
|
||||
Hacking: +{numeralWrapper.formatPercentage(ascendBenefits.hack)}<br />
|
||||
Strength: +{numeralWrapper.formatPercentage(ascendBenefits.str)}<br />
|
||||
Defense: +{numeralWrapper.formatPercentage(ascendBenefits.def)}<br />
|
||||
Dexterity: +{numeralWrapper.formatPercentage(ascendBenefits.dex)}<br />
|
||||
Agility: +{numeralWrapper.formatPercentage(ascendBenefits.agi)}<br />
|
||||
Charisma: +{numeralWrapper.formatPercentage(ascendBenefits.cha)}<br />
|
||||
Hacking: +{numeralWrapper.formatPercentage(ascendBenefits.hack/100)}<br />
|
||||
Strength: +{numeralWrapper.formatPercentage(ascendBenefits.str/100)}<br />
|
||||
Defense: +{numeralWrapper.formatPercentage(ascendBenefits.def/100)}<br />
|
||||
Dexterity: +{numeralWrapper.formatPercentage(ascendBenefits.dex/100)}<br />
|
||||
Agility: +{numeralWrapper.formatPercentage(ascendBenefits.agi/100)}<br />
|
||||
Charisma: +{numeralWrapper.formatPercentage(ascendBenefits.cha/100)}<br />
|
||||
</pre>
|
||||
<button className="std-button" onClick={confirm}>Ascend</button>
|
||||
<button className="std-button" onClick={cancel}>Cancel</button>
|
||||
@ -50,14 +48,14 @@ interface IProps {
|
||||
}
|
||||
|
||||
export function Panel1(props: IProps): React.ReactElement {
|
||||
const [rerender, setRerender] = useState(false);
|
||||
const setRerender = useState(false)[1];
|
||||
|
||||
useEffect(() => {
|
||||
const id = setInterval(() => setRerender(old => !old), 1000);
|
||||
return () => clearInterval(id);
|
||||
}, []);
|
||||
|
||||
function ascend() {
|
||||
function ascend(): void {
|
||||
const popupId = `gang-management-ascend-member ${props.member.name}`;
|
||||
createPopup(popupId, ascendPopup, {
|
||||
member: props.member,
|
||||
|
@ -9,7 +9,7 @@ interface IProps {
|
||||
}
|
||||
|
||||
export function Panel2(props: IProps): React.ReactElement {
|
||||
const [rerender, setRerender] = useState(false);
|
||||
const setRerender = useState(false)[1];
|
||||
const [currentTask, setCurrentTask] = useState(props.member.task);
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -6,7 +6,7 @@ interface IProps {
|
||||
}
|
||||
|
||||
export function Panel3(props: IProps): React.ReactElement {
|
||||
const [rerender, setRerender] = useState(false);
|
||||
const setRerender = useState(false)[1];
|
||||
|
||||
useEffect(() => {
|
||||
const id = setInterval(() => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import React, { useState } from "react";
|
||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
import { ManagementSubpage } from "./ManagementSubpage";
|
||||
import { TerritorySubpage } from "./TerritorySubpage";
|
||||
|
@ -9,7 +9,7 @@ interface IProps {
|
||||
}
|
||||
|
||||
export function TerritorySubpage(props: IProps): React.ReactElement {
|
||||
const [rerender, setRerender] = useState(false);
|
||||
const setRerender = useState(false)[1];
|
||||
|
||||
useEffect(() => {
|
||||
const id = setInterval(() => setRerender(old => !old), 1000);
|
||||
@ -25,13 +25,12 @@ export function TerritorySubpage(props: IProps): React.ReactElement {
|
||||
|
||||
function formatTerritoryP(n: number): string {
|
||||
const v = n * 100;
|
||||
let displayNumber;
|
||||
if (n <= 0) {
|
||||
if (v <= 0) {
|
||||
return formatNumber(0, 2);
|
||||
} else if (n >= 100) {
|
||||
} else if (v >= 100) {
|
||||
return formatNumber(100, 2);
|
||||
} else {
|
||||
return formatNumber(n, 2);
|
||||
return formatNumber(v, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,37 +115,3 @@ export function TerritorySubpage(props: IProps): React.ReactElement {
|
||||
</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({
|
||||
panelOpened: !this.state.panelOpened,
|
||||
});
|
||||
|
@ -12,10 +12,6 @@ type IProps = {
|
||||
onAttempt: (answer: string) => void;
|
||||
}
|
||||
|
||||
type IState = {
|
||||
answer: string;
|
||||
}
|
||||
|
||||
export function CodingContractPopup(props: IProps): React.ReactElement {
|
||||
const [answer, setAnswer] = useState("");
|
||||
|
||||
|
@ -14,8 +14,6 @@ import { Popup } from "./Popup";
|
||||
import { createElement } from "../../../utils/uiHelpers/createElement";
|
||||
import { removeElementById } from "../../../utils/uiHelpers/removeElementById";
|
||||
|
||||
type ReactComponent = new(...args: any[]) => React.Component<any, any>;
|
||||
|
||||
let gameContainer: HTMLElement;
|
||||
|
||||
function getGameContainer(): void {
|
||||
|
Loading…
Reference in New Issue
Block a user