From a5f0d173bfb5965cc14a662bbf54290d524a9649 Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 6 Oct 2017 20:37:11 -0700 Subject: [PATCH] add ability banlist for personal rand closes #200 provide ability IDs (see bulbapedia) in a text file, each line has an ability ID number. --- pk3DS.Core/Randomizers/PersonalRandomizer.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pk3DS.Core/Randomizers/PersonalRandomizer.cs b/pk3DS.Core/Randomizers/PersonalRandomizer.cs index 216f438..b59be51 100644 --- a/pk3DS.Core/Randomizers/PersonalRandomizer.cs +++ b/pk3DS.Core/Randomizers/PersonalRandomizer.cs @@ -1,4 +1,7 @@ using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; using pk3DS.Core.Structures.PersonalInfo; namespace pk3DS.Core.Randomizers @@ -41,6 +44,13 @@ public PersonalRandomizer(PersonalInfo[] table, GameConfig game) { Game = game; Table = table; + if (File.Exists("bannedabilites.txt")) + { + var data = File.ReadAllLines("bannedabilities.txt"); + var list = new List(BannedAbilities); + list.AddRange(data.Select(z => Convert.ToInt32(z))); + BannedAbilities = list; + } } public void Execute() @@ -154,12 +164,13 @@ private void RandomizeStats(PersonalInfo z) private int GetRandomType() => rnd.Next(0, TypeCount); private int GetRandomEggGroup() => rnd.Next(1, eggGroupCount); private int GetRandomHeldItem() => Game.Info.HeldItems[rnd.Next(1, Game.Info.HeldItems.Length)]; + private readonly IList BannedAbilities = new int[0]; private int GetRandomAbility() { const int WonderGuard = 25; int newabil; do newabil = rnd.Next(1, Game.Info.MaxAbilityID + 1); - while (newabil == WonderGuard && !AllowWonderGuard); + while (newabil == WonderGuard && !AllowWonderGuard || BannedAbilities.Contains(newabil)); return newabil; } }