mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-30 03:23:48 +01:00
Make buy coffee UI reflect if we're buying coffee
This commit is contained in:
parent
fe83ca0f3f
commit
9ffec86b58
@ -2,6 +2,8 @@
|
|||||||
// (top-left panel in the Industry UI)
|
// (top-left panel in the Industry UI)
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
|
|
||||||
|
import { BuyCoffee } from "../Actions";
|
||||||
|
|
||||||
import { OfficeSpace } from "../OfficeSpace";
|
import { OfficeSpace } from "../OfficeSpace";
|
||||||
import { Industries } from "../IndustryData";
|
import { Industries } from "../IndustryData";
|
||||||
import { IndustryUpgrades } from "../IndustryUpgrades";
|
import { IndustryUpgrades } from "../IndustryUpgrades";
|
||||||
@ -226,30 +228,39 @@ function Upgrades(props: { office: OfficeSpace; rerender: () => void }): React.R
|
|||||||
const i = upgrade[0];
|
const i = upgrade[0];
|
||||||
const baseCost = upgrade[1];
|
const baseCost = upgrade[1];
|
||||||
const priceMult = upgrade[2];
|
const priceMult = upgrade[2];
|
||||||
|
|
||||||
let cost = 0;
|
let cost = 0;
|
||||||
|
let disabled = false;
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 0: //Coffee, cost is static per employee
|
case 0: //Coffee, cost is static per employee
|
||||||
cost = props.office.employees.length * baseCost;
|
cost = props.office.employees.length * baseCost;
|
||||||
|
disabled = cost > corp.funds || props.office.coffeeMult > 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
cost = baseCost * Math.pow(priceMult, division.upgrades[i]);
|
cost = baseCost * Math.pow(priceMult, division.upgrades[i]);
|
||||||
|
disabled = cost > corp.funds;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClick(): void {
|
function onClick(): void {
|
||||||
if (corp.funds < cost) return;
|
if (corp.funds < cost) return;
|
||||||
corp.funds = corp.funds - cost;
|
corp.funds = corp.funds - cost;
|
||||||
|
|
||||||
|
if (i == 0) {
|
||||||
|
BuyCoffee(corp, props.office);
|
||||||
|
} else {
|
||||||
division.upgrade(upgrade, {
|
division.upgrade(upgrade, {
|
||||||
corporation: corp,
|
corporation: corp,
|
||||||
office: props.office,
|
office: props.office,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
props.rerender();
|
props.rerender();
|
||||||
}
|
}
|
||||||
|
|
||||||
upgrades.push(
|
upgrades.push(
|
||||||
<Tooltip key={index} title={upgrade[5]}>
|
<Tooltip key={index} title={upgrade[5]}>
|
||||||
<span>
|
<span>
|
||||||
<Button disabled={corp.funds < cost} onClick={onClick}>
|
<Button disabled={disabled} onClick={onClick}>
|
||||||
{upgrade[4]} -
|
{upgrade[4]} -
|
||||||
<MoneyCost money={cost} corp={corp} />
|
<MoneyCost money={cost} corp={corp} />
|
||||||
</Button>
|
</Button>
|
||||||
|
Loading…
Reference in New Issue
Block a user