From 29a55ed346c6600dbd68bbda4411201b9106ef1b Mon Sep 17 00:00:00 2001 From: Roman Shterenzon Date: Sun, 13 Sep 2020 11:25:47 +0300 Subject: [PATCH] Move DeckType into cards --- cards.js | 15 +++++++++++---- deckType.js | 3 --- example.html | 1 - example.js | 2 +- index.html | 1 - 5 files changed, 12 insertions(+), 10 deletions(-) delete mode 100644 deckType.js diff --git a/cards.js b/cards.js index 387191c..0d71e8a 100644 --- a/cards.js +++ b/cards.js @@ -1,5 +1,11 @@ var cards = (function() { + const DeckType = Object.freeze({ + STANDARD: 0, + EUCHRE: 1, + PINOCHLE: 2 + }); + //The global options var opt = { cardSize: { @@ -14,7 +20,7 @@ var cards = (function() { cardsUrl: 'img/cards.png', blackJoker: false, redJoker: false, - type: STANDARD, + type: DeckType.STANDARD, loop: 1 }; var zIndexCounter = 1; @@ -41,16 +47,16 @@ var cards = (function() { } } switch (opt.type) { - case STANDARD: + case DeckType.STANDARD: opt.acesHigh = false; start = opt.acesHigh ? 2 : 1; end = start + 12; break; - case EUCHRE: + case DeckType.EUCHRE: start = 9; end = start + 5; break; - case PINOCHLE: + case DeckType.PINOCHLE: start = 9; end = start + 5; opt.loop = 2; @@ -384,6 +390,7 @@ var cards = (function() { Deck: Deck, Hand: Hand, Pile: Pile, + DeckType: DeckType, shuffle: shuffle }; })(); diff --git a/deckType.js b/deckType.js deleted file mode 100644 index ba9858e..0000000 --- a/deckType.js +++ /dev/null @@ -1,3 +0,0 @@ -const STANDARD = 0; -const EUCHRE = 1; -const PINOCHLE = 2; diff --git a/example.html b/example.html index ed41304..2145216 100644 --- a/example.html +++ b/example.html @@ -20,7 +20,6 @@

Cards.js - Example

in the public domain. - diff --git a/example.js b/example.js index 3b49e22..0a531ff 100644 --- a/example.js +++ b/example.js @@ -1,6 +1,6 @@ //Tell the library which element to use for the table -cards.init({table:'#card-table', type:STANDARD}); +cards.init({table:'#card-table', type:cards.DeckType.STANDARD}); //Create a new deck of cards deck = new cards.Deck(); diff --git a/index.html b/index.html index 1a8ada8..b7dc2f3 100644 --- a/index.html +++ b/index.html @@ -80,7 +80,6 @@ } -