From 31efb453bc34b01112143d596f52e2b65ace8900 Mon Sep 17 00:00:00 2001 From: Hamcha Date: Tue, 10 Sep 2019 15:11:39 +0200 Subject: [PATCH] Make so clicking on cards will remove them from the decklist --- src/components/DeckBuilder/DeckList.vue | 7 ++++++- src/views/DeckBuilder.vue | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/components/DeckBuilder/DeckList.vue b/src/components/DeckBuilder/DeckList.vue index 5191343..1625597 100644 --- a/src/components/DeckBuilder/DeckList.vue +++ b/src/components/DeckBuilder/DeckList.vue @@ -1,6 +1,6 @@ @@ -512,5 +512,19 @@ export default class DeckBuilder extends Vue { const url = createPonyheadURL(this.decklist.map(c => c.data)); window.open(url, "_blank"); } + + private cardRemoved(card: CardSlot) { + const idx = this.decklist.findIndex(c => c.data.ID == card.data.ID); + if (idx < 0) { + throw new Error("Removing card that isn't in the deck?"); + } + const deckitem = this.decklist[idx]; + deckitem.howmany -= 1; + if (deckitem.howmany <= 0) { + this.decklist.splice(idx, 1); + } else { + Vue.set(this.decklist, idx, deckitem); + } + } }