add singularity function for exporting game save

This commit is contained in:
phyzical 2022-09-07 16:11:51 +08:00
parent 2592c6ccd8
commit ca2f1a62a5
No known key found for this signature in database
GPG Key ID: 91E97494BCA22BCF
3 changed files with 35 additions and 0 deletions

@ -205,6 +205,8 @@ const singularity = {
installAugmentations: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost), installAugmentations: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost),
isFocused: SF4Cost(0.1), isFocused: SF4Cost(0.1),
setFocus: SF4Cost(0.1), setFocus: SF4Cost(0.1),
exportGame: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost / 2),
exportGameBonus: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost / 4),
b1tflum3: SF4Cost(16), b1tflum3: SF4Cost(16),
destroyW0r1dD43m0n: SF4Cost(32), destroyW0r1dD43m0n: SF4Cost(32),
getCurrentWork: SF4Cost(0.5), getCurrentWork: SF4Cost(0.5),

@ -53,6 +53,8 @@ import { CreateProgramWork, isCreateProgramWork } from "../Work/CreateProgramWor
import { FactionWork } from "../Work/FactionWork"; import { FactionWork } from "../Work/FactionWork";
import { FactionWorkType } from "../Work/data/FactionWorkType"; import { FactionWorkType } from "../Work/data/FactionWorkType";
import { CompanyWork } from "../Work/CompanyWork"; import { CompanyWork } from "../Work/CompanyWork";
import { canGetBonus, onExport } from "../ExportBonus";
import { saveObject } from "../SaveObject";
export function NetscriptSingularity(): InternalAPI<ISingularity> { export function NetscriptSingularity(): InternalAPI<ISingularity> {
const getAugmentation = function (ctx: NetscriptContext, name: string): Augmentation { const getAugmentation = function (ctx: NetscriptContext, name: string): Augmentation {
@ -1304,5 +1306,14 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
if (!player.currentWork) return null; if (!player.currentWork) return null;
return player.currentWork.APICopy(); return player.currentWork.APICopy();
}, },
exportGame: (ctx: NetscriptContext) => (): void => {
helpers.checkSingularityAccess(ctx);
onExport(player);
return saveObject.exportGame();
},
exportGameBonus: (ctx: NetscriptContext) => (): boolean => {
helpers.checkSingularityAccess(ctx);
return canGetBonus();
},
}; };
} }

@ -1496,6 +1496,28 @@ export interface TIX {
* @public * @public
*/ */
export interface Singularity { export interface Singularity {
/**
* Backup game save.
* @remarks
* RAM cost: 1 GB * 16/4/1
*
*
* This function will automatically opens the backup save prompt and claim the free faction favour if available.
*
*/
exportGame(): void;
/**
* Returns Backup save bonus availability.
* @remarks
* RAM cost: 0.5 GB * 16/4/1
*
*
* This function will check if there is a bonus for backing up your save.
*
*/
exportGameBonus(): boolean;
/** /**
* Take university class. * Take university class.
* *