Fixing my previous mistakes

This commit is contained in:
Mughur 2022-08-26 00:27:39 +03:00
parent a6d4ef4147
commit 9d1b48e076
5 changed files with 34 additions and 32 deletions

@ -37,7 +37,7 @@ export function NetscriptCodingContract(): InternalAPI<ICodingContract> {
throw new Error("The answer provided was not a number, string, or array"); throw new Error("The answer provided was not a number, string, or array");
// Convert answer to string. // Convert answer to string.
const answerStr = typeof answer === 'string' ? answer : JSON.stringify(answer); const answerStr = typeof answer === "string" ? answer : JSON.stringify(answer);
const creward = contract.reward; const creward = contract.reward;
if (creward === null) throw new Error("Somehow solved a contract that didn't have a reward"); if (creward === null) throw new Error("Somehow solved a contract that didn't have a reward");

@ -5,8 +5,6 @@ import { applySleeveGains, Work, WorkType } from "./Work";
import { CONSTANTS } from "../../../Constants"; import { CONSTANTS } from "../../../Constants";
import { GeneralActions } from "../../../Bladeburner/data/GeneralActions"; import { GeneralActions } from "../../../Bladeburner/data/GeneralActions";
import { WorkStats } from "../../../Work/WorkStats"; import { WorkStats } from "../../../Work/WorkStats";
import { Contract } from "src/Bladeburner/Contract";
import { Contracts } from "src/Bladeburner/data/Contracts";
interface SleeveBladeburnerWorkParams { interface SleeveBladeburnerWorkParams {
type: string; type: string;
@ -38,20 +36,20 @@ export class SleeveBladeburnerWork extends Work {
this.cyclesWorked += cycles; this.cyclesWorked += cycles;
const actionIdent = player.bladeburner.getActionIdFromTypeAndName(this.actionType, this.actionName); const actionIdent = player.bladeburner.getActionIdFromTypeAndName(this.actionType, this.actionName);
if (!actionIdent) throw new Error(`Error getting ${this.actionName} action`); if (!actionIdent) throw new Error(`Error getting ${this.actionName} action`);
if (this.actionType === "Contracts"){ if (this.actionType === "Contracts") {
const action=player.bladeburner.getActionObject(actionIdent); const action = player.bladeburner.getActionObject(actionIdent);
if (!action) throw new Error(`Error getting ${this.actionName} action object`); if (!action) throw new Error(`Error getting ${this.actionName} action object`);
if (action.count<=0){ if (action.count <= 0) {
sleeve.stopWork(player); sleeve.stopWork(player);
return 0; return 0;
} }
} }
while (this.cyclesWorked > this.cyclesNeeded(player, sleeve)) { while (this.cyclesWorked > this.cyclesNeeded(player, sleeve)) {
if (this.actionType === "Contracts"){ if (this.actionType === "Contracts") {
const action=player.bladeburner.getActionObject(actionIdent); const action = player.bladeburner.getActionObject(actionIdent);
if (!action) throw new Error(`Error getting ${this.actionName} action object`); if (!action) throw new Error(`Error getting ${this.actionName} action object`);
if (action.count<=0){ if (action.count <= 0) {
sleeve.stopWork(player); sleeve.stopWork(player);
return 0; return 0;
} }
@ -63,7 +61,7 @@ export class SleeveBladeburnerWork extends Work {
if (!exp) throw new Error(`Somehow there was no exp for action ${this.actionType} ${this.actionName}`); if (!exp) throw new Error(`Somehow there was no exp for action ${this.actionType} ${this.actionName}`);
applySleeveGains(player, sleeve, exp, 1); applySleeveGains(player, sleeve, exp, 1);
} }
if (retValue.money>0)player.gainMoney(retValue.money,"sleeves") if (retValue.money > 0) player.gainMoney(retValue.money, "sleeves");
this.cyclesWorked -= this.cyclesNeeded(player, sleeve); this.cyclesWorked -= this.cyclesNeeded(player, sleeve);
} }
return 0; return 0;

@ -64,7 +64,7 @@ export class SleeveCrimeWork extends Work {
APICopy(): Record<string, unknown> { APICopy(): Record<string, unknown> {
return { return {
type: this.type, type: this.type,
name: this.crimeType crimeType : this.crimeType,
}; };
} }

@ -44,7 +44,11 @@ export class SleeveFactionWork extends Work {
[FactionWorkType.FIELD]: getFactionFieldWorkRepGain, [FactionWorkType.FIELD]: getFactionFieldWorkRepGain,
[FactionWorkType.SECURITY]: getFactionSecurityWorkRepGain, [FactionWorkType.SECURITY]: getFactionSecurityWorkRepGain,
}; };
return repFormulas[this.factionWorkType](sleeve, faction.favor) * sleeve.shockBonus(); return (
repFormulas[this.factionWorkType](sleeve, faction.favor) *
sleeve.shockBonus() *
BitNodeMultipliers.FactionWorkRepGain
);
} }
getFaction(): Faction { getFaction(): Faction {

@ -101,7 +101,7 @@ export function EarningsElement(props: IProps): React.ReactElement {
if (isSleeveCrimeWork(props.sleeve.currentWork)) { if (isSleeveCrimeWork(props.sleeve.currentWork)) {
const gains = props.sleeve.currentWork.getExp(); const gains = props.sleeve.currentWork.getExp();
data = [ data = [
[`Money:`, <Money money={5 * gains.money * BitNodeMultipliers.CrimeMoney} />], [`Money:`, <Money money={5 * gains.money} />],
[`Hacking Exp:`, `${numeralWrapper.formatExp(5 * gains.hackExp * BitNodeMultipliers.CrimeExpGain)}`], [`Hacking Exp:`, `${numeralWrapper.formatExp(5 * gains.hackExp * BitNodeMultipliers.CrimeExpGain)}`],
[`Strength Exp:`, `${numeralWrapper.formatExp(5 * gains.strExp * BitNodeMultipliers.CrimeExpGain)}`], [`Strength Exp:`, `${numeralWrapper.formatExp(5 * gains.strExp * BitNodeMultipliers.CrimeExpGain)}`],
[`Defense Exp:`, `${numeralWrapper.formatExp(5 * gains.defExp * BitNodeMultipliers.CrimeExpGain)}`], [`Defense Exp:`, `${numeralWrapper.formatExp(5 * gains.defExp * BitNodeMultipliers.CrimeExpGain)}`],
@ -114,25 +114,25 @@ export function EarningsElement(props: IProps): React.ReactElement {
const rates = props.sleeve.currentWork.calculateRates(player, props.sleeve); const rates = props.sleeve.currentWork.calculateRates(player, props.sleeve);
data = [ data = [
[`Money:`, <MoneyRate money={5 * rates.money} />], [`Money:`, <MoneyRate money={5 * rates.money} />],
[`Hacking Exp:`, `${numeralWrapper.formatExp(5 * rates.hackExp * BitNodeMultipliers.ClassGymExpGain)} / sec`], [`Hacking Exp:`, `${numeralWrapper.formatExp(5 * rates.hackExp)} / sec`],
[`Strength Exp:`, `${numeralWrapper.formatExp(5 * rates.strExp * BitNodeMultipliers.ClassGymExpGain)} / sec`], [`Strength Exp:`, `${numeralWrapper.formatExp(5 * rates.strExp)} / sec`],
[`Defense Exp:`, `${numeralWrapper.formatExp(5 * rates.defExp * BitNodeMultipliers.ClassGymExpGain)} / sec`], [`Defense Exp:`, `${numeralWrapper.formatExp(5 * rates.defExp)} / sec`],
[`Dexterity Exp:`, `${numeralWrapper.formatExp(5 * rates.dexExp * BitNodeMultipliers.ClassGymExpGain)} / sec`], [`Dexterity Exp:`, `${numeralWrapper.formatExp(5 * rates.dexExp)} / sec`],
[`Agility Exp:`, `${numeralWrapper.formatExp(5 * rates.agiExp * BitNodeMultipliers.ClassGymExpGain)} / sec`], [`Agility Exp:`, `${numeralWrapper.formatExp(5 * rates.agiExp)} / sec`],
[`Charisma Exp:`, `${numeralWrapper.formatExp(5 * rates.chaExp * BitNodeMultipliers.ClassGymExpGain)} / sec`], [`Charisma Exp:`, `${numeralWrapper.formatExp(5 * rates.chaExp)} / sec`],
]; ];
} }
if (isSleeveFactionWork(props.sleeve.currentWork)) { if (isSleeveFactionWork(props.sleeve.currentWork)) {
const rates = props.sleeve.currentWork.getExpRates(props.sleeve); const rates = props.sleeve.currentWork.getExpRates(props.sleeve);
const repGain = props.sleeve.currentWork.getReputationRate(props.sleeve); const repGain = props.sleeve.currentWork.getReputationRate(props.sleeve);
data = [ data = [
[`Hacking Exp:`, `${numeralWrapper.formatExp(5 * rates.hackExp * BitNodeMultipliers.FactionWorkExpGain)} / sec`], [`Hacking Exp:`, `${numeralWrapper.formatExp(5 * rates.hackExp)} / sec`],
[`Strength Exp:`, `${numeralWrapper.formatExp(5 * rates.strExp * BitNodeMultipliers.FactionWorkExpGain)} / sec`], [`Strength Exp:`, `${numeralWrapper.formatExp(5 * rates.strExp)} / sec`],
[`Defense Exp:`, `${numeralWrapper.formatExp(5 * rates.defExp * BitNodeMultipliers.FactionWorkExpGain)} / sec`], [`Defense Exp:`, `${numeralWrapper.formatExp(5 * rates.defExp)} / sec`],
[`Dexterity Exp:`, `${numeralWrapper.formatExp(5 * rates.dexExp * BitNodeMultipliers.FactionWorkExpGain)} / sec`], [`Dexterity Exp:`, `${numeralWrapper.formatExp(5 * rates.dexExp)} / sec`],
[`Agility Exp:`, `${numeralWrapper.formatExp(5 * rates.agiExp * BitNodeMultipliers.FactionWorkExpGain)} / sec`], [`Agility Exp:`, `${numeralWrapper.formatExp(5 * rates.agiExp)} / sec`],
[`Charisma Exp:`, `${numeralWrapper.formatExp(5 * rates.chaExp * BitNodeMultipliers.FactionWorkExpGain)} / sec`], [`Charisma Exp:`, `${numeralWrapper.formatExp(5 * rates.chaExp)} / sec`],
[`Reputation:`, <ReputationRate reputation={5 * repGain * BitNodeMultipliers.FactionWorkRepGain} />], [`Reputation:`, <ReputationRate reputation={repGain} />],
]; ];
} }
@ -140,12 +140,12 @@ export function EarningsElement(props: IProps): React.ReactElement {
const rates = props.sleeve.currentWork.getGainRates(player, props.sleeve); const rates = props.sleeve.currentWork.getGainRates(player, props.sleeve);
data = [ data = [
[`Money:`, <MoneyRate money={5 * rates.money * BitNodeMultipliers.CompanyWorkMoney} />], [`Money:`, <MoneyRate money={5 * rates.money * BitNodeMultipliers.CompanyWorkMoney} />],
[`Hacking Exp:`, `${numeralWrapper.formatExp(5 * rates.hackExp * BitNodeMultipliers.CompanyWorkExpGain)} / sec`], [`Hacking Exp:`, `${numeralWrapper.formatExp(5 * rates.hackExp)} / sec`],
[`Strength Exp:`, `${numeralWrapper.formatExp(5 * rates.strExp * BitNodeMultipliers.CompanyWorkExpGain)} / sec`], [`Strength Exp:`, `${numeralWrapper.formatExp(5 * rates.strExp)} / sec`],
[`Defense Exp:`, `${numeralWrapper.formatExp(5 * rates.defExp * BitNodeMultipliers.CompanyWorkExpGain)} / sec`], [`Defense Exp:`, `${numeralWrapper.formatExp(5 * rates.defExp)} / sec`],
[`Dexterity Exp:`, `${numeralWrapper.formatExp(5 * rates.dexExp * BitNodeMultipliers.CompanyWorkExpGain)} / sec`], [`Dexterity Exp:`, `${numeralWrapper.formatExp(5 * rates.dexExp)} / sec`],
[`Agility Exp:`, `${numeralWrapper.formatExp(5 * rates.agiExp * BitNodeMultipliers.CompanyWorkExpGain)} / sec`], [`Agility Exp:`, `${numeralWrapper.formatExp(5 * rates.agiExp)} / sec`],
[`Charisma Exp:`, `${numeralWrapper.formatExp(5 * rates.chaExp * BitNodeMultipliers.CompanyWorkExpGain)} / sec`], [`Charisma Exp:`, `${numeralWrapper.formatExp(5 * rates.chaExp)} / sec`],
[`Reputation:`, <ReputationRate reputation={5 * rates.reputation} />], [`Reputation:`, <ReputationRate reputation={5 * rates.reputation} />],
]; ];
} }