Permalink
Browse files

debugging message

  • Loading branch information...
egelmex committed Apr 14, 2012
1 parent 2467745 commit 40047dbdf5ac4d870adf9f384c91ab491ae42fa5
@@ -7,6 +7,7 @@
import java.util.Timer;
import no.arcticdrakefox.wolfbot.management.GameCore;
+import no.arcticdrakefox.wolfbot.management.Messages;
import no.arcticdrakefox.wolfbot.management.Player;
import no.arcticdrakefox.wolfbot.management.PlayerList;
import no.arcticdrakefox.wolfbot.management.StringHandler;
@@ -30,11 +31,11 @@
public static void main(String[] args) throws Exception {
- String server = "irc.lessthan3.net";
- String nick = "Wolfbot";
- String channel = "#wolfbot";
+ String server = "irc.lessthan3.net"; //$NON-NLS-1$
+ String nick = "Wolfbot"; //$NON-NLS-1$
+ String channel = "#wolfbot"; //$NON-NLS-1$
- Getopt g = new Getopt("WolfBot", args, "c:n:s:");
+ Getopt g = new Getopt("WolfBot", args, "c:n:s:"); //$NON-NLS-1$ //$NON-NLS-2$
//
int c;
while ((c = g.getopt()) != -1) {
@@ -47,18 +48,17 @@ public static void main(String[] args) throws Exception {
break;
case 's':
server = g.getOptarg();
- //
case '?':
+ System.out.println("help?! There is no stinking help."); //TODO
break; // getopt() already printed an error
- //
default:
- System.out.print("getopt() returned " + c + "\n");
+ System.out.print("getopt() returned " + c + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
- PircBot bot = new WolfBot(nick, "ruffruff");
+ PircBot bot = new WolfBot(nick, "ruffruff"); //$NON-NLS-1$
bot.setVerbose(true);
bot.connect(server);
bot.joinChannel(channel);
@@ -91,20 +91,20 @@ protected void onMessage(String channel, String sender, String login,
message = StringHandler.stripColour(message).trim();
if (message.charAt(0) != '!')
return;
- String[] args = message.split(" ");
+ String[] args = message.split(" "); //$NON-NLS-1$
String command = args[0];
// So, we ask the model for all commands matching the command string:
Collection<Command> validCommands = Collections2.filter(data.getCommands(), new CommandSelectorPredicate (command, MessageType.CHANNEL));
if (validCommands.size() > 1)
{
- sendIrcMessage(data.getChannel(), "More than one valid command. This is probably a bug. Aborting!");
+ sendIrcMessage(data.getChannel(), Messages.getString("WolfBot.error.multipleCommands")); //$NON-NLS-1$
return;
}
else if (validCommands.isEmpty())
{
- sendIrcMessage(data.getChannel(), "Unknown command...");
+ sendIrcMessage(data.getChannel(), Messages.getString("WolfBot.error.unknownCommand")); //$NON-NLS-1$
return;
}
@@ -140,7 +140,7 @@ protected void onPrivateMessage(String sender, String login,
// Ignore private messages that aren't commands
if (message.charAt(0) != '!')
return;
- String[] args = message.split(" ");
+ String[] args = message.split(" "); //$NON-NLS-1$
String command = args[0];
Player player = data.getPlayers().getPlayer(sender);
@@ -157,7 +157,7 @@ protected void onPrivateMessage(String sender, String login,
if (validCommands.size() > 1)
{
- sendIrcMessage(sender, "More than one valid command. This is probably a bug. Aborting!");
+ sendIrcMessage(sender, Messages.getString("WolfBot.error.multipleCommands")); //$NON-NLS-1$
return;
}/*
else if (validCommands.isEmpty())
@@ -217,10 +217,10 @@ protected void onQuit(String sourceNick, String sourceLogin, String sourceHostna
if (! (data.getState() == State.None || data.getState() == State.Starting))
{
if (data.getSilentMode()) {
- sendIrcMessage(data.getChannel(), String.format("%s has fled",
+ sendIrcMessage(data.getChannel(), String.format(Messages.getString("WolfBot.fled.noReveal"), //$NON-NLS-1$
bold(sourceNick)));
} else {
- sendIrcMessage(data.getChannel(), String.format("%s has fled - they were a %s",
+ sendIrcMessage(data.getChannel(), String.format(Messages.getString("WolfBot.fled.Reveal"), //$NON-NLS-1$
bold(sourceNick), player.getRole().toStringColor()));
}
}
@@ -246,24 +246,22 @@ public void sendRoleMessages() {
Team team = player.getRole().getTeam();
switch (team) {
case Wolves:
- sendIrcMessage(player.getName(), "You are on the " + team.getColor()
- + "wolf" + Colors.NORMAL
- + " team. You must attempt to eat the " + Team.Villagers.getColor()
- + " villagers!");
+ sendIrcMessage(player.getName(),
+ String.format(Messages.getString("WolfBot.intro.wolf"), //$NON-NLS-1$
+ new Object[] {StringHandler.colorise(Team.Wolves.getColor(), "wolf"), //$NON-NLS-1$
+ StringHandler.colorise(Team.Villagers.getColor(), "villagers")})); //$NON-NLS-1$
break;
case Villagers:
- sendIrcMessage(player.getName(), "You are on the "
- + team.getColor() + "villager" + Colors.NORMAL
- + " team. Defend against the invading " + Team.Wolves.getColor()
- + "wolf" + Colors.NORMAL + " incursion!");
+ sendIrcMessage(player.getName(),
+ String.format(Messages.getString("WolfBot.intro.villagers"), //$NON-NLS-1$
+ StringHandler.colorise(Team.Wolves.getColor(), "wolf"), Role.villager.toStringColor())); //$NON-NLS-1$
break;
case LoneWolf:
- sendIrcMessage(player.getName(), "You are on your"
- + Colors.PURPLE + "OWN" + Colors.NORMAL
- + " team. Kill EVERYONE!");
+ sendIrcMessage(player.getName(), String.format(Messages.getString("WolfBot.intro.LoneWolf"), //$NON-NLS-1$
+ StringHandler.colorise(Team.LoneWolf.getColor(), "OWN"))); //$NON-NLS-1$
default:
sendIrcMessage(player.getName(),
- "You are on an unknown team. Something has probably gone wrong here.");
+ Messages.getString("WolfBot.intro.unknown")); //$NON-NLS-1$
}
}
}
@@ -299,28 +297,28 @@ private void sendNightEndMessages(Role role, boolean publicMessage) {
}
public void voiceAll() {
- massMode(data.getPlayers().getLivingPlayers(), true, "v");
+ massMode(data.getPlayers().getLivingPlayers(), true, "v"); //$NON-NLS-1$
}
public void deVoiceAll() {
- massMode(data.getPlayers().getList(), false, "v");
+ massMode(data.getPlayers().getList(), false, "v"); //$NON-NLS-1$
}
private static final int MAX_MODE = 5;
private void massMode(List<Player> toChange, boolean add, String mode) {
- String modeToApply = "";
+ String modeToApply = ""; //$NON-NLS-1$
if (add) {
- modeToApply += "+";
+ modeToApply += "+"; //$NON-NLS-1$
} else {
- modeToApply += "-";
+ modeToApply += "-"; //$NON-NLS-1$
}
List<List<Player>> smallerLists = Lists.partition(toChange, MAX_MODE);
for (List<Player> ps : smallerLists) {
for (int i = 0; i < ps.size(); ++i)
modeToApply += mode;
- setMode(data.getChannel(), modeToApply + " "
+ setMode(data.getChannel(), modeToApply + " " //$NON-NLS-1$
+ StringHandler.listToStringSimplePlayers(ps));
}
}
@@ -18,7 +18,7 @@
private Messages() {
}
- public static String getString(String key, Object[] args) {
+ public static String getString(String key, Object... args) {
try {
int count = Integer.parseInt(RESOURCE_BUNDLE.getString(key + ".count"));
int rnd = rng.nextInt(count);
@@ -56,4 +56,8 @@ public static String listToStringSimplePlayers(List<Player> list){
ret += " " + list.get(i).getName();
return ret;
}
+
+ public static String colorise(final String color, final String text) {
+ return color + text + Colors.NORMAL;
+ }
}
@@ -67,7 +67,7 @@ public String nightEnd() {
return null;
else if (isAlive){
if (vote.isAlive()){
- vote.die(Messages.getString("Vigilante.killed", new Object[] {vote, vote.getRole()})); //$NON-NLS-1$
+ vote.die(Messages.getString("Vigilante.killed", vote, vote.getRole())); //$NON-NLS-1$
if (vote.isWolf()){
return Messages.getString("Vigilante.killedWolf", new Object[]{vote}); //$NON-NLS-1$
} else{
@@ -34,8 +34,9 @@ public Role getRole() {
@Override
public String roleInfo(PlayerList players) {
- return Messages.getString("Wolf.intro", //$NON-NLS-1$
- new Object[] {StringHandler.listToString(players.getWolves())});
+ Object [] params = new Object[] {StringHandler.listToString(players.getWolves())};
+
+ return Messages.getString("Wolf.intro", params);
}
@Override
@@ -161,3 +161,11 @@ Wolf.nightError=Correct usage: \!kill <someone>
Wolf.nightHelp=As a wolf, you can \!kill someone tonight or just \!rest
Wolf.rested=You decide to quell your bloodlust tonight.
Wolf.selfKill=Killing yourself doesn't seem very productive.
+WolfBot.error.multipleCommands=More than one valid command. This is probably a bug. Aborting\!
+WolfBot.error.unknownCommand=Unknown command...
+WolfBot.fled.noReveal=%s has fled
+WolfBot.fled.Reveal=%s has fled - they were a %s
+WolfBot.intro.LoneWolf=You are on your {0} team. Kill EVERYONE\!
+WolfBot.intro.unknown=You are on an unknown team. Something has probably gone wrong here.
+WolfBot.intro.villagers=You are on the %s team. Defend against the invading %s incursion\!
+WolfBot.intro.wolf=You are on the %s team. You must attempt to eat the %s\!

0 comments on commit 40047db

Please sign in to comment.