reconfigure move learn banned fixing

5c452b8b6b (commitcomment-25007984)

should have referenced move instead; move all update logic to
moverandomizer.
This commit is contained in:
Kurt
2017-10-16 09:22:01 -07:00
parent 5c452b8b6b
commit 30018fd9ed
3 changed files with 16 additions and 15 deletions

View File

@@ -32,11 +32,7 @@ public LearnsetRandomizer(GameConfig config, Learnset[] sets)
public bool Learn4Level1 = false;
public bool STAB { set => moverand.rSTAB = value; }
public IList<int> BannedMoves
{
get => moverand.BannedMoves;
set => moverand.BannedMoves = value;
}
public IList<int> BannedMoves { set => moverand.BannedMoves = value; }
public decimal rSTABPercent { set => moverand.rSTABPercent = value; }
public void Execute()

View File

@@ -125,5 +125,19 @@ public int GetRandomFirstMove(int[] types)
} while (!types.Contains(MoveData[move].Type));
return move;
}
public bool SanitizeMovesetForBannedMoves(int[] moves, int index)
{
bool updated = false;
for (int m = 0; m < moves.Length; m++)
{
if (!BannedMoves.Contains(moves[m]))
continue;
updated = true;
moves[m] = GetRandomFirstMove(index);
}
return updated;
}
}
}

View File

@@ -676,17 +676,8 @@ private void B_Randomize_Click(object sender, EventArgs e)
// sanitize moves
if (CB_Moves.SelectedIndex > 1) // learn source
{
bool update = false;
var moves = pk.Moves;
for (int m = 0; m < moves.Length; m++)
{
if (!learn.BannedMoves.Contains(moves[m]))
continue;
update = true;
moves[m] = move.GetRandomFirstMove(pk.Species);
}
if (update)
if (move.SanitizeMovesetForBannedMoves(moves, pk.Species))
pk.Moves = moves;
}
}