allowSmall -> defaultShowSmall, allow it to be overrided

This commit is contained in:
thepaperpilot 2022-03-02 20:28:11 -06:00
parent 48ef321c89
commit b9f28f764f
3 changed files with 4 additions and 4 deletions

View file

@ -9,7 +9,7 @@
"versionTitle": "Initial Commit",
"allowGoBack": true,
"allowSmall": false,
"defaultShowSmall": false,
"defaultDecimalsShown": 2,
"useHeader": true,
"banner": null,

View file

@ -6,14 +6,14 @@ import { State, persistent } from "@/game/persistence";
export interface Resource<T = DecimalSource> extends Ref<T> {
displayName: string;
precision: number;
small: boolean;
small?: boolean;
}
export function createResource<T extends State>(
defaultValue: T | Ref<T>,
displayName = "points",
precision = 0,
small = false
small = undefined
): Resource<T> {
const resource: Partial<Resource<T>> = persistent(defaultValue);
resource.displayName = displayName;

View file

@ -64,7 +64,7 @@ const thousandth = new Decimal(0.001);
const zero = new Decimal(0);
export function format(num: DecimalSource, precision?: number, small?: boolean): string {
if (precision == null) precision = projInfo.defaultDecimalsShown;
small = small || projInfo.allowSmall;
small = small ?? projInfo.defaultShowSmall;
num = new Decimal(num);
if (isNaN(num.sign) || isNaN(num.layer) || isNaN(num.mag)) {
return "NaN";