import { Injectable, Logger } from '@nestjs/common';
import { Player } from './player';

@Injectable()
export class PlayerService {
  private readonly logger = new Logger(PlayerService.name);
  private readonly players: Map<string, Player> = new Map();

  createPlayer(socketId: string) {
    const player: Player = new Player(socketId);
    this.players.set(socketId, player);
    this.logger.log([...this.players.entries()]);
  }

  addUserName(socketId: string, userName: string) {
    this.players.get(socketId).userName = userName;
    this.logger.log([...this.players.entries()]);
  }
}
