modifyStat :: (Monad m) => (Int -> Int) -> Stat -> CyoaT m ()
modifyStat f stat = do
  modifyPlayerState $ \ps -> ps { player_stats = Map.alter (Just . f' . fromJust) stat (player_stats ps) }
  when (stat == Health) $ do
    health <- getStat Health
    when (health == 0) $ do
      emit [outText "Életerőpontjaid elfogytak, kalandod itt véget ér."]
      die

  where f' (current, initial) = (new, initial)
          where new = clamp (0, initial) (f current)
        clamp (low, high) x | x < low = low
                            | x > high = high
                            | otherwise = x

da
modifyStat :: (Monad m) => (Int -> Int) -> Stat -> CyoaT m ()
modifyStat f stat = do
  modifyPlayerState $ \ps -> ps { player_stats = Map.alter (Just . f' . fromJust) stat (player_stats ps) }
  when (stat == Health) $ do
    health <- getStat Health
    when (health == 0) $ do
      emit [outText "Életerőpontjaid elfogytak, kalandod itt véget ér."]
      die

  where f' (current, initial) = (new, initial)
          where new = clamp (0, initial) (f current)
        clamp (low, high) x | x < low = low
                            | x > high = high
                            | otherwise = x
modifyStat f stat = do
  modifyPlayerState $ \ps -> ps { player_stats = Map.alter (Just . f' . fromJust) stat (player_stats ps) }
  when (stat == Health) $ do
    health <- getStat Health
    when (health == 0) $ do
      emit [outText "Életerőpontjaid elfogytak, kalandod itt véget ér."]
      die

  where f' (current, initial) = (new, initial)
          where new = clamp (0, initial) (f current)
        clamp (low, high) x | x < low = low
                            | x > high = high
                            | otherwise = x