2022-07-28 02:37:32 +02:00
|
|
|
import { IPerson } from "src/PersonObjects/IPerson";
|
2022-09-06 15:07:12 +02:00
|
|
|
import { Player } from "../Player";
|
2022-07-07 23:28:23 +02:00
|
|
|
|
|
|
|
export interface WorkStats {
|
|
|
|
money: number;
|
2022-07-13 04:43:03 +02:00
|
|
|
reputation: number;
|
2022-07-07 23:28:23 +02:00
|
|
|
hackExp: number;
|
|
|
|
strExp: number;
|
|
|
|
defExp: number;
|
|
|
|
dexExp: number;
|
|
|
|
agiExp: number;
|
|
|
|
chaExp: number;
|
|
|
|
intExp: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface newWorkStatsParams {
|
|
|
|
money?: number;
|
2022-07-13 04:43:03 +02:00
|
|
|
reputation?: number;
|
2022-07-07 23:28:23 +02:00
|
|
|
hackExp?: number;
|
|
|
|
strExp?: number;
|
|
|
|
defExp?: number;
|
|
|
|
dexExp?: number;
|
|
|
|
agiExp?: number;
|
|
|
|
chaExp?: number;
|
|
|
|
intExp?: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const newWorkStats = (params?: newWorkStatsParams): WorkStats => {
|
|
|
|
return {
|
|
|
|
money: params?.money ?? 0,
|
2022-07-13 04:43:03 +02:00
|
|
|
reputation: params?.reputation ?? 0,
|
2022-07-07 23:28:23 +02:00
|
|
|
hackExp: params?.hackExp ?? 0,
|
|
|
|
strExp: params?.strExp ?? 0,
|
|
|
|
defExp: params?.defExp ?? 0,
|
|
|
|
dexExp: params?.dexExp ?? 0,
|
|
|
|
agiExp: params?.agiExp ?? 0,
|
|
|
|
chaExp: params?.chaExp ?? 0,
|
|
|
|
intExp: params?.intExp ?? 0,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export const sumWorkStats = (w0: WorkStats, w1: WorkStats): WorkStats => {
|
|
|
|
return {
|
|
|
|
money: w0.money + w1.money,
|
2022-07-13 04:43:03 +02:00
|
|
|
reputation: w0.reputation + w1.reputation,
|
2022-07-07 23:28:23 +02:00
|
|
|
hackExp: w0.hackExp + w1.hackExp,
|
|
|
|
strExp: w0.strExp + w1.strExp,
|
|
|
|
defExp: w0.defExp + w1.defExp,
|
|
|
|
dexExp: w0.dexExp + w1.dexExp,
|
|
|
|
agiExp: w0.agiExp + w1.agiExp,
|
|
|
|
chaExp: w0.chaExp + w1.chaExp,
|
|
|
|
intExp: w0.intExp + w1.intExp,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-07-28 02:37:32 +02:00
|
|
|
export const scaleWorkStats = (w: WorkStats, n: number, scaleMoney = true): WorkStats => {
|
|
|
|
const m = scaleMoney ? n : 1;
|
2022-07-07 23:28:23 +02:00
|
|
|
return {
|
2022-07-28 02:37:32 +02:00
|
|
|
money: w.money * m,
|
2022-07-13 04:43:03 +02:00
|
|
|
reputation: w.reputation * n,
|
2022-07-07 23:28:23 +02:00
|
|
|
hackExp: w.hackExp * n,
|
|
|
|
strExp: w.strExp * n,
|
|
|
|
defExp: w.defExp * n,
|
|
|
|
dexExp: w.dexExp * n,
|
|
|
|
agiExp: w.agiExp * n,
|
|
|
|
chaExp: w.chaExp * n,
|
|
|
|
intExp: w.intExp * n,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-07-28 02:37:32 +02:00
|
|
|
export const applyWorkStats = (
|
|
|
|
target: IPerson,
|
|
|
|
workStats: WorkStats,
|
|
|
|
cycles: number,
|
|
|
|
source: string,
|
|
|
|
): WorkStats => {
|
|
|
|
const expStats = applyWorkStatsExp(target, workStats, cycles);
|
2022-07-07 23:28:23 +02:00
|
|
|
const gains = {
|
|
|
|
money: workStats.money * cycles,
|
2022-07-13 04:43:03 +02:00
|
|
|
reputation: 0,
|
2022-07-28 02:37:32 +02:00
|
|
|
hackExp: expStats.hackExp,
|
|
|
|
strExp: expStats.strExp,
|
|
|
|
defExp: expStats.defExp,
|
|
|
|
dexExp: expStats.dexExp,
|
|
|
|
agiExp: expStats.agiExp,
|
|
|
|
chaExp: expStats.chaExp,
|
|
|
|
intExp: expStats.intExp,
|
|
|
|
};
|
2022-09-06 15:07:12 +02:00
|
|
|
Player.gainMoney(gains.money, source);
|
2022-07-28 02:37:32 +02:00
|
|
|
|
|
|
|
return gains;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const applyWorkStatsExp = (target: IPerson, workStats: WorkStats, cycles: number): WorkStats => {
|
|
|
|
const gains = {
|
|
|
|
money: 0,
|
|
|
|
reputation: 0,
|
2022-07-13 04:43:03 +02:00
|
|
|
hackExp: workStats.hackExp * cycles,
|
|
|
|
strExp: workStats.strExp * cycles,
|
|
|
|
defExp: workStats.defExp * cycles,
|
|
|
|
dexExp: workStats.dexExp * cycles,
|
|
|
|
agiExp: workStats.agiExp * cycles,
|
|
|
|
chaExp: workStats.chaExp * cycles,
|
|
|
|
intExp: workStats.intExp * cycles,
|
2022-07-07 23:28:23 +02:00
|
|
|
};
|
2022-07-28 02:37:32 +02:00
|
|
|
target.gainHackingExp(gains.hackExp);
|
|
|
|
target.gainStrengthExp(gains.strExp);
|
|
|
|
target.gainDefenseExp(gains.defExp);
|
|
|
|
target.gainDexterityExp(gains.dexExp);
|
|
|
|
target.gainAgilityExp(gains.agiExp);
|
|
|
|
target.gainCharismaExp(gains.chaExp);
|
|
|
|
target.gainIntelligenceExp(gains.intExp);
|
2022-07-07 23:28:23 +02:00
|
|
|
return gains;
|
|
|
|
};
|