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