game :: Game Action Level ()
game = do
    (AIModifier aiM) <- modified player
    noTurn . aiM . handleAct =<< turn

    modifyLevel shadowCast
    
    playerDMap ~= mkDijkstraMap <$> (pure <$> access (loc <# aref player)) <*> access solid

    runEffects

    refs <- monsters <$> level

    forM_ refs $ \ref -> do
        (Hurt amount) <- modified ref
        hp <- getL baseHP <$> modified ref
        monster <- access (aref ref)
        if (hp - amount) <= 0 || dead monster
            then aref ref %= kill
            else runAI ref

    (Hurt amount) <- modified player
    hp <- getL baseHP <$> modified player
    isDead <- dead <$> access (aref player)
    if (hp - amount) <= 0 || isDead
        then aref player %= kill >> return ()
        else game
game :: Game Action Level ()
game = do
    (AIModifier aiM) <- modified player
    noTurn . aiM . handleAct =<< turn

    modifyLevel shadowCast
    
    playerDMap ~= mkDijkstraMap <$> (pure <$> access (loc <# aref player)) <*> access solid

    runEffects

    refs <- monsters <$> level

    forM_ refs $ \ref -> do
        (Hurt amount) <- modified ref
        hp <- getL baseHP <$> modified ref
        monster <- access (aref ref)
        if (hp - amount) <= 0 || dead monster
            then aref ref %= kill
            else runAI ref

    (Hurt amount) <- modified player
    hp <- getL baseHP <$> modified player
    isDead <- dead <$> access (aref player)
    if (hp - amount) <= 0 || isDead
        then aref player %= kill >> return ()
        else game
game = do
    (AIModifier aiM) <- modified player
    noTurn . aiM . handleAct =<< turn

    modifyLevel shadowCast
    
    playerDMap ~= mkDijkstraMap <$> (pure <$> access (loc <# aref player)) <*> access solid

    runEffects

    refs <- monsters <$> level

    forM_ refs $ \ref -> do
        (Hurt amount) <- modified ref
        hp <- getL baseHP <$> modified ref
        monster <- access (aref ref)
        if (hp - amount) <= 0 || dead monster
            then aref ref %= kill
            else runAI ref

    (Hurt amount) <- modified player
    hp <- getL baseHP <$> modified player
    isDead <- dead <$> access (aref player)
    if (hp - amount) <= 0 || isDead
        then aref player %= kill >> return ()
        else game