Hacker News new | ask | show | jobs
by deosjr 39 days ago
This might be your jam. I should revisit this, most of it is unimplemented. But the parsing part was interesting, since MTG has such a codified language for explaining the rules. My idea here was to take a card's rules text from the official API and parse it into smth that can be used in the game, so you could keep up with new sets with implementation. The weird rule-breaking edge cases will always fail, but a large set of design space can fit, I think.

See https://github.com/deosjr/pmtg/blob/master/parse.pl

2 comments

Somewhat related, check out https://github.com/wordbots/wordbots-parser, a digital card game where you write the cards and the engine parses them to determine what they do. It's fun to mess around with.
Hey, that's cool! I had the same idea too:

https://github.com/stassa/Gleemin

Although the code is nigh-on unreadable now ^_^@

>> The weird rule-breaking edge cases will always fail, but a large set of design space can fit, I think.

Well, in that case you just update the parser or the rules engine. That's precisely how M:tG Arena works and they 've managed to keep up with new sets at a pace never before seen in official M:tG engines. There was a time when writing an M:tG parser was considered impossible [1] and M:tG engines, both official and community ones, each had their own little DSL that they had to manually translate ability text into which could take months especially if the engine also had to be updated to use the new rules in a set. Eventually someone in Wizards realised this is just dumb and they did it the way you go about it above.

______________

[1] Source: my conversations with the folks behind Forge and other community-made M:tG engines.

Wow that is cool, thanks for that!