diff --git a/client/src/components/game.ctrl.btns.top.jsx b/client/src/components/game.ctrl.btns.top.jsx
index 4b81670c..8e09718c 100644
--- a/client/src/components/game.ctrl.btns.top.jsx
+++ b/client/src/components/game.ctrl.btns.top.jsx
@@ -8,6 +8,7 @@ const addState = connect(
const {
ws,
game,
+ account,
} = state;
function sendAbandon() {
@@ -20,6 +21,7 @@ const addState = connect(
return {
game,
+ account,
sendAbandon,
sendDraw,
@@ -39,6 +41,7 @@ const addState = connect(
function GameCtrlTopBtns(args) {
const {
game,
+ account,
leave,
sendAbandon,
@@ -48,6 +51,9 @@ function GameCtrlTopBtns(args) {
const finished = game && game.phase === 'Finished';
const { abandonState, drawState } = this.state;
+ const player = game.players.find(p => p.id === account.id);
+ const drawOffered = player && player.draw_offered;
+
const abandonStateTrue = e => {
e.stopPropagation();
this.setState({ abandonState: true });
@@ -66,10 +72,12 @@ function GameCtrlTopBtns(args) {
const abandonBtn = ;
- const drawClasses = `draw ${drawState ? 'confirming' : ''}`;
- const drawText = drawState ? 'Draw' : 'Offer';
+ const drawClasses = `draw ${drawState || drawOffered ? 'confirming' : ''}`;
+ const drawText = drawOffered
+ ? 'Offered'
+ : drawState ? 'Draw' : 'Offer';
const drawAction = drawState ? sendDraw : drawStateTrue;
- const drawBtn = ;
+ const drawBtn = ;
return (
diff --git a/client/src/components/player.box.jsx b/client/src/components/player.box.jsx
index 2790d69f..9d55606e 100644
--- a/client/src/components/player.box.jsx
+++ b/client/src/components/player.box.jsx
@@ -68,6 +68,11 @@ function Scoreboard(args) {
};
const winner = player.score === 'Win';
+ const chatText = player.draw_offered
+ ? 'draw?'
+ : chat || '\u00A0';
+
+ console.log(chatText);
if (!isPlayer) {
const nameClass = `name ${player.img ? 'subscriber' : ''}`;
@@ -77,7 +82,7 @@ function Scoreboard(args) {
{scoreText()}
{player.name}
![]()
-
{chat || '\u00A0'}
+
{chatText}
);
}
@@ -87,7 +92,7 @@ function Scoreboard(args) {
return (
-
{chat || '\u00A0'}
+
{chatText}
{scoreText()}
{player.name}
![]()
diff --git a/server/src/instance.rs b/server/src/instance.rs
index eec93a0d..07498300 100644
--- a/server/src/instance.rs
+++ b/server/src/instance.rs
@@ -335,24 +335,7 @@ impl Instance {
}
fn finish_condition(&mut self) -> bool {
- // tennis
- for player in self.players.iter() {
- if player.score == Score::Win {
- self.winner = Some(player.id);
- return true;
- }
- }
- // Game defaults to lose otherwise
- if self.rounds.len() < 4 {
- return false;
- }
-
- // both players afk
- if self.players.iter().all(|p| p.score == Score::Zero) {
- return true;
- }
-
- return false;
+ self.players.iter().any(|p| p.score == Score::Win)
}
pub fn finish(&mut self) -> &mut Instance {