Merge pull request #4087 from phyzical/feature/add-back-api-export

API BACKUP: add singularity function for exporting game save back
This commit is contained in:
hydroflame 2022-09-23 00:34:23 -03:00 committed by GitHub
commit ac1a057d35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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";
import { calculateCrimeWorkStats } from "../Work/formulas/Crime"; import { calculateCrimeWorkStats } from "../Work/formulas/Crime";
export function NetscriptSingularity(): InternalAPI<ISingularity> { export function NetscriptSingularity(): InternalAPI<ISingularity> {
@ -1317,5 +1319,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.
* *