Skip to content

Commit ba0f443

Browse files
Jens StåhlJens Ståhl
Jens Ståhl
authored and
Jens Ståhl
committed
Added character model
1 parent 889a6ea commit ba0f443

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

char.hs

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
data Class = Fighter | Rogue | Mage
2+
data Element = Physical | Fire | Ice | Earth | Water
3+
deriving Eq
4+
5+
data Res = Res {
6+
fireRes :: Int,
7+
coldRes :: Int,
8+
earthRes :: Int,
9+
waterRes :: Int
10+
}
11+
deriving Show
12+
13+
data Damage = Damage {
14+
amount :: Int,
15+
element :: Element
16+
}
17+
18+
data Stat = Stat {
19+
level :: Int,
20+
maxhp :: Int,
21+
hp :: Int,
22+
maxmp :: Int,
23+
mp :: Int,
24+
res :: Res
25+
}
26+
deriving Show
27+
28+
makeStat :: Int -> Class -> Stat
29+
makeStat level Rogue = genStat level 1.5 2.8 0.6 0.2
30+
31+
genStat :: Int -> Float -> Float -> Float -> Float -> Stat
32+
genStat level str dex vit ene = Stat level maxhp maxhp maxmp maxmp res
33+
where maxhp = ((floor (vit*10))*level)
34+
maxmp = ((floor (ene*10))*level)
35+
res = Res 0 0 0 0
36+
37+
applyResistance :: Damage -> Res -> Int
38+
applyResistance dmg res = 0
39+
40+
main = do
41+
putStrLn $ show $ makeStat 10 Rogue
42+

0 commit comments

Comments
 (0)