mirror of
https://github.com/MikuLeaks/MikuSB.git
synced 2026-06-04 11:24:00 +00:00
SupporterCard Affix can now be changed.
This commit is contained in:
@@ -4,8 +4,7 @@ namespace MikuSB.GameServer.Game.Support;
|
||||
|
||||
public static class SupportAffixService
|
||||
{
|
||||
// Returns (affixId, tier) - both 1-based. Returns (0,0) if pool not found.
|
||||
public static (uint AffixId, uint Tier) GenerateRandomAffix(int poolId)
|
||||
public static (uint AffixId, uint Tier) GenerateRandomAffix(int poolId, IEnumerable<uint>? excludedAffixIds = null)
|
||||
{
|
||||
if (!GameData.SupportAffixPoolData.TryGetValue(poolId, out var pool))
|
||||
return (0, 0);
|
||||
@@ -32,9 +31,20 @@ public static class SupportAffixService
|
||||
if (selectedAffixs.Count == 0)
|
||||
return (0, 0);
|
||||
|
||||
var affixId = selectedAffixs[Random.Shared.Next(selectedAffixs.Count)];
|
||||
var excluded = excludedAffixIds?.ToHashSet() ?? [];
|
||||
var candidates = selectedAffixs.Where(x => !excluded.Contains((uint)x)).ToList();
|
||||
if (candidates.Count == 0)
|
||||
candidates = selectedAffixs.ToList();
|
||||
|
||||
var affixId = candidates[Random.Shared.Next(candidates.Count)];
|
||||
var tierCount = GameData.SupportAffixData.GetValueOrDefault(affixId)?.TierCount ?? 5;
|
||||
var tier = (uint)(Random.Shared.Next(tierCount) + 1);
|
||||
return ((uint)affixId, tier);
|
||||
}
|
||||
|
||||
public static uint GenerateTier(uint affixId)
|
||||
{
|
||||
var tierCount = GameData.SupportAffixData.GetValueOrDefault((int)affixId)?.TierCount ?? 5;
|
||||
return (uint)(Random.Shared.Next(tierCount) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user