Skip to content

Commit

Permalink
Merge pull request #4084 from Rasmoh/expose_exports
Browse files Browse the repository at this point in the history
CORPORATION API: FIX #3655 Expose exports from Material
  • Loading branch information
hydroflame authored Sep 23, 2022
2 parents 4f64d3e + cc0fd19 commit a8e640e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/NetscriptFunctions/Corporation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,9 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
const materialName = helpers.string(ctx, "materialName", _materialName);
const material = getMaterial(divisionName, cityName, materialName);
const corporation = getCorporation();
const exports = material.exp.map((e) => {
return { div: e.ind, loc: e.city, amt: e.amt };
});
return {
cost: material.bCost,
sCost: material.sCost,
Expand All @@ -370,6 +373,7 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
cmp: corporation.unlockUpgrades[3] ? material.cmp : undefined,
prod: material.prd,
sell: material.sll,
exp: exports,
};
},
getProduct:
Expand Down
17 changes: 16 additions & 1 deletion src/ScriptEditor/NetscriptDefinitions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7233,10 +7233,25 @@ interface Material {
prod: number;
/** Amount of material sold */
sell: number;
/** cost to buy material */
/** Cost to buy material */
cost: number;
/** Sell cost, can be "MP+5" */
sCost: string | number;
/** Export orders */
exp: Export[];
}

/**
* Export order for a material
* @public
*/
interface Export {
/** Division the material is being exported to */
div: string;
/** City the material is being exported to */
loc: string;
/** Amount of material exported */
amt: string;
}

/**
Expand Down

0 comments on commit a8e640e

Please sign in to comment.