rotation solver: fix to use modulus instead of remainder operator
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.raids;
|
package net.runelite.client.plugins.raids;
|
||||||
|
|
||||||
|
import static java.lang.Math.floorMod;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import static net.runelite.client.plugins.raids.RaidRoom.GUARDIANS;
|
import static net.runelite.client.plugins.raids.RaidRoom.GUARDIANS;
|
||||||
@@ -97,7 +98,7 @@ class RotationSolver
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rooms[j] != rotation.get((i + j - start) % rotation.size()))
|
if (rooms[j] != rotation.get(floorMod(i + j - start, rotation.size())))
|
||||||
{
|
{
|
||||||
break COMPARE;
|
break COMPARE;
|
||||||
}
|
}
|
||||||
@@ -128,7 +129,7 @@ class RotationSolver
|
|||||||
|
|
||||||
if (rooms[i].getType() != RoomType.COMBAT || rooms[i] == UNKNOWN_COMBAT)
|
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()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,4 +77,12 @@ public class RotationSolverTest
|
|||||||
RotationSolver.solve(rooms);
|
RotationSolver.solve(rooms);
|
||||||
assertArrayEquals(new RaidRoom[]{GUARDIANS, VESPULA, SHAMANS, VASA}, 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user