How would you design such a DSL in Ruby? -
i've read ruby great domain specific languages. in past few months i've been creating browser game, rpg type. @ point, want users able take , finish quests. quests killing x amount of mobs, killing raid boss, maybe gathering items , such.
the whole process sounds intriguing , prone errors. thinking idea create dsl matter. way describe quests in simple language. don't have experience that.
do think idea ? , if so, have advice/tutorials suggest ?
if you're designing dsl, need take time thinking domain you're trying map language to. dsls removing repetitive boilerplate otherwise have write every task, focus on that. quests examples, common things see needing between quests? obviously, lot depend on how quests implemented "behind scenes" well.
i can imagine quest looking though:
qwest "retrieve grail" given_by :pope description "some hethan dragon took cup, go back!" condition "slay dragon" dragon.is_dead? end condition "grab grail" player.inventory.contains :grail end reward :phat_loot end here, dsl used create quest, give name, conditions, reward, , assign quest giver.
as far writing dsl goes, you'll want learn metaprogramming in ruby. know why_the_lucky_stiff has written article or 2 it, , poignant guide has chapter on (dwemthy’s array in chapter 6). had hard time understanding stuff why wrote. end buying metaprogramming ruby, , i've found useful.
Comments
Post a Comment