reversi 💮 💯
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import $ from 'cafy'; import ID from '../../../../cafy-id';
|
||||
import OthelloGame, { pack } from '../../../../models/othello-game';
|
||||
import ReversiGame, { pack } from '../../../../models/reversi-game';
|
||||
|
||||
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
// Get 'my' parameter
|
||||
@ -50,7 +50,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
}
|
||||
|
||||
// Fetch games
|
||||
const games = await OthelloGame.find(q, {
|
||||
const games = await ReversiGame.find(q, {
|
||||
sort,
|
||||
limit
|
||||
});
|
@ -1,19 +1,19 @@
|
||||
import $ from 'cafy'; import ID from '../../../../../cafy-id';
|
||||
import OthelloGame, { pack } from '../../../../../models/othello-game';
|
||||
import Othello from '../../../../../othello/core';
|
||||
import ReversiGame, { pack } from '../../../../../models/reversi-game';
|
||||
import Reversi from '../../../../../reversi/core';
|
||||
|
||||
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
// Get 'gameId' parameter
|
||||
const [gameId, gameIdErr] = $.type(ID).get(params.gameId);
|
||||
if (gameIdErr) return rej('invalid gameId param');
|
||||
|
||||
const game = await OthelloGame.findOne({ _id: gameId });
|
||||
const game = await ReversiGame.findOne({ _id: gameId });
|
||||
|
||||
if (game == null) {
|
||||
return rej('game not found');
|
||||
}
|
||||
|
||||
const o = new Othello(game.settings.map, {
|
||||
const o = new Reversi(game.settings.map, {
|
||||
isLlotheo: game.settings.isLlotheo,
|
||||
canPutEverywhere: game.settings.canPutEverywhere,
|
||||
loopedBoard: game.settings.loopedBoard
|
@ -1,4 +1,4 @@
|
||||
import Matching, { pack as packMatching } from '../../../../models/othello-matching';
|
||||
import Matching, { pack as packMatching } from '../../../../models/reversi-matching';
|
||||
|
||||
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
// Find session
|
@ -1,9 +1,9 @@
|
||||
import $ from 'cafy'; import ID from '../../../../cafy-id';
|
||||
import Matching, { pack as packMatching } from '../../../../models/othello-matching';
|
||||
import OthelloGame, { pack as packGame } from '../../../../models/othello-game';
|
||||
import Matching, { pack as packMatching } from '../../../../models/reversi-matching';
|
||||
import ReversiGame, { pack as packGame } from '../../../../models/reversi-game';
|
||||
import User from '../../../../models/user';
|
||||
import publishUserStream, { publishOthelloStream } from '../../../../publishers/stream';
|
||||
import { eighteight } from '../../../../othello/maps';
|
||||
import publishUserStream, { publishReversiStream } from '../../../../publishers/stream';
|
||||
import { eighteight } from '../../../../reversi/maps';
|
||||
|
||||
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
// Get 'userId' parameter
|
||||
@ -28,7 +28,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
});
|
||||
|
||||
// Create game
|
||||
const game = await OthelloGame.insert({
|
||||
const game = await ReversiGame.insert({
|
||||
createdAt: new Date(),
|
||||
user1Id: exist.parentId,
|
||||
user2Id: user._id,
|
||||
@ -47,14 +47,14 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
// Reponse
|
||||
res(await packGame(game, user));
|
||||
|
||||
publishOthelloStream(exist.parentId, 'matched', await packGame(game, exist.parentId));
|
||||
publishReversiStream(exist.parentId, 'matched', await packGame(game, exist.parentId));
|
||||
|
||||
const other = await Matching.count({
|
||||
childId: user._id
|
||||
});
|
||||
|
||||
if (other == 0) {
|
||||
publishUserStream(user._id, 'othello_no_invites');
|
||||
publishUserStream(user._id, 'reversi_no_invites');
|
||||
}
|
||||
} else {
|
||||
// Fetch child
|
||||
@ -88,8 +88,8 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
const packed = await packMatching(matching, child);
|
||||
|
||||
// 招待
|
||||
publishOthelloStream(child._id, 'invited', packed);
|
||||
publishReversiStream(child._id, 'invited', packed);
|
||||
|
||||
publishUserStream(child._id, 'othello_invited', packed);
|
||||
publishUserStream(child._id, 'reversi_invited', packed);
|
||||
}
|
||||
});
|
@ -1,4 +1,4 @@
|
||||
import Matching from '../../../../../models/othello-matching';
|
||||
import Matching from '../../../../../models/reversi-matching';
|
||||
|
||||
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
await Matching.remove({
|
Reference in New Issue
Block a user