From bfe2ab0f1e0c13e7ef89693bc0891c8f0622c2e6 Mon Sep 17 00:00:00 2001 From: Paul Buser Date: Sun, 12 Jan 2014 21:26:07 -0500 Subject: [PATCH 1/3] Add regexp event checking --- app/lib/world/script_event_prereqs.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/lib/world/script_event_prereqs.coffee b/app/lib/world/script_event_prereqs.coffee index fa250f7ce..9f3c529f9 100644 --- a/app/lib/world/script_event_prereqs.coffee +++ b/app/lib/world/script_event_prereqs.coffee @@ -12,5 +12,7 @@ module.exports.scriptMatchesEventPrereqs = scriptMatchesEventPrereqs = (script, return false if ap.lessThanOrEqualTo? and not (v <= ap.lessThanOrEqualTo) return false if ap.containingString? and v?.search(ap.containingString) == -1 return false if ap.notContainingString? and v?.search(ap.containingString) != -1 + return false if ap.containingRegexp? and v?.search(new RegExp(ap.containingRegexp)) == -1 + return false if ap.notContainingRegexp? and v?.search(new RegExp(ap.notContainingRegexp)) != -1 return true From b0ad3f5700af72945d6181770bc68ad0bb22abab Mon Sep 17 00:00:00 2001 From: Paul Buser Date: Mon, 13 Jan 2014 16:56:08 -0500 Subject: [PATCH 2/3] Add regex event checker in level.coffee --- server/schemas/level.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/schemas/level.coffee b/server/schemas/level.coffee index 3d4cc6f67..b6027754d 100644 --- a/server/schemas/level.coffee +++ b/server/schemas/level.coffee @@ -20,6 +20,8 @@ EventPrereqSchema = c.object {title: "Event Prerequisite", format: 'event-prereq lessThanOrEqualTo: {type: 'number', title: "<=", description: "Script requires the event's property chain value to be less than or equal to this value."} containingString: c.shortString(title: "Contains", description: "Script requires the event's property chain value to be a string containing this string.") notContainingString: c.shortString(title: "Does not contain", description: "Script requires the event's property chain value to *not* be a string containing this string.") + containingRegexp: c.shortString(title: "Contains Regexp", description: "Script requires the event's property chain value to be a string containing this regular expression.") + notContainingRegexp: c.shortString(title: "Does not contain regexp", description: "Script requires the event's property chain value to *not* be a string containing this regular expression.") GoalSchema = c.object {title: "Goal", description: "A goal that the player can accomplish.", required: ["name", "id"]}, name: c.shortString(title: "Name", description: "Name of the goal that the player will see, like \"Defeat eighteen dragons\".") From e958c1293db32b3f66a4e637af0ce7d861e140ea Mon Sep 17 00:00:00 2001 From: Paul Buser Date: Thu, 23 Jan 2014 21:57:12 -0500 Subject: [PATCH 3/3] Fixing my actual regexp checker --- app/lib/world/script_event_prereqs.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/lib/world/script_event_prereqs.coffee b/app/lib/world/script_event_prereqs.coffee index 9f3c529f9..52ed3f9b9 100644 --- a/app/lib/world/script_event_prereqs.coffee +++ b/app/lib/world/script_event_prereqs.coffee @@ -15,4 +15,4 @@ module.exports.scriptMatchesEventPrereqs = scriptMatchesEventPrereqs = (script, return false if ap.containingRegexp? and v?.search(new RegExp(ap.containingRegexp)) == -1 return false if ap.notContainingRegexp? and v?.search(new RegExp(ap.notContainingRegexp)) != -1 - return true + return true \ No newline at end of file