rmagic is a Ruby on Rails implementation of Magic the Gathering.
The engine supports only a few cards so far, but it's a start.
- Lots of tests and cucumber features and Capybara
- (Hopefully) amazingly clean code
- Declare attackers and defenders
- Tapping cards for mana
- Instants from cards, abilities from creatures, targeting both cards and players
- Temporary effects modifying power/toughness on creatures
- Activated abilities considering summoning sickness
- Spells and creatures interacting on the stack
- Enchantments attached to cards
- Counter spells
- Deck shuffling and drawing
- Mulligans
- Random first player
- Basic multiplayer interface with OAuth2 login
- Javascript REST-driven to enable a rich user experience
- Card graphics
- Flying, reach, devotion, lifelink, trample, monstrous
- Games can end, be won, be lost, be drawn
- After a period of inactivity, passes can be requested
We try to use as few model objects as possible.
Card
- cardsEffect
- temporary and permanent effects on cardsPlayer
- life, unspent manaDuel
- current player, phaseBattlefield
,Deck
,Graveyard
,Hand
,Exile
- zones whereCard
s areActionLog
- something that happened (optionally with manyActionLogTarget
s) - try and do everything with ActionLogs (e.g.draw
,tap
,untap
,attack
,defend
)DeclaredAttacker
,DeclaredDefender
- temporary wrappers around declared attackers, defenders
- Activated abilities actually go on the stack
- Support more game phases correctly
- Summoning sickness for activated abilities
- Sorceries
- Display counters on cards on web interface
- Token creatures
- Look at bullet or rack-mini-profiler to improve game performance
- Supports Fate vs Fury deck
- Scry
- User-assigned damage distribution
- Search through library
- Discard a card
- Maximum hand size
- Event triggers
- Specify resolved attack priority order
- An AI that makes sense
- Support exile zone
- User chat
- More than two player games
- Different game modes
- Data-driven cards, rather than in Ruby
- Comparison of supported features to the comprehensive rules
When developing, you'll want three terminals running each of:
rails server
- to catch changes in the Rails appgrunt serve
- to catch changes in the React appguard
- to enable LiveReload
Install MySQL as necessary before running bundle
:
sudo apt-get update
sudo apt-get install mysql-server mysql-client libmysqlclient-dev
sudo mysql_install_d
sudo mysql_secure_installation
If running El Capitan, you may need to brew link openssl --force
.
sudo apt-get install ruby-sass php5-cli
- Install NodeJS
npm install -g grunt grunt-cli
- Install composer as well
- Install Redis as a service as well
If using a user deploy
, you can deploy with Capistrano by running cap production deploy
.
Edit /env/environment
or .env
to set up your environment variables.
Make sure to run cap puma:stop
and cap puma:start
for Puma to pick up updated environment.
MYSQL_USERNAME="xxx"
MYSQL_PASSWORD="yyy"
SECRET_KEY_BASE="zzz"
SECRET_TOKEN="abc"
OAUTH_CLIENT_ID="123.google.com"
OAUTH_CLIENT_SECRET="abc123"
APPLICATION_CONFIG_SECRET_TOKEN="abc123"
WEBSOCKET_LOCATION="your.host:3001/websocket"
- For
OAUTH_CLIENT_*
variables, get these from your Google OAuth2 parameters (step 5)
rake spec
cucumber