diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-03-08 17:57:57 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-03-08 17:57:57 +0900 |
| commit | 155012846d8f142515390adb2754b45cdfbb74ef (patch) | |
| tree | 13b237f9464a7df918fee7f35ba6871d08c1ed1c /src/api/endpoints | |
| parent | Fix bug (diff) | |
| download | sharkey-155012846d8f142515390adb2754b45cdfbb74ef.tar.gz sharkey-155012846d8f142515390adb2754b45cdfbb74ef.tar.bz2 sharkey-155012846d8f142515390adb2754b45cdfbb74ef.zip | |
#1200
Diffstat (limited to 'src/api/endpoints')
| -rw-r--r-- | src/api/endpoints/othello/games.ts | 9 | ||||
| -rw-r--r-- | src/api/endpoints/othello/match.ts | 20 |
2 files changed, 19 insertions, 10 deletions
diff --git a/src/api/endpoints/othello/games.ts b/src/api/endpoints/othello/games.ts index 39963fcd29..dd9fb5ef52 100644 --- a/src/api/endpoints/othello/games.ts +++ b/src/api/endpoints/othello/games.ts @@ -7,12 +7,15 @@ module.exports = (params, user) => new Promise(async (res, rej) => { if (myErr) return rej('invalid my param'); const q = my ? { + is_started: true, $or: [{ - black_user_id: user._id + user1_id: user._id }, { - white_user_id: user._id + user2_id: user._id }] - } : {}; + } : { + is_started: true + }; // Fetch games const games = await Game.find(q, { diff --git a/src/api/endpoints/othello/match.ts b/src/api/endpoints/othello/match.ts index cb094bbc65..05b87a541a 100644 --- a/src/api/endpoints/othello/match.ts +++ b/src/api/endpoints/othello/match.ts @@ -3,6 +3,7 @@ import Matching, { pack as packMatching } from '../../models/othello-matching'; import Game, { pack as packGame } from '../../models/othello-game'; import User from '../../models/user'; import { publishOthelloStream } from '../../event'; +import { eighteight } from '../../../common/othello/maps'; module.exports = (params, user) => new Promise(async (res, rej) => { // Get 'user_id' parameter @@ -26,16 +27,21 @@ module.exports = (params, user) => new Promise(async (res, rej) => { _id: exist._id }); - const parentIsBlack = Math.random() > 0.5; - - // Start game + // Create game const game = await Game.insert({ created_at: new Date(), - black_user_id: parentIsBlack ? exist.parent_id : user._id, - white_user_id: parentIsBlack ? user._id : exist.parent_id, - turn_user_id: parentIsBlack ? exist.parent_id : user._id, + user1_id: exist.parent_id, + user2_id: user._id, + user1_accepted: false, + user2_accepted: false, + is_started: false, is_ended: false, - logs: [] + logs: [], + settings: { + map: eighteight, + bw: 'random', + is_llotheo: false + } }); // Reponse |