From 80fc16d27b8bc10956dbb81f5167bab6ad8b1682 Mon Sep 17 00:00:00 2001 From: Hamcha Date: Wed, 11 Sep 2019 21:07:06 +0200 Subject: [PATCH] Working card limits --- src/views/DeckBuilder.vue | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/views/DeckBuilder.vue b/src/views/DeckBuilder.vue index 4268e14..ee40a4c 100644 --- a/src/views/DeckBuilder.vue +++ b/src/views/DeckBuilder.vue @@ -303,6 +303,17 @@ function sortByColor(a: Card, b: Card) { return 0; } +function cardLimit(type: string) { + switch (type) { + case "Mane Character": + return 1; + case "Problem": + return 2; + default: + return 3; + } +} + @Component({ components: { DeckList, @@ -388,11 +399,17 @@ export default class DeckBuilder extends Vue { private get currentPage(): CardSlot[] { return this.filtered .slice(this.offset, this.offset + this.itemsPerPage) - .map(card => ({ - data: card, - limit: card.Type == "Problem" ? 2 : 3, - howmany: this.decklist.filter(c => c.data.ID == card.ID).length - })); + .map(card => { + const res = this.decklist.find(c => c.data.ID == card.ID); + if (res) { + return res; + } + return { + data: card, + limit: cardLimit(card.Type), + howmany: 0 + }; + }); } private elementIconURL(element: string): string { @@ -466,7 +483,7 @@ export default class DeckBuilder extends Vue { } else { this.decklist.push({ data: card, - limit: card.Type == "Problem" ? 2 : 3, + limit: cardLimit(card.Type), howmany: 1 }); }