From 8d327bb89792ac5cc8ff26fca1984a29187bf509 Mon Sep 17 00:00:00 2001 From: Patrick Wieth Date: Thu, 14 Dec 2023 23:31:30 +0100 Subject: [PATCH] fix broken card editing: action cards no ability --- src/views/CardCreatorPage.vue | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/views/CardCreatorPage.vue b/src/views/CardCreatorPage.vue index ccab6235..8cf8bb8f 100644 --- a/src/views/CardCreatorPage.vue +++ b/src/views/CardCreatorPage.vue @@ -1167,6 +1167,20 @@ export default { this.abilities ); } + // if an ability was created, but it has no effect, then this should be fixed + if (newModel.Abilities.length > 0) { + let effectsList = R.flatten(R.map( + x => R.values(R.pluck("Effects", x)), + newModel.Abilities)) + + if (R.any(y => y === undefined, effectsList)) { + this.notifyFail( + "Useless Ability", + "Card has an Ability, which does not do anything. Please add an Effect to the Ability." + ); + return; + } + } } else if (this.model.type === "Action") { // check if the old effects should be restored if (this.mode == Mode.EDIT && !this.clearAbilities && R.isEmpty(this.abilities)) { @@ -1183,20 +1197,15 @@ export default { this.abilities ); } - } - - // if an ability was created, but it has no effect, then this should be fixed - if (newModel.Abilities.length > 0) { - let effectsList = R.flatten(R.map( - x => R.values(R.pluck("Effects", x)), - newModel.Abilities)) - - if (R.any(y => y === undefined, effectsList)) { + // if an ability was created, but it has no effect, then this should be fixed + if (newModel.Effects.length == 0) { + console.log("newmodel", newModel) this.notifyFail( - "Useless Ability", - "Card has an Ability, which does not do anything. Please add an Effect to the Ability." + "No Effects", + "Card has no effect. Maybe you forgot to add an effect?" ); return; + } }