From 811571e23b68f4318794de3d34aa15cb91ec3d2d Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Tue, 19 Oct 2021 00:18:37 -0400 Subject: [Refactor] Lots of little patches + Make chatbox code a little cleaner + Add a bit of documentation + Begin prep for passwords + Function to easily grab decks from cards ~ I am going to have to completely re-do cards and decks probably. --- scripts/cards/card.js | 10 +++++----- scripts/cards/deck.js | 6 ++---- 2 files changed, 7 insertions(+), 9 deletions(-) (limited to 'scripts/cards') diff --git a/scripts/cards/card.js b/scripts/cards/card.js index 43dc965..47c7f17 100644 --- a/scripts/cards/card.js +++ b/scripts/cards/card.js @@ -7,16 +7,12 @@ const CardPos = ["top", "topl", "topr", "mid", "midt", "midb", "bot", "botl", "b // Every card should have a deck. // Use deck.appendCard or deck.prependCard to make a card visible class Card { - constructor (id, data) + constructor (data) { this.e = document.createElement("card"); this.generateElements(data); this.e.style.left = "0px"; this.e.style.top = "0px"; - - this.getID = function() { - return id; - } } // Generate a card with basic text only @@ -117,4 +113,8 @@ class Card { this.e.style.left = "0px"; this.e.style.top = "0px"; } + + getDeck() { + return this.e.parentElement.deck; + } } diff --git a/scripts/cards/deck.js b/scripts/cards/deck.js index caa62bc..27020f0 100644 --- a/scripts/cards/deck.js +++ b/scripts/cards/deck.js @@ -13,7 +13,7 @@ class Deck { y = 0; e = null; - constructor(id, options = {mode: "stack", smode: "one", sct: 0, pos: [0, 0]}) + constructor(options = {mode: "stack", smode: "one", sct: 0, pos: [0, 0]}) { // View mode // infdraw - infinite draw. always appears as if there are multiple cards @@ -53,9 +53,7 @@ class Deck { this.e.setAttribute("mode", options.mode); - this.getID = function() { - return id; - } + this.e.deck = this; } updatePos() -- cgit v1.2.3