fixes and pr comments

This commit is contained in:
phyzical 2022-04-11 21:54:50 +08:00
parent 43248bbc42
commit a66b5bfb69
3 changed files with 11 additions and 5 deletions

@ -307,7 +307,7 @@ export function SpecialLocation(props: IProps): React.ReactElement {
return renderGrafting(); return renderGrafting();
} }
case LocationName.Sector12CityHall: { case LocationName.Sector12CityHall: {
return (BitNodeMultipliers.CorporationSoftCap >= 0.15 && <></>) || <CreateCorporation />; return (BitNodeMultipliers.CorporationSoftCap < 0.15 && <></>) || <CreateCorporation />;
} }
case LocationName.Sector12NSA: { case LocationName.Sector12NSA: {
return renderBladeburner(); return renderBladeburner();

@ -79,7 +79,7 @@ export function NetscriptCorporation(
if (!corporationName) return false; if (!corporationName) return false;
if (player.bitNodeN !== 3 && !selfFund) throw new Error("cannot use seed funds outside of BitNode 3"); if (player.bitNodeN !== 3 && !selfFund) throw new Error("cannot use seed funds outside of BitNode 3");
if (BitNodeMultipliers.CorporationSoftCap < 0.15) if (BitNodeMultipliers.CorporationSoftCap < 0.15)
throw new Error(`You cannot create a corporation for Bitnode ${player.bitNodeN}`); throw new Error(`You cannot create a corporation in Bitnode ${player.bitNodeN}`);
if (selfFund) { if (selfFund) {
if (!player.canAfford(150e9)) return false; if (!player.canAfford(150e9)) return false;
@ -322,6 +322,9 @@ export function NetscriptCorporation(
const divisionName = helper.string("getUpgradeWarehouseCost", "divisionName", _divisionName); const divisionName = helper.string("getUpgradeWarehouseCost", "divisionName", _divisionName);
const cityName = helper.city("getUpgradeWarehouseCost", "cityName", _cityName); const cityName = helper.city("getUpgradeWarehouseCost", "cityName", _cityName);
const amt = helper.number("getUpgradeWarehouseCost", "amount", _amt); const amt = helper.number("getUpgradeWarehouseCost", "amount", _amt);
if (amt < 1) {
throw helper.makeRuntimeErrorMsg(`corporation.getUpgradeWarehouseCost`, "You must provide a positive number");
}
const warehouse = getWarehouse(divisionName, cityName); const warehouse = getWarehouse(divisionName, cityName);
return UpgradeWarehouseCost(warehouse, amt); return UpgradeWarehouseCost(warehouse, amt);
}, },
@ -384,12 +387,15 @@ export function NetscriptCorporation(
const corporation = getCorporation(); const corporation = getCorporation();
PurchaseWarehouse(corporation, getDivision(divisionName), cityName); PurchaseWarehouse(corporation, getDivision(divisionName), cityName);
}, },
upgradeWarehouse: function (_divisionName: unknown, _cityName: unknown, _amt: unknown): void { upgradeWarehouse: function (_divisionName: unknown, _cityName: unknown, _amt: unknown = 1): void {
checkAccess("upgradeWarehouse", 7); checkAccess("upgradeWarehouse", 7);
const divisionName = helper.string("upgradeWarehouse", "divisionName", _divisionName); const divisionName = helper.string("upgradeWarehouse", "divisionName", _divisionName);
const cityName = helper.city("upgradeWarehouse", "cityName", _cityName); const cityName = helper.city("upgradeWarehouse", "cityName", _cityName);
const amt = helper.number("upgradeWarehouse", "amount", _amt); const amt = helper.number("upgradeWarehouse", "amount", _amt);
const corporation = getCorporation(); const corporation = getCorporation();
if (amt < 1) {
throw helper.makeRuntimeErrorMsg(`corporation.upgradeWarehouse`, "You must provide a positive number");
}
UpgradeWarehouse(corporation, getDivision(divisionName), getWarehouse(divisionName, cityName), amt); UpgradeWarehouse(corporation, getDivision(divisionName), getWarehouse(divisionName, cityName), amt);
}, },
sellMaterial: function ( sellMaterial: function (

@ -6663,7 +6663,7 @@ export interface WarehouseAPI {
* @param cityName - Name of the city * @param cityName - Name of the city
* @param amt - amount of upgrades defaults to 1 * @param amt - amount of upgrades defaults to 1
*/ */
upgradeWarehouse(divisionName: string, cityName: string, amt: number): void; upgradeWarehouse(divisionName: string, cityName: string, amt?: number): void;
/** /**
* Create a new product * Create a new product
* @param divisionName - Name of the division * @param divisionName - Name of the division
@ -6707,7 +6707,7 @@ export interface WarehouseAPI {
* @param amt - amount of upgrades defaults to 1 * @param amt - amount of upgrades defaults to 1
* @returns cost to upgrade * @returns cost to upgrade
*/ */
getUpgradeWarehouseCost(adivisionName: any, acityName: any, amt: number): number; getUpgradeWarehouseCost(adivisionName: any, acityName: any, amt?: number): number;
/** /**
* Check if you have a warehouse in city * Check if you have a warehouse in city
* @returns true if warehouse is present, false if not * @returns true if warehouse is present, false if not