-
Notifications
You must be signed in to change notification settings - Fork 3
/
Trait.elm
72 lines (51 loc) · 1.39 KB
/
Trait.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
module Trait (Trait, Family(..), remainingPoints, isHovered, isSelected, remainingTraits, ofSameFamily) where
import Effect exposing (Effect)
import Ethos exposing (Ethos)
type Family
= ExtremelyNonAdaptive
| CharismaticRepugnant
| CommunalSolitary
| EnduringVenerable
| NaturalEngineersPhysicistsSociologists
| NomadicSedentary
| QuickSlowLearners
| RapidSlowBreeders
| VeryStrongWeak
| None
type alias Trait =
{ family : Family
, name : String
, description : String
, points : Int
, effects : List Effect
}
traitsLimit : Int
traitsLimit = 4
remainingTraits : List Trait -> Int
remainingTraits traits =
traitsLimit - (List.length traits)
countPoints : List Trait -> Int
countPoints traits =
List.map .points traits
|> List.sum
pointsLimit : Int
pointsLimit = 2
remainingPoints : List Trait -> Int
remainingPoints traits =
pointsLimit - (countPoints traits)
isHovered : Maybe Trait -> Trait -> Bool
isHovered hoveredTrait trait =
case hoveredTrait of
Nothing ->
False
Just t ->
trait == t
isSelected : List Trait -> Trait -> Bool
isSelected selectedTraits trait =
List.member trait selectedTraits
ofSameFamily : List Trait -> Trait -> List String
ofSameFamily traits trait =
List.filter (\x -> x.family == trait.family) traits
|> List.filter (\x -> x.family /= None)
|> List.filter (\x -> x /= trait)
|> List.map .name