function launchAngryBird()
{
    static $launchAmount = 0;
    global $maxThrows;
    global $pigHealth;
    if ($launchAmount < $maxThrows) {
        $launchAmount++;
        echo calculateHit();
        if ($pigHealth != 0) {
            launchAngryBird();
        }
    }
}
function launchAngryBird()
{
    static $aantalKeerAangeroepen;
    global $maximumThrows;
    global $pigHealth;
    echo calculateHit();
    $aantalKeerAangeroepen++;
    if ($aantalKeerAangeroepen == $maximumThrows) {
        if ($pigHealth <= 0) {
            echo "Gewonnen<br />";
        } else {
            echo "Verloren<br />";
        }
    } else {
        launchAngryBird();
    }
}
function launchAngryBird()
{
    static $functionLaunched = "0";
    global $maximumThrows;
    global $pigHealth;
    calculateHit();
    if ($functionLaunched < $maximumThrows) {
        $functionLaunched++;
        launchAngryBird();
    } elseif ($functionLaunched == $maximumThrows) {
        if ($pigHealth <= 0) {
            echo "Gewonnen!";
            return;
        } else {
            echo "Verloren!";
        }
    }
}
function launchAngryBird()
{
    global $pigHealth;
    global $maximumThrows;
    global $spelverloop;
    if ($maximumThrows != 0 && $pigHealth > 0) {
        $hitResult = calculateHit();
        --$maximumThrows;
        $spelverloop[] = $hitResult['string'];
        launchAngryBird();
    } else {
        if ($pigHealth > 0) {
            $spelverloop[] = 'Helaas, je hebt verloren.';
        } else {
            $spelverloop[] = 'Hoera! Hoera! Hoera! Je hebt gewonnen!';
        }
    }
}
function launchAngryBird()
{
    static $loung_made = 0;
    global $maximumThrows, $pigHealth, $spelverloop;
    //echo $maximumThrows . " " .$pigHealth. " ".$loung_made."<br>";
    $loung_made++;
    if ($loung_made <= $maximumThrows && $pigHealth > 0) {
        $hit_result = calculateHit();
        $spelverloop[] = $hit_result["massege"];
        //echo $hit_result["massege"];
        launchAngryBird();
    } else {
        if ($pigHealth == 0) {
            $spelverloop[] = "Gewonnen! <br>";
        } else {
            $spelverloop[] = "Verloren! <br>";
        }
        //echo "ik ben hier".$spelverloop[1];
    }
}
function launchAngryBird()
{
    global $pigHealth;
    global $maximumThrows;
    global $game;
    //anders herkent de functie het ni
    if ($maximumThrows != 0 && $pigHealth > 0) {
        $hit = calculateHit();
        $maximumThrows--;
        $game[] = $hit['pigs'];
        launchAngryBird();
    } else {
        if ($pigHealth == 0) {
            $game[] = "gewonnen!";
            //exit();
        } else {
            $game[] = "verloren!";
        }
    }
}
function launchAngryBird()
{
    global $maximumThrows;
    global $pigHealth;
    global $uitkomst;
    if ($maximumThrows != 0 && $pigHealth > 0) {
        $maximumThrows--;
        # Calculatehit returnt $stringsToPrintArray
        $hit = calculateHit();
        # Steek deze strings in de nieuwe array $uitkomst
        $uitkomst[] = $hit['string'];
        # Zo lang er nog pigs zijn en het max aantal beurten niet overschreden wordt blijft de functie zich herhalen.
        launchAngryBird();
    } else {
        if ($pigHealth <= 0) {
            $uitkomst[] = 'Gewonnen!!';
        } else {
            $uitkomst[] = 'Verloren... :(';
        }
    }
}
function launchAngryBird($pigHealth, $maximumThrows)
{
    static $fCount = 0;
    if ($fCount < $maximumThrows && $pigHealth != 0) {
        ++$fCount;
        if (calculateHit()) {
            if ($pigHealth === 2) {
                --$pigHealth;
                echo '<p>Raak! Er is nog maar ' . $pigHealth . ' varken over.</p>';
                return launchAngryBird($pigHealth, $maximumThrows);
            } else {
                --$pigHealth;
                echo '<p>Raak! Er zijn nog maar ' . $pigHealth . ' varkens over.</p>';
                return launchAngryBird($pigHealth, $maximumThrows);
            }
        } else {
            if ($pigHealth === 1) {
                $mis = '<p>Mis! Nog ' . $pigHealth . ' varken in het team.</p>';
                echo $mis;
                return launchAngryBird($pigHealth, $maximumThrows);
            } else {
                $mis = '<p>Mis! Nog ' . $pigHealth . ' varkens in het team.</p>';
                echo $mis;
                return launchAngryBird($pigHealth, $maximumThrows);
            }
        }
    } elseif ($fCount === $maximumThrows || $pigHealth === 0) {
        $einde = '';
        if ($pigHealth === 0) {
            $einde = '<p>Gewonnen!</p>';
            echo $einde;
        } elseif ($pigHealth > 0) {
            $einde = '<p>Verloren!</p>';
            echo $einde;
        }
    }
}
}
function launchAngryBird()
{
    global $pigHealth, $maximumThrows;
    static $aantalKeer = 0;
    $boodschap = "";
    while ($aantalKeer < $maximumThrows) {
        $aantalKeer++;
        $boodschap .= calculateHit() . "<br>";
    }
    if ($pigHealth > 0) {
        $boodschap .= "verloren!";
    } else {
        $boodschap .= "gewonnen!";
    }
    return $boodschap;
}
$boodschap = launchAngryBird();
?>
<html>
    <head>
        <title>gevorderde functies deel 2</title>
    </head>
    <body>
        <p><?php 
echo $boodschap;
?>
</p>
        
    </body>
</html>