Merge tag '1.6.6' into develop
1.6.6
This commit is contained in:
commit
620171f464
@ -2,7 +2,6 @@
|
|||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
|
|
||||||
## [1.6.5] - 2019-10-27
|
## [1.6.5] - 2019-10-27
|
||||||
# Added
|
# Added
|
||||||
- Offering of draws
|
- Offering of draws
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "mnml-client",
|
"name": "mnml-client",
|
||||||
"version": "1.6.5",
|
"version": "1.6.6",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "mnml-client",
|
"name": "mnml-client",
|
||||||
"version": "1.6.5",
|
"version": "1.6.6",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@ -8,6 +8,7 @@ const addState = connect(
|
|||||||
const {
|
const {
|
||||||
ws,
|
ws,
|
||||||
game,
|
game,
|
||||||
|
account,
|
||||||
} = state;
|
} = state;
|
||||||
|
|
||||||
function sendAbandon() {
|
function sendAbandon() {
|
||||||
@ -20,6 +21,7 @@ const addState = connect(
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
game,
|
game,
|
||||||
|
account,
|
||||||
|
|
||||||
sendAbandon,
|
sendAbandon,
|
||||||
sendDraw,
|
sendDraw,
|
||||||
@ -39,6 +41,7 @@ const addState = connect(
|
|||||||
function GameCtrlTopBtns(args) {
|
function GameCtrlTopBtns(args) {
|
||||||
const {
|
const {
|
||||||
game,
|
game,
|
||||||
|
account,
|
||||||
|
|
||||||
leave,
|
leave,
|
||||||
sendAbandon,
|
sendAbandon,
|
||||||
@ -48,6 +51,9 @@ function GameCtrlTopBtns(args) {
|
|||||||
const finished = game && game.phase === 'Finished';
|
const finished = game && game.phase === 'Finished';
|
||||||
const { abandonState, drawState } = this.state;
|
const { abandonState, drawState } = this.state;
|
||||||
|
|
||||||
|
const player = game.players.find(p => p.id === account.id);
|
||||||
|
const drawOffered = player && player.draw_offered;
|
||||||
|
|
||||||
const abandonStateTrue = e => {
|
const abandonStateTrue = e => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
this.setState({ abandonState: true });
|
this.setState({ abandonState: true });
|
||||||
@ -66,10 +72,12 @@ function GameCtrlTopBtns(args) {
|
|||||||
|
|
||||||
const abandonBtn = <button class={abandonClasses} disabled={finished} onClick={abandonAction}>{abandonText}</button>;
|
const abandonBtn = <button class={abandonClasses} disabled={finished} onClick={abandonAction}>{abandonText}</button>;
|
||||||
|
|
||||||
const drawClasses = `draw ${drawState ? 'confirming' : ''}`;
|
const drawClasses = `draw ${drawState || drawOffered ? 'confirming' : ''}`;
|
||||||
const drawText = drawState ? 'Draw' : 'Offer';
|
const drawText = drawOffered
|
||||||
|
? 'Offered'
|
||||||
|
: drawState ? 'Draw' : 'Offer';
|
||||||
const drawAction = drawState ? sendDraw : drawStateTrue;
|
const drawAction = drawState ? sendDraw : drawStateTrue;
|
||||||
const drawBtn = <button class={drawClasses} disabled={finished} onClick={drawAction}>{drawText}</button>;
|
const drawBtn = <button class={drawClasses} disabled={finished || drawOffered} onClick={drawAction}>{drawText}</button>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="instance-ctrl-btns">
|
<div class="instance-ctrl-btns">
|
||||||
|
|||||||
@ -68,6 +68,11 @@ function Scoreboard(args) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const winner = player.score === 'Win';
|
const winner = player.score === 'Win';
|
||||||
|
const chatText = chat
|
||||||
|
? chat
|
||||||
|
: player.draw_offered
|
||||||
|
? 'draw'
|
||||||
|
: '\u00A0';
|
||||||
|
|
||||||
if (!isPlayer) {
|
if (!isPlayer) {
|
||||||
const nameClass = `name ${player.img ? 'subscriber' : ''}`;
|
const nameClass = `name ${player.img ? 'subscriber' : ''}`;
|
||||||
@ -77,7 +82,7 @@ function Scoreboard(args) {
|
|||||||
<div class="score">{scoreText()}</div>
|
<div class="score">{scoreText()}</div>
|
||||||
<div class={nameClass}>{player.name}</div>
|
<div class={nameClass}>{player.name}</div>
|
||||||
<Img img={player.img} id={player.id} />
|
<Img img={player.img} id={player.id} />
|
||||||
<div class="msg">{chat || '\u00A0'}</div>
|
<div class="msg">{chatText}</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -87,7 +92,7 @@ function Scoreboard(args) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div class={boxClass}>
|
<div class={boxClass}>
|
||||||
<div class="msg">{chat || '\u00A0'}</div>
|
<div class="msg">{chatText}</div>
|
||||||
<div class="score">{scoreText()}</div>
|
<div class="score">{scoreText()}</div>
|
||||||
<div class={nameClass}>{player.name}</div>
|
<div class={nameClass}>{player.name}</div>
|
||||||
<Img img={player.img} id={player.id} />
|
<Img img={player.img} id={player.id} />
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "mnml-ops",
|
"name": "mnml-ops",
|
||||||
"version": "1.6.5",
|
"version": "1.6.6",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "mnml"
|
name = "mnml"
|
||||||
version = "1.6.5"
|
version = "1.6.6"
|
||||||
authors = ["ntr <ntr@smokestack.io>"]
|
authors = ["ntr <ntr@smokestack.io>"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@ -335,28 +335,18 @@ impl Instance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn finish_condition(&mut self) -> bool {
|
fn finish_condition(&mut self) -> bool {
|
||||||
// tennis
|
self.players.iter().any(|p| p.score == Score::Win)
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn finish(&mut self) -> &mut Instance {
|
pub fn finish(&mut self) -> &mut Instance {
|
||||||
self.phase = InstancePhase::Finished;
|
self.phase = InstancePhase::Finished;
|
||||||
|
|
||||||
|
for player in self.players.iter() {
|
||||||
|
if player.score == Score::Win {
|
||||||
|
self.winner = Some(player.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user