mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-12-23 16:13:07 +02:00
Refactorijg
This commit is contained in:
parent
2cdcbcc80e
commit
865fd25af1
19 changed files with 46 additions and 44 deletions
|
@ -58,7 +58,7 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import * as CRC32 from 'crc-32';
|
import * as CRC32 from 'crc-32';
|
||||||
import Reversi, { Color } from '../../../../../reversi/core';
|
import Reversi, { Color } from '../../../../../games/reversi/core';
|
||||||
import { url } from '../../../config';
|
import { url } from '../../../config';
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
|
|
|
@ -94,7 +94,7 @@
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import * as maps from '../../../../../reversi/maps';
|
import * as maps from '../../../../../games/reversi/maps';
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
props: ['game', 'connection'],
|
props: ['game', 'connection'],
|
||||||
|
|
|
@ -99,18 +99,18 @@ export default Vue.extend({
|
||||||
this.connection.on('matched', this.onMatched);
|
this.connection.on('matched', this.onMatched);
|
||||||
this.connection.on('invited', this.onInvited);
|
this.connection.on('invited', this.onInvited);
|
||||||
|
|
||||||
(this as any).api('reversi/games', {
|
(this as any).api('games/reversi/games', {
|
||||||
my: true
|
my: true
|
||||||
}).then(games => {
|
}).then(games => {
|
||||||
this.myGames = games;
|
this.myGames = games;
|
||||||
});
|
});
|
||||||
|
|
||||||
(this as any).api('reversi/games').then(games => {
|
(this as any).api('games/reversi/games').then(games => {
|
||||||
this.games = games;
|
this.games = games;
|
||||||
this.gamesFetching = false;
|
this.gamesFetching = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
(this as any).api('reversi/invitations').then(invitations => {
|
(this as any).api('games/reversi/invitations').then(invitations => {
|
||||||
this.invitations = this.invitations.concat(invitations);
|
this.invitations = this.invitations.concat(invitations);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
go(game) {
|
go(game) {
|
||||||
(this as any).api('reversi/games/show', {
|
(this as any).api('games/reversi/games/show', {
|
||||||
gameId: game.id
|
gameId: game.id
|
||||||
}).then(game => {
|
}).then(game => {
|
||||||
this.matching = null;
|
this.matching = null;
|
||||||
|
@ -146,7 +146,7 @@ export default Vue.extend({
|
||||||
(this as any).api('users/show', {
|
(this as any).api('users/show', {
|
||||||
username
|
username
|
||||||
}).then(user => {
|
}).then(user => {
|
||||||
(this as any).api('reversi/match', {
|
(this as any).api('games/reversi/match', {
|
||||||
userId: user.id
|
userId: user.id
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
|
@ -160,10 +160,10 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
cancel() {
|
cancel() {
|
||||||
this.matching = null;
|
this.matching = null;
|
||||||
(this as any).api('reversi/match/cancel');
|
(this as any).api('games/reversi/match/cancel');
|
||||||
},
|
},
|
||||||
accept(invitation) {
|
accept(invitation) {
|
||||||
(this as any).api('reversi/match', {
|
(this as any).api('games/reversi/match', {
|
||||||
userId: invitation.parent.id
|
userId: invitation.parent.id
|
||||||
}).then(game => {
|
}).then(game => {
|
||||||
if (game) {
|
if (game) {
|
||||||
|
|
|
@ -33,7 +33,7 @@ export default Vue.extend({
|
||||||
Progress.start();
|
Progress.start();
|
||||||
this.fetching = true;
|
this.fetching = true;
|
||||||
|
|
||||||
(this as any).api('reversi/games/show', {
|
(this as any).api('games/reversi/games/show', {
|
||||||
gameId: this.$route.params.game
|
gameId: this.$route.params.game
|
||||||
}).then(game => {
|
}).then(game => {
|
||||||
this.game = game;
|
this.game = game;
|
||||||
|
|
|
@ -33,7 +33,7 @@ export default Vue.extend({
|
||||||
Progress.start();
|
Progress.start();
|
||||||
this.fetching = true;
|
this.fetching = true;
|
||||||
|
|
||||||
(this as any).api('reversi/games/show', {
|
(this as any).api('games/reversi/games/show', {
|
||||||
gameId: this.$route.params.game
|
gameId: this.$route.params.game
|
||||||
}).then(game => {
|
}).then(game => {
|
||||||
this.game = game;
|
this.game = game;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
// MISSKEY REVERSI ENGINE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* true ... 黒
|
* true ... 黒
|
||||||
* false ... 白
|
* false ... 白
|
||||||
|
@ -18,7 +20,7 @@ export type Undo = {
|
||||||
/**
|
/**
|
||||||
* 色
|
* 色
|
||||||
*/
|
*/
|
||||||
color: Color,
|
color: Color;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* どこに打ったか
|
* どこに打ったか
|
|
@ -1,7 +1,7 @@
|
||||||
import * as mongo from 'mongodb';
|
import * as mongo from 'mongodb';
|
||||||
const deepcopy = require('deepcopy');
|
const deepcopy = require('deepcopy');
|
||||||
import db from '../db/mongodb';
|
import db from '../../../db/mongodb';
|
||||||
import { IUser, pack as packUser } from './user';
|
import { IUser, pack as packUser } from '../../user';
|
||||||
|
|
||||||
const ReversiGame = db.get<IReversiGame>('reversiGames');
|
const ReversiGame = db.get<IReversiGame>('reversiGames');
|
||||||
export default ReversiGame;
|
export default ReversiGame;
|
|
@ -1,7 +1,7 @@
|
||||||
import * as mongo from 'mongodb';
|
import * as mongo from 'mongodb';
|
||||||
const deepcopy = require('deepcopy');
|
const deepcopy = require('deepcopy');
|
||||||
import db from '../db/mongodb';
|
import db from '../../../db/mongodb';
|
||||||
import { IUser, pack as packUser } from './user';
|
import { IUser, pack as packUser } from '../../user';
|
||||||
|
|
||||||
const Matching = db.get<IMatching>('reversiMatchings');
|
const Matching = db.get<IMatching>('reversiMatchings');
|
||||||
export default Matching;
|
export default Matching;
|
|
@ -4,7 +4,7 @@ import Mute from '../models/mute';
|
||||||
import { pack } from '../models/notification';
|
import { pack } from '../models/notification';
|
||||||
import stream from './stream';
|
import stream from './stream';
|
||||||
import User from '../models/user';
|
import User from '../models/user';
|
||||||
import pushSw from '../publishers/push-sw';
|
import pushSw from './push-sw
|
||||||
|
|
||||||
export default (
|
export default (
|
||||||
notifiee: mongo.ObjectID,
|
notifiee: mongo.ObjectID,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import getUserName from '../renderers/get-user-name';
|
import getUserName from './get-user-name
|
||||||
import getNoteSummary from './get-note-summary';
|
import getNoteSummary from './get-note-summary';
|
||||||
import getReactionEmoji from './get-reaction-emoji';
|
import getReactionEmoji from './get-reaction-emoji';
|
||||||
|
|
||||||
|
|
|
@ -245,27 +245,27 @@ const endpoints: Endpoint[] = [
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'reversi/match',
|
name: 'games/reversi/match',
|
||||||
withCredential: true
|
withCredential: true
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'reversi/match/cancel',
|
name: 'games/reversi/match/cancel',
|
||||||
withCredential: true
|
withCredential: true
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'reversi/invitations',
|
name: 'games/reversi/invitations',
|
||||||
withCredential: true
|
withCredential: true
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'reversi/games',
|
name: 'games/reversi/games',
|
||||||
withCredential: true
|
withCredential: true
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
name: 'reversi/games/show'
|
name: 'games/reversi/games/show'
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import $ from 'cafy'; import ID from '../../../../cafy-id';
|
import $ from 'cafy'; import ID from '../../../../../cafy-id';
|
||||||
import ReversiGame, { pack } from '../../../../models/reversi-game';
|
import ReversiGame, { pack } from '../../../../../models/games/reversi/game';
|
||||||
import { ILocalUser } from '../../../../models/user';
|
import { ILocalUser } from '../../../../../models/user';
|
||||||
|
|
||||||
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
||||||
// Get 'my' parameter
|
// Get 'my' parameter
|
|
@ -1,7 +1,7 @@
|
||||||
import $ from 'cafy'; import ID from '../../../../../cafy-id';
|
import $ from 'cafy'; import ID from '../../../../../../cafy-id';
|
||||||
import ReversiGame, { pack } from '../../../../../models/reversi-game';
|
import ReversiGame, { pack } from '../../../../../../models/games/reversi/game';
|
||||||
import Reversi from '../../../../../reversi/core';
|
import Reversi from '../../../../../../games/reversi/core';
|
||||||
import { ILocalUser } from '../../../../../models/user';
|
import { ILocalUser } from '../../../../../../models/user';
|
||||||
|
|
||||||
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
||||||
// Get 'gameId' parameter
|
// Get 'gameId' parameter
|
|
@ -1,5 +1,5 @@
|
||||||
import Matching, { pack as packMatching } from '../../../../models/reversi-matching';
|
import Matching, { pack as packMatching } from '../../../../../models/games/reversi/matching';
|
||||||
import { ILocalUser } from '../../../../models/user';
|
import { ILocalUser } from '../../../../../models/user';
|
||||||
|
|
||||||
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
||||||
// Find session
|
// Find session
|
|
@ -1,9 +1,9 @@
|
||||||
import $ from 'cafy'; import ID from '../../../../cafy-id';
|
import $ from 'cafy'; import ID from '../../../../../cafy-id';
|
||||||
import Matching, { pack as packMatching } from '../../../../models/reversi-matching';
|
import Matching, { pack as packMatching } from '../../../../../models/games/reversi/matching';
|
||||||
import ReversiGame, { pack as packGame } from '../../../../models/reversi-game';
|
import ReversiGame, { pack as packGame } from '../../../../../models/games/reversi/game';
|
||||||
import User, { ILocalUser } from '../../../../models/user';
|
import User, { ILocalUser } from '../../../../../models/user';
|
||||||
import publishUserStream, { publishReversiStream } from '../../../../publishers/stream';
|
import publishUserStream, { publishReversiStream } from '../../../../../publishers/stream';
|
||||||
import { eighteight } from '../../../../reversi/maps';
|
import { eighteight } from '../../../../../games/reversi/maps';
|
||||||
|
|
||||||
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
||||||
// Get 'userId' parameter
|
// Get 'userId' parameter
|
|
@ -1,5 +1,5 @@
|
||||||
import Matching from '../../../../../models/reversi-matching';
|
import Matching from '../../../../../../models/games/reversi/matching';
|
||||||
import { ILocalUser } from '../../../../../models/user';
|
import { ILocalUser } from '../../../../../../models/user';
|
||||||
|
|
||||||
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
|
||||||
await Matching.remove({
|
await Matching.remove({
|
|
@ -1,10 +1,10 @@
|
||||||
import * as websocket from 'websocket';
|
import * as websocket from 'websocket';
|
||||||
import * as redis from 'redis';
|
import * as redis from 'redis';
|
||||||
import * as CRC32 from 'crc-32';
|
import * as CRC32 from 'crc-32';
|
||||||
import ReversiGame, { pack } from '../../../models/reversi-game';
|
import ReversiGame, { pack } from '../../../models/games/reversi/game';
|
||||||
import { publishReversiGameStream } from '../../../publishers/stream';
|
import { publishReversiGameStream } from '../../../publishers/stream';
|
||||||
import Reversi from '../../../reversi/core';
|
import Reversi from '../../../games/reversi/core';
|
||||||
import * as maps from '../../../reversi/maps';
|
import * as maps from '../../../games/reversi/maps';
|
||||||
import { ParsedUrlQuery } from 'querystring';
|
import { ParsedUrlQuery } from 'querystring';
|
||||||
|
|
||||||
export default function(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient, user?: any): void {
|
export default function(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient, user?: any): void {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import * as mongo from 'mongodb';
|
import * as mongo from 'mongodb';
|
||||||
import * as websocket from 'websocket';
|
import * as websocket from 'websocket';
|
||||||
import * as redis from 'redis';
|
import * as redis from 'redis';
|
||||||
import Matching, { pack } from '../../../models/reversi-matching';
|
import Matching, { pack } from '../../../models/games/reversi/matching';
|
||||||
import publishUserStream from '../../../publishers/stream';
|
import publishUserStream from '../../../publishers/stream';
|
||||||
|
|
||||||
export default function(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient, user: any): void {
|
export default function(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient, user: any): void {
|
||||||
|
|
Loading…
Reference in a new issue