From: Stephen Jianu Date: Thu, 22 Sep 2022 01:15:40 +0000 (-0500) Subject: Place SVG in card definitions and load from those X-Git-Url: https://stephenjianu.com/gitweb/?a=commitdiff_plain;h=ff787f7e64d67119c0da34b9c9f15c72f2d6955c;p=donsol-js.git Place SVG in card definitions and load from those --- diff --git a/sources/scripts/card.js b/sources/scripts/card.js index c253ea5..51f12e9 100644 --- a/sources/scripts/card.js +++ b/sources/scripts/card.js @@ -1,10 +1,11 @@ 'use strict' -function Card (sym, value, type, name = 'Unknown') { +function Card (sym, value, type, name = 'Unknown', svg = '') { this.symbol = sym this.value = value this.type = type this.name = name + this.svg = svg this.element = null this.is_flipped = false @@ -26,6 +27,7 @@ function Card (sym, value, type, name = 'Unknown') { const graphic = document.createElement('div') graphic.className = 'graphic' + graphic.innerHTML = this.svg face.appendChild(graphic) // Name diff --git a/sources/scripts/card.monster.js b/sources/scripts/card.monster.js index 2644db7..8382a45 100644 --- a/sources/scripts/card.monster.js +++ b/sources/scripts/card.monster.js @@ -1,7 +1,7 @@ 'use strict' -function Card_Monster (sym, value, type, name = 'Unknown') { - Card.call(this, sym, value, type, name) +function Card_Monster (sym, value, type, name = 'Unknown', svg = '') { + Card.call(this, sym, value, type, name, svg) this.touch = function () { if (this.is_flipped) { console.log('Card is already flipped'); return } diff --git a/sources/scripts/card.potion.js b/sources/scripts/card.potion.js index aa3d600..259f3af 100644 --- a/sources/scripts/card.potion.js +++ b/sources/scripts/card.potion.js @@ -1,7 +1,7 @@ 'use strict' -function Card_Potion (sym, value, type, name = 'Unknown') { - Card.call(this, sym, value, type, name) +function Card_Potion (sym, value, type, name = 'Unknown', svg = '') { + Card.call(this, sym, value, type, name, svg) this.touch = function () { if (this.is_flipped) { console.log('Card is already flipped'); return } diff --git a/sources/scripts/card.shield.js b/sources/scripts/card.shield.js index 19cd345..283ed10 100644 --- a/sources/scripts/card.shield.js +++ b/sources/scripts/card.shield.js @@ -1,7 +1,7 @@ 'use strict' -function Card_Shield (sym, value, type, name = 'Unknown') { - Card.call(this, sym, value, type, name) +function Card_Shield (sym, value, type, name = 'Unknown', svg = '') { + Card.call(this, sym, value, type, name, svg) this.touch = function () { if (this.is_flipped == true) { console.log('Card is already flipped'); return } diff --git a/sources/scripts/deck.js b/sources/scripts/deck.js index acf974e..502ee19 100644 --- a/sources/scripts/deck.js +++ b/sources/scripts/deck.js @@ -2,60 +2,60 @@ function Deck () { this.cards = [ - new Card_Potion('A', 11, HEART, 'White Mage'), - new Card_Potion('2', 2, HEART, 'Small Potion'), - new Card_Potion('3', 3, HEART, 'Small Potion'), - new Card_Potion('4', 4, HEART, 'Medium Potion'), - new Card_Potion('5', 5, HEART, 'Medium Potion'), - new Card_Potion('6', 6, HEART, 'Medium Potion'), - new Card_Potion('7', 7, HEART, 'Medium Potion'), - new Card_Potion('8', 8, HEART, 'Medium Potion'), - new Card_Potion('9', 9, HEART, 'Large Potion'), - new Card_Potion('10', 10, HEART, 'Large Potion'), - new Card_Potion('V', 11, HEART, 'White Mage'), - new Card_Potion('Q', 11, HEART, 'White Mage'), - new Card_Potion('K', 11, HEART, 'White Mage'), - new Card_Shield('A', 11, DIAMOND, 'Red Mage'), - new Card_Shield('2', 2, DIAMOND, 'Buckler'), - new Card_Shield('3', 3, DIAMOND, 'Buckler'), - new Card_Shield('4', 4, DIAMOND, 'Shield'), - new Card_Shield('5', 5, DIAMOND, 'Shield'), - new Card_Shield('6', 6, DIAMOND, 'Shield'), - new Card_Shield('7', 7, DIAMOND, 'Shield'), - new Card_Shield('8', 8, DIAMOND, 'Shield'), - new Card_Shield('9', 9, DIAMOND, 'Large Shield'), - new Card_Shield('10', 10, DIAMOND, 'Large Shield'), - new Card_Shield('V', 11, DIAMOND, 'Red Mage'), - new Card_Shield('Q', 11, DIAMOND, 'Red Mage'), - new Card_Shield('K', 11, DIAMOND, 'Red Mage'), - new Card_Monster('A', 17, CLOVE, 'Empress'), - new Card_Monster('2', 2, CLOVE, 'Rat'), - new Card_Monster('3', 3, CLOVE, 'Bat'), - new Card_Monster('4', 4, CLOVE, 'Imp'), - new Card_Monster('5', 5, CLOVE, 'Goblin'), - new Card_Monster('6', 6, CLOVE, 'Orc'), - new Card_Monster('7', 7, CLOVE, 'Ogre'), - new Card_Monster('8', 8, CLOVE, 'Beholder'), - new Card_Monster('9', 9, CLOVE, 'Medusa'), - new Card_Monster('10', 10, CLOVE, 'Demon'), - new Card_Monster('V', 11, CLOVE, 'Consort'), - new Card_Monster('Q', 13, CLOVE, 'Queen'), - new Card_Monster('K', 15, CLOVE, 'Regnant'), - new Card_Monster('A', 17, SPADE, 'Empress'), - new Card_Monster('2', 2, SPADE, 'Slime'), - new Card_Monster('3', 3, SPADE, 'Tunneler'), - new Card_Monster('4', 4, SPADE, 'Fiend'), - new Card_Monster('5', 5, SPADE, 'Drake'), - new Card_Monster('6', 6, SPADE, 'Specter'), - new Card_Monster('7', 7, SPADE, 'Ghost'), - new Card_Monster('8', 8, SPADE, 'Elemental'), - new Card_Monster('9', 9, SPADE, 'Witch'), - new Card_Monster('10', 10, SPADE, 'Familiar'), - new Card_Monster('V', 11, SPADE, 'Consort'), - new Card_Monster('Q', 13, SPADE, 'Queen'), - new Card_Monster('K', 15, SPADE, 'Regnant'), - new Card_Monster('J', 21, JOKER, 'First Donsol'), - new Card_Monster('J', 21, JOKER, 'Second Donsol') + new Card_Potion('A', 11, HEART, 'White Mage', ''), + new Card_Potion('2', 2, HEART, 'Small Potion', ''), + new Card_Potion('3', 3, HEART, 'Small Potion', ''), + new Card_Potion('4', 4, HEART, 'Medium Potion', ''), + new Card_Potion('5', 5, HEART, 'Medium Potion', ''), + new Card_Potion('6', 6, HEART, 'Medium Potion', ''), + new Card_Potion('7', 7, HEART, 'Medium Potion', ''), + new Card_Potion('8', 8, HEART, 'Medium Potion', ''), + new Card_Potion('9', 9, HEART, 'Large Potion', ''), + new Card_Potion('10', 10, HEART, 'Large Potion', ''), + new Card_Potion('V', 11, HEART, 'White Mage', ''), + new Card_Potion('Q', 11, HEART, 'White Mage', ''), + new Card_Potion('K', 11, HEART, 'White Mage', ''), + new Card_Shield('A', 11, DIAMOND, 'Red Mage', ''), + new Card_Shield('2', 2, DIAMOND, 'Buckler', ''), + new Card_Shield('3', 3, DIAMOND, 'Buckler', ''), + new Card_Shield('4', 4, DIAMOND, 'Shield', ''), + new Card_Shield('5', 5, DIAMOND, 'Shield', ''), + new Card_Shield('6', 6, DIAMOND, 'Shield', ''), + new Card_Shield('7', 7, DIAMOND, 'Shield', ''), + new Card_Shield('8', 8, DIAMOND, 'Shield', ''), + new Card_Shield('9', 9, DIAMOND, 'Large Shield', ''), + new Card_Shield('10', 10, DIAMOND, 'Large Shield', ''), + new Card_Shield('V', 11, DIAMOND, 'Red Mage', ''), + new Card_Shield('Q', 11, DIAMOND, 'Red Mage', ''), + new Card_Shield('K', 11, DIAMOND, 'Red Mage', ''), + new Card_Monster('A', 17, CLOVE, 'Empress', ''), + new Card_Monster('2', 2, CLOVE, 'Rat', ''), + new Card_Monster('3', 3, CLOVE, 'Bat', ''), + new Card_Monster('4', 4, CLOVE, 'Imp', ''), + new Card_Monster('5', 5, CLOVE, 'Goblin', ''), + new Card_Monster('6', 6, CLOVE, 'Orc', ''), + new Card_Monster('7', 7, CLOVE, 'Ogre', ''), + new Card_Monster('8', 8, CLOVE, 'Beholder', ''), + new Card_Monster('9', 9, CLOVE, 'Medusa', ''), + new Card_Monster('10', 10, CLOVE, 'Demon', ''), + new Card_Monster('V', 11, CLOVE, 'Consort', ''), + new Card_Monster('Q', 13, CLOVE, 'Queen', ''), + new Card_Monster('K', 15, CLOVE, 'Regnant', ''), + new Card_Monster('A', 17, SPADE, 'Empress', ''), + new Card_Monster('2', 2, SPADE, 'Slime', ''), + new Card_Monster('3', 3, SPADE, 'Tunneler', ''), + new Card_Monster('4', 4, SPADE, 'Fiend', ''), + new Card_Monster('5', 5, SPADE, 'Drake', ''), + new Card_Monster('6', 6, SPADE, 'Specter', ''), + new Card_Monster('7', 7, SPADE, 'Ghost', ''), + new Card_Monster('8', 8, SPADE, 'Elemental', ''), + new Card_Monster('9', 9, SPADE, 'Witch', ''), + new Card_Monster('10', 10, SPADE, 'Familiar', ''), + new Card_Monster('V', 11, SPADE, 'Consort', ''), + new Card_Monster('Q', 13, SPADE, 'Queen', ''), + new Card_Monster('K', 15, SPADE, 'Regnant', ''), + new Card_Monster('J', 21, JOKER, 'First Donsol', ''), + new Card_Monster('J', 21, JOKER, 'Second Donsol', '') ] let draw_pile = []