From 62e92eaf9201bd5dc51f49cd1b8132a60bf5a39c Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Sun, 6 Jan 2019 09:59:34 -0500 Subject: [PATCH] Allow generating other types of cards (ie 'character' and 'character-back') --- src/Deck.vue | 27 +++++++++++++++++++++----- src/Editor.vue | 6 +++--- src/template/hero/Hero.vue | 29 ++++++++++++++++++++++++++-- src/template/hero/character-back.svg | 8 +++----- src/template/hero/character.svg | 12 +++++++----- src/template/hero/deck.svg | 20 +++++++++---------- 6 files changed, 72 insertions(+), 30 deletions(-) diff --git a/src/Deck.vue b/src/Deck.vue index 4a9df9d..7ea77d5 100644 --- a/src/Deck.vue +++ b/src/Deck.vue @@ -15,17 +15,34 @@ props: ['cards'], components: {Hero}, + data() { + return { + selected: null, + } + }, + + watch: { + selected() { + this.$emit('input', this.selected); + } + }, + computed: { allCards() { return Object .keys(this.cards) .flatMap(cardType => this.cards[cardType].flatMap((card, index) => { - let cardWrapper = { + let cardWrapper = [{ type: cardType, - card: this.cards[cardType][index], - props: Hero.props, - }; - return Array(card.count || 1).fill(cardWrapper); + card: card, + }]; + if (card.back) { // TODO: a little hacky + cardWrapper.push({ + type: cardType + '-back', + card: card.back, + }); + } + return Array(card.count || 1).fill(cardWrapper).flat(); })); }, diff --git a/src/Editor.vue b/src/Editor.vue index 2a796f8..abadae6 100644 --- a/src/Editor.vue +++ b/src/Editor.vue @@ -42,10 +42,10 @@
diff --git a/src/template/hero/Hero.vue b/src/template/hero/Hero.vue index 5c47a5b..5c6468b 100644 --- a/src/template/hero/Hero.vue +++ b/src/template/hero/Hero.vue @@ -1,11 +1,36 @@