This repository has been archived on 2026-07-13. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
servicepoint-tanks/TanksServer/PlayerService.cs
2024-04-07 00:33:54 +02:00

18 lines
448 B
C#

using System.Collections.Concurrent;
using Microsoft.Extensions.Logging;
namespace TanksServer;
internal sealed class PlayerService(ILogger<PlayerService> logger)
{
private readonly ConcurrentDictionary<string, Player> _players = new();
public Player GetOrAdd(string name) => _players.GetOrAdd(name, _ => new Player(name));
}
internal class Player(string name)
{
public string Name => name;
public Guid Id => Guid.NewGuid();
}