mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-27 00:17:32 +01:00
commit
c4617e4b9a
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "bitburner",
|
||||
"version": "0.52.9",
|
||||
"version": "0.53.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"version": "0.52.9",
|
||||
"version": "0.53.0",
|
||||
"hasInstallScript": true,
|
||||
"license": "SEE LICENSE IN license.txt",
|
||||
"dependencies": {
|
||||
|
@ -10,6 +10,7 @@ import { Warehouse } from "./Warehouse";
|
||||
import { CorporationUnlockUpgrade } from "./data/CorporationUnlockUpgrades";
|
||||
import { CorporationUpgrade } from "./data/CorporationUpgrades";
|
||||
import { Cities } from "../Locations/Cities";
|
||||
import { EmployeePositions } from "./EmployeePositions";
|
||||
|
||||
export function NewIndustry(corporation: ICorporation, industry: string, name: string): void {
|
||||
for (let i = 0; i < corporation.divisions.length; ++i) {
|
||||
@ -232,3 +233,47 @@ export function BuyMaterial(material: Material, amt: number): void {
|
||||
}
|
||||
material.buy = amt;
|
||||
}
|
||||
|
||||
export function AssignJob(employee: Employee, job: string): void {
|
||||
if (!Object.values(EmployeePositions).includes(job)) throw new Error(`'${job}' is not a valid job.`);
|
||||
employee.pos = job;
|
||||
}
|
||||
|
||||
export function UpgradeOfficeSize(corp: ICorporation, office: OfficeSpace, size: number): void {
|
||||
const initialPriceMult = Math.round(office.size / CorporationConstants.OfficeInitialSize);
|
||||
const costMultiplier = 1.09;
|
||||
// Calculate cost to upgrade size by 15 employees
|
||||
let mult = 0;
|
||||
for (let i = 0; i < size / CorporationConstants.OfficeInitialSize; ++i) {
|
||||
mult += Math.pow(costMultiplier, initialPriceMult + i);
|
||||
}
|
||||
const cost = CorporationConstants.OfficeInitialCost * mult;
|
||||
console.log(cost);
|
||||
if (corp.funds.lt(cost)) return;
|
||||
office.size += size;
|
||||
corp.funds = corp.funds.minus(cost);
|
||||
}
|
||||
|
||||
export function ThrowParty(corp: ICorporation, office: OfficeSpace, costPerEmployee: number): number {
|
||||
const totalCost = costPerEmployee * office.employees.length;
|
||||
if (corp.funds.lt(totalCost)) return 0;
|
||||
corp.funds = corp.funds.minus(totalCost);
|
||||
let mult = 0;
|
||||
for (let i = 0; i < office.employees.length; ++i) {
|
||||
mult = office.employees[i].throwParty(costPerEmployee);
|
||||
}
|
||||
|
||||
return mult;
|
||||
}
|
||||
|
||||
export function PurchaseWarehouse(corp: ICorporation, division: IIndustry, city: string): void {
|
||||
if (corp.funds.lt(CorporationConstants.WarehouseInitialCost)) return;
|
||||
if (division.warehouses[city] instanceof Warehouse) return;
|
||||
division.warehouses[city] = new Warehouse({
|
||||
corp: corp,
|
||||
industry: division,
|
||||
loc: city,
|
||||
size: CorporationConstants.WarehouseInitialSize,
|
||||
});
|
||||
corp.funds = corp.funds.minus(CorporationConstants.WarehouseInitialCost);
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import { Money } from "../../ui/React/Money";
|
||||
import { MoneyCost } from "./MoneyCost";
|
||||
import { isRelevantMaterial } from "./Helpers";
|
||||
import { IndustryProductEquation } from "./IndustryProductEquation";
|
||||
import { PurchaseWarehouse } from "../Actions";
|
||||
|
||||
interface IProductProps {
|
||||
corp: ICorporation;
|
||||
@ -603,18 +604,8 @@ export function IndustryWarehouse(props: IProps): React.ReactElement {
|
||||
}
|
||||
|
||||
function purchaseWarehouse(division: IIndustry, city: string): void {
|
||||
if (props.corp.funds.lt(CorporationConstants.WarehouseInitialCost)) {
|
||||
dialogBoxCreate("You do not have enough funds to do this!");
|
||||
} else {
|
||||
division.warehouses[city] = new Warehouse({
|
||||
corp: props.corp,
|
||||
industry: division,
|
||||
loc: city,
|
||||
size: CorporationConstants.WarehouseInitialSize,
|
||||
});
|
||||
props.corp.funds = props.corp.funds.minus(CorporationConstants.WarehouseInitialCost);
|
||||
props.rerender();
|
||||
}
|
||||
PurchaseWarehouse(props.corp, division, city);
|
||||
props.rerender();
|
||||
}
|
||||
|
||||
if (props.warehouse instanceof Warehouse) {
|
||||
@ -622,7 +613,11 @@ export function IndustryWarehouse(props: IProps): React.ReactElement {
|
||||
} else {
|
||||
return (
|
||||
<div className={"cmpy-mgmt-warehouse-panel"}>
|
||||
<button className={"std-button"} onClick={() => purchaseWarehouse(props.division, props.currentCity)}>
|
||||
<button
|
||||
className={"std-button"}
|
||||
onClick={() => purchaseWarehouse(props.division, props.currentCity)}
|
||||
disabled={props.corp.funds.lt(CorporationConstants.WarehouseInitialCost)}
|
||||
>
|
||||
Purchase Warehouse (
|
||||
<MoneyCost money={CorporationConstants.WarehouseInitialCost} corp={props.corp} />)
|
||||
</button>
|
||||
|
@ -4,6 +4,7 @@ import { numeralWrapper } from "../../ui/numeralFormat";
|
||||
import { dialogBoxCreate } from "../../../utils/DialogBox";
|
||||
import { OfficeSpace } from "../OfficeSpace";
|
||||
import { ICorporation } from "../ICorporation";
|
||||
import { ThrowParty } from "../Actions";
|
||||
|
||||
interface IProps {
|
||||
office: OfficeSpace;
|
||||
@ -26,11 +27,7 @@ export function ThrowPartyPopup(props: IProps): React.ReactElement {
|
||||
if (props.corp.funds.lt(totalCost)) {
|
||||
dialogBoxCreate("You don't have enough company funds to throw a party!");
|
||||
} else {
|
||||
props.corp.funds = props.corp.funds.minus(totalCost);
|
||||
let mult = 0;
|
||||
for (let i = 0; i < props.office.employees.length; ++i) {
|
||||
mult = props.office.employees[i].throwParty(cost);
|
||||
}
|
||||
const mult = ThrowParty(props.corp, props.office, cost);
|
||||
dialogBoxCreate(
|
||||
"You threw a party for the office! The morale and happiness " +
|
||||
"of each employee increased by " +
|
||||
|
@ -6,6 +6,7 @@ import { CorporationConstants } from "../data/Constants";
|
||||
import { OfficeSpace } from "../OfficeSpace";
|
||||
import { ICorporation } from "../ICorporation";
|
||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
import { UpgradeOfficeSize } from "../Actions";
|
||||
|
||||
interface IProps {
|
||||
office: OfficeSpace;
|
||||
@ -48,8 +49,7 @@ export function UpgradeOfficeSizePopup(props: IProps): React.ReactElement {
|
||||
if (props.corp.funds.lt(cost)) {
|
||||
dialogBoxCreate("You don't have enough company funds to purchase this upgrade!");
|
||||
} else {
|
||||
props.office.size += size;
|
||||
props.corp.funds = props.corp.funds.minus(cost);
|
||||
UpgradeOfficeSize(props.corp, props.office, size);
|
||||
dialogBoxCreate("Office space increased! It can now hold " + props.office.size + " employees");
|
||||
props.rerender();
|
||||
}
|
||||
|
@ -27,6 +27,9 @@ import {
|
||||
SellProduct,
|
||||
SetSmartSupply,
|
||||
BuyMaterial,
|
||||
AssignJob,
|
||||
UpgradeOfficeSize,
|
||||
ThrowParty,
|
||||
} from "./Corporation/Actions";
|
||||
import { CorporationUnlockUpgrades } from "./Corporation/data/CorporationUnlockUpgrades";
|
||||
import { CorporationUpgrades } from "./Corporation/data/CorporationUpgrades";
|
||||
@ -561,6 +564,14 @@ function NetscriptFunctions(workerScript) {
|
||||
return division;
|
||||
}
|
||||
|
||||
function getOffice(divisionName, cityName) {
|
||||
const division = getDivision(divisionName);
|
||||
if (!(cityName in division.offices)) throw new Error(`Invalid city name '${cityName}'`);
|
||||
const office = division.offices[cityName];
|
||||
if (office === 0) throw new Error(`${division.name} has not expanded to '${cityName}'`);
|
||||
return office;
|
||||
}
|
||||
|
||||
function getWarehouse(divisionName, cityName) {
|
||||
const division = getDivision(divisionName);
|
||||
if (!(cityName in division.warehouses)) throw new Error(`Invalid city name '${cityName}'`);
|
||||
@ -583,6 +594,13 @@ function NetscriptFunctions(workerScript) {
|
||||
return product;
|
||||
}
|
||||
|
||||
function getEmployee(divisionName, cityName, employeeName) {
|
||||
const office = getOffice(divisionName, cityName);
|
||||
const employee = office.employees.find((e) => e.name === employeeName);
|
||||
if (employee === undefined) throw new Error(`Invalid employee name: '${employeeName}'`);
|
||||
return employee;
|
||||
}
|
||||
|
||||
const runAfterReset = function (cbScript = null) {
|
||||
//Run a script after reset
|
||||
if (cbScript && isString(cbScript)) {
|
||||
@ -4479,44 +4497,64 @@ function NetscriptFunctions(workerScript) {
|
||||
},
|
||||
}, // End Bladeburner
|
||||
|
||||
// corporation: {
|
||||
// expandIndustry: function (industryName, divisionName) {
|
||||
// NewIndustry(Player.corporation, industryName, divisionName);
|
||||
// },
|
||||
// expandCity: function (divisionName, cityName) {
|
||||
// const division = getDivision(divisionName);
|
||||
// NewCity(Player.corporation, division, cityName);
|
||||
// },
|
||||
// unlockUpgrade: function (upgradeName) {
|
||||
// const upgrade = Object.values(CorporationUnlockUpgrades).find((upgrade) => upgrade[2] === upgradeName);
|
||||
// if (upgrade === undefined) throw new Error("No upgrade named '${upgradeName}'");
|
||||
// UnlockUpgrade(Player.corporation, upgrade);
|
||||
// },
|
||||
// levelUpgrade: function (upgradeName) {
|
||||
// const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade[4] === upgradeName);
|
||||
// if (upgrade === undefined) throw new Error("No upgrade named '${upgradeName}'");
|
||||
// LevelUpgrade(Player.corporation, upgrade);
|
||||
// },
|
||||
// issueDividends: function (percent) {
|
||||
// IssueDividends(Player.corporation, percent);
|
||||
// },
|
||||
// sellMaterial: function (divisionName, cityName, materialName, amt, price) {
|
||||
// const material = getMaterial(divisionName, cityName, materialName);
|
||||
// SellMaterial(material, amt, price);
|
||||
// },
|
||||
// sellProduct: function (divisionName, cityName, productName, amt, price, all) {
|
||||
// const product = getProduct(divisionName, productName);
|
||||
// SellProduct(product, cityName, amt, price, all);
|
||||
// },
|
||||
// setSmartSupply: function (divisionName, cityName, enabled) {
|
||||
// const warehouse = getWarehouse(divisionName, cityName);
|
||||
// SetSmartSupply(warehouse, enabled);
|
||||
// },
|
||||
// buyMaterial: function (divisionName, cityName, materialName, amt) {
|
||||
// const material = getMaterial(divisionName, cityName, materialName);
|
||||
// BuyMaterial(material, amt);
|
||||
// },
|
||||
// }, // End Corporation API
|
||||
corporation: {
|
||||
expandIndustry: function (industryName, divisionName) {
|
||||
NewIndustry(Player.corporation, industryName, divisionName);
|
||||
},
|
||||
expandCity: function (divisionName, cityName) {
|
||||
const division = getDivision(divisionName);
|
||||
NewCity(Player.corporation, division, cityName);
|
||||
},
|
||||
unlockUpgrade: function (upgradeName) {
|
||||
const upgrade = Object.values(CorporationUnlockUpgrades).find((upgrade) => upgrade[2] === upgradeName);
|
||||
if (upgrade === undefined) throw new Error("No upgrade named '${upgradeName}'");
|
||||
UnlockUpgrade(Player.corporation, upgrade);
|
||||
},
|
||||
levelUpgrade: function (upgradeName) {
|
||||
const upgrade = Object.values(CorporationUpgrades).find((upgrade) => upgrade[4] === upgradeName);
|
||||
if (upgrade === undefined) throw new Error("No upgrade named '${upgradeName}'");
|
||||
LevelUpgrade(Player.corporation, upgrade);
|
||||
},
|
||||
issueDividends: function (percent) {
|
||||
IssueDividends(Player.corporation, percent);
|
||||
},
|
||||
sellMaterial: function (divisionName, cityName, materialName, amt, price) {
|
||||
const material = getMaterial(divisionName, cityName, materialName);
|
||||
SellMaterial(material, amt, price);
|
||||
},
|
||||
sellProduct: function (divisionName, cityName, productName, amt, price, all) {
|
||||
const product = getProduct(divisionName, productName);
|
||||
SellProduct(product, cityName, amt, price, all);
|
||||
},
|
||||
setSmartSupply: function (divisionName, cityName, enabled) {
|
||||
const warehouse = getWarehouse(divisionName, cityName);
|
||||
SetSmartSupply(warehouse, enabled);
|
||||
},
|
||||
buyMaterial: function (divisionName, cityName, materialName, amt) {
|
||||
const material = getMaterial(divisionName, cityName, materialName);
|
||||
BuyMaterial(material, amt);
|
||||
},
|
||||
employees: function (divisionName, cityName) {
|
||||
const office = getOffice(divisionName, cityName);
|
||||
return office.employees.map((e) => Object.assign({}, e));
|
||||
},
|
||||
assignJob: function (divisionName, cityName, employeeName, job) {
|
||||
const employee = getEmployee(divisionName, cityName, employeeName);
|
||||
AssignJob(employee, job);
|
||||
},
|
||||
hireEmployee: function (divisionName, cityName) {
|
||||
const office = getOffice(divisionName, cityName);
|
||||
office.hireRandomEmployee();
|
||||
},
|
||||
upgradeOfficeSize: function (divisionName, cityName, size) {
|
||||
const office = getOffice(divisionName, cityName);
|
||||
UpgradeOfficeSize(Player.corporation, office, size);
|
||||
},
|
||||
throwParty: function (divisionName, cityName, costPerEmployee) {
|
||||
const office = getOffice(divisionName, cityName);
|
||||
ThrowParty(Player.corporation, office, costPerEmployee);
|
||||
},
|
||||
}, // End Corporation API
|
||||
|
||||
// Coding Contract API
|
||||
codingcontract: {
|
||||
|
Loading…
Reference in New Issue
Block a user