Commit 99eeea35 by Jonathan Thomas

Expanding regex to include + signs in behavior args

parent b2805ea3
Pipeline #12456 passed with stages
in 1 minute 46 seconds
......@@ -14,6 +14,7 @@ All notable changes to **CreatureChat** are documented in this file. The format
### Changed
- **Huge improvements** to **chat prompt** for more *balanced* dialog and *predictable* behaviors
- Improved **Behavior regex** to include both `<BEHAVIOR arg>` and `*BEHAVIOR arg*` syntax, and ignore unknown behaviors.
- Expanded regex to support args with `+` sign (i.e. `<FRIENDSHIP +1>`)
- Improved **message cleaning** to remove any remaining `**` and `<>` after parsing behaviors
- Privacy Policy updated
......
......@@ -19,7 +19,7 @@ public class MessageParser {
LOGGER.info("Parsing message: {}", input);
StringBuilder cleanedMessage = new StringBuilder();
List<Behavior> behaviors = new ArrayList<>();
Pattern pattern = Pattern.compile("[<*](FOLLOW|FLEE|ATTACK|FRIENDSHIP|UNFOLLOW)(?:\\s+(-?\\d+))?[>*]");
Pattern pattern = Pattern.compile("[<*](FOLLOW|FLEE|ATTACK|FRIENDSHIP|UNFOLLOW)(?:\\s+([+-]?\\d+))?[>*]");
Matcher matcher = pattern.matcher(input);
while (matcher.find()) {
......
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