damagePlayer :: Monad m => PlayerID -> Int -> StateT GameState m ()
damagePlayer pID amount = do
  prevent <- use $ playerWithID pID.playerDamageToPrevent
  process prevent
  where
    process prevent
      | prevent >= amount =
        playerWithID pID.playerDamageToPrevent -= amount
      | prevent == 0 = do
        playerWithID pID.hp -= amount
        playerWithID pID.turnDamageTaken += amount
      | prevent < amount = do
        playerWithID pID.playerDamageToPrevent .= 0
        playerWithID pID.hp -= (amount - prevent)
        playerWithID pID.turnDamageTaken += (amount - prevent)
damagePlayer :: Monad m => PlayerID -> Int -> StateT GameState m ()
damagePlayer pID amount = do
  prevent <- use $ playerWithID pID.playerDamageToPrevent
  process prevent
  where
    process prevent
      | prevent >= amount =
        playerWithID pID.playerDamageToPrevent -= amount
      | prevent == 0 = do
        playerWithID pID.hp -= amount
        playerWithID pID.turnDamageTaken += amount
      | prevent < amount = do
        playerWithID pID.playerDamageToPrevent .= 0
        playerWithID pID.hp -= (amount - prevent)
        playerWithID pID.turnDamageTaken += (amount - prevent)
damagePlayer pID amount = do
  prevent <- use $ playerWithID pID.playerDamageToPrevent
  process prevent
  where
    process prevent
      | prevent >= amount =
        playerWithID pID.playerDamageToPrevent -= amount
      | prevent == 0 = do
        playerWithID pID.hp -= amount
        playerWithID pID.turnDamageTaken += amount
      | prevent < amount = do
        playerWithID pID.playerDamageToPrevent .= 0
        playerWithID pID.hp -= (amount - prevent)
        playerWithID pID.turnDamageTaken += (amount - prevent)