-
Notifications
You must be signed in to change notification settings - Fork 2
/
kins.hs
208 lines (155 loc) · 3.21 KB
/
kins.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
module Kins
( Selo(..)
, Tom(..)
, Cor(..)
, Kin
, tzolkin
, seloIndex
, tomIndex
, kinIndex
, ondaIndex
, findKin
, findCor
, findTom
, findSelo
, findGuia
, findAnalogo
, findAntipoda
, findOculto
, findOndaEncantada
, findFamilia
, findHarmonic
, readKin
, ondaEncantada
) where
import Helpers
data Selo
= Dragao
| Vento
| Noite
| Semente
| Serpente
| EnlacadorDeMundos
| Mao
| Estrela
| Lua
| Cachorro
| Macaco
| Humano
| CaminhanteDoCeu
| Mago
| Aguia
| Guerreiro
| Terra
| Espelho
| Tormenta
| Sol
deriving (Eq, Ord, Show, Read, Bounded, Enum)
data Tom
= Magnetico
| Lunar
| Eletrico
| AutoExistente
| Harmonico
| Ritmico
| Ressonante
| Galatico
| Solar
| Planetario
| Espectral
| Cristal
| Cosmico
deriving (Eq, Ord, Show, Read, Bounded, Enum)
data Cor
= Vermelho
| Branco
| Azul
| Amarelo
deriving (Eq, Ord, Show, Read, Bounded, Enum)
data Kin = Kin Selo Tom
deriving (Eq, Show, Read)
selos = [Dragao .. Sol]
tons = [Magnetico .. Cosmico]
cores = [Vermelho .. Amarelo]
castle = length tons * length cores
tzolkinLength = length selos * length tons
tzolkin :: [Kin]
tzolkin =
map findKin [1..tzolkinLength]
ondasEncantadas :: [Kin]
ondasEncantadas =
filter isMagnetico tzolkin
where
isMagnetico (Kin _ tom) = tom == Magnetico
seloIndex :: Selo -> Int
seloIndex selo =
selos !!? selo + 1
tomIndex :: Tom -> Int
tomIndex tom =
tons !!? tom + 1
kinIndex :: Kin -> Int
kinIndex kin =
tzolkin !!? kin + 1
ondaIndex :: Selo -> Int
ondaIndex selo =
ondasEncantadas !!? (Kin selo Magnetico) + 1
findSelo :: Int -> Selo
findSelo n =
selos !!< (n - 1)
findTom :: Int -> Tom
findTom n =
tons !!< (n - 1)
findCor :: Int -> Cor
findCor n =
cores !!< (n - 1)
findKin :: Int -> Kin
findKin n =
Kin (findSelo n) (findTom n)
findGuia :: Kin -> Kin
findGuia (Kin selo tom) =
findKin . (+) start . (*) castle $ factorList !!? tomDots
where
factorList = [1, 2, 3, 4, 0]
start = kinIndex (Kin selo tom)
tomDots = tomIndex tom `rem` 5
findAnalogo :: Kin -> Kin
findAnalogo (Kin selo tom) =
(Kin selo' tom)
where
selo' = findSelo $ 19 - seloIndex selo
findAntipoda :: Kin -> Kin
findAntipoda (Kin selo tom) =
(Kin selo' tom)
where
selo' = findSelo $ 10 + seloIndex selo
findOculto :: Kin -> Kin
findOculto (Kin selo tom) =
(Kin selo' tom')
where
selo' = findSelo $ 21 - seloIndex selo
tom' = findTom $ 14 - tomIndex tom
findOndaEncantada :: Kin -> Kin
findOndaEncantada (Kin selo tom) =
findKin $ kinIndex (Kin selo tom) - (tomIndex tom) + 1
findFamilia :: Kin -> [Selo]
findFamilia (Kin selo _) =
map findSelo [start,step..end]
where
start = seloIndex selo `rem` 5
step = start + 5
end = length selos - 1
findHarmonic :: [Int] -> Kin
findHarmonic list =
findKin (sum list)
seloColor :: Selo -> Cor
seloColor selo =
findCor $ seloIndex selo `rem` length cores
readKin :: Kin -> String
readKin (Kin selo tom) =
show selo ++ " " ++ show tom ++ " " ++ show (seloColor selo)
ondaEncantada :: Kin -> [Kin]
ondaEncantada kin =
map findKin [start .. end]
where
start = kinIndex $ findOndaEncantada kin
end = start + 12