Last active
August 29, 2015 14:01
-
-
Save L8D/7911fbaf0ad1b5642cd5 to your computer and use it in GitHub Desktop.
Some MTG rules-enforced environment simulator concept prototypes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import qualified Data.Set as S | |
data Color | |
= White | |
| Blue | |
| Black | |
| Red | |
| Green | |
deriving (Enum, Eq, Ord) | |
data Type | |
= Artifact | |
| Creature | |
| Enchantment | |
| Instant | |
| Land | |
| Planeswalker | |
| Sorcery | |
| Tribal | |
deriving (Enum, Eq, Ord) | |
data Subtype | |
= Plains | |
| Island | |
| Swamp | |
| Mountain | |
| Forest | |
| Locus | |
| Gate | |
| Lair | |
| Desert | |
| Urza's | |
| Mine | |
| PowerPlant | |
| Tower | |
| Human | |
| Merfolk | |
| Zombie | |
| Goblin | |
| Elf | |
deriving (Enum, Eq, Ord) | |
-- etc | |
-- helper lists | |
landTypes = S.fromAscList [Plains, Island, Swamp, Mountain, Forest, Locus, Gate, Urza's, Mine, PowerPlant, Tower] | |
creatureTypes = S.fromAscList [Human, Merfolk, Zombie, Golbin, Elf] | |
-- artifactTypes | |
-- enchantmentTypes | |
data Card | |
= Card | |
{ getName :: String | |
, getColors :: Set Color | |
, getTypes :: Set Type | |
, getSubtypes :: Set Subtype | |
, getLegendary :: Bool | |
, getBasic :: Bool | |
, getStateFunc :: Maybe (Game -> Game) | |
, getCounters :: [(String, Int)] | |
, getTapped :: Bool | |
, getPT :: Just (Int, Int) | |
, getCardID :: Target | |
} | |
data Player | |
= Player | |
{ getLife :: Int | |
, getLibrary :: [Card] | |
, getGraveyard :: [Card] | |
, getHand :: [Card] | |
, getBattlefield :: [Card] | |
, getExiled :: [Card] | |
, getPlayerID :: Target | |
} | |
type Target = Int | |
data Spell = Card [Target] | |
data Game | |
= Game | |
{ getPlayers :: [Player] | |
, getStack :: [Spell] | |
} | |
baseCard = Card | |
"Undefined" | |
S.empty | |
S.empty | |
S.empty | |
False | |
False | |
Nothing | |
[] | |
False | |
Nothing | |
0 | |
-- psuedo code for blood moon | |
bloodMoon | |
= baseCard | |
{ getName = "Blood Moon" | |
, getColors = S.singleton Red | |
, getTypes = S.singleton Enchantment | |
, getStateFunc = Just (\g -> g { getPlayers = { getBattlefield = map f } }) | |
} where f c | getBasic c = c -- if it's a basic land, ignore it | |
-- Add mountain to subtypes and remove all other land subtypes | |
| Land `member` getTypes c = | |
c { getSubypes = S.insert Mountain | |
(S.difference (getSubtypes c) landTypes) } | |
| otherwise = c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment