Added Backend Classes and FUnctions for an working Game. But lacking Implementations
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import type { FieldSize } from '@/scripts/interfaces/FieldSize.ts'
|
||||
import buildFieldArray from '@/scripts/utils/BuildFieldArray'
|
||||
|
||||
class LocalGame {
|
||||
public field: number[][]
|
||||
|
||||
constructor(fieldSize: FieldSize) {
|
||||
this.field = Array.from({ length: fieldSize.y }, () => Array(fieldSize.x).fill(0))
|
||||
this.field = buildFieldArray(fieldSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ import * as signalR from '@microsoft/signalr';
|
||||
|
||||
class GameConnection{
|
||||
public connection: signalR.HubConnection
|
||||
constructor(gameSession: string) {
|
||||
constructor(playerName: string, joinCode: number | undefined) {
|
||||
this.connection = new signalR.HubConnectionBuilder()
|
||||
.withUrl(`/gameHub?gameSession=${gameSession}`)
|
||||
.withUrl("/api/gamehub")
|
||||
.withAutomaticReconnect()
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import type { FieldSize } from "../interfaces/FieldSize";
|
||||
|
||||
function buildFieldArray(fieldSize: FieldSize): number[][]{
|
||||
return Array.from({ length: fieldSize.y }, () => Array(fieldSize.x).fill(0));
|
||||
}
|
||||
|
||||
export default buildFieldArray;
|
||||
Reference in New Issue
Block a user