diff --git a/html-client/cryps.css b/html-client/cryps.css
index 3ee0091f..c3436639 100755
--- a/html-client/cryps.css
+++ b/html-client/cryps.css
@@ -195,10 +195,15 @@ button:hover {
.vbox-table td {
border: 1px solid whitesmoke;
- padding: 0 0.5em;
+ padding: 0.2em;
text-align: center;
height: 40px;
cursor: pointer;
+ text-transform: uppercase;
+}
+
+.vbox-table td div {
+ border: 1px solid whitesmoke;
}
.spacer {
diff --git a/html-client/src/components/instance.component.jsx b/html-client/src/components/instance.component.jsx
index 1775fcc1..27cd72ab 100644
--- a/html-client/src/components/instance.component.jsx
+++ b/html-client/src/components/instance.component.jsx
@@ -6,8 +6,8 @@ const VboxContainer = require('./vbox.container');
const molecule = require('./molecule');
const saw = require('./saw.component');
-function Cryp(cryp) {
- const skills = range(0, 4).map((i) => {
+function Cryp(cryp, sendVboxApply) {
+ const skills = range(0, 4).map(i => {
const s = cryp.skills[i]
? cryp.skills[i].skill
: ( );
@@ -15,6 +15,19 @@ function Cryp(cryp) {
return ;
});
+ // needed for ondrop to fire
+ function onDragOver(e) {
+ e.preventDefault();
+ return false;
+ }
+
+ function onDrop(e) {
+ e.stopPropagation();
+ e.preventDefault();
+ const item = parseInt(e.dataTransfer.getData('text'), 10);
+ return sendVboxApply(cryp.id, item);
+ }
+
const stats = [
{ stat: 'hp', colour: '#1FF01F' },
{ stat: 'green_damage', colour: '#1FF01F' },
@@ -31,7 +44,12 @@ function Cryp(cryp) {
));
return (
-
+
{molecule}
{cryp.name}
@@ -52,11 +70,12 @@ function InstanceComponent(args) {
instance,
quit,
sendInstanceReady,
+ sendVboxApply,
} = args;
if (!instance) return ...
;
- const cryps = instance.cryps.map(Cryp);
+ const cryps = instance.cryps.map(c => Cryp(c, sendVboxApply));
return (
diff --git a/html-client/src/components/instance.container.jsx b/html-client/src/components/instance.container.jsx
index 0e8f5395..c739de84 100644
--- a/html-client/src/components/instance.container.jsx
+++ b/html-client/src/components/instance.container.jsx
@@ -12,7 +12,11 @@ const addState = connect(
return ws.sendInstanceReady(instance.instance);
}
- return { instance, account, sendInstanceReady };
+ function sendVboxApply(crypId, i) {
+ return ws.sendVboxApply(instance.instance, crypId, i);
+ }
+
+ return { instance, account, sendInstanceReady, sendVboxApply };
},
function receiveDispatch(dispatch, { instance, combiner }) {
diff --git a/html-client/src/components/vbox.component.jsx b/html-client/src/components/vbox.component.jsx
index 316ada0a..2c71de07 100644
--- a/html-client/src/components/vbox.component.jsx
+++ b/html-client/src/components/vbox.component.jsx
@@ -1,7 +1,13 @@
const preact = require('preact');
+const range = require('lodash/range');
function convertVar(v) {
return v || '';
+ // uncomment for double borders in vbox
+ // if (v) {
+ // return {v}
;
+ // }
+ // return;
}
function Vbox(args) {
@@ -20,6 +26,19 @@ function Vbox(args) {
const { vbox } = instance;
if (!instance.vbox) return false;
+ // lots of rubbish to make it flow nice
+ function boundClick(i) {
+ if (reclaiming) {
+ return sendVboxReclaim(i);
+ }
+
+ if (combiner.indexOf(i) === -1) {
+ const insert = combiner.findIndex(j => j === null);
+ combiner[insert] = i;
+ return setCombiner(combiner);
+ }
+ return setCombiner([i, null, null]);
+ }
function combinerRmv(i) {
combiner[i] = null;
@@ -47,21 +66,31 @@ function Vbox(args) {
);
});
+ const boundTds = range(0, 9).map(i => (
+ e.dataTransfer.setData('text', i)}
+ onClick={() => boundClick(i) }>
+ {convertVar(vbox.bound[i])}
+ |
+ ));
+
const boundRows = [
- | boundClick(0) }>{convertVar(vbox.bound[0])} |
- boundClick(1) }>{convertVar(vbox.bound[1])} |
- boundClick(2) }>{convertVar(vbox.bound[2])} |
+ {boundTds[0]}
+ {boundTds[1]}
+ {boundTds[2]}
,
- | boundClick(3) }>{convertVar(vbox.bound[3])} |
- boundClick(4) }>{convertVar(vbox.bound[4])} |
- boundClick(5) }>{convertVar(vbox.bound[5])} |
+ {boundTds[3]}
+ {boundTds[4]}
+ {boundTds[5]}
,
- | boundClick(6) }>{convertVar(vbox.bound[6])} |
- boundClick(7) }>{convertVar(vbox.bound[7])} |
- boundClick(8) }>{convertVar(vbox.bound[8])} |
+ {boundTds[6]}
+ {boundTds[7]}
+ {boundTds[8]}
,
];
diff --git a/html-client/src/components/vbox.container.jsx b/html-client/src/components/vbox.container.jsx
index ff5c5745..5e96c70f 100644
--- a/html-client/src/components/vbox.container.jsx
+++ b/html-client/src/components/vbox.container.jsx
@@ -21,10 +21,7 @@ const addState = connect(
}
function sendVboxReclaim(i) {
- if (reclaiming) {
- return ws.sendVboxReclaim(instance.instance, i);
- }
- return false;
+ return ws.sendVboxReclaim(instance.instance, i);
}
return {