From 6b6726f3a6d76fd2c5db66707c10b9381a33269d Mon Sep 17 00:00:00 2001 From: ntr Date: Sun, 27 Oct 2019 13:20:58 +1100 Subject: [PATCH 1/4] v1.6.6 --- VERSION | 2 +- acp/package.json | 2 +- client/package.json | 2 +- ops/package.json | 2 +- server/Cargo.toml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index 49ebdd60..83d1a5eb 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.6.5 \ No newline at end of file +1.6.6 \ No newline at end of file diff --git a/acp/package.json b/acp/package.json index 2591fabe..a1935bb7 100644 --- a/acp/package.json +++ b/acp/package.json @@ -1,6 +1,6 @@ { "name": "mnml-client", - "version": "1.6.5", + "version": "1.6.6", "description": "", "main": "index.js", "scripts": { diff --git a/client/package.json b/client/package.json index 790e7aed..b6b1c359 100644 --- a/client/package.json +++ b/client/package.json @@ -1,6 +1,6 @@ { "name": "mnml-client", - "version": "1.6.5", + "version": "1.6.6", "description": "", "main": "index.js", "scripts": { diff --git a/ops/package.json b/ops/package.json index 40211410..ae05c7f0 100755 --- a/ops/package.json +++ b/ops/package.json @@ -1,6 +1,6 @@ { "name": "mnml-ops", - "version": "1.6.5", + "version": "1.6.6", "description": "", "main": "index.js", "scripts": { diff --git a/server/Cargo.toml b/server/Cargo.toml index 4df35fa1..c80430f6 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mnml" -version = "1.6.5" +version = "1.6.6" authors = ["ntr "] [dependencies] From 343731e7e894f25c317bdc7b7e1a51a2a4a61f4b Mon Sep 17 00:00:00 2001 From: ntr Date: Sun, 27 Oct 2019 14:12:38 +1100 Subject: [PATCH 2/4] draw fixes and client side showing --- client/src/components/game.ctrl.btns.top.jsx | 14 +++++++++++--- client/src/components/player.box.jsx | 9 +++++++-- server/src/instance.rs | 19 +------------------ 3 files changed, 19 insertions(+), 23 deletions(-) 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 { From d5764f0067d2f0b94485423cf9361f2d76323446 Mon Sep 17 00:00:00 2001 From: ntr Date: Sun, 27 Oct 2019 14:18:20 +1100 Subject: [PATCH 3/4] draw text change --- client/src/components/player.box.jsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/client/src/components/player.box.jsx b/client/src/components/player.box.jsx index 9d55606e..6cace8a4 100644 --- a/client/src/components/player.box.jsx +++ b/client/src/components/player.box.jsx @@ -68,11 +68,11 @@ function Scoreboard(args) { }; const winner = player.score === 'Win'; - const chatText = player.draw_offered - ? 'draw?' - : chat || '\u00A0'; - - console.log(chatText); + const chatText = chat + ? chat + : player.draw_offered + ? 'draw' + : '\u00A0'; if (!isPlayer) { const nameClass = `name ${player.img ? 'subscriber' : ''}`; From 45aad71939b2227e4e3a58a9457f1a825ff9b9cc Mon Sep 17 00:00:00 2001 From: ntr Date: Sun, 27 Oct 2019 14:57:27 +1100 Subject: [PATCH 4/4] changelog --- CHANGELOG.md | 1 - server/src/instance.rs | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 009c5d41..01b06b18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,6 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). - ## [1.6.5] - 2019-10-27 # Added - Offering of draws diff --git a/server/src/instance.rs b/server/src/instance.rs index 07498300..2e65b9d6 100644 --- a/server/src/instance.rs +++ b/server/src/instance.rs @@ -340,6 +340,13 @@ impl Instance { pub fn finish(&mut self) -> &mut Instance { self.phase = InstancePhase::Finished; + + for player in self.players.iter() { + if player.score == Score::Win { + self.winner = Some(player.id); + } + } + self }