28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
import { PlayerInteractionInterface } from "../../PlayerInteractionInterface";
|
|
import { PlayerInteractionNetwork } from "../../PlayerInteractionNetwork";
|
|
import { PlayerHuman } from "./PlayerHuman";
|
|
import { NetworkClientNotifier } from "../../NetworkClientNotifier";
|
|
import { Tile } from "../Tile";
|
|
import { Board } from "../Board";
|
|
|
|
export class NetworkPlayer extends PlayerHuman {
|
|
socketId!: string;
|
|
playerInteraction: PlayerInteractionInterface = new PlayerInteractionNetwork(this);
|
|
clientNotifier: NetworkClientNotifier = new NetworkClientNotifier();
|
|
|
|
constructor(id: string, name: string, socketId: string ) {
|
|
super(id, name);
|
|
this.socketId = socketId;
|
|
}
|
|
|
|
async sendEvent(event: string, data:any = {}): Promise<void> {
|
|
this.clientNotifier.sendEvent(this, event, data);
|
|
}
|
|
async sendEventWithAck(event: string, data: any): Promise<any> {
|
|
return await this.clientNotifier.sendEventWithAck(this, event, data);
|
|
}
|
|
|
|
async chooseTile(board: Board): Promise<Tile> {
|
|
return await this.playerInteraction.chooseTile(board);
|
|
}
|
|
} |