Refactorijg

This commit is contained in:
syuilo 2018-07-07 19:01:33 +09:00
parent 2cdcbcc80e
commit 865fd25af1
19 changed files with 46 additions and 44 deletions

View file

@ -58,7 +58,7 @@
<script lang="ts">
import Vue from 'vue';
import * as CRC32 from 'crc-32';
import Reversi, { Color } from '../../../../../reversi/core';
import Reversi, { Color } from '../../../../../games/reversi/core';
import { url } from '../../../config';
export default Vue.extend({

View file

@ -94,7 +94,7 @@
<script lang="ts">
import Vue from 'vue';
import * as maps from '../../../../../reversi/maps';
import * as maps from '../../../../../games/reversi/maps';
export default Vue.extend({
props: ['game', 'connection'],

View file

@ -99,18 +99,18 @@ export default Vue.extend({
this.connection.on('matched', this.onMatched);
this.connection.on('invited', this.onInvited);
(this as any).api('reversi/games', {
(this as any).api('games/reversi/games', {
my: true
}).then(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.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);
});
@ -132,7 +132,7 @@ export default Vue.extend({
},
methods: {
go(game) {
(this as any).api('reversi/games/show', {
(this as any).api('games/reversi/games/show', {
gameId: game.id
}).then(game => {
this.matching = null;
@ -146,7 +146,7 @@ export default Vue.extend({
(this as any).api('users/show', {
username
}).then(user => {
(this as any).api('reversi/match', {
(this as any).api('games/reversi/match', {
userId: user.id
}).then(res => {
if (res == null) {
@ -160,10 +160,10 @@ export default Vue.extend({
},
cancel() {
this.matching = null;
(this as any).api('reversi/match/cancel');
(this as any).api('games/reversi/match/cancel');
},
accept(invitation) {
(this as any).api('reversi/match', {
(this as any).api('games/reversi/match', {
userId: invitation.parent.id
}).then(game => {
if (game) {

View file

@ -33,7 +33,7 @@ export default Vue.extend({
Progress.start();
this.fetching = true;
(this as any).api('reversi/games/show', {
(this as any).api('games/reversi/games/show', {
gameId: this.$route.params.game
}).then(game => {
this.game = game;

View file

@ -33,7 +33,7 @@ export default Vue.extend({
Progress.start();
this.fetching = true;
(this as any).api('reversi/games/show', {
(this as any).api('games/reversi/games/show', {
gameId: this.$route.params.game
}).then(game => {
this.game = game;

View file

@ -1,3 +1,5 @@
// MISSKEY REVERSI ENGINE
/**
* true ...
* false ...
@ -18,7 +20,7 @@ export type Undo = {
/**
*
*/
color: Color,
color: Color;
/**
*

View file

@ -1,7 +1,7 @@
import * as mongo from 'mongodb';
const deepcopy = require('deepcopy');
import db from '../db/mongodb';
import { IUser, pack as packUser } from './user';
import db from '../../../db/mongodb';
import { IUser, pack as packUser } from '../../user';
const ReversiGame = db.get<IReversiGame>('reversiGames');
export default ReversiGame;

View file

@ -1,7 +1,7 @@
import * as mongo from 'mongodb';
const deepcopy = require('deepcopy');
import db from '../db/mongodb';
import { IUser, pack as packUser } from './user';
import db from '../../../db/mongodb';
import { IUser, pack as packUser } from '../../user';
const Matching = db.get<IMatching>('reversiMatchings');
export default Matching;

View file

@ -4,7 +4,7 @@ import Mute from '../models/mute';
import { pack } from '../models/notification';
import stream from './stream';
import User from '../models/user';
import pushSw from '../publishers/push-sw';
import pushSw from './push-sw
export default (
notifiee: mongo.ObjectID,

View file

@ -1,4 +1,4 @@
import getUserName from '../renderers/get-user-name';
import getUserName from './get-user-name
import getNoteSummary from './get-note-summary';
import getReactionEmoji from './get-reaction-emoji';

View file

@ -245,27 +245,27 @@ const endpoints: Endpoint[] = [
},
{
name: 'reversi/match',
name: 'games/reversi/match',
withCredential: true
},
{
name: 'reversi/match/cancel',
name: 'games/reversi/match/cancel',
withCredential: true
},
{
name: 'reversi/invitations',
name: 'games/reversi/invitations',
withCredential: true
},
{
name: 'reversi/games',
name: 'games/reversi/games',
withCredential: true
},
{
name: 'reversi/games/show'
name: 'games/reversi/games/show'
},
{

View file

@ -1,6 +1,6 @@
import $ from 'cafy'; import ID from '../../../../cafy-id';
import ReversiGame, { pack } from '../../../../models/reversi-game';
import { ILocalUser } from '../../../../models/user';
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import ReversiGame, { pack } from '../../../../../models/games/reversi/game';
import { ILocalUser } from '../../../../../models/user';
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'my' parameter

View file

@ -1,7 +1,7 @@
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import ReversiGame, { pack } from '../../../../../models/reversi-game';
import Reversi from '../../../../../reversi/core';
import { ILocalUser } from '../../../../../models/user';
import $ from 'cafy'; import ID from '../../../../../../cafy-id';
import ReversiGame, { pack } from '../../../../../../models/games/reversi/game';
import Reversi from '../../../../../../games/reversi/core';
import { ILocalUser } from '../../../../../../models/user';
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'gameId' parameter

View file

@ -1,5 +1,5 @@
import Matching, { pack as packMatching } from '../../../../models/reversi-matching';
import { ILocalUser } from '../../../../models/user';
import Matching, { pack as packMatching } from '../../../../../models/games/reversi/matching';
import { ILocalUser } from '../../../../../models/user';
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Find session

View file

@ -1,9 +1,9 @@
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Matching, { pack as packMatching } from '../../../../models/reversi-matching';
import ReversiGame, { pack as packGame } from '../../../../models/reversi-game';
import User, { ILocalUser } from '../../../../models/user';
import publishUserStream, { publishReversiStream } from '../../../../publishers/stream';
import { eighteight } from '../../../../reversi/maps';
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import Matching, { pack as packMatching } from '../../../../../models/games/reversi/matching';
import ReversiGame, { pack as packGame } from '../../../../../models/games/reversi/game';
import User, { ILocalUser } from '../../../../../models/user';
import publishUserStream, { publishReversiStream } from '../../../../../publishers/stream';
import { eighteight } from '../../../../../games/reversi/maps';
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'userId' parameter

View file

@ -1,5 +1,5 @@
import Matching from '../../../../../models/reversi-matching';
import { ILocalUser } from '../../../../../models/user';
import Matching from '../../../../../../models/games/reversi/matching';
import { ILocalUser } from '../../../../../../models/user';
export default (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
await Matching.remove({

View file

@ -1,10 +1,10 @@
import * as websocket from 'websocket';
import * as redis from 'redis';
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 Reversi from '../../../reversi/core';
import * as maps from '../../../reversi/maps';
import Reversi from '../../../games/reversi/core';
import * as maps from '../../../games/reversi/maps';
import { ParsedUrlQuery } from 'querystring';
export default function(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient, user?: any): void {

View file

@ -1,7 +1,7 @@
import * as mongo from 'mongodb';
import * as websocket from 'websocket';
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';
export default function(request: websocket.request, connection: websocket.connection, subscriber: redis.RedisClient, user: any): void {