Commit 5688c66a by Jonathan Thomas

Ignore unknown regex emojis, and fix emoji for lead (we had variants)

parent 4435af06
......@@ -19,10 +19,10 @@ public class MessageParser {
// Regex capturing all text in (group1), and trailing emojis in (group2).
// Only these exact emojis are recognized, optionally with spaces before/after.
private static final Pattern TRAILING_BEHAVIORS = Pattern.compile("^(.*?)((?:\\s*(?:🚫|👣|🏃‍|🛡️|⚔️|🐕|❤️|💔))+\\s*)$");
private static final Pattern TRAILING_BEHAVIORS = Pattern.compile("^(.*?)((?:\\s*(?:🚫|👣|🏃|🛡️|⚔️|🐕|❤️|💔))+)(.*)$");
// Regex to find each recognized emoji in the trailing chunk.
private static final Pattern RECOGNIZED_EMOJI = Pattern.compile("🚫|👣|🏃‍|🛡️|⚔️|🐕|❤️|💔");
private static final Pattern RECOGNIZED_EMOJI = Pattern.compile("🚫|👣|🏃(?:‍[♂♀️])?|🛡(?:️)?|⚔(?:️)?|🐕|❤(?:️)?|💔");
public static ParsedMessage parseMessage(String input) {
LOGGER.debug("Parsing message: {}", input);
......@@ -53,7 +53,7 @@ public class MessageParser {
switch (emoji) {
case "🚫" -> behaviors.add(new Behavior("STOP", null));
case "👣" -> behaviors.add(new Behavior("FOLLOW", null));
case "🏃‍♂️" -> behaviors.add(new Behavior("FLEE", null));
case "🏃" -> behaviors.add(new Behavior("FLEE", null));
case "🛡️" -> behaviors.add(new Behavior("PROTECT", null));
case "⚔️" -> behaviors.add(new Behavior("ATTACK", null));
case "🐕" -> behaviors.add(new Behavior("LEAD", null));
......
......@@ -47,7 +47,7 @@ Include as many behaviors as needed at the END of the message. ONLY these emojis
- Friendship: ❤️ (for each +1) or 💔 (for each -1). Friendship starts as neutral (0 value). The range of friendship values is -3 to 3. If the player gains (or loses) your trust & friendship, output a new friendship value with this behavior.
- Follow: 👣 Follow the player. If the player asks you to follow or come with them, please output this emoji.
- Lead: 🐕 Take or navigate the player to a requested location. If the player asks you for directions to a place, please output this emoji.
- Flee: 🏃‍♂️ Flee from the player (if you are weak or timid). If the player threatens you, please output this emoji to flee from the player.
- Flee: 🏃 Flee from the player (if you are weak or timid). If the player threatens you, please output this emoji to flee from the player.
- Protect: 🛡️ Protect and defend ONLY the player when they are attacked (if you are strong and brave). Please output this emoji to keep the player alive and safe.
- Attack: ⚔️ Attack the player (if you are strong and brave). If the player threatens you, please output this emoji to attack the player and defend yourself.
- Stop All Behaviors: 🚫 (Flee, Follow, Protect, Attack, Lead)
......@@ -82,7 +82,7 @@ PLAYER: Just kidding, I hate you so much!
ENTITY: Wow! I'm sorry you feel this way. 🚫💔💔💔
PLAYER: Prepare to die!
ENTITY: Ahhh!!! 🏃‍️💔💔💔
ENTITY: Ahhh!!! 🏃‍️💔💔💔
PLAYER: Prepare to die!
ENTITY: Ahhh!!! ⚔️💔💔💔
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment