Skip to content
/ spells Public

Spells is a library for parsing the text on Magic the Gathering cards

License

Notifications You must be signed in to change notification settings

eirc/spells

Repository files navigation

Spells

Gem Version Build Status Code Climate PullReview stats Dependencies Status Coverage Status

Spells is a library for parsing the text on Magic: The Gathering cards.

Note that this is pre-pre-Alpha software and you should probably not really use it!

Installation

Add this line to your application's Gemfile:

gem 'spells'

And then execute:

$ bundle

Or install it yourself as:

$ gem install spells

Usage

Parsing activated abilities

card = Spells::Card.new
card.text = "{2}{R}, {T}: Ghost-Lit Raider deals 2 damage to target creature.
Channel - {3}{R}, Discard Ghost-Lit Raider: Ghost-Lit Raider deals 4 damage to target creature."
card.abilities.map &:text_value
# => ["{2}{R}, {T}: Ghost-Lit Raider deals 2 damage to target creature.", "Channel - {3}{R}, Discard Ghost-Lit Raider: Ghost-Lit Raider deals 4 damage to target creature."]
card.triggered_abilities.map &:text_value
# => []
card.activated_abilities.map &:text_value
# => ["{2}{R}, {T}: Ghost-Lit Raider deals 2 damage to target creature.", "Channel - {3}{R}, Discard Ghost-Lit Raider: Ghost-Lit Raider deals 4 damage to target creature."]

Parsing triggered abilities

card = Spells::Card.new
card.text = "Whenever Abomination blocks or becomes blocked by a green or white creature, destroy that creature at end of combat."
card.abilities.map &:text_value
# => ["Whenever Abomination blocks or becomes blocked by a green or white creature, destroy that creature at end of combat."]
card.triggered_abilities.map &:text_value
# => ["Whenever Abomination blocks or becomes blocked by a green or white creature, destroy that creature at end of combat."]
card.activated_abilities.map &:text_value
# => []

Development

This gem uses the treetop gem for declaring the syntax tree. Some resources on treetop:

Resources

Other open source or general resources related to Magic: The Gathering

Contributing

  1. Fork it ( https://github.com/[my-github-username]/spells/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

Spells is a library for parsing the text on Magic the Gathering cards

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages