thomaseding / mtg-pure

Purely functional Haskell "Magic: The Gathering" card model and game engine.
BSD 3-Clause "New" or "Revised" License
10 stars 0 forks source link
card-game game haskell magic-the-gathering mtg rules-engine

mtg-pure

Purely functional Haskell "Magic: The Gathering" card model and game engine.


About:

MtgPure is a showcase of how to make an elegant purely functional "Magic: The Gathering" DSL model and rules engine.


Model Goals:


Engine Goals:


Quickstart Interesting Files For Model


Quickstart Interesting Files For Engine


Quickstart:

$ cabal install fourmolu  # for code generation ; add to PATH if needed
$ cd src
$ runhaskell MtgPure/Model/Object/ToObjectN/CodeGen.hs
$ cd ..
$ cabal build
$ cabal repl
ghci> :m +MtgPure MtgPure.AllCards MtgPure.Cards MtgPure.Model.BasicLandType MtgPure.Model.LandType MtgPure.Model.Recursive
ghci> :i allCards
allCards :: [AnyCard]   -- Defined in `MtgPure.AllCards'
ghci> :i island
island :: Card OTLand   -- Defined in `MtgPure.Cards'
ghci> compare island island
EQ
ghci> print island
Card "Island" $ ElectCardFacet $ LandCharacteristic [] [BasicLand Island] $ LandSpec []
ghci> island == (Card "Island" $ ElectCardFacet $ LandCharacteristic [] [BasicLand Island] $ LandSpec [])
True
ghci> island == (Card "Island" $ ElectCardFacet $ LandCharacteristic [] [BasicLand Mountain] $ LandSpec [])
False
ghci> mainDemoGameplay -- runs Demo.MtgPure.Gameplay

Notes:

Screenshots:

Demo.MtgPure.Gameplay

https://user-images.githubusercontent.com/6971794/220497420-c35cd250-41be-44b8-bd27-16a470732c1c.mp4

App.AnsiInspector App.AnsiInspector

Contributors:

Contributions may or may not be accepted. If you are concerned about your time being wasted, please open an issue first to discuss. Entry-level contributions would probably be for card definitions or tests. More advanced contributions would be for the engine or model design.


Low priority:


Will not fix issues related to:


Haskell language options: