summaryrefslogtreecommitdiff
path: root/scripts/gui
diff options
context:
space:
mode:
authorKyle Gunger <corechg@gmail.com>2020-09-29 01:53:49 -0400
committerKyle Gunger <corechg@gmail.com>2020-09-29 01:53:49 -0400
commit673d16d8f2fb9d7b7df5f6fcadfbc665f329887c (patch)
treea75381de6b9d2441310599de71fd7ea5d143b153 /scripts/gui
parent04010b3b1f6ba6fc44d2cd0cd6a8a39446cd7b1d (diff)
More drag updates
Diffstat (limited to 'scripts/gui')
-rw-r--r--scripts/gui/table.js42
1 files changed, 35 insertions, 7 deletions
diff --git a/scripts/gui/table.js b/scripts/gui/table.js
index 7199f83..5c65ed4 100644
--- a/scripts/gui/table.js
+++ b/scripts/gui/table.js
@@ -5,7 +5,7 @@ class Table{
this.drag = drag;
drag.addEventListener("dragstart", (e) => {console.log(e)});
- drag.addEventListener("dragstop", (e) => {console.log(e)});
+ drag.addEventListener("dragstop", this.dragMsg.bind(this));
this.socket = socket;
@@ -47,16 +47,16 @@ class Table{
}
/* Deck and card functions */
- newDeck(options)
+ newDeck(id, options)
{
- var d = new Deck(options);
+ var d = new Deck(id, options);
this.decks.push(d);
this.root.appendChild(d.e);
}
- newCard(data, deck = 0)
+ newCard(id, data, deck = 0)
{
- var c = new Card(data);
+ var c = new Card(id, data);
this.decks[deck].appendCard(c);
this.drag.addTarget(c.e);
}
@@ -66,13 +66,41 @@ class Table{
for(let d of this.decks)
{
if(d.isInside(x, y))
- return true;
+ return d;
}
- return false;
+ return null;
+ }
+
+ checkCard (el)
+ {
+ for(let d of this.decks)
+ {
+ let c = d.checkCard(el);
+ if(c !== null)
+ return c;
+ }
+ return null;
}
dragCheck(cap)
{
console.log(cap);
}
+
+ dragMsg (event)
+ {
+ if(event.drag.length < 1)
+ return;
+
+ var c = this.checkCard(event.drag[0].e);
+ var d = this.checkDeck(event.x, event.y);
+
+ if(c !== null)
+ {
+ if(d !== null)
+ console.log({card: c.getID(), deck: d.getID()});
+ else
+ c.resetPos();
+ }
+ }
}