Skip to content

Commit

Permalink
chore: merge #31 from dev
Browse files Browse the repository at this point in the history
### Notes

- chore(web): physics & game controls
  • Loading branch information
Neosoulink authored Aug 30, 2024
2 parents 1dee200 + 8d89ba7 commit a1d9dea
Show file tree
Hide file tree
Showing 77 changed files with 3,746 additions and 1,456 deletions.
7 changes: 7 additions & 0 deletions .changeset/mighty-penguins-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@chess-d/configs": patch
---

# Logs

## chore(configs): disable unused local **typescript** rules
41 changes: 41 additions & 0 deletions .changeset/shaggy-buses-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
"web": patch
---

# Logs

## refactor(web): handle piece drop from piece group

- Move the `dropPiece` handler to `PiecesGroupModel`
- Handle `PiecesGroupModel` count update
- Handle `PieceModel` deletion
- `PiecesGroupModel` update PieceModes
- Update `PiecesModel` composition on set coords
- Update physics rotation

## refactor(web): implement physics debug

- Move out of the core the `Physics` helper
- Register it in the dependency container
- Add debug module
- Implement physics debug
- Add new turbo env to the dev process
- use **vite** `import.meta.env?.DEV` env as debug mode checker

## feat(web): use `PhysicsProperties` to position the board

- Add `@chess-d/rapier-physics`
- Add `physicsBody` property to chess-board component

## feat(web): handle piece dropping

## refactor(web): make `PieceModel` independent from board

## feat(web): implement pieces initializers

## feat(web): set base web architecture

- Initialize world module
- Initialize game module
- Initialize chess board module
- initialize core module
13 changes: 13 additions & 0 deletions .changeset/tidy-dingos-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
"@chess-d/rapier-physics": minor
---

# Logs

## refactor: implement force bounding-box usage

- Use `Object3D.userData` to pass `useBoundingBox`, forcing **bounding-box** usage

## feat(rapier-physics): base rapier physics integration

- Use `ThreeJS` RapierPhysics addon as base.
11 changes: 11 additions & 0 deletions .changeset/wise-taxis-act.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"api": patch
---

# Logs

## Init base server resources

- Initialize `graphql` code first.
- Initialize `webSocket` support.
- Use `WS` library
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,8 @@ pnpm-debug.log*
# Misc
.DS_Store
*.pem
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@
{
"mode": "auto"
}
],
"cSpell.words": [
"timestep",
"tsyringe"
]
}
3 changes: 2 additions & 1 deletion apps/api/nest-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true
"deleteOutDir": true,
"plugins": ["@nestjs/graphql"]
}
}
12 changes: 10 additions & 2 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,26 @@
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\""
},
"dependencies": {
"@apollo/server": "^4.10.4",
"@chess-d/api": "workspace:*",
"@nestjs/apollo": "^12.2.0",
"@nestjs/common": "^10.3.10",
"@nestjs/core": "^10.0.0",
"@nestjs/graphql": "^12.2.0",
"@nestjs/platform-express": "^10.3.10",
"@chess-d/api": "workspace:*",
"@nestjs/platform-ws": "^10.3.10",
"@nestjs/websockets": "^10.3.10",
"graphql": "^16.9.0",
"reflect-metadata": "^0.2.0",
"rxjs": "^7.8.1"
"rxjs": "^7.8.1",
"ws": "^8.18.0"
},
"devDependencies": {
"@chess-d/configs": "workspace:*",
"@nestjs/cli": "^10.0.0",
"@nestjs/schematics": "^10.1.2",
"@nestjs/testing": "^10.3.10",
"@types/ws": "^8.5.11",
"source-map-support": "^0.5.21",
"supertest": "^6.3.3",
"tsconfig-paths": "^4.2.0"
Expand Down
22 changes: 0 additions & 22 deletions apps/api/src/app.controller.spec.ts

This file was deleted.

12 changes: 0 additions & 12 deletions apps/api/src/app.controller.ts

This file was deleted.

23 changes: 16 additions & 7 deletions apps/api/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
import { Module } from "@nestjs/common";
import { ApolloDriver, ApolloDriverConfig } from "@nestjs/apollo";
import { ApolloServerPluginLandingPageLocalDefault } from "@apollo/server/plugin/landingPage/default";
import { join } from "path";
import { GraphQLModule } from "@nestjs/graphql";

import { LinksModule } from "./links/links.module";

import { AppService } from "./app.service";
import { AppController } from "./app.controller";
import { ExperienceModule } from "./experience/experience.module";

@Module({
imports: [LinksModule],
controllers: [AppController],
providers: [AppService]
imports: [
GraphQLModule.forRoot<ApolloDriverConfig>({
driver: ApolloDriver,
autoSchemaFile: join(process.cwd(), "src/schema.gql"),
playground: false,
plugins: [ApolloServerPluginLandingPageLocalDefault()]
}),
ExperienceModule
],
controllers: [],
providers: []
})
export class AppModule {}
8 changes: 0 additions & 8 deletions apps/api/src/app.service.ts

This file was deleted.

10 changes: 10 additions & 0 deletions apps/api/src/experience/experience.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Module } from "@nestjs/common";

import { ExperienceService } from "./services/experience.service";
import { ExperienceResolver } from "./resolvers/experience.resolver";
import { ExperienceGateway } from "./gateways/experience.gateway";

@Module({
providers: [ExperienceResolver, ExperienceService, ExperienceGateway]
})
export class ExperienceModule {}
18 changes: 18 additions & 0 deletions apps/api/src/experience/gateways/experience.gateway.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Test, TestingModule } from "@nestjs/testing";
import { ExperienceGateway } from "./experience.gateway";

describe("ExperienceGateway", () => {
let gateway: ExperienceGateway;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [ExperienceGateway]
}).compile();

gateway = module.get<ExperienceGateway>(ExperienceGateway);
});

it("should be defined", () => {
expect(gateway).toBeDefined();
});
});
38 changes: 38 additions & 0 deletions apps/api/src/experience/gateways/experience.gateway.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {
MessageBody,
OnGatewayConnection,
OnGatewayDisconnect,
OnGatewayInit,
SubscribeMessage,
WebSocketGateway,
WebSocketServer,
WsResponse
} from "@nestjs/websockets";
import { Server, WebSocket } from "ws";

@WebSocketGateway(4000)
export class ExperienceGateway
implements OnGatewayInit, OnGatewayConnection, OnGatewayDisconnect
{
@WebSocketServer()
server: Server;

afterInit() {
console.log(`WS: ${this.server.address().toString()}`);
}

handleConnection(client: WebSocket, ...args: any[]) {
console.log(`WS: New Client | ${client.url}`, args);
}

handleDisconnect(client: WebSocket) {
console.log(`WS: Client Disconnected | ${client.url}`);
}

@SubscribeMessage("events")
onEvent(@MessageBody() data: unknown): WsResponse<string> {
console.log(`WS: On Event | ${data}`);

return { event: "event", data: `data:${data}` };
}
}
19 changes: 19 additions & 0 deletions apps/api/src/experience/resolvers/experience.resolver.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Test, TestingModule } from "@nestjs/testing";
import { ExperienceResolver } from "./experience.resolver";
import { ExperienceService } from "./experience.service";

describe("ExperienceResolver", () => {
let resolver: ExperienceResolver;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [ExperienceResolver, ExperienceService]
}).compile();

resolver = module.get<ExperienceResolver>(ExperienceResolver);
});

it("should be defined", () => {
expect(resolver).toBeDefined();
});
});
12 changes: 12 additions & 0 deletions apps/api/src/experience/resolvers/experience.resolver.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Query, Resolver } from "@nestjs/graphql";
import { ExperienceService } from "../services/experience.service";

@Resolver()
export class ExperienceResolver {
constructor(private readonly experienceService: ExperienceService) {}

@Query(() => String)
async log() {
return this.experienceService.log();
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Test, TestingModule } from "@nestjs/testing";
import { LinksService } from "./links.service";
import { ExperienceService } from "./experience.service";

describe("LinksService", () => {
let service: LinksService;
describe("ExperienceService", () => {
let service: ExperienceService;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [LinksService]
providers: [ExperienceService]
}).compile();

service = module.get<LinksService>(LinksService);
service = module.get<ExperienceService>(ExperienceService);
});

it("should be defined", () => {
Expand Down
8 changes: 8 additions & 0 deletions apps/api/src/experience/services/experience.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Injectable } from "@nestjs/common";

@Injectable()
export class ExperienceService {
public async log() {
return "logged";
}
}
21 changes: 0 additions & 21 deletions apps/api/src/links/links.controller.spec.ts

This file was deleted.

Loading

0 comments on commit a1d9dea

Please sign in to comment.