raids plugin: refactor RaidRoom
This commit is contained in:
@@ -60,19 +60,8 @@ public class Raid
|
|||||||
|
|
||||||
if (room == null)
|
if (room == null)
|
||||||
{
|
{
|
||||||
RaidRoom.Type type = RaidRoom.Type.fromCode(layout.getRoomAt(i).getSymbol());
|
RoomType type = RoomType.fromCode(layout.getRoomAt(i).getSymbol());
|
||||||
room = new RaidRoom(null, type);
|
room = type.getUnsolvedRoom();
|
||||||
|
|
||||||
if (type == RaidRoom.Type.COMBAT)
|
|
||||||
{
|
|
||||||
room.setBoss(RaidRoom.Boss.UNKNOWN);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == RaidRoom.Type.PUZZLE)
|
|
||||||
{
|
|
||||||
room.setPuzzle(RaidRoom.Puzzle.UNKNOWN);
|
|
||||||
}
|
|
||||||
|
|
||||||
setRoom(room, i);
|
setRoom(room, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,7 +91,7 @@ public class Raid
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rooms[room.getPosition()].getType() == RaidRoom.Type.COMBAT)
|
if (rooms[room.getPosition()].getType() == RoomType.COMBAT)
|
||||||
{
|
{
|
||||||
combatRooms.add(rooms[room.getPosition()]);
|
combatRooms.add(rooms[room.getPosition()]);
|
||||||
}
|
}
|
||||||
@@ -113,7 +102,7 @@ public class Raid
|
|||||||
|
|
||||||
public String getRotationString()
|
public String getRotationString()
|
||||||
{
|
{
|
||||||
return Joiner.on(",").join(Arrays.stream(getCombatRooms()).map(r -> r.getBoss().getName()).toArray());
|
return Joiner.on(",").join(Arrays.stream(getCombatRooms()).map(RaidRoom::getName).toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toCode()
|
public String toCode()
|
||||||
@@ -144,7 +133,7 @@ public class Raid
|
|||||||
final int position = r.getPosition();
|
final int position = r.getPosition();
|
||||||
final RaidRoom room = getRoom(position);
|
final RaidRoom room = getRoom(position);
|
||||||
|
|
||||||
if (room == null || !(room.getType() == RaidRoom.Type.COMBAT || room.getType() == RaidRoom.Type.PUZZLE))
|
if (room == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -152,26 +141,8 @@ public class Raid
|
|||||||
switch (room.getType())
|
switch (room.getType())
|
||||||
{
|
{
|
||||||
case PUZZLE:
|
case PUZZLE:
|
||||||
final RaidRoom.Puzzle puzzle = room.getPuzzle();
|
|
||||||
sb.append(puzzle.getName());
|
|
||||||
|
|
||||||
if (puzzle == RaidRoom.Puzzle.UNKNOWN)
|
|
||||||
{
|
|
||||||
sb.append(" (puzzle)");
|
|
||||||
}
|
|
||||||
|
|
||||||
sb.append(", ");
|
|
||||||
break;
|
|
||||||
case COMBAT:
|
case COMBAT:
|
||||||
final RaidRoom.Boss boss = room.getBoss();
|
sb.append(room.getName()).append(", ");
|
||||||
sb.append(boss.getName());
|
|
||||||
|
|
||||||
if (boss == RaidRoom.Boss.UNKNOWN)
|
|
||||||
{
|
|
||||||
sb.append(" (combat)");
|
|
||||||
}
|
|
||||||
|
|
||||||
sb.append(", ");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,144 +24,37 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.raids;
|
package net.runelite.client.plugins.raids;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.RequiredArgsConstructor;
|
||||||
import net.runelite.api.Tile;
|
|
||||||
|
|
||||||
public class RaidRoom
|
@RequiredArgsConstructor
|
||||||
|
@Getter
|
||||||
|
enum RaidRoom
|
||||||
{
|
{
|
||||||
public static final int ROOM_MAX_SIZE = 32;
|
START("Start", RoomType.START),
|
||||||
|
END("End", RoomType.END),
|
||||||
|
SCAVENGERS("Scavengers", RoomType.SCAVENGERS),
|
||||||
|
FARMING("Farming", RoomType.FARMING),
|
||||||
|
EMPTY("Empty", RoomType.EMPTY),
|
||||||
|
|
||||||
@AllArgsConstructor
|
TEKTON("Tekton", RoomType.COMBAT),
|
||||||
public enum Type
|
MUTTADILES("Muttadiles", RoomType.COMBAT),
|
||||||
{
|
GUARDIANS("Guardians", RoomType.COMBAT),
|
||||||
START("Start", "#"),
|
VESPULA("Vespula", RoomType.COMBAT),
|
||||||
END("End", "¤"),
|
SHAMANS("Shamans", RoomType.COMBAT),
|
||||||
SCAVENGERS("Scavengers", "S"),
|
VASA("Vasa", RoomType.COMBAT),
|
||||||
FARMING("Farming", "F"),
|
VANGUARDS("Vanguards", RoomType.COMBAT),
|
||||||
COMBAT("Combat", "C"),
|
MYSTICS("Mystics", RoomType.COMBAT),
|
||||||
PUZZLE("Puzzle", "P"),
|
UNKNOWN_COMBAT("Unknown (combat)", RoomType.COMBAT),
|
||||||
EMPTY("Empty", " ");
|
|
||||||
|
|
||||||
@Getter
|
CRABS("Crabs", RoomType.PUZZLE),
|
||||||
private final String name;
|
ICE_DEMON("Ice Demon", RoomType.PUZZLE),
|
||||||
|
TIGHTROPE("Tightrope", RoomType.PUZZLE),
|
||||||
|
THIEVING("Thieving", RoomType.PUZZLE),
|
||||||
|
UNKNOWN_PUZZLE("Unknown (puzzle)", RoomType.PUZZLE);
|
||||||
|
|
||||||
@Getter
|
static final int ROOM_MAX_SIZE = 32;
|
||||||
private final String code;
|
|
||||||
|
|
||||||
public static Type fromCode(char code)
|
private final String name;
|
||||||
{
|
private final RoomType type;
|
||||||
for (Type type : Type.values())
|
|
||||||
{
|
|
||||||
if (type.getCode().equalsIgnoreCase(String.valueOf(code)))
|
|
||||||
{
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Type.EMPTY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
public enum Boss
|
|
||||||
{
|
|
||||||
TEKTON("Tekton"),
|
|
||||||
MUTTADILES("Muttadiles"),
|
|
||||||
GUARDIANS("Guardians"),
|
|
||||||
VESPULA("Vespula"),
|
|
||||||
SHAMANS("Shamans"),
|
|
||||||
VASA("Vasa"),
|
|
||||||
VANGUARDS("Vanguards"),
|
|
||||||
MYSTICS("Mystics"),
|
|
||||||
UNKNOWN("Unknown");
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
public static Boss fromString(String name)
|
|
||||||
{
|
|
||||||
for (Boss boss : Boss.values())
|
|
||||||
{
|
|
||||||
if (boss.getName().equalsIgnoreCase(name))
|
|
||||||
{
|
|
||||||
return boss;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
public enum Puzzle
|
|
||||||
{
|
|
||||||
CRABS("Crabs"),
|
|
||||||
ICE_DEMON("Ice Demon"),
|
|
||||||
TIGHTROPE("Tightrope"),
|
|
||||||
THIEVING("Thieving"),
|
|
||||||
UNKNOWN("Unknown");
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final String name;
|
|
||||||
|
|
||||||
public static Puzzle fromString(String name)
|
|
||||||
{
|
|
||||||
for (Puzzle puzzle : Puzzle.values())
|
|
||||||
{
|
|
||||||
if (puzzle.getName().equalsIgnoreCase(name))
|
|
||||||
{
|
|
||||||
return puzzle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final Tile base;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private Type type;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private Boss boss;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private Puzzle puzzle;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private RaidRoom previousRoom;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private RaidRoom nextRoom;
|
|
||||||
|
|
||||||
public RaidRoom(Tile base, Type type)
|
|
||||||
{
|
|
||||||
this.base = base;
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case COMBAT:
|
|
||||||
return "RaidRoom (type: " + type.getName() + ", " + boss.getName() + ")";
|
|
||||||
|
|
||||||
case PUZZLE:
|
|
||||||
return "RaidRoom (type: " + type.getName() + ", " + puzzle.getName() + ")";
|
|
||||||
|
|
||||||
default:
|
|
||||||
return "RaidRoom (type: " + type.getName() + ")";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,37 +125,41 @@ public class RaidsOverlay extends Overlay
|
|||||||
{
|
{
|
||||||
case COMBAT:
|
case COMBAT:
|
||||||
bossCount++;
|
bossCount++;
|
||||||
if (plugin.getRoomWhitelist().contains(room.getBoss().getName().toLowerCase()))
|
if (plugin.getRoomWhitelist().contains(room.getName().toLowerCase()))
|
||||||
{
|
{
|
||||||
color = Color.GREEN;
|
color = Color.GREEN;
|
||||||
}
|
}
|
||||||
else if (plugin.getRoomBlacklist().contains(room.getBoss().getName().toLowerCase())
|
else if (plugin.getRoomBlacklist().contains(room.getName().toLowerCase())
|
||||||
|| config.enableRotationWhitelist() && bossCount > bossMatches)
|
|| config.enableRotationWhitelist() && bossCount > bossMatches)
|
||||||
{
|
{
|
||||||
color = Color.RED;
|
color = Color.RED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String name = room == RaidRoom.UNKNOWN_COMBAT ? "Unknown" : room.getName();
|
||||||
|
|
||||||
panelComponent.getChildren().add(LineComponent.builder()
|
panelComponent.getChildren().add(LineComponent.builder()
|
||||||
.left(room.getType().getName())
|
.left(room.getType().getName())
|
||||||
.right(room.getBoss().getName())
|
.right(name)
|
||||||
.rightColor(color)
|
.rightColor(color)
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PUZZLE:
|
case PUZZLE:
|
||||||
if (plugin.getRoomWhitelist().contains(room.getPuzzle().getName().toLowerCase()))
|
if (plugin.getRoomWhitelist().contains(room.getName().toLowerCase()))
|
||||||
{
|
{
|
||||||
color = Color.GREEN;
|
color = Color.GREEN;
|
||||||
}
|
}
|
||||||
else if (plugin.getRoomBlacklist().contains(room.getPuzzle().getName().toLowerCase()))
|
else if (plugin.getRoomBlacklist().contains(room.getName().toLowerCase()))
|
||||||
{
|
{
|
||||||
color = Color.RED;
|
color = Color.RED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
name = room == RaidRoom.UNKNOWN_PUZZLE ? "Unknown" : room.getName();
|
||||||
|
|
||||||
panelComponent.getChildren().add(LineComponent.builder()
|
panelComponent.getChildren().add(LineComponent.builder()
|
||||||
.left(room.getType().getName())
|
.left(room.getType().getName())
|
||||||
.right(room.getPuzzle().getName())
|
.right(name)
|
||||||
.rightColor(color)
|
.rightColor(color)
|
||||||
.build());
|
.build());
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ import net.runelite.client.plugins.Plugin;
|
|||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.plugins.raids.solver.Layout;
|
import net.runelite.client.plugins.raids.solver.Layout;
|
||||||
import net.runelite.client.plugins.raids.solver.LayoutSolver;
|
import net.runelite.client.plugins.raids.solver.LayoutSolver;
|
||||||
import net.runelite.client.plugins.raids.solver.RotationSolver;
|
|
||||||
import net.runelite.client.ui.overlay.OverlayManager;
|
import net.runelite.client.ui.overlay.OverlayManager;
|
||||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||||
import net.runelite.client.util.Text;
|
import net.runelite.client.util.Text;
|
||||||
@@ -544,97 +543,69 @@ public class RaidsPlugin extends Plugin
|
|||||||
|
|
||||||
private RaidRoom determineRoom(Tile base)
|
private RaidRoom determineRoom(Tile base)
|
||||||
{
|
{
|
||||||
RaidRoom room = new RaidRoom(base, RaidRoom.Type.EMPTY);
|
|
||||||
int chunkData = client.getInstanceTemplateChunks()[base.getPlane()][(base.getSceneLocation().getX()) / 8][base.getSceneLocation().getY() / 8];
|
int chunkData = client.getInstanceTemplateChunks()[base.getPlane()][(base.getSceneLocation().getX()) / 8][base.getSceneLocation().getY() / 8];
|
||||||
InstanceTemplates template = InstanceTemplates.findMatch(chunkData);
|
InstanceTemplates template = InstanceTemplates.findMatch(chunkData);
|
||||||
|
|
||||||
if (template == null)
|
if (template == null)
|
||||||
{
|
{
|
||||||
return room;
|
return RaidRoom.EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (template)
|
switch (template)
|
||||||
{
|
{
|
||||||
case RAIDS_LOBBY:
|
case RAIDS_LOBBY:
|
||||||
case RAIDS_START:
|
case RAIDS_START:
|
||||||
room.setType(RaidRoom.Type.START);
|
return RaidRoom.START;
|
||||||
break;
|
|
||||||
|
|
||||||
case RAIDS_END:
|
case RAIDS_END:
|
||||||
room.setType(RaidRoom.Type.END);
|
return RaidRoom.END;
|
||||||
break;
|
|
||||||
|
|
||||||
case RAIDS_SCAVENGERS:
|
case RAIDS_SCAVENGERS:
|
||||||
case RAIDS_SCAVENGERS2:
|
case RAIDS_SCAVENGERS2:
|
||||||
room.setType(RaidRoom.Type.SCAVENGERS);
|
return RaidRoom.SCAVENGERS;
|
||||||
break;
|
|
||||||
|
|
||||||
case RAIDS_SHAMANS:
|
case RAIDS_SHAMANS:
|
||||||
room.setType(RaidRoom.Type.COMBAT);
|
return RaidRoom.SHAMANS;
|
||||||
room.setBoss(RaidRoom.Boss.SHAMANS);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RAIDS_VASA:
|
case RAIDS_VASA:
|
||||||
room.setType(RaidRoom.Type.COMBAT);
|
return RaidRoom.VASA;
|
||||||
room.setBoss(RaidRoom.Boss.VASA);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RAIDS_VANGUARDS:
|
case RAIDS_VANGUARDS:
|
||||||
room.setType(RaidRoom.Type.COMBAT);
|
return RaidRoom.VANGUARDS;
|
||||||
room.setBoss(RaidRoom.Boss.VANGUARDS);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RAIDS_ICE_DEMON:
|
case RAIDS_ICE_DEMON:
|
||||||
room.setType(RaidRoom.Type.PUZZLE);
|
return RaidRoom.ICE_DEMON;
|
||||||
room.setPuzzle(RaidRoom.Puzzle.ICE_DEMON);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RAIDS_THIEVING:
|
case RAIDS_THIEVING:
|
||||||
room.setType(RaidRoom.Type.PUZZLE);
|
return RaidRoom.THIEVING;
|
||||||
room.setPuzzle(RaidRoom.Puzzle.THIEVING);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RAIDS_FARMING:
|
case RAIDS_FARMING:
|
||||||
case RAIDS_FARMING2:
|
case RAIDS_FARMING2:
|
||||||
room.setType(RaidRoom.Type.FARMING);
|
return RaidRoom.FARMING;
|
||||||
break;
|
|
||||||
|
|
||||||
case RAIDS_MUTTADILES:
|
case RAIDS_MUTTADILES:
|
||||||
room.setType(RaidRoom.Type.COMBAT);
|
return RaidRoom.MUTTADILES;
|
||||||
room.setBoss(RaidRoom.Boss.MUTTADILES);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RAIDS_MYSTICS:
|
case RAIDS_MYSTICS:
|
||||||
room.setType(RaidRoom.Type.COMBAT);
|
return RaidRoom.MYSTICS;
|
||||||
room.setBoss(RaidRoom.Boss.MYSTICS);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RAIDS_TEKTON:
|
case RAIDS_TEKTON:
|
||||||
room.setType(RaidRoom.Type.COMBAT);
|
return RaidRoom.TEKTON;
|
||||||
room.setBoss(RaidRoom.Boss.TEKTON);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RAIDS_TIGHTROPE:
|
case RAIDS_TIGHTROPE:
|
||||||
room.setType(RaidRoom.Type.PUZZLE);
|
return RaidRoom.TIGHTROPE;
|
||||||
room.setPuzzle(RaidRoom.Puzzle.TIGHTROPE);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RAIDS_GUARDIANS:
|
case RAIDS_GUARDIANS:
|
||||||
room.setType(RaidRoom.Type.COMBAT);
|
return RaidRoom.GUARDIANS;
|
||||||
room.setBoss(RaidRoom.Boss.GUARDIANS);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RAIDS_CRABS:
|
case RAIDS_CRABS:
|
||||||
room.setType(RaidRoom.Type.PUZZLE);
|
return RaidRoom.CRABS;
|
||||||
room.setPuzzle(RaidRoom.Puzzle.CRABS);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RAIDS_VESPULA:
|
case RAIDS_VESPULA:
|
||||||
room.setType(RaidRoom.Type.COMBAT);
|
return RaidRoom.VESPULA;
|
||||||
room.setBoss(RaidRoom.Boss.VESPULA);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return room;
|
default:
|
||||||
|
return RaidRoom.EMPTY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2018, Kamiel
|
||||||
|
* Copyright (c) 2019, Adam <Adam@sigterm.info>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package net.runelite.client.plugins.raids;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Getter
|
||||||
|
enum RoomType
|
||||||
|
{
|
||||||
|
START("Start", '#'),
|
||||||
|
END("End", '¤'),
|
||||||
|
SCAVENGERS("Scavengers", 'S'),
|
||||||
|
FARMING("Farming", 'F'),
|
||||||
|
EMPTY("Empty", ' '),
|
||||||
|
COMBAT("Combat", 'C'),
|
||||||
|
PUZZLE("Puzzle", 'P');
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
private final char code;
|
||||||
|
|
||||||
|
RaidRoom getUnsolvedRoom()
|
||||||
|
{
|
||||||
|
switch (this)
|
||||||
|
{
|
||||||
|
case START:
|
||||||
|
return RaidRoom.START;
|
||||||
|
case END:
|
||||||
|
return RaidRoom.END;
|
||||||
|
case SCAVENGERS:
|
||||||
|
return RaidRoom.SCAVENGERS;
|
||||||
|
case FARMING:
|
||||||
|
return RaidRoom.FARMING;
|
||||||
|
case COMBAT:
|
||||||
|
return RaidRoom.UNKNOWN_COMBAT;
|
||||||
|
case PUZZLE:
|
||||||
|
return RaidRoom.UNKNOWN_PUZZLE;
|
||||||
|
case EMPTY:
|
||||||
|
default:
|
||||||
|
return RaidRoom.EMPTY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static RoomType fromCode(char code)
|
||||||
|
{
|
||||||
|
for (RoomType type : values())
|
||||||
|
{
|
||||||
|
if (type.getCode() == code)
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return EMPTY;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,58 +22,45 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.raids.solver;
|
package net.runelite.client.plugins.raids;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.List;
|
||||||
import net.runelite.client.plugins.raids.RaidRoom;
|
import static net.runelite.client.plugins.raids.RaidRoom.GUARDIANS;
|
||||||
import net.runelite.client.plugins.raids.RaidRoom.Boss;
|
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
|
class RotationSolver
|
||||||
{
|
{
|
||||||
private static class Rotation<E> extends ArrayList<E>
|
private static final List[] ROTATIONS =
|
||||||
{
|
|
||||||
Rotation(Collection<? extends E> bosses)
|
|
||||||
{
|
{
|
||||||
super(bosses);
|
Arrays.asList(TEKTON, VASA, GUARDIANS, MYSTICS, SHAMANS, MUTTADILES, VANGUARDS, VESPULA),
|
||||||
}
|
Arrays.asList(TEKTON, MUTTADILES, GUARDIANS, VESPULA, SHAMANS, VASA, VANGUARDS, MYSTICS),
|
||||||
|
Arrays.asList(VESPULA, VANGUARDS, MUTTADILES, SHAMANS, MYSTICS, GUARDIANS, VASA, TEKTON),
|
||||||
|
Arrays.asList(MYSTICS, VANGUARDS, VASA, SHAMANS, VESPULA, GUARDIANS, MUTTADILES, TEKTON)
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
static boolean solve(RaidRoom[] rooms)
|
||||||
public E get(int index)
|
|
||||||
{
|
|
||||||
if (index < 0)
|
|
||||||
{
|
|
||||||
index = index + size();
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.get(index % size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Rotation[] ROTATIONS =
|
|
||||||
{
|
|
||||||
new Rotation<>(Arrays.asList(Boss.TEKTON, Boss.VASA, Boss.GUARDIANS, Boss.MYSTICS, Boss.SHAMANS, Boss.MUTTADILES, Boss.VANGUARDS, Boss.VESPULA)),
|
|
||||||
new Rotation<>(Arrays.asList(Boss.TEKTON, Boss.MUTTADILES, Boss.GUARDIANS, Boss.VESPULA, Boss.SHAMANS, Boss.VASA, Boss.VANGUARDS, Boss.MYSTICS)),
|
|
||||||
new Rotation<>(Arrays.asList(Boss.VESPULA, Boss.VANGUARDS, Boss.MUTTADILES, Boss.SHAMANS, Boss.MYSTICS, Boss.GUARDIANS, Boss.VASA, Boss.TEKTON)),
|
|
||||||
new Rotation<>(Arrays.asList(Boss.MYSTICS, Boss.VANGUARDS, Boss.VASA, Boss.SHAMANS, Boss.VESPULA, Boss.GUARDIANS, Boss.MUTTADILES, Boss.TEKTON))
|
|
||||||
};
|
|
||||||
|
|
||||||
public static boolean solve(RaidRoom[] rooms)
|
|
||||||
{
|
{
|
||||||
if (rooms == null)
|
if (rooms == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rotation<Boss> 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;
|
||||||
}
|
}
|
||||||
@@ -96,21 +83,21 @@ public class RotationSolver
|
|||||||
return true;
|
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;
|
||||||
}
|
}
|
||||||
@@ -139,9 +126,9 @@ 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(match.get(index + i));
|
rooms[i] = match.get((index + i) % match.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Adam <Adam@sigterm.info>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package net.runelite.client.plugins.raids;
|
||||||
|
|
||||||
|
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;
|
||||||
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class RotationSolverTest
|
||||||
|
{
|
||||||
|
@Test
|
||||||
|
public void testSolve1()
|
||||||
|
{
|
||||||
|
RaidRoom[] rooms = new RaidRoom[]{VESPULA, UNKNOWN_COMBAT, UNKNOWN_COMBAT, VANGUARDS};
|
||||||
|
RotationSolver.solve(rooms);
|
||||||
|
assertArrayEquals(new RaidRoom[]{VESPULA, SHAMANS, VASA, VANGUARDS}, rooms);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSolve2()
|
||||||
|
{
|
||||||
|
RaidRoom[] rooms = new RaidRoom[]{UNKNOWN_COMBAT, UNKNOWN_COMBAT, MUTTADILES, TEKTON};
|
||||||
|
RotationSolver.solve(rooms);
|
||||||
|
assertArrayEquals(new RaidRoom[]{VESPULA, GUARDIANS, MUTTADILES, TEKTON}, rooms);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSolve3()
|
||||||
|
{
|
||||||
|
RaidRoom[] rooms = new RaidRoom[]{TEKTON, UNKNOWN_COMBAT, GUARDIANS, MYSTICS};
|
||||||
|
RotationSolver.solve(rooms);
|
||||||
|
assertArrayEquals(new RaidRoom[]{TEKTON, VASA, GUARDIANS, MYSTICS}, rooms);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSolve4()
|
||||||
|
{
|
||||||
|
RaidRoom[] rooms = new RaidRoom[]{VASA, UNKNOWN_COMBAT, UNKNOWN_COMBAT, GUARDIANS};
|
||||||
|
RotationSolver.solve(rooms);
|
||||||
|
assertArrayEquals(new RaidRoom[]{VASA, SHAMANS, VESPULA, GUARDIANS}, rooms);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user