Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #65 from egelmex/master

String externalising for Roles + some cleanups
  • Loading branch information...
commit 6a1e5e235320a9d8cc1665e5f77d95a899fdfe5c 2 parents 3beeeb6 + 2467745
@tpcarlson tpcarlson authored
Showing with 348 additions and 147 deletions.
  1. +2 −3 src/no/arcticdrakefox/wolfbot/management/BotConstants.java
  2. +38 −0 src/no/arcticdrakefox/wolfbot/management/Messages.java
  3. +1 −0  src/no/arcticdrakefox/wolfbot/management/WerewolfException.java
  4. +4 −3 src/no/arcticdrakefox/wolfbot/roles/ApprenticeScry.java
  5. +15 −15 src/no/arcticdrakefox/wolfbot/roles/AuraScry.java
  6. +12 −15 src/no/arcticdrakefox/wolfbot/roles/Baner.java
  7. +17 −16 src/no/arcticdrakefox/wolfbot/roles/Devil.java
  8. +3 −2 src/no/arcticdrakefox/wolfbot/roles/Diseased.java
  9. +9 −9 src/no/arcticdrakefox/wolfbot/roles/Ghost.java
  10. +7 −7 src/no/arcticdrakefox/wolfbot/roles/Mason.java
  11. +3 −2 src/no/arcticdrakefox/wolfbot/roles/Mayor.java
  12. +12 −11 src/no/arcticdrakefox/wolfbot/roles/Necromancer.java
  13. +6 −5 src/no/arcticdrakefox/wolfbot/roles/OldMan.java
  14. +15 −20 src/no/arcticdrakefox/wolfbot/roles/Scry.java
  15. +5 −4 src/no/arcticdrakefox/wolfbot/roles/ToughGuy.java
  16. +17 −16 src/no/arcticdrakefox/wolfbot/roles/Vigilante.java
  17. +4 −3 src/no/arcticdrakefox/wolfbot/roles/Villager.java
  18. +15 −16 src/no/arcticdrakefox/wolfbot/roles/Wolf.java
  19. +163 −0 src/no/arcticdrakefox/wolfbot/roles/messages.properties
View
5 src/no/arcticdrakefox/wolfbot/management/BotConstants.java
@@ -1,11 +1,10 @@
package no.arcticdrakefox.wolfbot.management;
-import com.google.common.base.Joiner;
-import com.google.common.collect.Lists;
-
import no.arcticdrakefox.wolfbot.model.Role;
import no.arcticdrakefox.wolfbot.roles.SkipPlayer;
+import com.google.common.collect.Lists;
+
public class BotConstants {
public static final String NO_VOTES = "Noone ;_;";
public static final String SKIP_VOTE_NICKNAME = "Skipped!";
View
38 src/no/arcticdrakefox/wolfbot/management/Messages.java
@@ -0,0 +1,38 @@
+package no.arcticdrakefox.wolfbot.management;
+
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.Random;
+import java.util.ResourceBundle;
+
+public class Messages {
+ private static final String BUNDLE_NAME = "no.arcticdrakefox.wolfbot.roles.messages"; //$NON-NLS-1$
+
+ private static final Object[] empty = new Object[] {};
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
+ .getBundle(BUNDLE_NAME);
+
+ private static final Random rng = new Random();
+
+ private Messages() {
+ }
+
+ public static String getString(String key, Object[] args) {
+ try {
+ int count = Integer.parseInt(RESOURCE_BUNDLE.getString(key + ".count"));
+ int rnd = rng.nextInt(count);
+ return MessageFormat.format(RESOURCE_BUNDLE.getString(key+"."+rnd), args);
+ } catch (MissingResourceException e) {
+ try {
+ return MessageFormat.format(RESOURCE_BUNDLE.getString(key), args);
+ } catch (MissingResourceException ex) {
+ return "Missing String in properties file.";
+ }
+ }
+ }
+
+ public static String getString(String key) {
+ return getString(key, empty);
+ }
+}
View
1  src/no/arcticdrakefox/wolfbot/management/WerewolfException.java
@@ -1,5 +1,6 @@
package no.arcticdrakefox.wolfbot.management;
+@SuppressWarnings("serial")
public class WerewolfException extends Exception
{
String message;
View
7 src/no/arcticdrakefox/wolfbot/roles/ApprenticeScry.java
@@ -1,5 +1,6 @@
package no.arcticdrakefox.wolfbot.roles;
+import no.arcticdrakefox.wolfbot.management.Messages;
import no.arcticdrakefox.wolfbot.management.PlayerList;
import no.arcticdrakefox.wolfbot.model.Role;
@@ -28,12 +29,12 @@ public Role getRole() {
@Override
public String roleInfo(PlayerList players) {
- return "You are the apprentice Scry. You will take over if your master dies.";
+ return Messages.getString("ApprenticeScry.intro"); //$NON-NLS-1$
}
@Override
public String nightStart() {
- if (active && !informed) return "Your master has been killed - you now have his powers." + super.nightStart();
+ if (active && !informed) return Messages.getString("ApprenticeScry.upgrade") + super.nightStart(); //$NON-NLS-1$
if (active) return super.nightStart();
return null;
}
@@ -51,6 +52,6 @@ public String nightEnd() {
}
@Override
public String helpText() {
- return "The apprentice scry has been learning from his master for years. If his master dies, he will gain his scrying power.";
+ return Messages.getString("ApprenticeScry.help"); //$NON-NLS-1$
}
}
View
30 src/no/arcticdrakefox/wolfbot/roles/AuraScry.java
@@ -1,5 +1,6 @@
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;
@@ -23,41 +24,40 @@ public Role getRole() {
@Override
public String roleInfo(PlayerList players) {
- return "You are the Aura Scry, each night you will be able to see whether " +
- "a player has a special ability.";
+ return Messages.getString("AuraScry.info"); //$NON-NLS-1$
}
@Override
public String nightStart() {
isReady = false;
- return "The stars smile on you tonight. You may !scry a person or just !rest";
+ return Messages.getString("AuraScry.nightInstructions"); //$NON-NLS-1$
}
@Override
public String nightAction(String message, PlayerList players) {
- String[] args = message.trim().split(" ", 2);
- if (args[0].equals("!scry")){
+ String[] args = message.trim().split(" ", 2); //$NON-NLS-1$
+ if (args[0].equals("!scry")){ //$NON-NLS-1$
if (args.length != 2)
- return "Correct usage: !scry <someone>";
+ return Messages.getString("AuraScry.correctUsage"); //$NON-NLS-1$
if (isReady)
- return "You may only scry one person each night.";
+ return Messages.getString("AuraScry.tooManyPeople"); //$NON-NLS-1$
Player target = players.getPlayer(args[1]);
if (target == null)
return targetNotFound(args[1]);
else {
if (target.equals(this)){
- return "You don't need your special powers to know that you are a scry.";
+ return Messages.getString("AuraScry.selfScry"); //$NON-NLS-1$
} else if (target.isAlive()){
isReady = true;
vote = target;
- return String.format("You set up your array of candles, orbs and artifacts, concentrating your efforts on %s", target);
+ return Messages.getString("AuraScry.Scried", new Object[] {target}); //$NON-NLS-1$
} else
- return String.format("%s is already dead.", target);
+ return Messages.getString("AuraScry.allreadyDead", new Object[] {target}); //$NON-NLS-1$
}
- } else if (args[0].equals("!rest")){
+ } else if (args[0].equals("!rest")){ //$NON-NLS-1$
isReady = true;
vote = null;
- return "You rest for tonight, confident that you already know all you need.";
+ return Messages.getString("AuraScry.rest"); //$NON-NLS-1$
} else
return null;
}
@@ -69,14 +69,14 @@ public String nightEnd() {
} else {
Role r = vote.getRole();
return (r != Role.villager) && (r!=Role.wolf) ?
- String.format("%s has an aura. They clearly have some power, though you know not what it may be.", vote)
- : String.format("%s does not appear to have any powers, whatever their crimes.", vote);
+ Messages.getString("AuraScry.hasAura", new Object[] {vote}) //$NON-NLS-1$
+ : Messages.getString("AuraScry.noAura", new Object[] {vote}); //$NON-NLS-1$
}
}
@Override
public String helpText() {
- return "The aura scry can look into the spirit world to sense the mental strength of others. He can focus on someone at night and will know if they have any special powers - but won't know what they are! ";
+ return Messages.getString("AuraScry.help"); //$NON-NLS-1$
}
}
View
27 src/no/arcticdrakefox/wolfbot/roles/Baner.java
@@ -1,12 +1,9 @@
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;
-import no.arcticdrakefox.wolfbot.predicates.TeamPredicate;
-
-import com.google.common.collect.Collections2;
public class Baner extends Player {
@@ -26,21 +23,21 @@ public Role getRole() {
@Override
public String roleInfo(PlayerList players) {
- return "You are the terror that flaps into the night! You are Wolfsbane! Baner of wolves! Each night you may choose one person to protect from wolf attacks.";
+ return Messages.getString("Baner.description"); //$NON-NLS-1$
}
@Override
public String nightStart() {
isReady = false;
- return "It's time. !bane the wolves from someone tonight or !rest";
+ return Messages.getString("Baner.nightInstructions"); //$NON-NLS-1$
}
@Override
public String nightAction(String message, PlayerList players) {
- String[] args = message.trim().split(" ", 2);
- if (args[0].equals("!bane")){
+ String[] args = message.trim().split(" ", 2); //$NON-NLS-1$
+ if (args[0].equals("!bane")){ //$NON-NLS-1$
if (args.length != 2)
- return "Correct usage: !bane <someone>";
+ return Messages.getString("Baner.correctUsage"); //$NON-NLS-1$
Player target = players.getPlayer(args[1]);
if (target == null)
return targetNotFound(args[1]);
@@ -49,16 +46,16 @@ public String nightAction(String message, PlayerList players) {
vote(target);
isReady = true;
if (target.equals(this))
- return "You fortify your defenses and set up traps. The wolves will never catch you!";
+ return Messages.getString("Baner.selfBane"); //$NON-NLS-1$
else
- return String.format("You don your purple cape and matching bell-shaped hat. %s will not die on your watch!", target);
+ return Messages.getString("Baner.bane", new Object[] {target}); //$NON-NLS-1$
} else
- return String.format("You are too late to save %s, they are dead already.", target);
+ return Messages.getString("Baner.tooLate", new Object[] {target}); //$NON-NLS-1$
}
- } else if (args[0].equals("!rest")){
+ } else if (args[0].equals("!rest")){ //$NON-NLS-1$
isReady = true;
vote = null;
- return "You give up. The village can die for all you care.";
+ return Messages.getString("Baner.rest"); //$NON-NLS-1$
} else
return null;
}
@@ -70,6 +67,6 @@ public String nightEnd() {
@Override
public String helpText() {
- return "The Baner can protect a member of the village each night, including themselves. If the wolves attack that person, they will be driven off and nobody will die.";
+ return Messages.getString("Baner.help"); //$NON-NLS-1$
}
}
View
33 src/no/arcticdrakefox/wolfbot/roles/Devil.java
@@ -1,5 +1,6 @@
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.management.StringHandler;
@@ -24,8 +25,8 @@ public Role getRole() {
@Override
public String roleInfo(PlayerList players) {
- return String.format("You are a devil, an evil creature. You may check a person's role each night, or sacrifice someone. The wolves are %s, and you are on their side!",
- StringHandler.listToString(players.getWolves())
+ return Messages.getString("Devil.intro", //$NON-NLS-1$
+ new Object[] {StringHandler.listToString(players.getWolves())}
);
}
@@ -33,40 +34,40 @@ public String roleInfo(PlayerList players) {
public String nightStart() {
isReady = false;
scryVote = null;
- return "The moon is in alignment. You may !scry a person, !kill them or just !rest";
+ return Messages.getString("Devil.nightInstructions"); //$NON-NLS-1$
}
@Override
public String nightAction(String message, PlayerList players) {
- String[] args = message.trim().split(" ", 2);
- if (args[0].matches("!scry|!kill")){
+ String[] args = message.trim().split(" ", 2); //$NON-NLS-1$
+ if (args[0].matches("!scry|!kill")){ //$NON-NLS-1$
if (args.length != 2)
- return "Correct usage: !scry <someone> or !kill <someone>";
+ return Messages.getString("Devil.nightHelp"); //$NON-NLS-1$
if (isReady)
- return "You may only scry one person each night.";
+ return Messages.getString("Devil.multipleScryError"); //$NON-NLS-1$
Player target = players.getPlayer(args[1]);
if (target == null)
return targetNotFound(args[1]);
else {
if (target.equals(this)){
- return "It makes no sense to target yourself.";
+ return Messages.getString("Devil.selfScry"); //$NON-NLS-1$
} else if (target.isAlive()){
isReady = true;
- if (args[0].equals("!scry")){
+ if (args[0].equals("!scry")){ //$NON-NLS-1$
scryVote = target;
- return String.format("You start a dark prayer to your evil gods, staring into the soul of %s", target);
+ return Messages.getString("Devil.successfulFeedback", new Object[]{target}); //$NON-NLS-1$
} else {
vote = target;
- return String.format("Though unbefitting of one of your stature, you abandon your artifacts and get out to hunt %s", target);
+ return Messages.getString("Devil.restFeedback", new Object[]{target}); //$NON-NLS-1$
}
} else
- return String.format("%s is already dead.", target);
+ return Messages.getString("Devil.targetDied", new Object[]{target}); //$NON-NLS-1$
}
- } else if (args[0].equals("!rest")){
+ } else if (args[0].equals("!rest")){ //$NON-NLS-1$
isReady = true;
vote = null;
scryVote = null;
- return "You rest for tonight, confident that you already know all you need.";
+ return Messages.getString("Devil.rested"); //$NON-NLS-1$
}
return null;
}
@@ -76,12 +77,12 @@ public String nightEnd() {
if (scryVote == null){
return null;
} else {
- return String.format("%s is a %s", vote, vote.getRole());
+ return Messages.getString("Devil.result", new Object[] {vote, vote.getRole()}); //$NON-NLS-1$
}
}
@Override
public String helpText() {
- return "The devil is an evil creature who can look deep into someone's soul and know what they are capable of. He can also sacrifice people at night, if he prefers.";
+ return Messages.getString("Devil.roleHelp"); //$NON-NLS-1$
}
}
View
5 src/no/arcticdrakefox/wolfbot/roles/Diseased.java
@@ -2,6 +2,7 @@
import java.util.Collection;
+import no.arcticdrakefox.wolfbot.management.Messages;
import no.arcticdrakefox.wolfbot.management.Player;
import no.arcticdrakefox.wolfbot.management.PlayerList;
import no.arcticdrakefox.wolfbot.model.Role;
@@ -28,7 +29,7 @@ public Role getRole() {
@Override
public String roleInfo(PlayerList players) {
- return "You are diseased, your man-meat will poison any wolf that eats you.";
+ return Messages.getString("Diseased.intro"); //$NON-NLS-1$
}
@Override
@@ -67,7 +68,7 @@ public boolean apply(Player player) {
@Override
public String helpText() {
- return "I taste bad. Don't eat me!";
+ return Messages.getString("Diseased.helptext"); //$NON-NLS-1$
}
}
View
18 src/no/arcticdrakefox/wolfbot/roles/Ghost.java
@@ -1,5 +1,6 @@
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;
@@ -25,28 +26,27 @@ public Role getRole() {
@Override
public String roleInfo(PlayerList players) {
- return "Ghosts can comunicate with the living, one charactor at a time.";
+ return Messages.getString("Ghost.init"); //$NON-NLS-1$
}
@Override
public String nightStart() {
if (isAlive()) return null;
- return "What would you like to say to the living !Say <somthing>.";
+ return Messages.getString("Ghost.nightHelp"); //$NON-NLS-1$
}
@Override
public String nightAction(String message, PlayerList players) {
if (!isAlive()) {
- String[] args = message.trim().split(" ", 2);
- if (args[0].equals("!say")) {
+ String[] args = message.trim().split(" ", 2); //$NON-NLS-1$
+ if (args[0].equals("!say")) { //$NON-NLS-1$
if (args.length != 2)
- return "Correct usage: !say <Letter>";
+ return Messages.getString("Ghost.nightError"); //$NON-NLS-1$
msg = args[1].trim().substring(0, 1);
isReady = true;
WolfBotModel.getInstance().sendIrcMessage(WolfBotModel.getInstance().getChannel(),
- String.format("The voice of the dead can be heard pn the wind." +
- "You make out the letter '%s'", msg));
- return String.format("Your message '%s' will be relayed", msg);
+ Messages.getString("Ghost.say", new Object[] {msg})); //$NON-NLS-1$
+ return Messages.getString("Ghost.feedback", new Object[] { msg}); //$NON-NLS-1$
}
}
@@ -60,7 +60,7 @@ public String nightEnd() {
@Override
public String helpText() {
- return "Once the ghost dies they will be able to communicate with the living.";
+ return Messages.getString("Ghost.help"); //$NON-NLS-1$
}
}
View
14 src/no/arcticdrakefox/wolfbot/roles/Mason.java
@@ -1,5 +1,6 @@
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.management.StringHandler;
@@ -23,11 +24,10 @@ public Role getRole() {
@Override
public String roleInfo(PlayerList players) {
- return String.format("Since childhood, you have had close friends."
- +"Ones you know you can absolutely depend upon even in situations like this"
- +"The masons are %s",
- StringHandler.listToString(players.getRole(Role.mason))
- );
+ Object[] tmp = new Object[] {StringHandler.listToString(players.getRole(Role.mason))};
+
+ return Messages.getString("Mason.intro") //$NON-NLS-1$
+ + Messages.getString("Mason.theMasons", tmp);//$NON-NLS-1$
}
@Override
@@ -37,7 +37,7 @@ public String nightStart() {
@Override
public String nightAction(String message, PlayerList players) {
- return "There is nothing for you to do at night but rest and hope for the best.";
+ return Messages.getString("Mason.nightError"); //$NON-NLS-1$
}
@Override
@@ -47,6 +47,6 @@ public String nightEnd() {
@Override
public String helpText() {
- return "The masons have only one difference from the standard villager - they know who all the other masons are.";
+ return Messages.getString("Mason.help"); //$NON-NLS-1$
}
}
View
5 src/no/arcticdrakefox/wolfbot/roles/Mayor.java
@@ -1,5 +1,6 @@
package no.arcticdrakefox.wolfbot.roles;
+import no.arcticdrakefox.wolfbot.management.Messages;
import no.arcticdrakefox.wolfbot.management.PlayerList;
import no.arcticdrakefox.wolfbot.model.Role;
@@ -17,10 +18,10 @@ public Role getRole ()
@Override
public String roleInfo(PlayerList players){
- return "You are the village Mayor and your opinion is well respected by your fellow villagers. Try not to get eaten or lynched!";
+ return Messages.getString("Mayor.intro"); //$NON-NLS-1$
}
@Override
public String helpText() {
- return "The Mayor is well respected by the villagers - his voice counts more than anyone else when it comes to lynching time!";
+ return Messages.getString("Mayor.help"); //$NON-NLS-1$
}
}
View
23 src/no/arcticdrakefox/wolfbot/roles/Necromancer.java
@@ -1,5 +1,6 @@
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;
@@ -22,37 +23,37 @@ public Role getRole() {
@Override
public String roleInfo(PlayerList players) {
- return "You are a necromancer, capable of bringing people back from the dead as you once managed to do for yourself.";
+ return Messages.getString("Necromancer.init"); //$NON-NLS-1$
}
@Override
public String nightStart() {
isReady = false;
- return "The time is right. You may !ghost a person back to life or just !rest";
+ return Messages.getString("Necromancer.nightHelp"); //$NON-NLS-1$
}
@Override
public String nightAction(String message, PlayerList players) {
- String[] args = message.trim().split(" ", 2);
- if (args[0].equals("!ghost")){
+ String[] args = message.trim().split(" ", 2); //$NON-NLS-1$
+ if (args[0].equals("!ghost")){ //$NON-NLS-1$
if (args.length != 2)
- return "Correct usage: !ghost <someone>";
+ return Messages.getString("Necromancer.nightError"); //$NON-NLS-1$
Player target = players.getPlayer(args[1]);
if (target == null)
return targetNotFound(args[1]);
else {
if (target.isAlive()){
- return String.format("%s is still amongst the living.", target);
+ return Messages.getString("Necromancer.targetLiving", new Object[]{target}); //$NON-NLS-1$
} else {
vote(target);
isReady = true;
- return String.format("Life leaves your body as you trail off the spirit world, trying to find %s", target);
+ return Messages.getString("Necromancer.target", new Object[]{target}); //$NON-NLS-1$
}
}
- } else if (args[0].equals("!rest")){
+ } else if (args[0].equals("!rest")){ //$NON-NLS-1$
isReady = true;
vote = null;
- return "You cannot think of a worthy man to bring back. Tonight, you will rest.";
+ return Messages.getString("Necromancer.rested"); //$NON-NLS-1$
} else
return null;
}
@@ -65,12 +66,12 @@ else if (vote.isAlive()){
return null;
} else {
vote.revive();
- return String.format("A villager emerges at dawn, walking about as if they had never died at all. %s lives again!", vote);
+ return String.format(Messages.getString("Necromancer.success"), vote); //$NON-NLS-1$
}
}
@Override
public String helpText() {
- return "The ghost is capable of raising the dead at night.";
+ return Messages.getString("Necromancer.help"); //$NON-NLS-1$
}
}
View
11 src/no/arcticdrakefox/wolfbot/roles/OldMan.java
@@ -1,5 +1,6 @@
package no.arcticdrakefox.wolfbot.roles;
+import no.arcticdrakefox.wolfbot.management.Messages;
import no.arcticdrakefox.wolfbot.management.PlayerList;
import no.arcticdrakefox.wolfbot.model.Role;
import no.arcticdrakefox.wolfbot.model.WolfBotModel;
@@ -8,7 +9,7 @@
@Override
public String roleInfo(PlayerList players) {
- return "You are an old man. Your time is almost up...";
+ return Messages.getString("OldMan.intro"); //$NON-NLS-1$
}
private int ttl;
@@ -20,7 +21,7 @@ public OldMan(String name) {
@Override
public String nightAction(String message, PlayerList players) {
- return "You do not have any night actions. You should probably be resting up, old man.";
+ return Messages.getString("OldMan.nightError"); //$NON-NLS-1$
}
@Override
@@ -33,14 +34,14 @@ public String nightStart() {
public String nightEnd() {
if (ttl == 0)
{
- die (String.format("%s died in the night, but not by the hand of a wolf.", getName()));
- return "It looks like your time in this world is up. As the last breath escapes your tired body, you think you hear a low growling...";
+ die (Messages.getString("OldMan.died", new Object[] {getName()})); //$NON-NLS-1$
+ return Messages.getString("OldMan.diedFeedback"); //$NON-NLS-1$
}
return null;
}
@Override
public String helpText() {
- return "The old man appears to be a normal villager - but he will die soon whether he gets eaten or not! He will survive one night for each wolf, plus one.";
+ return Messages.getString("OldMan.help"); //$NON-NLS-1$
}
}
View
35 src/no/arcticdrakefox/wolfbot/roles/Scry.java
@@ -2,6 +2,7 @@
import java.util.Collection;
+import no.arcticdrakefox.wolfbot.management.Messages;
import no.arcticdrakefox.wolfbot.management.Player;
import no.arcticdrakefox.wolfbot.management.PlayerList;
import no.arcticdrakefox.wolfbot.model.Role;
@@ -46,42 +47,40 @@ public Role getRole() {
@Override
public String roleInfo(PlayerList players) {
- return "You are a scry. Every night you may check a person for lycanthropy. Beware, for you are the wolves primary target.";
+ return Messages.getString("Scry.intro"); //$NON-NLS-1$
}
@Override
public String nightStart() {
isReady = false;
- return "The moon is in alignment. You may !scry a person or just !rest";
+ return Messages.getString("Scry.nightHelp"); //$NON-NLS-1$
}
@Override
public String nightAction(String message, PlayerList players) {
- String[] args = message.trim().split(" ", 2);
- if (args[0].equals("!scry")) {
+ String[] args = message.trim().split(" ", 2); //$NON-NLS-1$
+ if (args[0].equals("!scry")) { //$NON-NLS-1$
if (args.length != 2)
- return "Correct usage: !scry <someone>";
+ return Messages.getString("Scry.nightError"); //$NON-NLS-1$
if (isReady)
- return "You may only scry one person each night.";
+ return Messages.getString("Scry.twoScries"); //$NON-NLS-1$
Player target = players.getPlayer(args[1]);
if (target == null)
return targetNotFound(args[1]);
else {
if (target.equals(this)) {
- return "You don't need your special powers to know that you are a scry.";
+ return Messages.getString("Scry.selfScry"); //$NON-NLS-1$
} else if (target.isAlive()) {
isReady = true;
vote = target;
- return String
- .format("You set up your array of candles, orbs and artifacts, concentrating your efforts on %s",
- target);
+ return Messages.getString("Scry.success",new Object []{target});
} else
- return String.format("%s is already dead.", target);
+ return Messages.getString("Scry.deadError", new Object[]{target}); //$NON-NLS-1$
}
- } else if (args[0].equals("!rest")) {
+ } else if (args[0].equals("!rest")) { //$NON-NLS-1$
isReady = true;
vote = null;
- return "You rest for tonight, confident that you already know all you need.";
+ return Messages.getString("Scry.rest"); //$NON-NLS-1$
} else
return null;
}
@@ -91,17 +90,13 @@ public String nightEnd() {
if (vote == null) {
return null;
} else {
- return vote.isWolf() ? String
- .format("%s shows all the signs of lycanthropy. They are undoubtedly a wolf, but do you dare to tell anyone?",
- vote)
- : String.format(
- "%s, though certainly not an innocent person, does not appear to be a werewolf.",
- vote);
+ return vote.isWolf() ? Messages.getString("Scry.foundWolf",new Object[]{vote})
+ : Messages.getString("Scry.foundNonWolf",new Object[]{vote});
}
}
@Override
public String helpText() {
- return "The scry can use his psychic talents to stare into someone's soul at night - if they are a wolf, he will know!";
+ return Messages.getString("Scry.help"); //$NON-NLS-1$
}
}
View
9 src/no/arcticdrakefox/wolfbot/roles/ToughGuy.java
@@ -1,5 +1,6 @@
package no.arcticdrakefox.wolfbot.roles;
+import no.arcticdrakefox.wolfbot.management.Messages;
import no.arcticdrakefox.wolfbot.management.PlayerList;
import no.arcticdrakefox.wolfbot.model.Role;
import no.arcticdrakefox.wolfbot.model.WolfBotModel;
@@ -25,7 +26,7 @@ public Role getRole() {
@Override
public String roleInfo(PlayerList players) {
- return "You are a burly villager, the blacksmith's apprentice.";
+ return Messages.getString("ToughGuy.intro"); //$NON-NLS-1$
}
@Override
@@ -35,7 +36,7 @@ public String nightStart() {
if (WolfBotModel.getInstance().getSilentMode()) {
die (delayedCause);
} else {
- die(String.format("In the dead of night %s finally succumbs to their wounds, blood pooling like tar by the anvil...", getName()));
+ die(Messages.getString("ToughGuy.died", new Object[]{getName()})); //$NON-NLS-1$
}
}
@@ -51,7 +52,7 @@ public void die (String causeOfDeath)
this.delayedCause = causeOfDeath;
// In silent mode players just see no one died
} else {
- this.causeOfDeath = String.format ("%s is down but not out. It doesn't look like they'll live much longer though.", getName());
+ this.causeOfDeath = Messages.getString("ToughGuy.wounded",new Object[]{getName()}); //$NON-NLS-1$
}
}
else
@@ -61,6 +62,6 @@ public void die (String causeOfDeath)
}
@Override
public String helpText() {
- return "The tough guy can survive a wolf's bite - for a while! He will succumb to his injuries the following evening.";
+ return Messages.getString("ToughGuy.help"); //$NON-NLS-1$
}
}
View
33 src/no/arcticdrakefox/wolfbot/roles/Vigilante.java
@@ -1,5 +1,6 @@
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;
@@ -22,40 +23,40 @@ public Role getRole() {
@Override
public String roleInfo(PlayerList players) {
- return "You are the vigilante, capable of enforcing justice on your own at night.";
+ return Messages.getString("Vigilante.intro"); //$NON-NLS-1$
}
@Override
public String nightStart() {
isReady = false;
- return "Under the cover of darkness you may !kill a suspect or just !rest";
+ return Messages.getString("Vigilante.nightHelp"); //$NON-NLS-1$
}
@Override
public String nightAction(String message, PlayerList players) {
- String[] args = message.trim().split(" ", 2);
- if (args[0].equals("!kill")){
+ String[] args = message.trim().split(" ", 2); //$NON-NLS-1$
+ if (args[0].equals("!kill")){ //$NON-NLS-1$
if (args.length != 2)
- return "Correct usage: !kill <someone>";
+ return Messages.getString("Vigilante.nightError"); //$NON-NLS-1$
Player target = players.getPlayer(args[1]);
if (target == null)
return targetNotFound(args[1]);
else {
if (target.isAlive()){
if (target.equals(this))
- return "Killing yourself doesn't seem very productive.";
+ return Messages.getString("Vigilante.errorSelfKill"); //$NON-NLS-1$
else {
vote(target);
isReady = true;
- return String.format("You sharpen your blade. %s will die tonight.", target);
+ return Messages.getString("Vigilante.successTarget", new Object []{target}); //$NON-NLS-1$
}
} else
- return String.format("You are too late to kill %s, they are dead already.", target);
+ return Messages.getString("Vigilante.tooLate", new Object[] {target}); //$NON-NLS-1$
}
- } else if (args[0].equals("!rest")){
+ } else if (args[0].equals("!rest")){ //$NON-NLS-1$
isReady = true;
vote = null;
- return "You deem it unwise to take anyone's life without more evidence. Tonight, you will gather your strength.";
+ return Messages.getString("Vigilante.successSkip"); //$NON-NLS-1$
} else
return null;
}
@@ -66,22 +67,22 @@ public String nightEnd() {
return null;
else if (isAlive){
if (vote.isAlive()){
- vote.die(String.format("As the villagers search %s's home, they find a silver blade stuck in their throat. A vigilante struck down this %s tonight!", vote, vote.getRole()));
+ vote.die(Messages.getString("Vigilante.killed", new Object[] {vote, vote.getRole()})); //$NON-NLS-1$
if (vote.isWolf()){
- return String.format("Under the cover of darkness, you hide behind %s's bedroom door and jab a silver knife in their throat as they pass. Their body slumps to the ground and reverts to its true, grotesque form. You have done your village a great service!", vote);
+ return Messages.getString("Vigilante.killedWolf", new Object[]{vote}); //$NON-NLS-1$
} else{
- return String.format("Under the cover of darkness, you hide behind %s's bedroom door and jab a silver knife in their throat as they pass. As they lay bleeding, you realize that you have taken an innocent life. You mutter a respectful prayer and head home sullenly.", vote);
+ return Messages.getString("Vigilante.KilledInnosent", new Object[]{vote}); //$NON-NLS-1$
}
} else {
- return String.format("Under the cover of darkness, you sneak into %s's abode, only to find them dead already. Someone got here before you!", vote);
+ return Messages.getString("Vigilante.wolvesGotThereFirst", new Object[]{vote}); //$NON-NLS-1$
}
} else {
- return String.format("Under the cover of darkness, you open %s's door, but before you can step in you feel a searing pain running down your back. As your slump around on the ground, a large, gnarling shadow stands above you...", vote);
+ return Messages.getString("Vigilante.KilledFirst", new Object[]{vote}); //$NON-NLS-1$
}
}
@Override
public String helpText() {
- return "The vigilante can attempt to !kill someone at night - hopefully a wolf, if they guess right. If not, then the villagers die even faster!";
+ return Messages.getString("Vigilante.help"); //$NON-NLS-1$
}
}
View
7 src/no/arcticdrakefox/wolfbot/roles/Villager.java
@@ -1,5 +1,6 @@
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;
@@ -17,7 +18,7 @@ public Role getRole() {
@Override
public String roleInfo(PlayerList players){
- return "You are a common villager. Try not to get eaten or lynched!";
+ return Messages.getString("Villager.intro"); //$NON-NLS-1$
}
@Override
@@ -32,7 +33,7 @@ public String nightStart() {
@Override
public String nightAction(String message, PlayerList players) {
- return "You do not have any night actions. Please stop pestering me, filthy commoner.";
+ return Messages.getString("Villager.nightError"); //$NON-NLS-1$
}
@Override
@@ -42,6 +43,6 @@ public String nightEnd() {
@Override
public String helpText() {
- return "This role is the normal villager, with no special powers. Try to survive without getting lynched or eaten!";
+ return Messages.getString("Villager.help"); //$NON-NLS-1$
}
}
View
31 src/no/arcticdrakefox/wolfbot/roles/Wolf.java
@@ -1,5 +1,6 @@
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.management.StringHandler;
@@ -33,47 +34,45 @@ public Role getRole() {
@Override
public String roleInfo(PlayerList players) {
- return String.format("You're a werewolf! The wolves are %s",
- StringHandler.listToString(players.getWolves())
- );
+ return Messages.getString("Wolf.intro", //$NON-NLS-1$
+ new Object[] {StringHandler.listToString(players.getWolves())});
}
@Override
public String nightStart() {
isReady = false;
if (ill) {
- return "Something you ate last night did not agree with you. You will not feel better till you !rest.";
+ return Messages.getString("Wolf.ill"); //$NON-NLS-1$
} else {
- return "As a wolf, you can !kill someone tonight or just !rest";
+ return Messages.getString("Wolf.nightHelp"); //$NON-NLS-1$
}
}
@Override
public String nightAction(String message, PlayerList players) {
if (!ill) {
- String[] args = message.trim().split(" ", 2);
- if (args[0].equals("!kill")) {
+ String[] args = message.trim().split(" ", 2); //$NON-NLS-1$
+ if (args[0].equals("!kill")) { //$NON-NLS-1$
if (args.length != 2)
- return "Correct usage: !kill <someone>";
+ return Messages.getString("Wolf.nightError"); //$NON-NLS-1$
Player target = players.getPlayer(args[1]);
if (target == null)
return targetNotFound(args[1]);
else {
if (target.equals(this)) {
- return "Killing yourself doesn't seem very productive.";
+ return Messages.getString("Wolf.selfKill"); //$NON-NLS-1$
} else if (target.isAlive()) {
vote(target);
isReady = true;
- return String
- .format("You sharpen your fangs. They will taste *%s's* blood tonight!",
- target);
+ return Messages.getString("Wolf.nightConfirmation", //$NON-NLS-1$
+ new Object[] {target});
} else
- return String.format("*%s* is already dead.", target);
+ return Messages.getString("Wolf.alreadyDead", new Object[] {target}); //$NON-NLS-1$
}
- } else if (args[0].equals("!rest")) {
+ } else if (args[0].equals("!rest")) { //$NON-NLS-1$
isReady = true;
vote = null;
- return "You decide to quell your bloodlust tonight.";
+ return Messages.getString("Wolf.rested"); //$NON-NLS-1$
} else
return null;
} else {
@@ -92,6 +91,6 @@ public String nightEnd() {
@Override
public String helpText() {
- return "The werewolf is the main enemy to all villagers - their aim is to eat everyone before they get lynched!";
+ return Messages.getString("Wolf.help"); //$NON-NLS-1$
}
}
View
163 src/no/arcticdrakefox/wolfbot/roles/messages.properties
@@ -0,0 +1,163 @@
+#Apprentice Scry
+ApprenticeScry.help.count=1
+ApprenticeScry.help.0=The apprentice scry has been learning from his master for years. If his master dies, he will gain his scrying power.
+
+ApprenticeScry.intro.count=1
+ApprenticeScry.intro.0=You are the apprentice Scry. You will take over if your master dies.
+
+ApprenticeScry.upgrade.count=1
+ApprenticeScry.upgrade.0=Your master has been killed - you now have his powers.
+!!!!
+
+
+#Aura Scry
+
+! {0} = TARGET
+AuraScry.allreadyDead.count=1
+AuraScry.allreadyDead.0={0} is already dead.
+
+AuraScry.correctUsage.count=2
+AuraScry.correctUsage.0=Correct usage: \!scry <someone>
+AuraScry.correctUsage.1=Silly Billy! try \!scry <someon>
+
+AuraScry.hasAura.count-1
+AuraScry.hasAura.0={0} has an aura. They clearly have some power, though you know not what it may be.
+
+AuraScry.help.count=1
+AuraScry.help.0=The aura scry can look into the spirit world to sense the mental strength of others. He can focus on someone at night and will know if they have any special powers - but won't know what they are\!
+
+AuraScry.info.count=1
+AuraScry.info.0=You are the Aura Scry, each night you will be able to see whether a player has a special ability.
+
+AuraScry.nightInstructions.count=1
+AuraScry.nightInstructions.0=The stars smile on you tonight. You may \!scry a person or just \!rest
+
+!{0} = TARGET
+AuraScry.noAura.count=1
+AuraScry.noAura.0={0} does not appear to have any powers, whatever their crimes.
+
+AuraScry.rest.count=1
+AuraScry.rest.0=You rest for tonight, confident that you already know all you need.
+
+AuraScry.Scried.count=1
+AuraScry.Scried.0=You set up your array of candles, orbs and artifacts, concentrating your efforts on {0}
+
+AuraScry.selfScry.count=1
+AuraScry.selfScry.0=You don't need your special powers to know that you are a scry.
+
+AuraScry.tooManyPeople.count=1
+AuraScry.tooManyPeople.0=You may only scry one person each night.
+!!!!!
+
+#Baner
+! {0} = Target
+Baner.bane=You don your purple cape and matching bell-shaped hat. {0} will not die on your watch\!
+Baner.correctUsage=Correct usage: \!bane <someone>
+Baner.description=You are the terror that flaps into the night\! You are Wolfsbane\! Baner of wolves\! Each night you may choose one person to protect from wolf attacks.
+Baner.help=The Baner can protect a member of the village each night, including themselves. If the wolves attack that person, they will be driven off and nobody will die.
+Baner.nightInstructions=It's time. \!bane the wolves from someone tonight or \!rest
+Baner.rest=You give up. The village can die for all you care.
+Baner.selfBane=You fortify your defenses and set up traps. The wolves will never catch you\!
+!{0} = TARGET
+Baner.tooLate=You are too late to save {0}, they are dead already.
+
+
+#Devil
+Devil.intro=You are a devil, an evil creature. You may check a person's role each night, or sacrifice someone. The wolves are {0}, and you are on their side\!
+Devil.multipleScryError=You may only scry one person each night.
+Devil.nightHelp=Correct usage: \!scry <someone> or \!kill <someone>
+Devil.nightInstructions=The moon is in alignment. You may \!scry a person, \!kill them or just \!rest
+Devil.rested=You rest for tonight, confident that you already know all you need.
+Devil.restFeedback=Though unbefitting of one of your stature, you abandon your artifacts and get out to hunt {0}
+Devil.result={0} is a {1}
+Devil.roleHelp=The devil is an evil creature who can look deep into someone's soul and know what they are capable of. He can also sacrifice people at night, if he prefers.
+Devil.selfScry=It makes no sense to target yourself.
+Devil.successfulFeedback=You start a dark prayer to your evil gods, staring into the soul of {0}.
+Devil.targetDied={0} is already dead.
+
+#Diseased
+Diseased.helptext=I taste bad. Don't eat me\!
+Diseased.intro=You are diseased, your man-meat will poison any wolf that eats you.
+
+#Gost
+Ghost.feedback=Your message '{0}' will be relayed
+Ghost.help=Once the ghost dies they will be able to communicate with the living.
+Ghost.init=Ghosts can comunicate with the living, one charactor at a time.
+Ghost.nightError=Correct usage: \!say <Letter>
+Ghost.nightHelp=What would you like to say to the living \!Say <somthing>.
+Ghost.say=The voice of the dead can be heard pn the wind. You make out the letter {0}'
+
+#Mason
+Mason.help=The masons have only one difference from the standard villager - they know who all the other masons are.
+Mason.intro=Since childhood, you have had close friends. Ones you know you can absolutely depend upon even in situations like this
+Mason.nightError=There is nothing for you to do at night but rest and hope for the best.
+Mason.theMasons=The masons are {0}
+
+#Mayor
+Mayor.help=The Mayor is well respected by the villagers - his voice counts more than anyone else when it comes to lynching time\!
+Mayor.intro=You are the village Mayor and your opinion is well respected by your fellow villagers. Try not to get eaten or lynched\!
+Necromancer.help=The ghost is capable of raising the dead at night.
+Necromancer.init=You are a necromancer, capable of bringing people back from the dead as you once managed to do for yourself.
+Necromancer.nightError=Correct usage: \!ghost <someone>
+Necromancer.nightHelp=The time is right. You may \!ghost a person back to life or just \!rest
+Necromancer.rested=You cannot think of a worthy man to bring back. Tonight, you will rest.
+Necromancer.success=A villager emerges at dawn, walking about as if they had never died at all. {0} lives again\!
+Necromancer.target=Life leaves your body as you trail off the spirit world, trying to find {0}.
+Necromancer.targetLiving={0} is still amongst the living.
+
+#Old Man
+OldMan.died={0} died in the night, but not by the hand of a wolf.
+OldMan.diedFeedback=It looks like your time in this world is up. As the last breath escapes your tired body, you think you hear a low growling...
+OldMan.help=The old man appears to be a normal villager - but he will die soon whether he gets eaten or not\! He will survive one night for each wolf, plus one.
+OldMan.intro=You are an old man. Your time is almost up...
+OldMan.nightError=You do not have any night actions. You should probably be resting up, old man.
+
+#Scry
+Scry.deadError={0} is already dead.
+Scry.foundNonWolf={0}, though certainly not an innocent person, does not appear to be a werewolf.
+Scry.foundWolf={0} shows all the signs of lycanthropy. They are undoubtedly a wolf, but do you dare to tell anyone?
+Scry.help=The scry can use his psychic talents to stare into someone's soul at night - if they are a wolf, he will know\!
+Scry.intro=You are a scry. Every night you may check a person for lycanthropy. Beware, for you are the wolves primary target.
+Scry.nightError=Correct usage: \!scry <someone>
+Scry.nightHelp=The moon is in alignment. You may \!scry a person or just \!rest
+Scry.rest=You rest for tonight, confident that you already know all you need.
+Scry.selfScry=You don't need your special powers to know that you are a scry.
+Scry.success=You set up your array of candles, orbs and artifacts, concentrating your efforts on {0}
+Scry.twoScries=You may only scry one person each night.
+
+#Tough Guy
+ToughGuy.died=In the dead of night {0} finally succumbs to their wounds, blood pooling like tar by the anvil...
+ToughGuy.help=The tough guy can survive a wolf's bite - for a while\! He will succumb to his injuries the following evening.
+ToughGuy.intro=You are a burly villager, the blacksmith's apprentice.
+ToughGuy.wounded={0} is down but not out. It doesn't look like they'll live much longer though.
+
+#Vigilante
+Vigilante.errorSelfKill=Killing yourself doesn't seem very productive.
+Vigilante.help=The vigilante can attempt to \!kill someone at night - hopefully a wolf, if they guess right. If not, then the villagers die even faster\!
+Vigilante.intro=You are the vigilante, capable of enforcing justice on your own at night.
+Vigilante.killed=As the villagers search {0}'s home, they find a silver blade stuck in their throat. A vigilante struck down this {1} tonight\!
+Vigilante.KilledFirst=Under the cover of darkness, you open {0}'s door, but before you can step in you feel a searing pain running down your back. As your slump around on the ground, a large, gnarling shadow stands above you...
+Vigilante.KilledInnosent=Under the cover of darkness, you hide behind {0}'s bedroom door and jab a silver knife in their throat as they pass. As they lay bleeding, you realize that you have taken an innocent life. You mutter a respectful prayer and head home sullenly.
+Vigilante.killedWolf=Under the cover of darkness, you hide behind {0}'s bedroom door and jab a silver knife in their throat as they pass. Their body slumps to the ground and reverts to its true, grotesque form. You have done your village a great service\!
+Vigilante.nightError=Correct usage: \!kill <someone>
+Vigilante.nightHelp=Under the cover of darkness you may \!kill a suspect or just \!rest
+Vigilante.successSkip=You deem it unwise to take anyone's life without more evidence. Tonight, you will gather your strength.
+Vigilante.successTarget=You sharpen your blade. {0} will die tonight.
+Vigilante.tooLate=You are too late to kill {0}, they are dead already.
+Vigilante.wolvesGotThereFirst=Under the cover of darkness, you sneak into {0}'s abode, only to find them dead already. Someone got here before you\!
+
+#Villager
+Villager.help=This role is the normal villager, with no special powers. Try to survive without getting lynched or eaten\!
+Villager.intro=You are a common villager. Try not to get eaten or lynched\!
+Villager.nightError=You do not have any night actions. Please stop pestering me, filthy commoner.
+
+#Wolf
+Wolf.alreadyDead={0} is already dead.
+Wolf.help=The werewolf is the main enemy to all villagers - their aim is to eat everyone before they get lynched\!
+Wolf.ill=Something you ate last night did not agree with you. You will not feel better till you \!rest.
+Wolf.intro=You're a werewolf\! The wolves are {0}.
+Wolf.nightConfirmation=You sharpen your fangs. They will taste {0}'s blood tonight\!
+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.
Please sign in to comment.
Something went wrong with that request. Please try again.