diff --git a/WORKLOG.md b/WORKLOG.md
index 9443ce7e..1f63906f 100644
--- a/WORKLOG.md
+++ b/WORKLOG.md
@@ -4,6 +4,7 @@
* serde serialize privatise
* stripe prod
* mobile styles
+* change score to enum
* pct based translates for combat animation
* account page
* graphs n shit
diff --git a/client/assets/styles/styles.less b/client/assets/styles/styles.less
index 4a171ab0..3ba42538 100644
--- a/client/assets/styles/styles.less
+++ b/client/assets/styles/styles.less
@@ -466,8 +466,7 @@ header {
/* poor man's
*/
padding: 0.5em 2em 0 0;
- margin-bottom: 2em;
- border-bottom: 0.1em solid whitesmoke;
+ border-bottom: 0.1em solid #444;
}
@@ -476,7 +475,7 @@ header {
}
.inventory {
- margin-right: 2em;
+ margin: 2em 2em 0 0;
grid-area: inventory;
display: grid;
diff --git a/client/src/components/controls.jsx b/client/src/components/controls.jsx
index a0bed3ec..0fb9c396 100644
--- a/client/src/components/controls.jsx
+++ b/client/src/components/controls.jsx
@@ -1,8 +1,9 @@
const preact = require('preact');
const { connect } = require('preact-redux');
-const PlayerCtrl = require('./player.ctrl');
const PlayCtrl = require('./play.ctrl');
+const InstanceCtrl = require('./instance.ctrl');
+const GameCtrl = require('./game.ctrl');
const TeamCtrl = require('./team.ctrl');
const addState = connect(
@@ -30,7 +31,8 @@ function Controls(args) {
sendGameReady,
} = args;
- if (game || instance) return ;
+ if (game) return ;
+ if (instance) return ;
if (nav === 'play' || !nav) return
if (nav === 'team' || !nav) return
diff --git a/client/src/components/game.ctrl.jsx b/client/src/components/game.ctrl.jsx
new file mode 100644
index 00000000..e63cea4a
--- /dev/null
+++ b/client/src/components/game.ctrl.jsx
@@ -0,0 +1,96 @@
+const preact = require('preact');
+const { connect } = require('preact-redux');
+
+const actions = require('../actions');
+
+// dunno if this is a good idea
+// bashing together instance and game to save having two panels
+
+const addState = connect(
+ function receiveState(state) {
+ const {
+ ws,
+ game,
+ account,
+ animating,
+ } = state;
+
+ function sendReady() {
+ document.activeElement.blur();
+ return ws.sendGameReady(game.id);
+ }
+
+ return {
+ game,
+ sendReady,
+ account,
+ animating,
+ };
+ },
+
+ function receiveDispatch(dispatch) {
+ function quit() {
+ dispatch(actions.setGame(null));
+ dispatch(actions.setInstance(null));
+ }
+
+ return { quit };
+ }
+);
+
+function scoreboard(game, player, isOpponent) {
+ const text = game.phase === 'Finished'
+ ? player.wins > game.rounds / 2 && 'Winner'
+ : '';
+
+ const classes =`scoreboard ${player.ready ? 'ready' : ''}`;
+
+ const body = isOpponent
+ ? (
+
+ | {player.name} |
+ | {player.wins} / {player.losses} |
+ | {player.ready ? 'ready' : ''} |
+
+ ) : (
+
+ | {player.ready ? 'ready' : ''} |
+ | {player.wins} / {player.losses} |
+ | {player.name} |
+
+ );
+
+ return (
+
+ );
+}
+
+function Controls(args) {
+ const {
+ account,
+ game,
+ animating,
+ sendReady,
+ quit,
+ } = args;
+
+ if (!game) return false;
+
+ const opponent = game.players.find(t => t.id !== account.id);
+ const player = game.players.find(t => t.id === account.id);
+
+ const readyBtn = ;
+ const quitBtn = ;
+
+ return (
+
+ );
+}
+
+module.exports = addState(Controls);
diff --git a/client/src/components/game.footer.jsx b/client/src/components/game.footer.jsx
index 3c989c3a..1daa4981 100644
--- a/client/src/components/game.footer.jsx
+++ b/client/src/components/game.footer.jsx
@@ -56,7 +56,6 @@ function GameFooter(props) {
showNav,
quit,
- skip,
setShowNav,
sendGameReady,
sendInstanceState,
diff --git a/client/src/components/player.ctrl.jsx b/client/src/components/instance.ctrl.jsx
similarity index 60%
rename from client/src/components/player.ctrl.jsx
rename to client/src/components/instance.ctrl.jsx
index d8b72cdb..0b1a630e 100644
--- a/client/src/components/player.ctrl.jsx
+++ b/client/src/components/instance.ctrl.jsx
@@ -1,30 +1,23 @@
const preact = require('preact');
const { connect } = require('preact-redux');
-// dunno if this is a good idea
-// bashing together instance and game to save having two panels
-
const addState = connect(
function receiveState(state) {
const {
ws,
instance,
- game,
account,
animating,
} = state;
function sendReady() {
document.activeElement.blur()
- if (game) return ws.sendGameReady(game.id);
- if (instance) return ws.sendInstanceReady(instance.id);
+ return ws.sendInstanceReady(instance.id);
return false;
}
- const gameObject = game || instance;
-
return {
- gameObject,
+ instance,
sendReady,
account,
animating,
@@ -32,9 +25,9 @@ const addState = connect(
},
);
-function scoreboard(gameObject, player, isOpponent) {
- const text = gameObject.phase === 'Finished'
- ? player.wins > gameObject.rounds / 2 && 'Winner'
+function scoreboard(instance, player, isOpponent) {
+ const text = instance.phase === 'Finished'
+ ? player.wins > instance.rounds / 2 && 'Winner'
: '';
const classes =`scoreboard ${player.ready ? 'ready' : ''}`;
@@ -64,21 +57,20 @@ function scoreboard(gameObject, player, isOpponent) {
function Controls(args) {
const {
account,
- gameObject,
- animating,
+ instance,
sendReady,
} = args;
- if (!gameObject) return false;
+ if (!instance) return false;
- const opponent = gameObject.players.find(t => t.id !== account.id);
- const player = gameObject.players.find(t => t.id === account.id);
+ const opponent = instance.players.find(t => t.id !== account.id);
+ const player = instance.players.find(t => t.id === account.id);
return (
);
}
diff --git a/client/src/socket.jsx b/client/src/socket.jsx
index 58a04f86..78ebd771 100644
--- a/client/src/socket.jsx
+++ b/client/src/socket.jsx
@@ -177,7 +177,7 @@ function createSocket(events) {
let pongTimeout;
function onPong() {
events.setPing(Date.now() - ping);
- // pongTimeout = setTimeout(sendPing, 1000);
+ pongTimeout = setTimeout(sendPing, 1000);
}
// -------------