public static string GetPlayerName(int playerId) { if (PlayerCache.TryGetValue(playerId, out var playerName)) { return(playerName); } playerName = KReader.getGNameFromId(playerId); PlayerCache.Add(playerId, playerName); return(playerName); }
public Player Create(int gameId, string name) { int playerId = _serivceFactory.Random.Next(1000); while (_playerCache.Get(playerId) != null) { playerId = _serivceFactory.Random.Next(1000); } var player = new Player { Id = playerId, GameId = gameId, Name = name, }; _playerCache.Add(playerId, player); return(player); }