summaryrefslogtreecommitdiff
path: root/scripts/cards/deck.js
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2021-02-15 14:55:16 -0500
committerKyle Gunger <kgunger12@gmail.com>2021-02-15 14:55:16 -0500
commitfcf01353f94b11b8ca6db8ead14d2ec89a0275f4 (patch)
tree89b01bd941854f83477ba6cb3b7e283f95bf710a /scripts/cards/deck.js
parent8798a7f1fbdbf13ca31d21c0242fbfa26bf36b6a (diff)
Get on track for moving cards around
Diffstat (limited to 'scripts/cards/deck.js')
-rw-r--r--scripts/cards/deck.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/scripts/cards/deck.js b/scripts/cards/deck.js
index dcfa1e9..4800e54 100644
--- a/scripts/cards/deck.js
+++ b/scripts/cards/deck.js
@@ -46,8 +46,11 @@ class Deck {
this.sct = options.sct > 0 ? options.sct : 0;
this.e = document.createElement("deck");
+
+ // x and y values are on a scale from 0 to 1, 0 being top left, 1 being bottom right.
this.e.style.setProperty("--x", options.pos[0]);
this.e.style.setProperty("--y", options.pos[1]);
+
this.e.setAttribute("mode", options.mode);
this.getID = function() {
@@ -121,6 +124,17 @@ class Deck {
return c;
}
+ removeCardByID(id)
+ {
+ for(let i in this.cards)
+ {
+ if(this.cards[i].getID() == id)
+ return this.removeCard(i);
+ }
+
+ return null;
+ }
+
removeFront()
{
return this.removeCard(this.cards.length - 1);
@@ -151,4 +165,14 @@ class Deck {
}
return null;
}
+
+ hasCard(id)
+ {
+ for(let c of this.cards)
+ {
+ if(c.getID() === id)
+ return c;
+ }
+ return null;
+ }
}