diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2022-07-17 20:17:28 -0400 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2022-07-17 20:17:28 -0400 |
commit | c9edb73751d20bb3c09b406895ca6982b455c9e4 (patch) | |
tree | c6cca364d2612db9bda4776ea19d8856fa29c92d /scripts/cards/deck.js | |
parent | 0e010b53fbaa243760f5aabd8ad5ed85c87243fd (diff) |
Some fixes
Diffstat (limited to 'scripts/cards/deck.js')
-rw-r--r-- | scripts/cards/deck.js | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/scripts/cards/deck.js b/scripts/cards/deck.js index 27020f0..941df8c 100644 --- a/scripts/cards/deck.js +++ b/scripts/cards/deck.js @@ -13,7 +13,7 @@ class Deck { y = 0; e = null; - constructor(options = {mode: "stack", smode: "one", sct: 0, pos: [0, 0]}) + constructor(id, options = {mode: "stack", smode: "one", sct: 0, pos: [0, 0]}) { // View mode // infdraw - infinite draw. always appears as if there are multiple cards @@ -54,6 +54,10 @@ class Deck { this.e.setAttribute("mode", options.mode); this.e.deck = this; + + this.getID = function() { + return id; + } } updatePos() @@ -91,8 +95,11 @@ class Deck { } else { let temp = this.cards.slice(0, index); temp[temp.length - 1].e.after(card.e); - temp.push(card); - this.cards.unshift(...temp); + this.cards.unshift(card); + + for(let i = temp.length - 1; i >= 0; i--) + this.cards.unshift(temp[i]); + this.updatePos(); } } @@ -108,6 +115,9 @@ class Deck { this.cards[index1 - 1].e.after(this.cards[index1]); this.cards[index2 - 1].e.after(this.cards[index2]); + + this.cards[index1].setPos(index1); + this.cards[index2].setPos(index2); } removeCard(index) |