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

@ -369,35 +369,42 @@ 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
@ -411,8 +418,9 @@ public class Board extends Entity<Board> implements BoardInterface
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);