diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2021-02-15 14:55:16 -0500 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2021-02-15 14:55:16 -0500 |
commit | fcf01353f94b11b8ca6db8ead14d2ec89a0275f4 (patch) | |
tree | 89b01bd941854f83477ba6cb3b7e283f95bf710a /scripts/gui/table.js | |
parent | 8798a7f1fbdbf13ca31d21c0242fbfa26bf36b6a (diff) |
Get on track for moving cards around
Diffstat (limited to 'scripts/gui/table.js')
-rw-r--r-- | scripts/gui/table.js | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/scripts/gui/table.js b/scripts/gui/table.js index 8fc1ea0..0d21262 100644 --- a/scripts/gui/table.js +++ b/scripts/gui/table.js @@ -83,6 +83,38 @@ class Table{ return null; } + moveCard(card, newDeck) + { + for(let d of this.decks) + { + if (d.removeCardByID(card.getID()) !== null) + break; + } + card.resetPos(); + newDeck.appendCard(card); + } + + moveByID(cardID, deckID) + { + let card, deck; + for(let d of this.decks) + { + let c = d.hasCard(cardID) + if(c !== null) + card = c; + + if(d.getID() == deckID) + deck = d; + } + + this.moveCard(card, deck); + } + + checkMove(cardID, deckID) + { + this.socket.send("game", {}); + } + dragCheck(cap) { console.log(cap); @@ -99,7 +131,7 @@ class Table{ if(c !== null) { if(d !== null) - console.log({card: c.getID(), deck: d.getID()}); + this.moveCard(c, d); else c.resetPos(); } |