Made it so by default, challenges can't be entered when complete

This commit is contained in:
thepaperpilot 2021-09-19 11:28:44 -05:00
parent 1acf01014f
commit 54cfb28bd6
2 changed files with 10 additions and 5 deletions

View file

@ -9,11 +9,15 @@
resetNotify: challenge.active, resetNotify: challenge.active,
notify: challenge.active && challenge.canComplete, notify: challenge.active && challenge.canComplete,
done: challenge.completed, done: challenge.completed,
canStart: challenge.canStart,
maxed: challenge.maxed maxed: challenge.maxed
}" }"
> >
<div v-if="title"><component :is="title" /></div> <div v-if="title"><component :is="title" /></div>
<button :style="{ backgroundColor: challenge.maxed ? null : buttonColor }" @click="toggle"> <button
:style="{ backgroundColor: challenge.canStart ? buttonColor : null }"
@click="toggle"
>
{{ buttonText }} {{ buttonText }}
</button> </button>
<component v-if="fullDisplay" :is="fullDisplay" /> <component v-if="fullDisplay" :is="fullDisplay" />
@ -101,12 +105,11 @@ export default defineComponent({
min-height: 50px; min-height: 50px;
width: 120px; width: 120px;
border-radius: var(--border-radius); border-radius: var(--border-radius);
cursor: pointer;
box-shadow: none !important; box-shadow: none !important;
background: transparent; background: transparent;
} }
.challenge.maxed button { .challenge.canStart button {
cursor: unset; cursor: pointer;
} }
</style> </style>

View file

@ -268,7 +268,9 @@ export function addLayer(layer: RawLayer, player?: Partial<PlayerData>): void {
setDefault(layer.challenges.data[id], "onComplete", undefined, false); setDefault(layer.challenges.data[id], "onComplete", undefined, false);
setDefault(layer.challenges.data[id], "onEnter", undefined, false); setDefault(layer.challenges.data[id], "onEnter", undefined, false);
setDefault(layer.challenges.data[id], "onExit", undefined, false); setDefault(layer.challenges.data[id], "onExit", undefined, false);
setDefault(layer.challenges.data[id], "canStart", true); setDefault(layer.challenges.data[id], "canStart", function() {
return Decimal.lt(this.completions, this.completionLimit);
});
setDefault(layer.challenges.data[id], "completionLimit", new Decimal(1)); setDefault(layer.challenges.data[id], "completionLimit", new Decimal(1));
setDefault(layer.challenges.data[id], "mark", function() { setDefault(layer.challenges.data[id], "mark", function() {
return Decimal.gt(this.completionLimit, 1) && this.maxed; return Decimal.gt(this.completionLimit, 1) && this.maxed;