Project

spells

0.0
No commit activity in last 3 years
No release in over 3 years
Spells is a library for parsing the text on Magic the Gathering cards
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
>= 0
>= 0

Runtime

 Project Readme

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