fix game btns

This commit is contained in:
ntr 2019-10-18 15:51:45 +11:00
parent daa1b6214b
commit aa5b76551f
3 changed files with 24 additions and 4 deletions

View File

@ -10,6 +10,7 @@ const addState = connect(
chatShow,
chatWheel,
instance,
game,
} = state;
function sendInstanceChat(instance, i) {
@ -18,6 +19,7 @@ const addState = connect(
return {
instance,
game,
chatShow,
chatWheel,
@ -39,6 +41,7 @@ const addState = connect(
function Chat(args) {
const {
instance,
game,
chatShow,
chatWheel,
@ -47,7 +50,7 @@ function Chat(args) {
} = args;
function onClick(i) {
sendInstanceChat(instance.id, i);
sendInstanceChat(instance ? instance.id : game && game.id, i);
setChatShow(false);
return true;
}

View File

@ -8,6 +8,8 @@ const addState = connect(
const {
ws,
game,
account,
chatShow,
animating,
} = state;
@ -30,6 +32,8 @@ const addState = connect(
return {
game,
account,
chatShow,
sendAbandon,
sendGameSkillClear,
sendReady,
@ -60,6 +64,8 @@ function GameCtrlBtns(args) {
const {
game,
animating,
account,
chatShow,
getInstanceState,
sendGameSkillClear,

View File

@ -4,6 +4,7 @@ const { connect } = require('preact-redux');
const actions = require('../actions');
const PlayerBox = require('./player.box');
const Chat = require('./chat');
const GameCtrlButtons = require('./game.ctrl.btns');
const GameCtrlTopButtons = require('./game.ctrl.btns.top');
@ -13,12 +14,16 @@ const addState = connect(
animating,
game,
account,
chatShow,
instanceChat,
} = state;
return {
animating,
game,
account,
chatShow,
instanceChat,
};
},
);
@ -28,6 +33,8 @@ function Controls(args) {
animating,
account,
game,
chatShow,
instanceChat,
} = args;
if (!game) return false;
@ -61,13 +68,17 @@ function Controls(args) {
</div>
);
const bottom = chatShow
? <Chat />
: <PlayerBox player={player} isPlayer={true} chat={instanceChat && instanceChat[player.id]} />;
return (
<aside>
{timer}
<div class="controls instance-ctrl">
<GameCtrlTopButtons />
<PlayerBox player={opponent}/>
<PlayerBox player={player} isPlayer={true} />
<PlayerBox player={opponent} chat={instanceChat && instanceChat[opponent.id]}/>
{bottom}
<GameCtrlButtons />
</div>
</aside>