forked from mirror/misskey
✌️
This commit is contained in:
parent
59fbf693ed
commit
a8d086596f
@ -113,6 +113,36 @@ export default function(request: websocket.request, connection: websocket.connec
|
||||
}
|
||||
});
|
||||
|
||||
//#region 盤面に最初から石がないなどして始まった瞬間に勝敗が決定する場合があるのでその処理
|
||||
const o = new Othello(freshGame.settings.map, {
|
||||
isLlotheo: freshGame.settings.is_llotheo
|
||||
});
|
||||
|
||||
if (o.isEnded) {
|
||||
let winner;
|
||||
if (o.winner == 'black') {
|
||||
winner = freshGame.black == 1 ? freshGame.user1_id : freshGame.user2_id;
|
||||
} else if (o.winner == 'white') {
|
||||
winner = freshGame.black == 1 ? freshGame.user2_id : freshGame.user1_id;
|
||||
} else {
|
||||
winner = null;
|
||||
}
|
||||
|
||||
await Game.update({
|
||||
_id: gameId
|
||||
}, {
|
||||
$set: {
|
||||
is_ended: true,
|
||||
winner_id: winner
|
||||
}
|
||||
});
|
||||
|
||||
publishOthelloGameStream(gameId, 'ended', {
|
||||
winner_id: winner
|
||||
});
|
||||
}
|
||||
//#endregion
|
||||
|
||||
publishOthelloGameStream(gameId, 'started', await pack(gameId));
|
||||
}, 3000);
|
||||
}
|
||||
|
@ -49,6 +49,15 @@ export default class Othello {
|
||||
b: this.blackP,
|
||||
w: this.whiteP
|
||||
}];
|
||||
|
||||
// ゲームが始まった時点で片方の色の石しかないか、始まった時点で勝敗が決定するようなマップの場合がある
|
||||
if (this.canPutSomewhere('black').length == 0) {
|
||||
if (this.canPutSomewhere('white').length == 0) {
|
||||
this.turn = null;
|
||||
} else {
|
||||
this.turn = 'white';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user