Skip to content

Commit

Permalink
Fix issues that caused the randomizer processing to be stuck in an in…
Browse files Browse the repository at this point in the history
…finite loop
  • Loading branch information
bartz24games@gmail.com committed Jan 19, 2021
1 parent 39331fd commit f6e362a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace FF13Randomizer
{
public partial class FormMain : Form
{
public static string Version { get; set; } = "1.8.2";
public static string Version { get; set; } = "1.8.3";

public static bool PlandoModified { get; set; } = false;

Expand Down
18 changes: 13 additions & 5 deletions Randomizers/RandoCrystarium.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,20 @@ public void SetRemaining(List<DataStoreCrystarium> list)
List<DataStoreCrystarium> others;
do
{
others = new CrystariumType[] { CrystariumType.HP, CrystariumType.Strength, CrystariumType.Magic }.SelectMany(t => crystarium.DataList.Where(o => o.Role == c.Role && o.Stage == c.Stage && o.Type == t)).ToList();
others = new CrystariumType[] { CrystariumType.HP, CrystariumType.Strength, CrystariumType.Magic }.SelectMany(t => crystarium.DataList.Where(o => o.Role == c.Role && o.Stage == stage && o.Type == t)).ToList();
stage--;
} while (others.Count == 0);
DataStoreCrystarium other = others[RandomNum.RandInt(0, others.Count - 1)];
c.Type = other.Type;
c.Value = other.Value;
} while (others.Count == 0 && stage > 0);
if (others.Count > 0)
{
DataStoreCrystarium other = others[RandomNum.RandInt(0, others.Count - 1)];
c.Type = other.Type;
c.Value = other.Value;
}
else
{
c.Type = new CrystariumType[] { CrystariumType.HP, CrystariumType.Strength, CrystariumType.Magic }[RandomNum.RandInt(0, 2)];
c.Value = 1;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Randomizers/RandoEnemies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ private void RandomizeDebuffs(DataStoreEnemy enemy, Enemy enemyID, int modifier,
plandoDebuffResists[enemyID].ForEach(pair => { bounds[pair.Key] = new int[] { pair.Value, pair.Value }; if (pair.Value == 100) immunities--; });
}

immunities = Math.Max(0, Math.Min(11, immunities));
immunities = Math.Max(0, Math.Min(11 - bounds.Values.Where(a => a[0] == 100 && a[1] == 100).Count(), immunities));

for (int i = 0; i < immunities; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion StatValues.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void Randomize(int variance)

public void Randomize(Tuple<int, int>[] bounds, long amount)
{
int randTotal = (int)Math.Min(Math.Min(amount, bounds.Select(t => (long)t.Item2).Sum()), Int32.MaxValue);
int randTotal = (int)Math.Min(Math.Min(amount, bounds.Select(t => (long)t.Item2 - (long)t.Item1).Sum()), Int32.MaxValue);
while (Vals.Sum() < randTotal)
{
int select = SelectNext();
Expand Down
1 change: 1 addition & 0 deletions VersionOrder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class VersionOrder
"1.8.0.Pre-3",
"1.8.0",
"1.8.1",
"1.8.2",
FormMain.Version
};

Expand Down

0 comments on commit f6e362a

Please sign in to comment.