Skip to content

soundasleep/rmagic

Repository files navigation

rmagic Build Status Code Climate Test Coverage

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.

Features

  • 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

ActiveRecord concepts

We try to use as few model objects as possible.

  • Card - cards
  • Effect - temporary and permanent effects on cards
  • Player - life, unspent mana
  • Duel - current player, phase
  • Battlefield, Deck, Graveyard, Hand, Exile - zones where Cards are
  • ActionLog - something that happened (optionally with many ActionLogTargets) - try and do everything with ActionLogs (e.g. draw, tap, untap, attack, defend)
  • DeclaredAttacker, DeclaredDefender - temporary wrappers around declared attackers, defenders

TODO

  • 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

Release 0 goals

Release 1 goals

  • Supports Fate vs Fury deck
  • Scry
  • User-assigned damage distribution
  • Search through library
  • Discard a card
  • Maximum hand size
  • Event triggers

Later goals

  • Specify resolved attack priority order
  • An AI that makes sense
  • Support exile zone
  • User chat

Probably never

  • More than two player games
  • Different game modes
  • Data-driven cards, rather than in Ruby
  • Comparison of supported features to the comprehensive rules

Development

When developing, you'll want three terminals running each of:

  • rails server - to catch changes in the Rails app
  • grunt serve - to catch changes in the React app
  • guard - to enable LiveReload

Ubuntu

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

Mac OS X

If running El Capitan, you may need to brew link openssl --force.

Deployment

  • 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.

Sample /env/environment or .env

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"

Tests

rake spec
cucumber

About

A Multiplayer Magic the Gathering engine in Ruby on Rails

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published