3h - Add more Characters to the Map-Chars.

This commit is contained in:
ulumulu1510 2016-02-26 19:04:18 +01:00 committed by Olof Larsson
parent 259cf71e27
commit 1b03e64387
2 changed files with 29 additions and 15 deletions

View File

@ -1,5 +1,7 @@
package com.massivecraft.factions; package com.massivecraft.factions;
import org.bukkit.ChatColor;
public class Const public class Const
{ {
// Collections & Aspects // Collections & Aspects
@ -20,7 +22,11 @@ public class Const
public static final int MAP_HEIGHT = 8; public static final int MAP_HEIGHT = 8;
public static final int MAP_HEIGHT_FULL = 17; public static final int MAP_HEIGHT_FULL = 17;
public static final char[] MAP_KEY_CHARS = "\\/#?$%=&^ABCDEFGHJKLMNOPQRSTUVWXYZ1234567890abcdeghjmnopqrsuvwxyz".toCharArray(); public static final char[] MAP_KEY_CHARS = "\\/#?笣$%=&^ABCDEFGHJKLMNOPQRSTUVWXYZÄÖÜÆØÅ1234567890abcdeghjmnopqrsuvwxyÿzäöüæøåâêîûô".toCharArray();
public static final String MAP_KEY_WILDERNESS = ChatColor.GRAY.toString() + "-";
public static final String MAP_KEY_SEPARATOR = ChatColor.AQUA.toString() + "+";
public static final String MAP_KEY_OVERFLOW = ChatColor.MAGIC.toString() + "-" + ChatColor.RESET.toString();
public static final String MAP_OVERFLOW_MESSAGE = MAP_KEY_OVERFLOW + ": Too Many Factions (>" + MAP_KEY_CHARS.length + ") on this Map.";
// SHOW // SHOW

View File

@ -355,7 +355,7 @@ public class Board extends Entity<Board> implements BoardInterface
ArrayList<String> ret = new ArrayList<String>(); ArrayList<String> ret = new ArrayList<String>();
Faction centerFaction = this.getFactionAt(centerPs); Faction centerFaction = this.getFactionAt(centerPs);
ret.add(Txt.titleize("("+centerPs.getChunkX() + "," + centerPs.getChunkZ()+") "+centerFaction.getName(observer))); ret.add(Txt.titleize("(" + centerPs.getChunkX() + "," + centerPs.getChunkZ() + ") " + centerFaction.getName(observer)));
int halfWidth = width / 2; int halfWidth = width / 2;
int halfHeight = height / 2; int halfHeight = height / 2;
@ -369,50 +369,58 @@ public class Board extends Entity<Board> implements BoardInterface
Map<Faction, Character> fList = new HashMap<Faction, Character>(); Map<Faction, Character> fList = new HashMap<Faction, Character>();
int chrIdx = 0; int chrIdx = 0;
boolean overflown = false;
// For each row // For each row
for (int dz = 0; dz < height; dz++) for (int dz = 0; dz < height; dz++)
{ {
// Draw and add that row // Draw and add that row
String row = ""; StringBuilder row = new StringBuilder();
for (int dx = 0; dx < width; dx++) for (int dx = 0; dx < width; dx++)
{ {
if(dx == halfWidth && dz == halfHeight) if (dx == halfWidth && dz == halfHeight)
{ {
row += ChatColor.AQUA+"+"; row.append(Const.MAP_KEY_SEPARATOR);
continue; continue;
} }
if ( ! overflown && chrIdx >= Const.MAP_KEY_CHARS.length) overflown = true;
PS herePs = topLeftPs.plusChunkCoords(dx, dz); PS herePs = topLeftPs.plusChunkCoords(dx, dz);
Faction hereFaction = this.getFactionAt(herePs); Faction hereFaction = this.getFactionAt(herePs);
boolean contains = fList.containsKey(hereFaction);
if (hereFaction.isNone()) if (hereFaction.isNone())
{ {
row += ChatColor.GRAY+"-"; row.append(Const.MAP_KEY_WILDERNESS);
}
else if ( ! contains && overflown)
{
row.append(Const.MAP_KEY_OVERFLOW);
} }
else else
{ {
if (!fList.containsKey(hereFaction)) if ( ! contains) fList.put(hereFaction, Const.MAP_KEY_CHARS[chrIdx++]);
fList.put(hereFaction, Const.MAP_KEY_CHARS[chrIdx++]);
char fchar = fList.get(hereFaction); char fchar = fList.get(hereFaction);
row += hereFaction.getColorTo(observer) + "" + fchar; row.append(hereFaction.getColorTo(observer).toString()).append(fchar);
} }
} }
ret.add(row); ret.add(row.toString());
} }
// Get the compass // Get the compass
ArrayList<String> asciiCompass = AsciiCompass.getAsciiCompass(inDegrees, ChatColor.RED, Txt.parse("<a>")); ArrayList<String> asciiCompass = AsciiCompass.getAsciiCompass(inDegrees, ChatColor.RED, Txt.parse("<a>"));
// Add the compass // Add the compass
ret.set(1, asciiCompass.get(0)+ret.get(1).substring(3*3)); ret.set(1, asciiCompass.get(0) + ret.get(1).substring(3*3));
ret.set(2, asciiCompass.get(1)+ret.get(2).substring(3*3)); ret.set(2, asciiCompass.get(1) + ret.get(2).substring(3*3));
ret.set(3, asciiCompass.get(2)+ret.get(3).substring(3*3)); ret.set(3, asciiCompass.get(2) + ret.get(3).substring(3*3));
String fRow = ""; String fRow = "";
for (Faction keyfaction : fList.keySet()) for (Faction keyfaction : fList.keySet())
{ {
fRow += ""+keyfaction.getColorTo(observer) + fList.get(keyfaction) + ": " + keyfaction.getName() + " "; fRow += keyfaction.getColorTo(observer).toString() + fList.get(keyfaction) + ": " + keyfaction.getName() + " ";
} }
if (overflown) fRow += Const.MAP_OVERFLOW_MESSAGE;
fRow = fRow.trim(); fRow = fRow.trim();
ret.add(fRow); ret.add(fRow);