From fcf01353f94b11b8ca6db8ead14d2ec89a0275f4 Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Mon, 15 Feb 2021 14:55:16 -0500 Subject: Get on track for moving cards around --- scripts/cards/deck.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'scripts/cards/deck.js') 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; + } } -- cgit v1.2.3