Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- newtype Health = Health Int deriving Num
- newtype Attack = Attack Int deriving Num
- newtype Defense = Defense Int deriving Num
- data Fighter = MkFighter
- { health :: Health
- , attack :: Attack
- , defense :: Defense
- , actions :: [Action]
- }
- type Knight = Fighter
- type Monster = Fighter
- act x = x { actions = tail $ actions x }
- duel :: Fighter -> Fighter -> Fighter
- duel x y = case head $ actions x of
- AcAttack xa -> duel (y { health = health y - (Health xa) }) (act y)
- AcPotion xa -> duel y (x { health = health x + (Health xa) })
- AcDefenseSpell xa -> duel y (x { defense = defense x + (Defense xa) })
- AcRunAway -> y
Advertisement
Add Comment
Please, Sign In to add comment