raids: Implemented !layout command

This commit is contained in:
Im2be
2020-01-09 19:14:41 +01:00
parent 4dbae7459f
commit 595ec442c8

View File

@@ -24,37 +24,45 @@
*/ */
package net.runelite.client.plugins.raids.solver; package net.runelite.client.plugins.raids.solver;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import net.runelite.client.plugins.raids.RaidRoom; import net.runelite.client.plugins.raids.RaidRoom;
import net.runelite.client.plugins.raids.RaidRoom.Boss; import net.runelite.client.plugins.raids.RoomType;
import java.util.Arrays;
import java.util.List;
import static net.runelite.client.plugins.raids.RaidRoom.GUARDIANS;
import static net.runelite.client.plugins.raids.RaidRoom.MUTTADILES;
import static net.runelite.client.plugins.raids.RaidRoom.MYSTICS;
import static net.runelite.client.plugins.raids.RaidRoom.SHAMANS;
import static net.runelite.client.plugins.raids.RaidRoom.TEKTON;
import static net.runelite.client.plugins.raids.RaidRoom.UNKNOWN_COMBAT;
import static net.runelite.client.plugins.raids.RaidRoom.VANGUARDS;
import static net.runelite.client.plugins.raids.RaidRoom.VASA;
import static net.runelite.client.plugins.raids.RaidRoom.VESPULA;
public class RotationSolver public class RotationSolver
{ {
private static final Rotation[] ROTATIONS = private static final List[] ROTATIONS =
{ {
new Rotation<>(Arrays.asList(Boss.TEKTON, Boss.VASA, Boss.GUARDIANS, Boss.MYSTICS, Boss.SHAMANS, Boss.MUTTADILES, Boss.VANGUARDS, Boss.VESPULA)), Arrays.asList(TEKTON, VASA, GUARDIANS, MYSTICS, SHAMANS, MUTTADILES, VANGUARDS, VESPULA),
new Rotation<>(Arrays.asList(Boss.TEKTON, Boss.MUTTADILES, Boss.GUARDIANS, Boss.VESPULA, Boss.SHAMANS, Boss.VASA, Boss.VANGUARDS, Boss.MYSTICS)), Arrays.asList(TEKTON, MUTTADILES, GUARDIANS, VESPULA, SHAMANS, VASA, VANGUARDS, MYSTICS),
new Rotation<>(Arrays.asList(Boss.VESPULA, Boss.VANGUARDS, Boss.MUTTADILES, Boss.SHAMANS, Boss.MYSTICS, Boss.GUARDIANS, Boss.VASA, Boss.TEKTON)), Arrays.asList(VESPULA, VANGUARDS, MUTTADILES, SHAMANS, MYSTICS, GUARDIANS, VASA, TEKTON),
new Rotation<>(Arrays.asList(Boss.MYSTICS, Boss.VANGUARDS, Boss.VASA, Boss.SHAMANS, Boss.VESPULA, Boss.GUARDIANS, Boss.MUTTADILES, Boss.TEKTON)) Arrays.asList(MYSTICS, VANGUARDS, VASA, SHAMANS, VESPULA, GUARDIANS, MUTTADILES, TEKTON)
}; };
public static void solve(RaidRoom[] rooms) public static boolean solve(RaidRoom[] rooms)
{ {
if (rooms == null) if (rooms == null)
{ {
return; return false;
} }
Rotation match = null; List<RaidRoom> match = null;
Integer start = null; Integer start = null;
Integer index = null; Integer index = null;
int known = 0; int known = 0;
for (int i = 0; i < rooms.length; i++) for (int i = 0; i < rooms.length; i++)
{ {
if (rooms[i] == null || rooms[i].getBoss() == null || rooms[i].getBoss() == Boss.UNKNOWN) if (rooms[i] == null || rooms[i].getType() != RoomType.COMBAT || rooms[i] == UNKNOWN_COMBAT)
{ {
continue; continue;
} }
@@ -69,29 +77,29 @@ public class RotationSolver
if (known < 2) if (known < 2)
{ {
return; return false;
} }
if (known == rooms.length) if (known == rooms.length)
{ {
return; return true;
} }
for (Rotation rotation : ROTATIONS) for (List rotation : ROTATIONS)
{ {
COMPARE: COMPARE:
for (int i = 0; i < rotation.size(); i++) for (int i = 0; i < rotation.size(); i++)
{ {
if (rooms[start].getBoss() == rotation.get(i)) if (rooms[start] == rotation.get(i))
{ {
for (int j = start + 1; j < rooms.length; j++) for (int j = start + 1; j < rooms.length; j++)
{ {
if (rooms[j].getBoss() == null || rooms[j].getBoss() == Boss.UNKNOWN) if (rooms[j].getType() != RoomType.COMBAT || rooms[j] == UNKNOWN_COMBAT)
{ {
continue; continue;
} }
if (rooms[j].getBoss() != rotation.get(i + j - start)) if (rooms[j] != rotation.get((i + j - start) % rotation.size()))
{ {
break COMPARE; break COMPARE;
} }
@@ -99,7 +107,7 @@ public class RotationSolver
if (match != null && match.equals(rotation)) if (match != null && match.equals(rotation))
{ {
return; return false;
} }
index = i - start; index = i - start;
@@ -110,7 +118,7 @@ public class RotationSolver
if (match == null) if (match == null)
{ {
return; return false;
} }
for (int i = 0; i < rooms.length; i++) for (int i = 0; i < rooms.length; i++)
@@ -120,30 +128,11 @@ public class RotationSolver
continue; continue;
} }
if (rooms[i].getBoss() == null || rooms[i].getBoss() == Boss.UNKNOWN) if (rooms[i].getType() != RoomType.COMBAT || rooms[i] == UNKNOWN_COMBAT)
{ {
rooms[i].setBoss((Boss) match.get(index + i)); rooms[i] = match.get((index + i) % match.size());
} }
} }
return true;
}
private static class Rotation<E> extends ArrayList<E>
{
Rotation(final Collection<? extends E> bosses)
{
super(bosses);
}
@Override
public E get(int index)
{
if (index < 0)
{
index = index + size();
}
return super.get(index % size());
}
} }
} }