From 35bcd89c03a795a16501248ca0ebf6a6e05afa46 Mon Sep 17 00:00:00 2001 From: ntr Date: Tue, 21 May 2019 16:55:17 +1000 Subject: [PATCH] scoreboard --- client/assets/styles/instance.css | 4 ++ client/src/components/info.component.jsx | 47 ------------------ client/src/components/instance.component.jsx | 51 +++++++++++++++++++- client/src/components/instance.equip.jsx | 5 +- client/src/constants.jsx | 4 ++ 5 files changed, 62 insertions(+), 49 deletions(-) diff --git a/client/assets/styles/instance.css b/client/assets/styles/instance.css index 1e946a42..be711d78 100644 --- a/client/assets/styles/instance.css +++ b/client/assets/styles/instance.css @@ -28,6 +28,10 @@ grid-area: top; } +.instance .scoreboard { + grid-area: cryps; +} + .instance-ui-btn { font-size: 100%; padding: 0; diff --git a/client/src/components/info.component.jsx b/client/src/components/info.component.jsx index 15d86923..d1020a19 100644 --- a/client/src/components/info.component.jsx +++ b/client/src/components/info.component.jsx @@ -91,51 +91,6 @@ function Info(args) { ); } - function playerRound(id) { - if (!instance.rounds.length) return null; - return instance.rounds[instance.rounds.length - 1].find(r => r.player_ids.includes(id)); - } - - function playerText(p) { - const round = playerRound(p.id); - if (!round) { - return p.ready - ? 'ready' - : ''; - } - - if (round.finished) return 'finished'; - if (round.game_id) return 'in game'; - - return p.ready - ? 'ready' - : ''; - } - - function ScoreBoard() { - if (info[0]) return null; - - const players = instance.players.map((p, i) => { - const pText = playerText(p); - return ( - - {p.name} - {p.score.wins} / {p.score.losses} - {pText} - - ); - }); - - return ( - - - {players} - -
- ); - } - function Combos() { if (!player) return false; @@ -185,6 +140,4 @@ function Info(args) { ); } -// Takes up too much space maybe a context switch - module.exports = Info; diff --git a/client/src/components/instance.component.jsx b/client/src/components/instance.component.jsx index e2f40ba6..9dab67b1 100644 --- a/client/src/components/instance.component.jsx +++ b/client/src/components/instance.component.jsx @@ -46,10 +46,13 @@ function Instance(args) { } const rdyClasses = `instance-btn instance-ui-btn ${player.ready ? 'ready' : ''}`; + const readyInfo = instance.phase === 'Lobby' + ? 'lobbyReady' + : 'ready'; const readyBtn = ( @@ -69,6 +72,51 @@ function Instance(args) { background: player.ready ? 'forestgreen' : 'whitesmoke', }; + function playerRound(id) { + if (!instance.rounds.length) return null; + return instance.rounds[instance.rounds.length - 1].find(r => r.player_ids.includes(id)); + } + + function playerText(p) { + const round = playerRound(p.id); + if (!round) { + return p.ready + ? 'ready' + : ''; + } + + if (round.finished) return 'finished'; + if (round.game_id) return 'in game'; + + return p.ready + ? 'ready' + : ''; + } + + function ScoreBoard() { + if (instance.phase !== 'Lobby') return null; + + const players = instance.players.map((p, i) => { + const pText = playerText(p); + return ( + + {p.name} + {p.score.wins} / {p.score.losses} + {pText} + + ); + }); + + return ( + + + {players} + +
+ ); + } + const timer = (
 
@@ -84,6 +132,7 @@ function Instance(args) { + diff --git a/client/src/components/instance.equip.jsx b/client/src/components/instance.equip.jsx index 6e148b26..1981b97f 100644 --- a/client/src/components/instance.equip.jsx +++ b/client/src/components/instance.equip.jsx @@ -14,7 +14,7 @@ const addState = connect( return ws.sendVboxUnequip(instance.id, crypId, item); } - return { player, itemInfo, info, sendUnequip, activeCryp, itemUnequip }; + return { player, itemInfo, instance, info, sendUnequip, activeCryp, itemUnequip }; }, function receiveDispatch(dispatch) { @@ -42,6 +42,7 @@ const addState = connect( function Equipment(props) { const { player, + instance, itemUnequip, setItemEquip, @@ -54,6 +55,8 @@ function Equipment(props) { setInfo, } = props; + if (instance.phase === 'Lobby') return false; + const { vbox } = player; const fullInfo = itemInfo.items.find(i => i.item === itemUnequip); diff --git a/client/src/constants.jsx b/client/src/constants.jsx index 1c1f1cf6..6f904de1 100644 --- a/client/src/constants.jsx +++ b/client/src/constants.jsx @@ -27,6 +27,10 @@ module.exports = { item: 'READY', description: 'Ends the VBOX PHASE. If your opponent is also ready the GAME PHASE begins.', }, + lobbyReady: { + item: 'READY', + description: 'Ready for the game to begin. When all players are ready the first VBOX PHASE begins.', + }, reclaim: { item: 'RECLAIM', description: 'Reclaim ITEMS for half the purchase cost of their combined ITEMS.\nClick to enable and click ITEM to reclaim.',