-
Notifications
You must be signed in to change notification settings - Fork 22
/
Utils.hs
80 lines (56 loc) · 1.8 KB
/
Utils.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{-# LANGUAGE TypeOperators #-}
module Utils where
import Types
import Data.Label.Pure
import Data.Monoid
import Data.Set (Set)
import qualified Data.Set as Set
object :: Timestamp -> Ref Player -> Zone -> Object
object ts rOwner zone = Object
{ _name = Nothing
, _colors = mempty
, _types = mempty
, _zone = zone
, _owner = rOwner
, _controller = rOwner
, _timestamp = ts
, _counters = mempty
, _tapStatus = Nothing
, _power = Nothing
, _toughness = Nothing
, _damage = Nothing
, _play = Nothing
, _staticKeywordAbilities = []
, _continuousEffects = []
, _activatedAbilities = []
, _triggeredAbilities = []
, _replacementEffects = []
}
basicType :: ObjectTypes
basicType = mempty { _supertypes = Set.singleton Basic }
legendaryType :: ObjectTypes
legendaryType = mempty { _supertypes = Set.singleton Legendary }
artifactType :: ObjectTypes
artifactType = mempty { _artifactTypes = Just mempty }
enchantmentType :: ObjectTypes
enchantmentType = mempty { _enchantmentTypes = Just mempty }
instantType :: ObjectTypes
instantType = mempty { _instantTypes = Just mempty }
landType :: ObjectTypes
landType = mempty { _landTypes = Just mempty }
sorceryType :: ObjectTypes
sorceryType = mempty { _sorceryTypes = Just mempty }
class ObjectType a where
objectTypeLabel :: ObjectTypes :-> Maybe (Set a)
instance ObjectType ArtifactType where
objectTypeLabel = artifactTypes
instance ObjectType CreatureType where
objectTypeLabel = creatureTypes
instance ObjectType EnchantmentType where
objectTypeLabel = enchantmentTypes
instance ObjectType LandType where
objectTypeLabel = landTypes
instance ObjectType PlaneswalkerType where
objectTypeLabel = planeswalkerTypes
objectType :: ObjectType a => a -> ObjectTypes
objectType ty = set objectTypeLabel (Just (Set.singleton ty)) mempty