fix: Fixes invalid professions. (#1882)

This commit is contained in:
Kamron Batman 2024-07-22 20:15:24 -07:00 • committed by GitHub
parent e41d35d3d7
commit 0a07109cc1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 133 additions and 131 deletions

View file

@ -745,6 +745,12 @@ public static class Utility
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T RandomList<T>(params T[] list) => list.RandomElement();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T RandomElement<T>(this ReadOnlySpan<T> list) => list.Length == 0 ? (T)default : list[Random(list.Length)];
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T RandomElement<T>(this T[] list) => list.RandomElement(default);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T RandomElement<T>(this IList<T> list) => list.RandomElement(default);
@ -858,6 +864,10 @@ public static class Utility
return value;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T RandomElement<T>(this T[] list, T valueIfZero) =>
list.Length == 0 ? valueIfZero : list[Random(list.Length)];
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static T RandomElement<T>(this IList<T> list, T valueIfZero) =>
list.Count == 0 ? valueIfZero : list[Random(list.Count)];