function staminatest_run()
{
    global $session;
    page_header("Stamina Testing");
    switch (httpget("op")) {
        case "start":
            output("Testing Testing!");
            break;
        case "add":
            output("Attempting to install an action called Sexins, with these parameters:`n`nStarting and Maximum costs: 500`nMinimum cost: 200`nReps for a Reduction: 20`nReduction: 10`n");
            install_action("Sexins", array("maxcost" => 25000, "mincost" => 10000, "expperrep" => 100, "expforlvl" => 1000, "costreduction" => 10, "dkpct" => 2.5));
            break;
        case "process":
            output("Processing the Sexins action");
            process_action("Sexins");
            break;
        case "newday":
            output("Processing a New Day");
            stamina_process_newday();
            break;
        case "buff":
            output("Applying a stamina buff to Sexins for the current user, for 20 rounds, reducing action cost to half.");
            apply_stamina_buff('ultra-sexy-buff-for-sexins', array("name" => "Ultra Sexy Buff for Sexins", "action" => "Sexins", "costmod" => 0.5, "expmod" => 0.8, "rounds" => 5, "roundmsg" => "Round Message!", "wearoffmsg" => "Wearoff Message!"));
            output("Also applying a Stamina Class buff to all Hunting actions, reducing their cost to half for twenty rounds.");
            apply_stamina_buff('huntclasstest', array("name" => "Hunting Class test buff", "class" => "Hunting", "costmod" => 0.5, "expmod" => 0.8, "rounds" => 20, "roundmsg" => "Round Message!", "wearoffmsg" => "Wearoff Message!"));
            break;
        case "get":
            $thingtodebug = get_player_action("Sexins");
            debug($thingtodebug);
            break;
        case "uninstall":
            output("Uninstalling the Sexins action, deleting all actions entries and associated buffs");
            uninstall_action("Sexins");
            break;
        case "dragonkill":
            output("Processing a Dragon Kill");
            stamina_process_dragonkill();
            break;
        case "calcbuffs":
            output("Calculating Buffs");
            stamina_calculate_buffed_cost("Sexins");
            break;
        case "calcexp":
            output("Calculating Buffed EXP");
            stamina_calculate_buffed_exp("Sexins");
            break;
    }
    addnav("Install an action called Sexins", "runmodule.php?module=staminatest&op=add");
    addnav("Uninstall", "runmodule.php?module=staminatest&op=uninstall");
    addnav("Process the Sexins Action for the current user", "runmodule.php?module=staminatest&op=process");
    addnav("Process newday", "runmodule.php?module=staminatest&op=newday");
    addnav("Add a buff", "runmodule.php?module=staminatest&op=buff");
    addnav("Get Stamina", "runmodule.php?module=staminatest&op=get");
    addnav("Process a Dragon Kill", "runmodule.php?module=staminatest&op=dragonkill");
    addnav("Calculate Buffed Cost", "runmodule.php?module=staminatest&op=calcbuffs");
    addnav("Calculate Buffed exp", "runmodule.php?module=staminatest&op=calcexp");
    addnav("Back to the Grotto", "superuser.php");
    page_footer();
    return true;
}
rawoutput("<table style='border: solid 1px #000000' bgcolor='{$colorbackground}' cellpadding='0' cellspacing='0' width='100%' height='20'><tr><td width='{$redwidth}%' bgcolor='{$colorred}'></td><td width='{$amberwidth}%' bgcolor='{$coloramber}'></td><td width='{$greenwidth}%' bgcolor='{$colorgreen}'></td><td width='{$pctgrey}%'></td></tr></table>");
output("Total Stamina: %s / %s | Amber point: %s | Red point: %s", number_format($stamina), number_format($daystamina), number_format($amberpoint), number_format($redpoint));
output("`n`nHere is the nitty-gritty of your Stamina statistics.  The most important value is the total cost, over there on the right.  If there's anything in the Buff column, something's temporarily affecting the cost of performing that action (negative numbers are good!).  More details follow after the stats.`n`n");
rawoutput("<table width=100%><tr><td><b>Action</b></td><td><b>Experience</b></td><td><b>Natural Cost</b></td><td><b>Buff</b></td><td><b>Total</b></td></tr>");
$act = get_player_action_list();
foreach ($act as $key => $values) {
    $lvlinfo = stamina_level_up($key);
    $nextlvlexp = round($lvlinfo['nextlvlexp']);
    $nextlvlexpdisplay = number_format($nextlvlexp);
    $currentlvlexp = round($lvlinfo['currentlvlexp']);
    $currentlvlexpdisplay = number_format($currentlvlexp);
    $cost = $values['naturalcost'];
    $level = $values['lvl'];
    $exp = $values['exp'];
    $mincost = $values['mincost'];
    $costwithbuff = stamina_calculate_buffed_cost($key);
    $modifier = $costwithbuff - $cost;
    $bonus = "None";
    if ($modifier < 0) {
        $bonus = "`@" . number_format($modifier) . "`0";
    } elseif ($modifier > 0) {
        $bonus = "`\$" . number_format($modifier) . "`0";
    }
    //current exp - current lvl exp / current exp - nextlvlexp
    $expforlvl = $nextlvlexp - $currentlvlexp;
    $expoflvl = $exp - $currentlvlexp;
    if ($values['lvl'] < 100) {
        $pct = $expoflvl / $expforlvl * 100;
    }
    $nonpct = 100 - $pct;
    rawoutput("<tr><td>");
function stamina_take_action_cost($action, $userid = false)
{
    global $session;
    if ($userid === false) {
        $userid = $session['user']['acctid'];
    }
    $totalcost = stamina_calculate_buffed_cost($action, $userid);
    removestamina($totalcost, $userid);
    return $totalcost;
}