using System; using System.Collections.Generic; using static DDD.SpawnScheduleUtils; namespace DDD { public class RandomSpawnScheduleBuilder : ISpawnScheduleBuilder { public SpawnSchedule Build(SpawnScheduleBuildArgs args) { var randomGenerator = new Random(args.Seed); int normalQuota = Math.Max(0, args.NormalQuota); int specialQuota = Math.Max(0, args.SpecialQuota); if (args.NormalIds == null || args.NormalIds.Count == 0) normalQuota = 0; if (args.SpecialIds == null || args.SpecialIds.Count == 0) specialQuota = 0; int total = normalQuota + specialQuota; if (total == 0) return new SpawnSchedule(Array.Empty()); // 스페셜 위치만 무작위 고정(정확히 specialQuota개) var specialPositions = new HashSet(); PickUniqueIndices(total, specialQuota, randomGenerator, specialPositions); int normalIndex = 0; int specialIndex = 0; var result = new List(total); for (int i = 0; i < total; i++) { bool isSpecial = specialPositions.Contains(i); if (isSpecial) { var id = NextRoundRobin(args.SpecialIds, ref specialIndex); if (string.IsNullOrEmpty(id) == false) { result.Add(id); } } else { var id = NextRoundRobin(args.NormalIds, ref normalIndex); if (string.IsNullOrEmpty(id) == false) { result.Add(id); } } } return new SpawnSchedule(result); } } }