module

MarkerParser

Constants

ADD_ITEM_PATTERN = /\[ADD_ITEM:([^:]+):([^\]]+)\]/
DAMAGE_PATTERN = /\[DAMAGE:(\d+)\]/
DEBUG = (ENV.fetch("CRYSTAL_QUEST_DEBUG", "0")) == "1"

Debug mode mirrors the game loop (CRYSTAL_QUEST_DEBUG=1).

HEAL_PATTERN = /\[HEAL:(\d+)\]/
MOVE_PATTERN = /\[MOVE:([^\]]+)\]/
REMOVE_ITEM_PATTERN = /\[REMOVE_ITEM:([^\]]+)\]/
ROLL_PATTERN = /\[ROLL:(\d+)d(\d+)(?:([+-]\d+))?\]/

Class methods

process(state : GameState, response : String) : String

Process markers in a DM response and execute game actions. Uses $~ (MatchData from the gsub match) instead of re-running each pattern against the already-matched string.

Source