-
Notifications
You must be signed in to change notification settings - Fork 3
/
Ethos.elm
57 lines (40 loc) · 1.19 KB
/
Ethos.elm
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
module Ethos (Ethos, Dichotomy(..), isHovered, isSelected, remainingPoints, dichotomyToString) where
import Effect exposing (Effect)
type Dichotomy
= CollectivistIndividualist
| XenophobeXenophile
| MilitaristPacifist
| MaterialistSpiritualist
dichotomyToString : Dichotomy -> String
dichotomyToString dichotomy =
case dichotomy of
CollectivistIndividualist -> "Collectivist - Individualist"
XenophobeXenophile -> "Xenophobe - Xenophile"
MilitaristPacifist -> "Militarist - Pacifist"
MaterialistSpiritualist -> "Materialist - Spiritualist"
type alias Ethos =
{ dichotomy : Dichotomy
, name : String
, points : Int
, description : String
, effects : List Effect
}
countPoints : List Ethos -> Int
countPoints ethoses =
List.map .points ethoses
|> List.sum
pointsLimit : Int
pointsLimit = 3
remainingPoints : List Ethos -> Int
remainingPoints ethoses =
pointsLimit - (countPoints ethoses)
isHovered : Maybe Ethos -> Ethos -> Bool
isHovered hoveredEthos ethos =
case hoveredEthos of
Nothing ->
False
Just e ->
ethos == e
isSelected : List Ethos -> Ethos -> Bool
isSelected selectedEthoses ethos =
List.member ethos selectedEthoses