/
ItemKind.hs
150 lines (137 loc) · 3.21 KB
/
ItemKind.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
module ItemKind where
import Data.Binary
import qualified Data.List as L
import qualified Data.IntMap as IM
import Color
import Effect
data ItemKind = ItemKind
{ jsymbol :: !Char
, jflavour :: [Flavour]
, jname :: String
, jsecret :: String
, jeffect :: Effect
, jquant :: Roll
, jfreq :: !Int
}
deriving (Show, Eq, Ord)
-- a + b * lvl + roll(c + d * lvl)
type Roll = (Word8, Word8, Word8, Word8)
type Flavour = (Color, Bool) -- the flag tells to use fancy color names
rollOne = (1, 0, 0, 0)
zipPlain cs = L.zip cs (repeat False)
zipFancy cs = L.zip cs (repeat True)
darkCol = [Red .. Cyan]
brightCol = [BrRed .. BrCyan] -- BrBlack is not really that bright
stdCol = darkCol ++ brightCol
stdFlav = zipPlain stdCol ++ zipFancy stdCol
flavourToName :: Flavour -> String
flavourToName (c, False) = colorToName c
flavourToName (c, True) = colorToName' c
flavourToColor :: Flavour -> Color
flavourToColor (c, _) = c
dungeonLoot :: IM.IntMap ItemKind
dungeonLoot = IM.fromDistinctAscList (L.zip [0..] loot)
getIK ik = dungeonLoot IM.! ik
loot :: [ItemKind]
loot =
[amulet, dart, gem, gem1, gem2, gem3, gold,
potion_water, potion_healing,
ring, scroll, sword,
wand_domination]
amulet, dart, gem, gem1, gem2, gem3, gold :: ItemKind
potion, potion_water, potion_healing :: ItemKind
ring, scroll, sword :: ItemKind
wand, wand_domination :: ItemKind
amulet = ItemKind
{ jsymbol = '"'
, jflavour = [(BrWhite, True)]
, jname = "amulet"
, jsecret = ""
, jeffect = NoEffect
, jquant = rollOne
, jfreq = 10
}
dart = ItemKind
{ jsymbol = ')'
, jflavour = [(Yellow, False)]
, jname = "dart"
, jsecret = ""
, jeffect = AffectHP (-1)
, jquant = (3, 0, 6, 0)
, jfreq = 40
}
gem = ItemKind
{ jsymbol = '*'
, jflavour = zipPlain brightCol -- natural, so not fancy
, jname = "gem"
, jsecret = ""
, jeffect = NoEffect
, jquant = rollOne
, jfreq = 5 -- x4, below
}
gem1 = gem
gem2 = gem
gem3 = gem
gold = ItemKind
{ jsymbol = '$'
, jflavour = [(BrYellow, False)]
, jname = "gold piece"
, jsecret = ""
, jeffect = NoEffect
, jquant = (0, 3, 0, 10)
, jfreq = 80
}
potion = ItemKind
{ jsymbol = '!'
, jflavour = zipFancy stdCol
, jname = "potion"
, jsecret = ""
, jeffect = NoEffect
, jquant = rollOne
, jfreq = 20
}
potion_water = potion
{ jsecret = "of water"
}
potion_healing = potion
{ jeffect = AffectHP 20
}
ring = ItemKind
{ jsymbol = '='
, jflavour = [(BrWhite, False)]
, jname = "ring"
, jsecret = ""
, jeffect = NoEffect
, jquant = rollOne
, jfreq = 10
}
scroll = ItemKind
{ jsymbol = '?'
, jflavour = zipFancy darkCol -- arcane and old
, jname = "scroll"
, jsecret = ""
, jeffect = NoEffect
, jquant = rollOne
, jfreq = 10
}
sword = ItemKind
{ jsymbol = ')'
, jflavour = [(BrCyan, False)]
, jname = "sword"
, jsecret = ""
, jeffect = AffectHP (-3)
, jquant = rollOne
, jfreq = 70
}
wand = ItemKind
{ jsymbol = '/'
, jflavour = [(BrRed, True)]
, jname = "wand"
, jeffect = NoEffect
, jsecret = ""
, jquant = rollOne
, jfreq = 30
}
wand_domination = wand
{ jeffect = Dominate
}