2011-07-18 22:06:02 +02:00
|
|
|
package com.massivecraft.factions.util;
|
2011-02-06 13:36:11 +01:00
|
|
|
|
2017-03-01 13:19:13 +01:00
|
|
|
import java.util.List;
|
2011-02-06 13:36:11 +01:00
|
|
|
|
2017-03-01 13:19:13 +01:00
|
|
|
import com.massivecraft.massivecore.collections.MassiveList;
|
|
|
|
|
|
|
|
import static com.massivecraft.factions.util.AsciiCompassDirection.*;
|
2011-02-06 13:36:11 +01:00
|
|
|
|
2011-10-10 01:21:05 +02:00
|
|
|
public class AsciiCompass
|
|
|
|
{
|
2017-03-01 13:19:13 +01:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// COMPASS
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
|
|
|
public static List<String> getAsciiCompass(double degrees)
|
2011-10-10 01:21:05 +02:00
|
|
|
{
|
2017-03-01 13:19:13 +01:00
|
|
|
return getAsciiCompass(AsciiCompassDirection.getByDegrees(degrees));
|
2011-02-06 13:36:11 +01:00
|
|
|
}
|
|
|
|
|
2017-03-01 13:19:13 +01:00
|
|
|
private static List<String> getAsciiCompass(AsciiCompassDirection directionFacing)
|
2011-10-10 01:21:05 +02:00
|
|
|
{
|
2017-03-01 13:19:13 +01:00
|
|
|
// Create
|
|
|
|
List<String> ret = new MassiveList<>();
|
|
|
|
|
|
|
|
// Fill
|
|
|
|
ret.add(visualizeRow(directionFacing, NW, N, NE));
|
|
|
|
ret.add(visualizeRow(directionFacing, W, NONE, E));
|
|
|
|
ret.add(visualizeRow(directionFacing, SW, S, SE));
|
2011-02-06 13:36:11 +01:00
|
|
|
|
2017-03-01 13:19:13 +01:00
|
|
|
// Return
|
|
|
|
return ret;
|
2012-03-13 14:27:03 +01:00
|
|
|
}
|
2011-02-06 13:36:11 +01:00
|
|
|
|
2017-03-01 13:19:13 +01:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// VISUALIZE ROW
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
|
|
|
private static String visualizeRow(AsciiCompassDirection directionFacing, AsciiCompassDirection... cardinals)
|
2011-10-10 01:21:05 +02:00
|
|
|
{
|
2017-03-01 13:19:13 +01:00
|
|
|
// Catch
|
|
|
|
if (cardinals == null) throw new NullPointerException("cardinals");
|
2011-02-06 13:36:11 +01:00
|
|
|
|
2017-03-01 13:19:13 +01:00
|
|
|
// Create
|
|
|
|
StringBuilder ret = new StringBuilder(cardinals.length);
|
2011-02-06 13:36:11 +01:00
|
|
|
|
2017-03-01 13:19:13 +01:00
|
|
|
// Fill
|
|
|
|
for (AsciiCompassDirection asciiCardinal : cardinals)
|
|
|
|
{
|
|
|
|
ret.append(asciiCardinal.visualize(directionFacing));
|
|
|
|
}
|
2011-02-06 13:36:11 +01:00
|
|
|
|
2017-03-01 13:19:13 +01:00
|
|
|
// Return
|
|
|
|
return ret.toString();
|
2011-02-06 13:36:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|