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