mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-30 09:57:32 +01:00
rename functions in staneks gift
This commit is contained in:
parent
6e12e3a85b
commit
443b0b6a89
@ -227,7 +227,7 @@ export class Gang implements IGang {
|
|||||||
AllGangs[thisGang].territory += territoryGain;
|
AllGangs[thisGang].territory += territoryGain;
|
||||||
if (AllGangs[thisGang].territory > 0.999) AllGangs[thisGang].territory = 1;
|
if (AllGangs[thisGang].territory > 0.999) AllGangs[thisGang].territory = 1;
|
||||||
AllGangs[otherGang].territory -= territoryGain;
|
AllGangs[otherGang].territory -= territoryGain;
|
||||||
if (AllGangs[thisGang].territory < 0.001) AllGangs[thisGang].territory = 0;
|
if (AllGangs[thisGang].territory) AllGangs[thisGang].territory = 0;
|
||||||
if (thisGang === gangName) {
|
if (thisGang === gangName) {
|
||||||
this.clash(true); // Player won
|
this.clash(true); // Player won
|
||||||
AllGangs[otherGang].power *= 1 / 1.01;
|
AllGangs[otherGang].power *= 1 / 1.01;
|
||||||
|
@ -22,28 +22,29 @@ export function NetscriptStanek(player: IPlayer, workerScript: WorkerScript, hel
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
width: function (): number {
|
giftWidth: function (): number {
|
||||||
helper.updateDynamicRam("width", getRamCost(player, "stanek", "width"));
|
helper.updateDynamicRam("giftWidth", getRamCost(player, "stanek", "giftWidth"));
|
||||||
checkStanekAPIAccess("width");
|
checkStanekAPIAccess("giftWidth");
|
||||||
return staneksGift.width();
|
return staneksGift.width();
|
||||||
},
|
},
|
||||||
height: function (): number {
|
giftHeight: function (): number {
|
||||||
helper.updateDynamicRam("height", getRamCost(player, "stanek", "height"));
|
helper.updateDynamicRam("giftHeight", getRamCost(player, "stanek", "giftHeight"));
|
||||||
checkStanekAPIAccess("height");
|
checkStanekAPIAccess("giftHeight");
|
||||||
return staneksGift.height();
|
return staneksGift.height();
|
||||||
},
|
},
|
||||||
charge: function (_rootX: unknown, _rootY: unknown): Promise<void> {
|
chargeFragment: function (_rootX: unknown, _rootY: unknown): Promise<void> {
|
||||||
const rootX = helper.number("stanek.charge", "rootX", _rootX);
|
const rootX = helper.number("stanek.chargeFragment", "rootX", _rootX);
|
||||||
const rootY = helper.number("stanek.charge", "rootY", _rootY);
|
const rootY = helper.number("stanek.chargeFragment", "rootY", _rootY);
|
||||||
|
|
||||||
helper.updateDynamicRam("charge", getRamCost(player, "stanek", "charge"));
|
helper.updateDynamicRam("chargeFragment", getRamCost(player, "stanek", "chargeFragment"));
|
||||||
checkStanekAPIAccess("charge");
|
checkStanekAPIAccess("chargeFragment");
|
||||||
const fragment = staneksGift.findFragment(rootX, rootY);
|
const fragment = staneksGift.findFragment(rootX, rootY);
|
||||||
if (!fragment) throw helper.makeRuntimeErrorMsg("stanek.charge", `No fragment with root (${rootX}, ${rootY}).`);
|
if (!fragment)
|
||||||
|
throw helper.makeRuntimeErrorMsg("stanek.chargeFragment", `No fragment with root (${rootX}, ${rootY}).`);
|
||||||
const time = staneksGift.inBonus() ? 200 : 1000;
|
const time = staneksGift.inBonus() ? 200 : 1000;
|
||||||
return netscriptDelay(time, workerScript).then(function () {
|
return netscriptDelay(time, workerScript).then(function () {
|
||||||
const charge = staneksGift.charge(player, fragment, workerScript.scriptRef.threads);
|
const charge = staneksGift.charge(player, fragment, workerScript.scriptRef.threads);
|
||||||
workerScript.log("stanek.charge", () => `Charged fragment for ${charge} charge.`);
|
workerScript.log("stanek.chargeFragment", () => `Charged fragment for ${charge} charge.`);
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -61,49 +62,49 @@ export function NetscriptStanek(player: IPlayer, workerScript: WorkerScript, hel
|
|||||||
return { ...af.copy(), ...af.fragment().copy() };
|
return { ...af.copy(), ...af.fragment().copy() };
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
clear: function (): void {
|
clearGift: function (): void {
|
||||||
helper.updateDynamicRam("clear", getRamCost(player, "stanek", "clear"));
|
helper.updateDynamicRam("clearGift", getRamCost(player, "stanek", "clearGift"));
|
||||||
checkStanekAPIAccess("clear");
|
checkStanekAPIAccess("clearGift");
|
||||||
workerScript.log("stanek.clear", () => `Cleared Stanek's Gift.`);
|
workerScript.log("stanek.clearGift", () => `Cleared Stanek's Gift.`);
|
||||||
staneksGift.clear();
|
staneksGift.clear();
|
||||||
},
|
},
|
||||||
canPlace: function (_rootX: unknown, _rootY: unknown, _rotation: unknown, _fragmentId: unknown): boolean {
|
canPlaceFragment: function (_rootX: unknown, _rootY: unknown, _rotation: unknown, _fragmentId: unknown): boolean {
|
||||||
const rootX = helper.number("stanek.canPlace", "rootX", _rootX);
|
const rootX = helper.number("stanek.canPlaceFragment", "rootX", _rootX);
|
||||||
const rootY = helper.number("stanek.canPlace", "rootY", _rootY);
|
const rootY = helper.number("stanek.canPlaceFragment", "rootY", _rootY);
|
||||||
const rotation = helper.number("stanek.canPlace", "rotation", _rotation);
|
const rotation = helper.number("stanek.canPlaceFragment", "rotation", _rotation);
|
||||||
const fragmentId = helper.number("stanek.canPlace", "fragmentId", _fragmentId);
|
const fragmentId = helper.number("stanek.canPlaceFragment", "fragmentId", _fragmentId);
|
||||||
helper.updateDynamicRam("canPlace", getRamCost(player, "stanek", "canPlace"));
|
helper.updateDynamicRam("canPlaceFragment", getRamCost(player, "stanek", "canPlaceFragment"));
|
||||||
checkStanekAPIAccess("canPlace");
|
checkStanekAPIAccess("canPlaceFragment");
|
||||||
const fragment = FragmentById(fragmentId);
|
const fragment = FragmentById(fragmentId);
|
||||||
if (!fragment) throw helper.makeRuntimeErrorMsg("stanek.canPlace", `Invalid fragment id: ${fragmentId}`);
|
if (!fragment) throw helper.makeRuntimeErrorMsg("stanek.canPlaceFragment", `Invalid fragment id: ${fragmentId}`);
|
||||||
const can = staneksGift.canPlace(rootX, rootY, rotation, fragment);
|
const can = staneksGift.canPlace(rootX, rootY, rotation, fragment);
|
||||||
return can;
|
return can;
|
||||||
},
|
},
|
||||||
place: function (_rootX: unknown, _rootY: unknown, _rotation: unknown, _fragmentId: unknown): boolean {
|
placeFragment: function (_rootX: unknown, _rootY: unknown, _rotation: unknown, _fragmentId: unknown): boolean {
|
||||||
const rootX = helper.number("stanek.place", "rootX", _rootX);
|
const rootX = helper.number("stanek.placeFragment", "rootX", _rootX);
|
||||||
const rootY = helper.number("stanek.place", "rootY", _rootY);
|
const rootY = helper.number("stanek.placeFragment", "rootY", _rootY);
|
||||||
const rotation = helper.number("stanek.place", "rotation", _rotation);
|
const rotation = helper.number("stanek.placeFragment", "rotation", _rotation);
|
||||||
const fragmentId = helper.number("stanek.place", "fragmentId", _fragmentId);
|
const fragmentId = helper.number("stanek.placeFragment", "fragmentId", _fragmentId);
|
||||||
helper.updateDynamicRam("place", getRamCost(player, "stanek", "place"));
|
helper.updateDynamicRam("placeFragment", getRamCost(player, "stanek", "placeFragment"));
|
||||||
checkStanekAPIAccess("place");
|
checkStanekAPIAccess("placeFragment");
|
||||||
const fragment = FragmentById(fragmentId);
|
const fragment = FragmentById(fragmentId);
|
||||||
if (!fragment) throw helper.makeRuntimeErrorMsg("stanek.place", `Invalid fragment id: ${fragmentId}`);
|
if (!fragment) throw helper.makeRuntimeErrorMsg("stanek.placeFragment", `Invalid fragment id: ${fragmentId}`);
|
||||||
return staneksGift.place(rootX, rootY, rotation, fragment);
|
return staneksGift.place(rootX, rootY, rotation, fragment);
|
||||||
},
|
},
|
||||||
get: function (_rootX: unknown, _rootY: unknown): IActiveFragment | undefined {
|
getFragment: function (_rootX: unknown, _rootY: unknown): IActiveFragment | undefined {
|
||||||
const rootX = helper.number("stanek.get", "rootX", _rootX);
|
const rootX = helper.number("stanek.getFragment", "rootX", _rootX);
|
||||||
const rootY = helper.number("stanek.get", "rootY", _rootY);
|
const rootY = helper.number("stanek.getFragment", "rootY", _rootY);
|
||||||
helper.updateDynamicRam("get", getRamCost(player, "stanek", "get"));
|
helper.updateDynamicRam("getFragment", getRamCost(player, "stanek", "getFragment"));
|
||||||
checkStanekAPIAccess("get");
|
checkStanekAPIAccess("getFragment");
|
||||||
const fragment = staneksGift.findFragment(rootX, rootY);
|
const fragment = staneksGift.findFragment(rootX, rootY);
|
||||||
if (fragment !== undefined) return fragment.copy();
|
if (fragment !== undefined) return fragment.copy();
|
||||||
return undefined;
|
return undefined;
|
||||||
},
|
},
|
||||||
remove: function (_rootX: unknown, _rootY: unknown): boolean {
|
removeFragment: function (_rootX: unknown, _rootY: unknown): boolean {
|
||||||
const rootX = helper.number("stanek.remove", "rootX", _rootX);
|
const rootX = helper.number("stanek.removeFragment", "rootX", _rootX);
|
||||||
const rootY = helper.number("stanek.remove", "rootY", _rootY);
|
const rootY = helper.number("stanek.removeFragment", "rootY", _rootY);
|
||||||
helper.updateDynamicRam("remove", getRamCost(player, "stanek", "remove"));
|
helper.updateDynamicRam("removeFragment", getRamCost(player, "stanek", "removeFragment"));
|
||||||
checkStanekAPIAccess("remove");
|
checkStanekAPIAccess("removeFragment");
|
||||||
return staneksGift.delete(rootX, rootY);
|
return staneksGift.delete(rootX, rootY);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
16
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
16
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -4066,14 +4066,14 @@ interface Stanek {
|
|||||||
* RAM cost: 0.4 GB
|
* RAM cost: 0.4 GB
|
||||||
* @returns The width of the gift.
|
* @returns The width of the gift.
|
||||||
*/
|
*/
|
||||||
width(): number;
|
giftWidth(): number;
|
||||||
/**
|
/**
|
||||||
* Stanek's Gift height.
|
* Stanek's Gift height.
|
||||||
* @remarks
|
* @remarks
|
||||||
* RAM cost: 0.4 GB
|
* RAM cost: 0.4 GB
|
||||||
* @returns The height of the gift.
|
* @returns The height of the gift.
|
||||||
*/
|
*/
|
||||||
height(): number;
|
giftHeight(): number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Charge a fragment, increasing its power.
|
* Charge a fragment, increasing its power.
|
||||||
@ -4083,7 +4083,7 @@ interface Stanek {
|
|||||||
* @param rootY - rootY Root Y against which to align the top left of the fragment.
|
* @param rootY - rootY Root Y against which to align the top left of the fragment.
|
||||||
* @returns Promise that lasts until the charge action is over.
|
* @returns Promise that lasts until the charge action is over.
|
||||||
*/
|
*/
|
||||||
charge(rootX: number, rootY: number): Promise<void>;
|
chargeFragment(rootX: number, rootY: number): Promise<void>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List possible fragments.
|
* List possible fragments.
|
||||||
@ -4108,7 +4108,7 @@ interface Stanek {
|
|||||||
* @remarks
|
* @remarks
|
||||||
* RAM cost: 0 GB
|
* RAM cost: 0 GB
|
||||||
*/
|
*/
|
||||||
clear(): void;
|
clearGift(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if fragment can be placed at specified location.
|
* Check if fragment can be placed at specified location.
|
||||||
@ -4121,7 +4121,7 @@ interface Stanek {
|
|||||||
* @param fragmentId - fragmentId ID of the fragment to place.
|
* @param fragmentId - fragmentId ID of the fragment to place.
|
||||||
* @returns true if the fragment can be placed at that position. false otherwise.
|
* @returns true if the fragment can be placed at that position. false otherwise.
|
||||||
*/
|
*/
|
||||||
canPlace(rootX: number, rootY: number, rotation: number, fragmentId: number): boolean;
|
canPlaceFragment(rootX: number, rootY: number, rotation: number, fragmentId: number): boolean;
|
||||||
/**
|
/**
|
||||||
* Place fragment on Stanek's Gift.
|
* Place fragment on Stanek's Gift.
|
||||||
* @remarks
|
* @remarks
|
||||||
@ -4133,7 +4133,7 @@ interface Stanek {
|
|||||||
* @param fragmentId - ID of the fragment to place.
|
* @param fragmentId - ID of the fragment to place.
|
||||||
* @returns true if the fragment can be placed at that position. false otherwise.
|
* @returns true if the fragment can be placed at that position. false otherwise.
|
||||||
*/
|
*/
|
||||||
place(rootX: number, rootY: number, rotation: number, fragmentId: number): boolean;
|
placeFragment(rootX: number, rootY: number, rotation: number, fragmentId: number): boolean;
|
||||||
/**
|
/**
|
||||||
* Get placed fragment at location.
|
* Get placed fragment at location.
|
||||||
* @remarks
|
* @remarks
|
||||||
@ -4143,7 +4143,7 @@ interface Stanek {
|
|||||||
* @param rootY - Y against which to align the top left of the fragment.
|
* @param rootY - Y against which to align the top left of the fragment.
|
||||||
* @returns The fragment at [rootX, rootY], if any.
|
* @returns The fragment at [rootX, rootY], if any.
|
||||||
*/
|
*/
|
||||||
get(rootX: number, rootY: number): ActiveFragment | undefined;
|
getFragment(rootX: number, rootY: number): ActiveFragment | undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove fragment at location.
|
* Remove fragment at location.
|
||||||
@ -4154,7 +4154,7 @@ interface Stanek {
|
|||||||
* @param rootY - Y against which to align the top left of the fragment.
|
* @param rootY - Y against which to align the top left of the fragment.
|
||||||
* @returns The fragment at [rootX, rootY], if any.
|
* @returns The fragment at [rootX, rootY], if any.
|
||||||
*/
|
*/
|
||||||
remove(rootX: number, rootY: number): boolean;
|
removeFragment(rootX: number, rootY: number): boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user