Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 4 commits
  • 15 files changed
  • 0 commit comments
  • 2 contributors
Commits on Apr 13, 2012
@tpcarlson tpcarlson Merge pull request #65 from egelmex/master
String externalising for Roles + some cleanups
6a1e5e2
Commits on Apr 14, 2012
@tpcarlson tpcarlson Victory refactor
Closes #34
7c29426
@egelmex debugging message 40047db
@egelmex Merge branch 'master' of https://github.com/tpcarlson/Werewolf
Conflicts:
	src/no/arcticdrakefox/wolfbot/management/Messages.java
	src/no/arcticdrakefox/wolfbot/roles/messages.properties
44af530
View
18 .classpath
@@ -1,9 +1,9 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="lib" path="lib/pircbot.jar"/>
- <classpathentry kind="lib" path="lib/guava-11.0.1.jar"/>
- <classpathentry kind="lib" path="lib/java-getopt-1.0.13.jar"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="lib/pircbot.jar"/>
+ <classpathentry kind="lib" path="lib/guava-11.0.1.jar"/>
+ <classpathentry kind="lib" path="lib/java-getopt-1.0.13.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
View
118 build.xml
@@ -1,59 +1,59 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!-- WARNING: Eclipse auto-generated file.
- Any modifications will be overwritten.
- To include a user specific buildfile here, simply create one in the same
- directory with the processing instruction <?eclipse.ant.import?>
- as the first entry and export the buildfile again. -->
-<project basedir="." default="build" name="WereWolf">
- <property environment="env"/>
- <property name="ECLIPSE_HOME" value="../../../../usr/share/eclipse"/>
- <property name="debuglevel" value="source,lines,vars"/>
- <property name="target" value="1.7"/>
- <property name="source" value="1.7"/>
- <path id="WereWolf.classpath">
- <pathelement location="bin"/>
- <pathelement location="lib/pircbot.jar"/>
- <pathelement location="lib/guava-11.0.1.jar"/>
- <pathelement location="lib/java-getopt-1.0.13.jar"/>
- </path>
- <target name="init">
- <mkdir dir="bin"/>
- <copy includeemptydirs="false" todir="bin">
- <fileset dir="src">
- <exclude name="**/*.java"/>
- </fileset>
- </copy>
- </target>
- <target name="clean">
- <delete dir="bin"/>
- </target>
- <target depends="clean" name="cleanall"/>
- <target depends="build-subprojects,build-project" name="build"/>
- <target name="build-subprojects"/>
- <target depends="init" name="build-project">
- <echo message="${ant.project.name}: ${ant.file}"/>
- <javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}">
- <src path="src"/>
- <classpath refid="WereWolf.classpath"/>
- </javac>
- </target>
- <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
- <target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
- <copy todir="${ant.library.dir}">
- <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
- </copy>
- <unzip dest="${ant.library.dir}">
- <patternset includes="jdtCompilerAdapter.jar"/>
- <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
- </unzip>
- </target>
- <target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
- <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
- <antcall target="build"/>
- </target>
- <target name="WolfBot">
- <java classname="no.arcticdrakefox.wolfbot.WolfBot" failonerror="true" fork="yes">
- <classpath refid="WereWolf.classpath"/>
- </java>
- </target>
-</project>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- WARNING: Eclipse auto-generated file.
+ Any modifications will be overwritten.
+ To include a user specific buildfile here, simply create one in the same
+ directory with the processing instruction <?eclipse.ant.import?>
+ as the first entry and export the buildfile again. -->
+<project basedir="." default="build" name="WereWolf">
+ <property environment="env"/>
+ <property name="ECLIPSE_HOME" value="../../../../usr/share/eclipse"/>
+ <property name="debuglevel" value="source,lines,vars"/>
+ <property name="target" value="1.7"/>
+ <property name="source" value="1.7"/>
+ <path id="WereWolf.classpath">
+ <pathelement location="bin"/>
+ <pathelement location="lib/pircbot.jar"/>
+ <pathelement location="lib/guava-11.0.1.jar"/>
+ <pathelement location="lib/java-getopt-1.0.13.jar"/>
+ </path>
+ <target name="init">
+ <mkdir dir="bin"/>
+ <copy includeemptydirs="false" todir="bin">
+ <fileset dir="src">
+ <exclude name="**/*.java"/>
+ </fileset>
+ </copy>
+ </target>
+ <target name="clean">
+ <delete dir="bin"/>
+ </target>
+ <target depends="clean" name="cleanall"/>
+ <target depends="build-subprojects,build-project" name="build"/>
+ <target name="build-subprojects"/>
+ <target depends="init" name="build-project">
+ <echo message="${ant.project.name}: ${ant.file}"/>
+ <javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}">
+ <src path="src"/>
+ <classpath refid="WereWolf.classpath"/>
+ </javac>
+ </target>
+ <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
+ <target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
+ <copy todir="${ant.library.dir}">
+ <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
+ </copy>
+ <unzip dest="${ant.library.dir}">
+ <patternset includes="jdtCompilerAdapter.jar"/>
+ <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
+ </unzip>
+ </target>
+ <target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
+ <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
+ <antcall target="build"/>
+ </target>
+ <target name="WolfBot">
+ <java classname="no.arcticdrakefox.wolfbot.WolfBot" failonerror="true" fork="yes">
+ <classpath refid="WereWolf.classpath"/>
+ </java>
+ </target>
+</project>
View
64 src/no/arcticdrakefox/wolfbot/WolfBot.java
@@ -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,7 +91,7 @@ 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:
@@ -99,12 +99,12 @@ protected void onMessage(String channel, String sender, String login,
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));
}
}
View
55 src/no/arcticdrakefox/wolfbot/management/GameCore.java
@@ -8,6 +8,7 @@
import java.util.List;
import no.arcticdrakefox.wolfbot.management.commands.Commands;
+import no.arcticdrakefox.wolfbot.management.victory.Victory;
import no.arcticdrakefox.wolfbot.model.MessageType;
import no.arcticdrakefox.wolfbot.model.Role;
import no.arcticdrakefox.wolfbot.model.State;
@@ -15,8 +16,6 @@
import no.arcticdrakefox.wolfbot.model.WolfBotModel;
import no.arcticdrakefox.wolfbot.predicates.TeamPredicate;
-import org.jibble.pircbot.Colors;
-
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
@@ -113,32 +112,36 @@ public static boolean checkLynchMajority(WolfBotModel data) {
}
private static boolean checkVictory(WolfBotModel data) {
- int wolfCount = data.getPlayers().wolfCount();
- if (wolfCount < 1) {
- data.getWolfBot().sendIrcMessage(data.getChannel(),
- "With all wolves exterminated, the village is safe once again.");
- endGame(data);
- return true;
- } else if (wolfCount * 2 >= data.getPlayers().playerCount()) {
- if (wolfCount == 1)
- data.getWolfBot().sendIrcMessage(
- data.getChannel(),
- String.format(
- "After turning on the last remaining %svillager%s, %s prowls on to terrorize somewhere else.",
- Team.Villagers.getColor(), Colors.NORMAL,
- StringHandler.listToString(data.getPlayers().getWolves())));
- else
- data.getWolfBot().sendIrcMessage(
- data.getChannel(),
- String.format("%s turn on the last villagers. With all food depleted, " +
- "they leave the village behind to find fresh meat elsewhere.",
- bold(StringHandler.listToString(data.getPlayers().getWolves()))));
+ List<Victory> victoryConditions = Lists.newArrayList(data.getVictoryConditions());
+ Collections.sort(victoryConditions);
+ boolean isGameOver = false;
+ String victoryString = null;
+ for (Victory v : victoryConditions)
+ {
+ if (v.isVictory(data.getPlayers()))
+ {
+ isGameOver = true;
+ victoryString = v.getVictoryMessage(data.getPlayers());
+ break;
+ }
+ }
+
+ if (isGameOver && victoryString == null)
+ {
+ data.getWolfBot().sendIrcMessage(data.getChannel(), "No victory string defined!");
+ }
+ else if (isGameOver)
+ {
+ data.getWolfBot().sendIrcMessage(data.getChannel(), victoryString);
+ }
+
+ // Regardless, we want to endGame here
+ if (isGameOver)
+ {
endGame(data);
-
- // End of the game - return true here.
- return true;
}
- return false;
+
+ return isGameOver;
}
public static void startDay(WolfBotModel data) {
View
2 src/no/arcticdrakefox/wolfbot/management/Messages.java
@@ -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);
View
13 src/no/arcticdrakefox/wolfbot/management/PlayerList.java
@@ -21,10 +21,19 @@ public PlayerList(){
//List information
+ /**
+ *
+ * @return Count of wolves
+ */
public int wolfCount(){
return getWolves().size();
}
+ /**
+ * Returns the number of living players
+ *
+ * @return Number of players still alive
+ */
public int playerCount(){
return getLivingPlayers().size();
}
@@ -88,7 +97,7 @@ public String roleCountToString(){
public List<Player> getPlayersWithNightActions() {
List<Player> ret = new ArrayList<Player>(players.size());
- System.out.println(players.size());
+
for (Player player : players)
{
if (player.isAlive() || player.hasDeadActions())
@@ -101,7 +110,7 @@ public String roleCountToString(){
public List<Player> getLivingPlayers(){
List<Player> ret = new ArrayList<Player>(players.size());
- System.out.println(players.size());
+
for (Player player : players)
{
if (player.isAlive())
View
4 src/no/arcticdrakefox/wolfbot/management/StringHandler.java
@@ -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;
+ }
}
View
33 src/no/arcticdrakefox/wolfbot/management/victory/Victory.java
@@ -0,0 +1,33 @@
+package no.arcticdrakefox.wolfbot.management.victory;
+
+import no.arcticdrakefox.wolfbot.management.PlayerList;
+
+public abstract class Victory implements Comparable<Victory>
+{
+ private int priority;
+
+ public Victory (int priority)
+ {
+ this.priority = priority;
+ }
+
+ public int getPriority() {
+ return priority;
+ }
+
+ /*
+ * isVictory must be called before getVictoryMessage
+ */
+ public abstract boolean isVictory (PlayerList players);
+ /*
+ * isVictory must be called before getVictoryMessage
+ */
+ public abstract String getVictoryMessage(PlayerList players);
+
+ public int compareTo (Victory comparator)
+ {
+ return comparator.getPriority() - this.priority;
+ }
+
+
+}
View
20 src/no/arcticdrakefox/wolfbot/management/victory/VillagerVictory.java
@@ -0,0 +1,20 @@
+package no.arcticdrakefox.wolfbot.management.victory;
+
+import no.arcticdrakefox.wolfbot.management.PlayerList;
+
+public class VillagerVictory extends Victory {
+
+ public VillagerVictory(int priority) {
+ super(priority);
+ }
+
+ @Override
+ public boolean isVictory(PlayerList players) {
+ return players.wolfCount() < 1;
+ }
+
+ @Override
+ public String getVictoryMessage(PlayerList players) {
+ return "With all wolves exterminated, the village is safe once again.";
+ }
+}
View
39 src/no/arcticdrakefox/wolfbot/management/victory/WolfVictory.java
@@ -0,0 +1,39 @@
+package no.arcticdrakefox.wolfbot.management.victory;
+
+import no.arcticdrakefox.wolfbot.management.PlayerList;
+import no.arcticdrakefox.wolfbot.management.StringHandler;
+import no.arcticdrakefox.wolfbot.model.Team;
+import static no.arcticdrakefox.wolfbot.WolfBot.bold;
+
+import org.jibble.pircbot.Colors;
+
+public class WolfVictory extends Victory
+{
+ public WolfVictory(int priority) {
+ super(priority);
+ }
+
+ @Override
+ public boolean isVictory(PlayerList players) {
+ return players.wolfCount() * 2 >= players.playerCount();
+ }
+
+ @Override
+ public String getVictoryMessage(PlayerList players)
+ {
+ if (players.wolfCount() == 1)
+ {
+ return String.format(
+ "After turning on the last remaining %svillager%s, %s prowls on to terrorize somewhere else.",
+ Team.Villagers.getColor(), Colors.NORMAL,
+ StringHandler.listToString(players.getWolves()));
+ }
+ else
+ {
+ return String.format("%s turn on the last villagers. With all food depleted, " +
+ "they leave the village behind to find fresh meat elsewhere.",
+ bold(StringHandler.listToString(players.getWolves())));
+ }
+ }
+
+}
View
20 src/no/arcticdrakefox/wolfbot/model/WolfBotModel.java
@@ -7,6 +7,9 @@
import no.arcticdrakefox.wolfbot.management.PlayerList;
import no.arcticdrakefox.wolfbot.management.commands.Command;
import no.arcticdrakefox.wolfbot.management.commands.Commands;
+import no.arcticdrakefox.wolfbot.management.victory.Victory;
+import no.arcticdrakefox.wolfbot.management.victory.VillagerVictory;
+import no.arcticdrakefox.wolfbot.management.victory.WolfVictory;
import com.google.common.collect.Lists;
@@ -33,6 +36,17 @@ private void initCommands ()
commands.add(Commands.END_COMMAND);
}
+ private void initVictoryConditions ()
+ {
+ victoryConditions = Lists.newArrayList();
+
+ // The argument to the constructor here tells the game what priority you
+ // wish to assign to this victory condition. See GameCore#checkVictory
+ // for more.
+ victoryConditions.add(new VillagerVictory(0));
+ victoryConditions.add(new WolfVictory(0));
+ }
+
private String channel;
private String password;
private PlayerList players;
@@ -42,7 +56,12 @@ private void initCommands ()
private boolean silentMode = false;
private Collection<Command> commands;
+ private Collection<Victory> victoryConditions;
+ public Collection<Victory> getVictoryConditions() {
+ return victoryConditions;
+ }
+
public Collection<Command> getCommands() {
return commands;
}
@@ -80,6 +99,7 @@ public WolfBotModel(PlayerList players, State state, Timer startGameTimer,
this.wolfBot = wolfBot;
Commands.setModel (this);
initCommands ();
+ initVictoryConditions ();
}
View
132 src/no/arcticdrakefox/wolfbot/roles/Ghost.java
@@ -1,66 +1,66 @@
-package no.arcticdrakefox.wolfbot.roles;
-
-import no.arcticdrakefox.wolfbot.management.Messages;
-import no.arcticdrakefox.wolfbot.management.Player;
-import no.arcticdrakefox.wolfbot.management.PlayerList;
-import no.arcticdrakefox.wolfbot.model.Role;
-import no.arcticdrakefox.wolfbot.model.WolfBotModel;
-
-public class Ghost extends Player {
-
- public Ghost(String name) {
- super(name);
- }
-
- String msg = null;
-
- @Override
- public boolean isWolf() {
- return false;
- }
-
- @Override
- public Role getRole() {
- return Role.ghost;
- }
-
- @Override
- public String roleInfo(PlayerList players) {
- return Messages.getString("Ghost.init"); //$NON-NLS-1$
- }
-
- @Override
- public String nightStart() {
- if (isAlive()) return null;
- return Messages.getString("Ghost.nightHelp"); //$NON-NLS-1$
- }
-
- @Override
- public String nightAction(String message, PlayerList players) {
- if (!isAlive()) {
- String[] args = message.trim().split(" ", 2); //$NON-NLS-1$
- if (args[0].equals("!say")) { //$NON-NLS-1$
- if (args.length != 2)
- return Messages.getString("Ghost.nightError"); //$NON-NLS-1$
- msg = args[1].trim().substring(0, 1);
- isReady = true;
- WolfBotModel.getInstance().sendIrcMessage(WolfBotModel.getInstance().getChannel(),
- Messages.getString("Ghost.say", new Object[] {msg})); //$NON-NLS-1$
- return Messages.getString("Ghost.feedback", new Object[] { msg}); //$NON-NLS-1$
- }
- }
-
- return null;
- }
-
- @Override
- public String nightEnd() {
- return null;
- }
-
- @Override
- public String helpText() {
- return Messages.getString("Ghost.help"); //$NON-NLS-1$
- }
-
-}
+package no.arcticdrakefox.wolfbot.roles;
+
+import no.arcticdrakefox.wolfbot.management.Messages;
+import no.arcticdrakefox.wolfbot.management.Player;
+import no.arcticdrakefox.wolfbot.management.PlayerList;
+import no.arcticdrakefox.wolfbot.model.Role;
+import no.arcticdrakefox.wolfbot.model.WolfBotModel;
+
+public class Ghost extends Player {
+
+ public Ghost(String name) {
+ super(name);
+ }
+
+ String msg = null;
+
+ @Override
+ public boolean isWolf() {
+ return false;
+ }
+
+ @Override
+ public Role getRole() {
+ return Role.ghost;
+ }
+
+ @Override
+ public String roleInfo(PlayerList players) {
+ return Messages.getString("Ghost.init"); //$NON-NLS-1$
+ }
+
+ @Override
+ public String nightStart() {
+ if (isAlive()) return null;
+ return Messages.getString("Ghost.nightHelp"); //$NON-NLS-1$
+ }
+
+ @Override
+ public String nightAction(String message, PlayerList players) {
+ if (!isAlive()) {
+ String[] args = message.trim().split(" ", 2); //$NON-NLS-1$
+ if (args[0].equals("!say")) { //$NON-NLS-1$
+ if (args.length != 2)
+ return Messages.getString("Ghost.nightError"); //$NON-NLS-1$
+ msg = args[1].trim().substring(0, 1);
+ isReady = true;
+ WolfBotModel.getInstance().sendIrcMessage(WolfBotModel.getInstance().getChannel(),
+ Messages.getString("Ghost.say", new Object[] {msg})); //$NON-NLS-1$
+ return Messages.getString("Ghost.feedback", new Object[] { msg}); //$NON-NLS-1$
+ }
+ }
+
+ return null;
+ }
+
+ @Override
+ public String nightEnd() {
+ return null;
+ }
+
+ @Override
+ public String helpText() {
+ return Messages.getString("Ghost.help"); //$NON-NLS-1$
+ }
+
+}
View
2 src/no/arcticdrakefox/wolfbot/roles/Vigilante.java
@@ -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{
View
5 src/no/arcticdrakefox/wolfbot/roles/Wolf.java
@@ -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
View
8 src/no/arcticdrakefox/wolfbot/roles/messages.properties
@@ -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\!

No commit comments for this range

Something went wrong with that request. Please try again.