mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-13 03:03:54 +01:00
Fixed bug with Corporation bribing. Hoisted isRelevantMaterial() function in IndustryWarehouse up to a class method
This commit is contained in:
parent
c3bc6a0c28
commit
d75ff5d95b
@ -10,7 +10,8 @@ import { Corporation,
|
|||||||
OfficeInitialSize,
|
OfficeInitialSize,
|
||||||
SellSharesCooldown,
|
SellSharesCooldown,
|
||||||
WarehouseInitialCost,
|
WarehouseInitialCost,
|
||||||
WarehouseInitialSize } from "../Corporation";
|
WarehouseInitialSize,
|
||||||
|
BribeToRepRatio } from "../Corporation";
|
||||||
|
|
||||||
import { Industries,
|
import { Industries,
|
||||||
IndustryStartingCosts,
|
IndustryStartingCosts,
|
||||||
@ -23,6 +24,7 @@ import { Product } from "../Product";
|
|||||||
|
|
||||||
import { Player } from "../../Player";
|
import { Player } from "../../Player";
|
||||||
|
|
||||||
|
import { Factions } from "../../Faction/Factions";
|
||||||
import { Cities } from "../../Locations/Cities";
|
import { Cities } from "../../Locations/Cities";
|
||||||
|
|
||||||
import { numeralWrapper } from "../../ui/numeralFormat";
|
import { numeralWrapper } from "../../ui/numeralFormat";
|
||||||
@ -146,6 +148,7 @@ export class CorporationEventHandler {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
const cancelButton = createPopupCloseButton(popupId, {
|
const cancelButton = createPopupCloseButton(popupId, {
|
||||||
|
class: "std-button",
|
||||||
display: "inline-block",
|
display: "inline-block",
|
||||||
innerText: "Cancel",
|
innerText: "Cancel",
|
||||||
})
|
})
|
||||||
|
@ -76,7 +76,7 @@ function ProductComponent(props) {
|
|||||||
if (!product.fin) {
|
if (!product.fin) {
|
||||||
if (hasUpgradeDashboard) {
|
if (hasUpgradeDashboard) {
|
||||||
return (
|
return (
|
||||||
<div className={"cmpy-mgmt-warehouse-product-div"} key={product.name}>
|
<div className={"cmpy-mgmt-warehouse-product-div"}>
|
||||||
<p>Designing {product.name}...</p><br />
|
<p>Designing {product.name}...</p><br />
|
||||||
<p>{numeralWrapper.format(product.prog, "0.00")}% complete</p>
|
<p>{numeralWrapper.format(product.prog, "0.00")}% complete</p>
|
||||||
<br />
|
<br />
|
||||||
@ -102,7 +102,7 @@ function ProductComponent(props) {
|
|||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
<div className={"cmpy-mgmt-warehouse-product-div"} key={product.name}>
|
<div className={"cmpy-mgmt-warehouse-product-div"}>
|
||||||
<p>Designing {product.name}...</p><br />
|
<p>Designing {product.name}...</p><br />
|
||||||
<p>{numeralWrapper.format(product.prog, "0.00")}% complete</p>
|
<p>{numeralWrapper.format(product.prog, "0.00")}% complete</p>
|
||||||
</div>
|
</div>
|
||||||
@ -111,7 +111,7 @@ function ProductComponent(props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={"cmpy-mgmt-warehouse-product-div"} key={props.key}>
|
<div className={"cmpy-mgmt-warehouse-product-div"}>
|
||||||
<p className={"tooltip"}>
|
<p className={"tooltip"}>
|
||||||
{product.name}: {numeralWrapper.format(product.data[city][0], nfB)} ({numeralWrapper.format(totalGain, nfB)}/s)
|
{product.name}: {numeralWrapper.format(product.data[city][0], nfB)} ({numeralWrapper.format(totalGain, nfB)}/s)
|
||||||
<span className={"tooltiptext"}>
|
<span className={"tooltiptext"}>
|
||||||
@ -255,7 +255,7 @@ function MaterialComponent(props) {
|
|||||||
const marketTaButtonOnClick = eventHandler.createMaterialMarketTaPopup.bind(eventHandler, mat, division);
|
const marketTaButtonOnClick = eventHandler.createMaterialMarketTaPopup.bind(eventHandler, mat, division);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={"cmpy-mgmt-warehouse-material-div"} key={props.key}>
|
<div className={"cmpy-mgmt-warehouse-material-div"}>
|
||||||
<div style={{display: "inline-block"}}>
|
<div style={{display: "inline-block"}}>
|
||||||
<p className={"tooltip"}>
|
<p className={"tooltip"}>
|
||||||
{mat.name}: {numeralWrapper.format(mat.qty, nfB)} ({numeralWrapper.format(totalGain, nfB)}/s)
|
{mat.name}: {numeralWrapper.format(mat.qty, nfB)} ({numeralWrapper.format(totalGain, nfB)}/s)
|
||||||
@ -331,6 +331,19 @@ function MaterialComponent(props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class IndustryWarehouse extends BaseReactComponent {
|
export class IndustryWarehouse extends BaseReactComponent {
|
||||||
|
// Returns a boolean indicating whether the given material is relevant for the
|
||||||
|
// current industry.
|
||||||
|
isRelevantMaterial(matName, division) {
|
||||||
|
// Materials that affect Production multiplier
|
||||||
|
const prodMultiplierMats = ["Hardware", "Robots", "AICores", "RealEstate"];
|
||||||
|
|
||||||
|
if (Object.keys(division.reqMats).includes(matName)) { return true; }
|
||||||
|
if (division.prodMats.includes(matName)) { return true; }
|
||||||
|
if (prodMultiplierMats.includes(matName)) { return true; }
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
renderWarehouseUI() {
|
renderWarehouseUI() {
|
||||||
const corp = this.corp();
|
const corp = this.corp();
|
||||||
const division = this.routing().currentDivision; // Validated in render()
|
const division = this.routing().currentDivision; // Validated in render()
|
||||||
@ -418,34 +431,20 @@ export class IndustryWarehouse extends BaseReactComponent {
|
|||||||
corp.rerender();
|
corp.rerender();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Materials that affect Production multiplier
|
|
||||||
const prodMultiplierMats = ["Hardware", "Robots", "AICores", "RealEstate"];
|
|
||||||
|
|
||||||
// Returns a boolean indicating whether the given material is relevant for the
|
|
||||||
// current industry.
|
|
||||||
function isRelevantMaterial(matName) {
|
|
||||||
if (Object.keys(division.reqMats).includes(matName)) { return true; }
|
|
||||||
if (division.prodMats.includes(matName)) { return true; }
|
|
||||||
if (prodMultiplierMats.includes(matName)) { return true; }
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create React components for materials
|
// Create React components for materials
|
||||||
const mats = [];
|
const mats = [];
|
||||||
for (const matName in warehouse.materials) {
|
for (const matName in warehouse.materials) {
|
||||||
if (warehouse.materials[matName] instanceof Material) {
|
if (warehouse.materials[matName] instanceof Material) {
|
||||||
// Only create UI for materials that are relevant for the industry
|
// Only create UI for materials that are relevant for the industry
|
||||||
if (isRelevantMaterial(matName)) {
|
if (this.isRelevantMaterial(matName, division)) {
|
||||||
mats.push(MaterialComponent({
|
mats.push(<MaterialComponent
|
||||||
city: this.props.currentCity,
|
city={this.props.currentCity}
|
||||||
corp: corp,
|
corp={corp}
|
||||||
division: division,
|
division={division}
|
||||||
eventHandler: this.eventHandler(),
|
eventHandler={this.eventHandler()}
|
||||||
key: matName,
|
key={matName}
|
||||||
mat: warehouse.materials[matName],
|
mat={warehouse.materials[matName]}
|
||||||
warehouse: warehouse,
|
warehouse={warehouse} />);
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -455,15 +454,14 @@ export class IndustryWarehouse extends BaseReactComponent {
|
|||||||
if (division.makesProducts && Object.keys(division.products).length > 0) {
|
if (division.makesProducts && Object.keys(division.products).length > 0) {
|
||||||
for (const productName in division.products) {
|
for (const productName in division.products) {
|
||||||
if (division.products[productName] instanceof Product) {
|
if (division.products[productName] instanceof Product) {
|
||||||
products.push(ProductComponent({
|
products.push(<ProductComponent
|
||||||
city: this.props.currentCity,
|
city={this.props.currentCity}
|
||||||
corp: corp,
|
corp={corp}
|
||||||
division: division,
|
division={division}
|
||||||
eventHandler: this.eventHandler(),
|
eventHandler={this.eventHandler()}
|
||||||
key: productName,
|
key={productName}
|
||||||
product: division.products[productName],
|
product={division.products[productName]}
|
||||||
warehouse: warehouse,
|
warehouse={warehouse} />);
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user