mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-26 11:10:58 +02:00
Change money to automatically color grey when something cannot be bought.
This commit is contained in:
+12
-2
@@ -1,6 +1,16 @@
|
||||
import * as React from "react";
|
||||
import { numeralWrapper } from "../../ui/numeralFormat";
|
||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||
|
||||
export function Money(money: number | string): JSX.Element {
|
||||
return <span className={"money-gold samefont"}>{typeof money === 'number' ? numeralWrapper.formatMoney(money) : money}</span>
|
||||
interface IProps {
|
||||
money: number | string;
|
||||
player?: IPlayer;
|
||||
}
|
||||
export function Money(props: IProps): JSX.Element {
|
||||
if(props.player !== undefined) {
|
||||
if(typeof props.money !== 'number') throw new Error('if player if provided, money should be number, contact dev');
|
||||
if(!props.player.canAfford(props.money))
|
||||
return <span className={"unbuyable samefont"}>{numeralWrapper.formatMoney(props.money)}</span>
|
||||
}
|
||||
return <span className={"money-gold samefont"}>{typeof props.money === 'number' ? numeralWrapper.formatMoney(props.money) : props.money}</span>
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import React from 'react';
|
||||
import { numeralWrapper } from "../../ui/numeralFormat";
|
||||
import { Money } from "../../ui/React/Money";
|
||||
|
||||
export function MoneyRate(money: number): JSX.Element {
|
||||
return Money(`${numeralWrapper.formatMoney(money)} / sec`);
|
||||
return <Money money={`${numeralWrapper.formatMoney(money)} / sec`} />;
|
||||
}
|
||||
Reference in New Issue
Block a user