Fix respecing buyables

This commit is contained in:
thepaperpilot 2021-06-26 01:45:05 -05:00
parent 6a13fdbfaa
commit 273b9e0118
5 changed files with 13 additions and 14 deletions

View file

@ -53,12 +53,7 @@ export default {
}
},
respec() {
// If they're controlling confirmRespec, assume they're also controlling what's being respecced
if (this.confirmRespec != undefined) {
this.$emit("respec");
} else {
layers[this.layer || this.tab.layer].buyables.respec();
}
layers[this.layer || this.tab.layer].buyables.respec?.();
}
}
};

View file

@ -17,12 +17,8 @@
<div slot="footer">
<div class="modal-footer">
<div class="modal-flex-grow"></div>
<button class="button modal-button danger" @click="cancel">
Yes!
</button>
<button class="button modal-button" @click="cancel">
Cancel
</button>
<danger-button class="button modal-button" @click="confirm" skipConfirm>Yes</danger-button>
<button class="button modal-button" @click="cancel">Cancel</button>
</div>
</div>
</Modal>

View file

@ -18,7 +18,8 @@ export default {
}
},
props: {
disabled: Boolean
disabled: Boolean,
skipConfirm: Boolean
},
watch: {
confirming(newValue) {
@ -27,6 +28,10 @@ export default {
},
methods: {
click() {
if (this.skipConfirm) {
this.$emit('click');
return;
}
if (this.confirming) {
this.$emit('click');
}

View file

@ -160,7 +160,7 @@ export default {
},
buyables: {
showRespec: true,
reset() { // Optional, reset things and give back your currency. Having this function makes a respec button appear
respec() { // Optional, reset things and give back your currency. Having this function makes a respec button appear
player[this.layer].points = player[this.layer].points.add(player[this.layer].spentOnBuyables) // A built-in thing to keep track of this but only keeps a single value
this.reset();
resetLayer(this.layer, true) // Force a reset

View file

@ -242,6 +242,9 @@ export function addLayer(layer, player = null) {
} else {
layer.buyables.reset.forceCached = false;
}
if (layer.buyables.respec != undefined) {
layer.buyables.respec.forceCached = false;
}
for (let id in layer.buyables) {
if (isPlainObject(layer.buyables[id])) {
layer.buyables[id].amount = function() {