Fix swapping party not properly packing
This commit is contained in:
@@ -74,6 +74,17 @@ public class PokemonPartyImpl : IPokemonParty
|
||||
/// Swaps two Pokemon in the party around.
|
||||
/// </summary>
|
||||
public void Swap(int index1, int index2)
|
||||
{
|
||||
(_pokemon[index1], _pokemon[index2]) = (_pokemon[index2], _pokemon[index1]);
|
||||
var originalIndex1Value = _pokemon[index1];
|
||||
var originalIndex2Value = _pokemon[index2];
|
||||
Pack();
|
||||
var newIndex1 = Array.IndexOf(_pokemon, originalIndex1Value);
|
||||
var newIndex2 = Array.IndexOf(_pokemon, originalIndex2Value);
|
||||
OnSwap?.Invoke(this, (newIndex1, newIndex2));
|
||||
}
|
||||
|
||||
private void SwapWithoutPack(int index1, int index2)
|
||||
{
|
||||
(_pokemon[index1], _pokemon[index2]) = (_pokemon[index2], _pokemon[index1]);
|
||||
OnSwap?.Invoke(this, (index1, index2));
|
||||
@@ -106,7 +117,7 @@ public class PokemonPartyImpl : IPokemonParty
|
||||
{
|
||||
if (_pokemon[j] == null)
|
||||
continue;
|
||||
Swap(i, j);
|
||||
SwapWithoutPack(i, j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user