rotation solver: fix to use modulus instead of remainder operator

This commit is contained in:
Adam
2019-11-16 12:46:42 -05:00
parent 99fd6278e6
commit 7052977448
2 changed files with 11 additions and 2 deletions

View File

@@ -24,6 +24,7 @@
*/
package net.runelite.client.plugins.raids;
import static java.lang.Math.floorMod;
import java.util.Arrays;
import java.util.List;
import static net.runelite.client.plugins.raids.RaidRoom.GUARDIANS;
@@ -97,7 +98,7 @@ class RotationSolver
continue;
}
if (rooms[j] != rotation.get((i + j - start) % rotation.size()))
if (rooms[j] != rotation.get(floorMod(i + j - start, rotation.size())))
{
break COMPARE;
}
@@ -128,7 +129,7 @@ class RotationSolver
if (rooms[i].getType() != RoomType.COMBAT || rooms[i] == UNKNOWN_COMBAT)
{
rooms[i] = match.get((index + i) % match.size());
rooms[i] = match.get(floorMod(index + i, match.size()));
}
}

View File

@@ -77,4 +77,12 @@ public class RotationSolverTest
RotationSolver.solve(rooms);
assertArrayEquals(new RaidRoom[]{GUARDIANS, VESPULA, SHAMANS, VASA}, rooms);
}
@Test
public void testSolve6()
{
RaidRoom[] rooms = new RaidRoom[]{UNKNOWN_COMBAT, UNKNOWN_COMBAT, TEKTON, MUTTADILES};
RotationSolver.solve(rooms);
assertArrayEquals(new RaidRoom[]{VANGUARDS, MYSTICS, TEKTON, MUTTADILES}, rooms);
}
}