/// <summary> /// Generates random CharacterId /// </summary> /// <param name="counter">Counter of number of tries to generate a random character Id.</param> /// <returns>CharacterId</returns> public static long generateCharacterId(int counter = 0) { long Result = StaticRandom.NextLong(); if (Database.Characters.Get(Result) != null) { if (counter < 100) { counter++; generateCharacterId(counter); } else { throw new ArgumentException($"CharacterHelper::generateCharacterId - Can not generate random character Id after {counter} tries"); } } return(Result); }