forked from profectus/Profectus
Added minimumGain to resetButton
This commit is contained in:
parent
42fe66c891
commit
98c7cd7724
1 changed files with 13 additions and 3 deletions
|
@ -15,7 +15,7 @@ import {
|
||||||
TreeNodeOptions
|
TreeNodeOptions
|
||||||
} from "features/trees/tree";
|
} from "features/trees/tree";
|
||||||
import player from "game/player";
|
import player from "game/player";
|
||||||
import Decimal from "util/bignum";
|
import Decimal, { DecimalSource } from "util/bignum";
|
||||||
import {
|
import {
|
||||||
Computable,
|
Computable,
|
||||||
GetComputableType,
|
GetComputableType,
|
||||||
|
@ -33,6 +33,7 @@ export interface ResetButtonOptions extends ClickableOptions {
|
||||||
showNextAt?: Computable<boolean>;
|
showNextAt?: Computable<boolean>;
|
||||||
display?: Computable<CoercableComponent>;
|
display?: Computable<CoercableComponent>;
|
||||||
canClick?: Computable<boolean>;
|
canClick?: Computable<boolean>;
|
||||||
|
minimumGain?: Computable<DecimalSource>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ResetButton<T extends ResetButtonOptions> = Replace<
|
export type ResetButton<T extends ResetButtonOptions> = Replace<
|
||||||
|
@ -42,6 +43,7 @@ export type ResetButton<T extends ResetButtonOptions> = Replace<
|
||||||
showNextAt: GetComputableTypeWithDefault<T["showNextAt"], true>;
|
showNextAt: GetComputableTypeWithDefault<T["showNextAt"], true>;
|
||||||
display: GetComputableTypeWithDefault<T["display"], Ref<JSX.Element>>;
|
display: GetComputableTypeWithDefault<T["display"], Ref<JSX.Element>>;
|
||||||
canClick: GetComputableTypeWithDefault<T["canClick"], Ref<boolean>>;
|
canClick: GetComputableTypeWithDefault<T["canClick"], Ref<boolean>>;
|
||||||
|
minimumGain: GetComputableTypeWithDefault<T["minimumGain"], 1>;
|
||||||
onClick: VoidFunction;
|
onClick: VoidFunction;
|
||||||
}
|
}
|
||||||
>;
|
>;
|
||||||
|
@ -53,6 +55,7 @@ export type GenericResetButton = Replace<
|
||||||
showNextAt: ProcessedComputable<boolean>;
|
showNextAt: ProcessedComputable<boolean>;
|
||||||
display: ProcessedComputable<CoercableComponent>;
|
display: ProcessedComputable<CoercableComponent>;
|
||||||
canClick: ProcessedComputable<boolean>;
|
canClick: ProcessedComputable<boolean>;
|
||||||
|
minimumGain: ProcessedComputable<DecimalSource>;
|
||||||
}
|
}
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
@ -64,6 +67,7 @@ export function createResetButton<T extends ClickableOptions & ResetButtonOption
|
||||||
|
|
||||||
processComputable(resetButton as T, "showNextAt");
|
processComputable(resetButton as T, "showNextAt");
|
||||||
setDefault(resetButton, "showNextAt", true);
|
setDefault(resetButton, "showNextAt", true);
|
||||||
|
setDefault(resetButton, "minimumGain", 1);
|
||||||
|
|
||||||
if (resetButton.resetDescription == null) {
|
if (resetButton.resetDescription == null) {
|
||||||
resetButton.resetDescription = computed(() =>
|
resetButton.resetDescription = computed(() =>
|
||||||
|
@ -80,7 +84,10 @@ export function createResetButton<T extends ClickableOptions & ResetButtonOption
|
||||||
<b>
|
<b>
|
||||||
{displayResource(
|
{displayResource(
|
||||||
resetButton.conversion.gainResource,
|
resetButton.conversion.gainResource,
|
||||||
unref(resetButton.conversion.actualGain)
|
Decimal.max(
|
||||||
|
unref(resetButton.conversion.actualGain),
|
||||||
|
unref(resetButton.minimumGain as ProcessedComputable<DecimalSource>)
|
||||||
|
)
|
||||||
)}
|
)}
|
||||||
</b>{" "}
|
</b>{" "}
|
||||||
{resetButton.conversion.gainResource.displayName}
|
{resetButton.conversion.gainResource.displayName}
|
||||||
|
@ -99,7 +106,10 @@ export function createResetButton<T extends ClickableOptions & ResetButtonOption
|
||||||
|
|
||||||
if (resetButton.canClick == null) {
|
if (resetButton.canClick == null) {
|
||||||
resetButton.canClick = computed(() =>
|
resetButton.canClick = computed(() =>
|
||||||
Decimal.gt(unref(resetButton.conversion.actualGain), 0)
|
Decimal.gte(
|
||||||
|
unref(resetButton.conversion.actualGain),
|
||||||
|
unref(resetButton.minimumGain as ProcessedComputable<DecimalSource>)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue