I am writing a text-based adventure game in Haskell for experience after reading LYAH, but I need help writing a function in which two data structures (in this case two players) are accessed and another structure (another [attacked] player) is returned. Thanks!
data Player = Player { name :: String
, hp :: Int
, atk :: Int
, def :: Int
, spd :: Int
} deriving (Show, Eq)
data Qstat = Qstat Int Int Int Int
lv :: Qstat
lv = Qstat 1 1 1 1
describe :: Player -> String
describe (Player {name = n, hp = h, atk = a, def = d, spd = s})
= "Name: " ++ n
++ ", HP: " ++ (show h)
++ ", ATK: " ++ (show a)
++ ", DEF: " ++ (show d)
++ ", SPD: " ++ (show s)
promote :: Qstat -> Player -> Player
promote (Qstat w x y z) (Player {name = n, hp = h, atk = a, def = d, spd = s})
= Player n (h + w) (a + x) (d + y) (s + z)
gets :: Player -> Qstat
gets (Player {name = n, hp = h, atk = a, def = d, spd = s})
= Qstat n h a d s
attack :: Player -> Player -> Player
attack = --how can I access the stats of both players (preferably without do notation)
attack (Player {name = n, hp = h, atk = a, def = d, spd = s}) ...