Skip to content
/ Magic Public
forked from MedeaMelana/Magic

Haskell implementation of Magic: The Gathering

Notifications You must be signed in to change notification settings

4u7/Magic

 
 

Repository files navigation

Build Status

Magic: The Gathering in Haskell

A Haskell implementation of the rules of Wizards of the Coast's Magic: The Gathering.

This project has multiple goals:

  • to succinctly and correctly model the interactions between Magic cards;
  • to provide an elegant and correct API to express Magic cards in;
  • to provide a web server that is able to run a full game where clients play against each other.

Scope

Magic is a big game. This implementation targets only a specific part of it. For now, only two-player games and only cards, rules, card types and abilities available and relevant in the Magic 2013 core set are targeted.

A good indication of the current progress is to open module M13 and see how many M13 cards have been implemented yet. A list of issues to be fixed before the whole of M13 can be implemented can be found on GitHub.

There is also a command-line interface that allows you to play the game. To run it, follow the installation instructions below and run the executable that it produced by building Magic-CLI. This will run a two-player game with preselected decks.

Building

You need GHC 7.8 or greater and cabal-install 1.20 or greater to build Magic.

Clone the repository and create Cabal sandboxes for the projects in dependency order:

$ git clone git@github.com:MedeaMelana/Magic.git
$ cd REPO/Magic
$ cabal sandbox init
$ cabal install --dependencies-only
$ cabal build
$ cd REPO/Magic-Cards
$ cabal sandbox init
$ cabal sandbox add-source ../Magic
$ cabal install --dependencies-only
$ cabal build

If you want to run the web server:

$ cd REPO/Magic-Web-Server
$ cabal sandbox init
$ cabal sandbox add-source ../Magic
$ cabal sandbox add-source ../Magic-Cards
$ cabal install --dependencies-only
$ cabal build
$ dist/build/magic-web-server/magic-web-server

If you want to run the command-line interface:

$ cd REPO/Magic-CLI
$ cabal sandbox init
$ cabal sandbox add-source ../Magic
$ cabal sandbox add-source ../Magic-Cards
$ cabal install --dependencies-only
$ cabal build
$ dist/build/magic-cli/magic-cli

Talking to the web server

The web server runs on websockets. Currently it starts a new game for every websocket connection that is opened, and that connection has full access to all the cards in the game. That is, there is no hidden information yet, and you can't have two clients play a game against each other yet: the connecting client controls all the players in the game.

Messages to and from the server are in JSON format. There is no documentation yet about the exact form of these messages, partly because it still unstable and changes often. However, the JSON messages from the server should be reasonably clear and should contain everything you need to build a proper client.

About

Haskell implementation of Magic: The Gathering

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Haskell 96.8%
  • JavaScript 1.5%
  • HTML 1.1%
  • Other 0.6%