https://github.com/radar/mtg
Magic: The Gathering, but in Ruby
https://github.com/radar/mtg
Last synced: 29 days ago
JSON representation
Magic: The Gathering, but in Ruby
- Host: GitHub
- URL: https://github.com/radar/mtg
- Owner: radar
- Created: 2021-09-27T03:32:14.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-06-28T05:06:10.000Z (11 months ago)
- Last Synced: 2024-10-09T23:09:12.743Z (7 months ago)
- Language: Ruby
- Homepage:
- Size: 1000 KB
- Stars: 62
- Watchers: 3
- Forks: 11
- Open Issues: 126
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Magic: The Gathering: The Ruby Project
This is an attempt to build a somewhat functional simulation of Magic: The Gathering in Ruby.
It is incredibly rudimentary. I have little-to-no prior game programming experience. You have been warned.
Parts of this have been inspired by [Grove](https://github.com/pinky39/grove) -- a C# implementation of MTG. And other parts have been inspired by [Mage](https://github.com/magefree/mage). Kudos to them for sharing their code openly!
Unlike Grove and Mage, this implementation does not have any UI. Use your imagination!
## Getting Started
To get started with this project:
```
bundle install
bundle exec rspec
```All the tests should pass.
## Implementing a card
Let's say we want to implement a simple card, such as [Story Seeker](https://scryfall.com/card/khm/34/story-seeker). We can do this by creating a new card at `lib/magic/cards/story_seeker.rb`, and then we can use the `CardBuilder` DSL to build this card. Given that this card does not have any activated abilities or other effects, the code is quite simple:
```ruby
module Magic
module Cards
StorySeeker = Creature("Story Seeker") do
cost generic: 1, white: 1
creature_type("Dwarf Cleric")
keywords :lifelink
power 2
toughness 2
end
end
end
```You might end up implementing cards that are more complex, like [Annul](https://scryfall.com/card/khm/42/annul), which has a resolution effect that counters a target artifact or enchantment spell. You can see how this is handled at [Magic::Cards::Annul](lib/magic/cards/annul.rb).
If you're unsure how to implement a card, read through the current cards that exist -- you might find something there that matches what you need.
You might find some cards that do not use the `CardBuilder` DSL. These are cards that were implemented before the `CardBuilder` DSL was added. Can you switch these over to using the `CardBuilder` DSL?
## Contributing in other ways
Other than cards, you could contribute by adding additional test cases around things like combat, or existing card abilities. Be sure to check the Issues for this project to see if anything is open and listed there.
## Copyright
Magic: The Gathering is copyright of Wizards of the Coast.