Skip to content

Commit

Permalink
Creating gameEngine folder under gameplay (#736)
Browse files Browse the repository at this point in the history
  • Loading branch information
kev306 authored Feb 8, 2025
1 parent 992a025 commit 472377b
Show file tree
Hide file tree
Showing 56 changed files with 81 additions and 73 deletions.
2 changes: 1 addition & 1 deletion src/databaseAdapters/user.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import User from '../models/user';
import { IUser } from '../gameplay/types';
import { IUser } from '../gameplay/gameEngine/types';
import { S3AvatarSet } from '../clients/s3/S3Agent';

interface DatabaseAdapter {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import shuffleArray from '../util/shuffleArray';
import shuffleArray from '../../util/shuffleArray';
import { IRecoverable, RecoverableComponent } from './types';

const ANON_NAMES = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Phase } from '../../phases/types';
import { Card, ICard } from '../types';
import { SocketUser } from '../../../sockets/types';
import { SocketUser } from '../../../../sockets/types';

class LadyOfTheLake implements ICard {
private thisRoom: any;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Phase } from '../../phases/types';
import { Card, ICard } from '../types';
import { SocketUser } from '../../../sockets/types';
import { SocketUser } from '../../../../sockets/types';

class RefOfTheRain implements ICard {
private thisRoom: any;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Phase } from '../../phases/types';
import { Card, ICard } from '../types';
import { SocketUser } from '../../../sockets/types';
import { SocketUser } from '../../../../sockets/types';

class SireOfTheSea implements ICard {
private thisRoom: any;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SocketUser } from '../../sockets/types';
import { SocketUser } from '../../../sockets/types';

export enum Card {
LadyOfTheLake = 'Lady of the Lake',
Expand Down
26 changes: 13 additions & 13 deletions src/gameplay/game.ts → src/gameplay/gameEngine/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import _ from 'lodash';

import Room, { RoomConfig } from './room';
import usernamesIndexes from '../myFunctions/usernamesIndexes';
import User from '../models/user';
import GameRecord from '../models/gameRecord';
import RatingPeriodGameRecord from '../models/RatingPeriodGameRecord';
import { isMod } from '../modsadmins/mods';
import { isTO } from '../modsadmins/tournamentOrganizers';
import { isDev } from '../modsadmins/developers';
import { modOrTOString } from '../modsadmins/modOrTO';
import usernamesIndexes from '../../myFunctions/usernamesIndexes';
import User from '../../models/user';
import GameRecord from '../../models/gameRecord';
import RatingPeriodGameRecord from '../../models/RatingPeriodGameRecord';
import { isMod } from '../../modsadmins/mods';
import { isTO } from '../../modsadmins/tournamentOrganizers';
import { isDev } from '../../modsadmins/developers';
import { modOrTOString } from '../../modsadmins/modOrTO';

import { RoomCreationType } from './roomTypes';
import { Phase } from './phases/types';
Expand All @@ -22,17 +22,17 @@ import {
} from './types';
import { GameTimer, Timeouts } from './gameTimer';
import { VoidGameTracker } from './voidGameTracker';
import { SocketUser } from '../sockets/types';
import { SocketUser } from '../../sockets/types';
import { avalonRoles, rolesThatCantGuessMerlin } from './roles/roles';
import { avalonCards } from './cards/cards';
import { avalonPhases, commonPhases } from './phases/phases';
import { Card } from './cards/types';
import { Role } from './roles/types';
import { millisToStr } from '../util/time';
import shuffleArray from '../util/shuffleArray';
import { millisToStr } from '../../util/time';
import shuffleArray from '../../util/shuffleArray';
import { Anonymizer } from './anonymizer';
import { sendReplyToCommand } from '../sockets/sockets';
import { gamesPlayedMetric } from '../metrics/gameMetrics';
import { sendReplyToCommand } from '../../sockets/sockets';
import { gamesPlayedMetric } from '../../metrics/gameMetrics';

export const WAITING = 'Waiting';
export const MIN_PLAYERS = 5;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ButtonSettings, isGamePhase, Phase } from './phases/types';
import Game, { getRandomInt } from './game';
import { postGameMoveChecks } from '../sockets/sockets';
import { postGameMoveChecks } from '../../sockets/sockets';
import { Alliance } from './types';

// All in milliseconds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This wrapper mainly serves as a way to detect and make callbacks
// to the socket.js file for updates.
import Game, { GameConfig } from './game';
import { SocketUser } from '../sockets/types';
import { SocketUser } from '../../sockets/types';
import { Alliance } from './types';

type SocketServerCallback = (action: string, game: GameWrapper) => void;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import usernamesIndexes from '../../../myFunctions/usernamesIndexes';
import usernamesIndexes from '../../../../myFunctions/usernamesIndexes';
import { ButtonSettings, IPhase, Phase } from '../types';
import { SocketUser } from '../../../sockets/types';
import { SocketUser } from '../../../../sockets/types';
import { Alliance } from '../../types';
import { Role } from '../../roles/types';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import usernamesIndexes from '../../../myFunctions/usernamesIndexes';
import usernamesIndexes from '../../../../myFunctions/usernamesIndexes';
import { Phase } from '../types';
import { Card } from '../../cards/types';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import usernamesIndexes from '../../../myFunctions/usernamesIndexes';
import usernamesIndexes from '../../../../myFunctions/usernamesIndexes';
import { Phase } from '../types';

class Ref {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import usernamesIndexes from '../../../myFunctions/usernamesIndexes';
import usernamesIndexes from '../../../../myFunctions/usernamesIndexes';
import { Phase } from '../types';

class Sire {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ButtonSettings, IPhase, Phase } from '../types';
import { SocketUser } from '../../../sockets/types';
import { SocketUser } from '../../../../sockets/types';
import { Alliance } from '../../types';

class Finished implements IPhase {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ButtonSettings, IPhase, Phase } from '../types';
import { SocketUser } from '../../../sockets/types';
import { SocketUser } from '../../../../sockets/types';

class Frozen implements IPhase {
static phase = Phase.Frozen;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ButtonSettings, IPhase, Phase } from '../types';
import { SocketUser } from '../../../sockets/types';
import { SocketUser } from '../../../../sockets/types';

class Paused implements IPhase {
static phase = Phase.Paused;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import usernamesIndexes from '../../../myFunctions/usernamesIndexes';
import usernamesIndexes from '../../../../myFunctions/usernamesIndexes';
import { ButtonSettings, IPhase, Phase } from '../types';
import { MIN_PLAYERS, NUM_PLAYERS_ON_MISSION } from '../../game';
import { SocketUser } from '../../../sockets/types';
import { SocketUser } from '../../../../sockets/types';

class PickingTeam implements IPhase {
static phase = Phase.PickingTeam;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ButtonSettings, IPhase, Phase } from '../types';
import { SocketUser } from '../../../sockets/types';
import { SocketUser } from '../../../../sockets/types';
import { Alliance } from '../../types';

class Voided implements IPhase {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import usernamesIndexes from '../../../myFunctions/usernamesIndexes';
import usernamesIndexes from '../../../../myFunctions/usernamesIndexes';
import { ButtonSettings, IPhase, Phase } from '../types';
import { Alliance } from '../../types';
import { SocketUser } from '../../../sockets/types';
import { SocketUser } from '../../../../sockets/types';

class VotingMission implements IPhase {
static phase = Phase.VotingMission;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import usernamesIndexes from '../../../myFunctions/usernamesIndexes';
import usernamesIndexes from '../../../../myFunctions/usernamesIndexes';
import { ButtonSettings, IPhase, Phase } from '../types';
import { Alliance } from '../../types';
import { SocketUser } from '../../../sockets/types';
import { SocketUser } from '../../../../sockets/types';

class VotingTeam implements IPhase {
static phase = Phase.VotingTeam;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SocketUser } from '../../sockets/types';
import { SocketUser } from '../../../sockets/types';

export enum Phase {
// Core phases
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions src/gameplay/room.ts → src/gameplay/gameEngine/room.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
// @ts-nocheck
import { GAME_MODE_NAMES, GameMode } from './gameModes';
import { SocketUser } from '../sockets/types';
import { SocketUser } from '../../sockets/types';
import Game, { MIN_PLAYERS } from './game';
import { Timeouts } from './gameTimer';
import { ReadyPrompt } from '../sockets/readyPrompt';
import { ReadyPrompt } from '../../sockets/readyPrompt';
import { avalonRoles } from './roles/roles';
import { avalonCards } from './cards/cards';
import { avalonPhases, commonPhases } from './phases/phases';
import { Role } from './roles/types';
import { Phase } from './phases/types';
import { millisToStr } from '../util/time';
import { millisToStr } from '../../util/time';
import { RoomPlayer } from './types';
import { isMod } from '../modsadmins/mods';
import { isAdmin } from '../modsadmins/admins';
import { isMod } from '../../modsadmins/mods';
import { isAdmin } from '../../modsadmins/admins';

export class RoomConfig {
host: string;
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import Game, { GameConfig, NUM_PLAYERS_ON_MISSION } from '../game';
import { RoomConfig } from '../room';
import { GameMode } from '../gameModes';
import { ReadyPrompt } from '../../sockets/readyPrompt';
import { ReadyPrompt } from '../../../sockets/readyPrompt';
import { RoomCreationType } from '../roomTypes';
import { Phase } from '../phases/types';
import { Alliance } from '../types';
import { Card } from '../cards/types';
import { Role } from '../roles/types';

jest.mock('../gameWrapper');
jest.mock('../../models/gameRecord');
jest.mock('../../models/user');
jest.mock('../../models/RatingPeriodGameRecord');
jest.mock('../../../models/gameRecord');
jest.mock('../../../models/user');
jest.mock('../../../models/RatingPeriodGameRecord');

describe('Game Engine', () => {
let game: Game;
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/models/user.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import mongoose from 'mongoose';
// @ts-ignore
import passportLocalMongoose from 'passport-local-mongoose';
import type { IUser } from '../gameplay/types';
import type { IUser } from '../gameplay/gameEngine/types';

const UserSchema = new mongoose.Schema<IUser>({
username: {
Expand Down
2 changes: 1 addition & 1 deletion src/rewards/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Role } from '../gameplay/roles/types';
import { Role } from '../gameplay/gameEngine/roles/types';

const constants = {
ADMIN_BADGE: 'ADMIN_BADGE',
Expand Down
2 changes: 1 addition & 1 deletion src/rewards/getRewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { isMod } from '../modsadmins/mods';
import { isTO } from '../modsadmins/tournamentOrganizers';
import { isDev } from '../modsadmins/developers';
import { PatreonAgent } from '../clients/patreon/patreonAgent';
import { IUser } from '../gameplay/types';
import { IUser } from '../gameplay/gameEngine/types';
import { PatreonController } from '../clients/patreon/patreonController';
import constants from './constants';
import { S3Agent } from '../clients/s3/S3Agent';
Expand Down
8 changes: 6 additions & 2 deletions src/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ import { sendEmailVerification } from '../myFunctions/sendEmailVerification';

import { disallowVPNs } from '../util/vpnDetection';
import Settings from '../settings';
import { Alliance } from '../gameplay/types';
import { resRoles, rolesToAlliances, spyRoles } from '../gameplay/roles/roles';
import { Alliance } from '../gameplay/gameEngine/types';
import {
resRoles,
rolesToAlliances,
spyRoles,
} from '../gameplay/gameEngine/roles/roles';
import { sendResetPassword } from '../myFunctions/sendResetPassword';
import uuid from 'uuid';
import { captchaMiddleware } from '../util/captcha';
Expand Down
2 changes: 1 addition & 1 deletion src/routes/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Request } from 'express';
import { IUser } from '../gameplay/types';
import { IUser } from '../gameplay/gameEngine/types';

export interface EnrichedRequest extends Request {
user: IUser;
Expand Down
2 changes: 1 addition & 1 deletion src/sockets/bot.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from 'axios';
import { Phase } from '../gameplay/phases/types';
import { Phase } from '../gameplay/gameEngine/phases/types';

export const enabledBots = [];
enabledBots.push({
Expand Down
8 changes: 4 additions & 4 deletions src/sockets/commands/admin/atestgame.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @ts-nocheck

import { Command } from '../types';
import gameRoom from '../../../gameplay/gameWrapper';
import gameRoom from '../../../gameplay/gameEngine/gameWrapper';
import { SocketUser } from '../../types';
import { SimpleBotSocket } from '../../bot';
import {
Expand All @@ -12,9 +12,9 @@ import {
sendToAllChat,
socketCallback,
} from '../../sockets';
import { RoomCreationType } from '../../../gameplay/roomTypes';
import { Role } from '../../../gameplay/roles/types';
import { Card } from '../../../gameplay/cards/types';
import { RoomCreationType } from '../../../gameplay/gameEngine/roomTypes';
import { Role } from '../../../gameplay/gameEngine/roles/types';
import { Card } from '../../../gameplay/gameEngine/cards/types';

function addBots(args: string[], senderSocket: SocketUser, roomId: number) {
if (!args[1]) {
Expand Down
4 changes: 2 additions & 2 deletions src/sockets/commands/mod/mforcemove.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Command } from '../types';
import { modOrTOString } from '../../../modsadmins/modOrTO';
import { getIndexFromUsername, rooms } from '../../sockets';
import { Alliance } from '../../../gameplay/types';
import { Phase } from '../../../gameplay/phases/types';
import { Alliance } from '../../../gameplay/gameEngine/types';
import { Phase } from '../../../gameplay/gameEngine/phases/types';

export const mforcemove: Command = {
command: 'mforcemove',
Expand Down
2 changes: 1 addition & 1 deletion src/sockets/commands/mod/mtogglepause.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Command } from '../types';
import { rooms } from '../../sockets';
import { Phase } from '../../../gameplay/phases/types';
import { Phase } from '../../../gameplay/gameEngine/phases/types';

export const mtogglepause: Command = {
command: 'mtogglepause',
Expand Down
4 changes: 2 additions & 2 deletions src/sockets/filters/createRoomFilter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import GameWrapper from '../../gameplay/gameWrapper';
import { WAITING } from '../../gameplay/game';
import GameWrapper from '../../gameplay/gameEngine/gameWrapper';
import { WAITING } from '../../gameplay/gameEngine/game';

export class CreateRoomFilter {
// Returns true if user can create a room. Else false.
Expand Down
Loading

0 comments on commit 472377b

Please sign in to comment.