mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-20 14:43:48 +01:00
Merge pull request #3325 from danielyxie/stanek-formula-rework
stanek-formula-rework
This commit is contained in:
commit
1bf12d29b5
@ -10,7 +10,7 @@ export interface IActiveFragmentParams {
|
||||
|
||||
export class ActiveFragment {
|
||||
id: number;
|
||||
avgCharge: number;
|
||||
highestCharge: number;
|
||||
numCharge: number;
|
||||
rotation: number;
|
||||
x: number;
|
||||
@ -21,14 +21,14 @@ export class ActiveFragment {
|
||||
this.id = params.fragment.id;
|
||||
this.x = params.x;
|
||||
this.y = params.y;
|
||||
this.avgCharge = 0;
|
||||
this.highestCharge = 0;
|
||||
this.numCharge = 0;
|
||||
this.rotation = params.rotation;
|
||||
} else {
|
||||
this.id = -1;
|
||||
this.x = -1;
|
||||
this.y = -1;
|
||||
this.avgCharge = -1;
|
||||
this.highestCharge = -1;
|
||||
this.numCharge = -1;
|
||||
this.rotation = -1;
|
||||
}
|
||||
@ -71,7 +71,7 @@ export class ActiveFragment {
|
||||
const fragment = FragmentById(this.id);
|
||||
if (fragment === null) throw new Error("ActiveFragment id refers to unknown Fragment.");
|
||||
const c = new ActiveFragment({ x: this.x, y: this.y, rotation: this.rotation, fragment: fragment });
|
||||
c.avgCharge = this.avgCharge;
|
||||
c.highestCharge = this.highestCharge;
|
||||
c.numCharge = this.numCharge;
|
||||
return c;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { FactionNames } from '../Faction/data/FactionNames';
|
||||
import { FactionNames } from "../Faction/data/FactionNames";
|
||||
import { Fragment } from "./Fragment";
|
||||
import { ActiveFragment } from "./ActiveFragment";
|
||||
import { FragmentType } from "./FragmentType";
|
||||
@ -19,19 +19,23 @@ export class StaneksGift implements IStaneksGift {
|
||||
fragments: ActiveFragment[] = [];
|
||||
|
||||
baseSize(): number {
|
||||
return StanekConstants.BaseSize + BitNodeMultipliers.StaneksGiftExtraSize + Player.sourceFileLvl(13)
|
||||
return StanekConstants.BaseSize + BitNodeMultipliers.StaneksGiftExtraSize + Player.sourceFileLvl(13);
|
||||
}
|
||||
|
||||
width(): number {
|
||||
return Math.min(Math.floor(this.baseSize() / 2 + 1),StanekConstants.MaxSize);
|
||||
return Math.max(2, Math.min(Math.floor(this.baseSize() / 2 + 1), StanekConstants.MaxSize));
|
||||
}
|
||||
height(): number {
|
||||
return Math.min(Math.floor(this.baseSize() / 2 + 0.6),StanekConstants.MaxSize);
|
||||
return Math.max(3, Math.min(Math.floor(this.baseSize() / 2 + 0.6), StanekConstants.MaxSize));
|
||||
}
|
||||
|
||||
charge(player: IPlayer, af: ActiveFragment, threads: number): void {
|
||||
af.avgCharge = (af.numCharge * af.avgCharge + threads) / (af.numCharge + 1);
|
||||
af.numCharge++;
|
||||
if (threads > af.highestCharge) {
|
||||
af.numCharge = (af.highestCharge * af.numCharge) / threads + 1;
|
||||
af.highestCharge = threads;
|
||||
} else {
|
||||
af.numCharge += threads / af.highestCharge;
|
||||
}
|
||||
|
||||
const cotmg = Factions[FactionNames.ChurchOfTheMachineGod];
|
||||
cotmg.playerReputation += (player.faction_rep_mult * (Math.pow(threads, 0.95) * (cotmg.favor + 100))) / 1000;
|
||||
@ -66,7 +70,7 @@ export class StaneksGift implements IStaneksGift {
|
||||
for (const neighboor of neighboors) {
|
||||
boost *= neighboor.fragment().power;
|
||||
}
|
||||
return CalculateEffect(fragment.avgCharge, fragment.numCharge, fragment.fragment().power, boost);
|
||||
return CalculateEffect(fragment.highestCharge, fragment.numCharge, fragment.fragment().power, boost);
|
||||
}
|
||||
|
||||
canPlace(rootX: number, rootY: number, rotation: number, fragment: Fragment): boolean {
|
||||
@ -126,7 +130,7 @@ export class StaneksGift implements IStaneksGift {
|
||||
|
||||
clearCharge(): void {
|
||||
this.fragments.forEach((f) => {
|
||||
f.avgCharge = 0;
|
||||
f.highestCharge = 0;
|
||||
f.numCharge = 0;
|
||||
});
|
||||
}
|
||||
|
@ -48,9 +48,7 @@ export function FragmentInspector(props: IProps): React.ReactElement {
|
||||
}
|
||||
const f = props.fragment.fragment();
|
||||
|
||||
let charge = `${numeralWrapper.formatStaneksGiftCharge(props.fragment.avgCharge)} avg. * ${
|
||||
props.fragment.numCharge
|
||||
} times`;
|
||||
let charge = numeralWrapper.formatStaneksGiftCharge(props.fragment.highestCharge * props.fragment.numCharge);
|
||||
let effect = "N/A";
|
||||
// Boosters and cooling don't deal with heat.
|
||||
if ([FragmentType.Booster, FragmentType.None, FragmentType.Delete].includes(f.type)) {
|
||||
|
@ -27,20 +27,20 @@ export function Stanek(): React.ReactElement {
|
||||
|
||||
function addCharge(): void {
|
||||
staneksGift.fragments.forEach((f) => {
|
||||
f.avgCharge = 1e21;
|
||||
f.highestCharge = 1e21;
|
||||
f.numCharge = 1e21;
|
||||
});
|
||||
}
|
||||
|
||||
function modCharge(modify: number): (x: number) => void {
|
||||
return function (cycles: number): void {
|
||||
staneksGift.fragments.forEach((f) => (f.avgCharge += cycles * modify));
|
||||
staneksGift.fragments.forEach((f) => (f.highestCharge += cycles * modify));
|
||||
};
|
||||
}
|
||||
|
||||
function resetCharge(): void {
|
||||
staneksGift.fragments.forEach((f) => {
|
||||
f.avgCharge = 0;
|
||||
f.highestCharge = 0;
|
||||
f.numCharge = 0;
|
||||
});
|
||||
}
|
||||
|
2
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
2
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -4089,7 +4089,7 @@ export interface Fragment {
|
||||
*/
|
||||
export interface ActiveFragment {
|
||||
id: number;
|
||||
avgCharge: number;
|
||||
highestCharge: number;
|
||||
numCharge: number;
|
||||
rotation: number;
|
||||
x: number;
|
||||
|
Loading…
Reference in New Issue
Block a user