function wcgpoints_newdaystamina_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "wcgpoints_increased":
            if ($args['newpoints'] > 1) {
                set_module_pref("daysleft", 5);
                output("`0World Community Grid has updated your statistics, and you now have five game days of extra Stamina!`n`n");
            }
            break;
        case "stamina-newday":
            if (get_module_pref("daysleft")) {
                output("`0Because you're helping to combat suffering with World Community Grid, your starting Stamina has been increased by ten per cent!`n`n");
                increment_module_pref("daysleft", -1);
                output("You have %s days of enhanced Stamina left.  The counter is reset to five every time World Community Grid updates your statistics, which usually happens once every 24 hours.`n`n", get_module_pref("daysleft"));
                require_once "modules/staminasystem/lib/lib.php";
                addstamina(100000);
            }
            break;
        case "wcg-features-desc":
            output("`bStamina Boost`b: every time World Community Grid reports that you've earned some Cobblestones, you'll get an extra 10% of Stamina for five Game Days.`n`n");
            break;
    }
    return $args;
}
function rationpack_use($args)
{
    $full = get_module_pref("fullness", "staminafood");
    if ($full >= 100) {
        output("You pick up the ration pack, and eye it for a moment.  Then, you put it right back where it was.  You're `ifar`i too full to eat anything more for now.`n`n");
        unset($args['destroyafteruse']);
        unset($args['usetext']);
        return $args;
    }
    //debug($args);
    require_once "modules/staminasystem/lib/lib.php";
    addstamina(100000);
    increment_module_pref("fullness", 40, "staminafood");
    increment_module_pref("fat", 40, "staminafood");
    increment_module_pref("nutrition", 30, "staminafood");
    if ($full < 0) {
        output("You still feel as though you haven't eaten in days.`n`n");
    }
    if ($full >= 0 && $full < 50) {
        output("You feel a little less hungry.`n`n");
    }
    if ($full >= 50 && $full < 100) {
        output("You still feel as though you've got room for more!`n`n");
    }
    if ($full >= 100) {
        output("You're stuffed!  You feel as though you can't possibly eat anything more today.`n`n");
    }
    return $args;
}
function iitems_moduleprefs_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "iitems-use-item":
            if ($args['master']['modulepref'] && $args['master']['modulepref_module'] && $args['modulepref_type']) {
                $module = $args['master']['modulepref_module'];
                $pref = $args['master']['modulepref'];
                $val = $args['master']['modulepref_val'];
                if ($args['master']['modulepref_type'] == "increment") {
                    increment_module_pref($pref, $val, $module);
                } else {
                    if ($args['master']['modulepref_type'] == "set") {
                        set_module_pref($pref, $val, $module);
                    }
                }
            }
            break;
        case "iitems-superuser":
            output("`bIItems: Module Prefs`b`n");
            output("Alter module prefs upon use of the item.  Good for modules where items could be used, but which don't support IItems yet.`n");
            output("`bmodulepref`b - the name of the modulepref to alter.`n");
            output("`bmodulepref_module`b - the name of the module to which this pref belongs.`n");
            output("`bmodulepref_type`b - either \"increment\" or \"set\", for incrementing or setting moduleprefs.`n");
            output("`bmodulepref_val`b - the value to set or increment.`n");
            output("Example usage:`nmodulepref = availablestays | modulepref_module = inncoupons | modulepref_type = increment | modulepref_val = 5.  Gives the player five free stays at the Inn when this item is used.`n`n");
            break;
    }
    return $args;
}
function energydrink_use($args)
{
    require_once "modules/staminasystem/lib/lib.php";
    $full = get_module_pref("fullness", "staminafood");
    if ($full >= 100) {
        output("You eye the bottle critically.  Then, you put it right back where it was.  You're `ifar`i too full to imbibe anything more for now.`n`n");
        unset($args['destroyafteruse']);
        unset($args['usetext']);
        return $args;
    }
    addstamina(50000);
    increment_module_pref("fullness", 5, "staminafood");
    $full = get_module_pref("fullness", "staminafood");
    if ($full < 0) {
        output("You still feel as though you haven't eaten in days.`n`n");
    }
    if ($full >= 0 && $full < 50) {
        output("You feel a little less hungry.`n`n");
    }
    if ($full >= 50 && $full < 100) {
        output("You still feel as though you've got room for more!`n`n");
    }
    if ($full >= 100) {
        output("You're stuffed!  You feel as though you can't possibly eat anything more today.`n`n");
    }
    return $args;
}
function hunterslodge_specialcomments_small_use($args)
{
    global $session;
    increment_module_pref("commentsleft", 4, "specialcomments");
    $left = get_module_pref("commentsleft", "specialcomments");
    output("`0You now have `b%s`b Special Comments left to use.`n`n", $left);
    return $args;
}
function pub_newpittsburgh_drinks_dohook($hookname, $args)
{
    global $session;
    $drinks = array("brainhem" => array("price" => 35, "verbosename" => "Brain Hemorrhage"), "monstermash" => array("price" => 50, "verbosename" => "Monster Mash"), "specialsauce" => array("price" => 65, "verbosename" => "Special Sauce"));
    switch ($hookname) {
        case "pub_newpittsburgh_bartender":
            if ($session['user']['race'] == "Robot") {
                if ($session['user']['sex']) {
                    $lovelad = "lad";
                } else {
                    $lovelad = "love";
                }
                $args['text']['hello'] = "George looks you up and down, eyes sliding over your smooth glass skin.  \"`2You're a Robot, aren't you, " . $lovelad . "?`0\"`n`n\"`#That I am.  Are you going to tell me that you don't serve my type in here?`0\"`n`n\"`2On the contrary, Chuck, we'd be `ivery`i pleased to cater to our Robot customers, but we just don't have the power, y'see.  Setting up one of those fancy lamps just takes more amps than our genny can kick out.  You ask most of the pubs on the Island, it's the same way.`0\"`n`n\"`#I see.`0\"`n`n\"`2We've got games, though.  And telly.  You're more than welcome here, it's just...`0\" he shrugs his shoulders and spreads his hands.  \"`2I don't have anything to sell you that you'd want to buy.`0\"`n`n`#Fair enough`0, you suppose.";
            } else {
                $args['drinks'] = $drinks;
            }
            break;
        case "pub_newpittsburgh_drink":
            $drink = httpget("drink");
            switch ($drink) {
                case "brainhem":
                    $session['user']['gold'] -= 35;
                    output("\"`2All right Chuck,`0\" says George, bringing up a jar of pickled brains.  They look far too small to be human, even pickled - perhaps the size of rabbit brains.  The wrinkled grey things bob peacefully around as George carefully pours a measure of the fluid into a shot glass with the help of a funnel.`n`nThe liquid smells a lot like embalming fluid.`n`nTastes like it, too, albeit with a nice alcoholic glow.`n`n");
                    output("You feel `2Energetic!`0`n`n");
                    apply_buff('pub_newpittsburgh_brainhem', array("name" => "`2Brain Hemorrhage Fuzzies", "rounds" => 15, "defmod" => 1.12, "roundmsg" => "Thanks to your Brain Hemorrhage Fuzzies, your defensive movements are more fluid!", "wearoff" => "You feel the effects of the Brain Hemorrhage fade away.", "schema" => "pub_newpittsburgh"));
                    //require_once "modules/staminasystem/lib/lib.php";
                    //addstamina(5000);
                    break;
                case "monstermash":
                    $session['user']['gold'] -= 50;
                    output("George hands you a tall glass filled with artfully-swirled monster grey matter, garnished with a jolly little paper umbrella and a slice of brainstem.`n`n");
                    if ($session['user']['race'] != "Zombie") {
                        output("You take a sip.  It's... honestly, it's awful.  It tastes like a mix of chicken and beef fat, raw eggs, and blood.  Lots of blood.  Not meaning to be impolite you knock the glass back quickly, trying to ignore the cold, semi-solid lumps slowly sliding over your tongue and curling down your throat.`n`n");
                        output("You feel `4Sick and Grumpy!`0`n`n");
                        apply_buff('pub_newpittsburgh_monstermash', array("name" => "`2Monster Mash Grumps", "rounds" => 25, "atkmod" => 1.2, "roundmsg" => "`4The awful Zombie drink makes you feel `\$aggressive!", "wearoff" => "`4You feel the effects of the Monster Mash fade away.  Thank goodness for that.", "schema" => "pub_newpittsburgh"));
                        //require_once "modules/staminasystem/lib/lib.php";
                        //addstamina(5000);
                    } else {
                        output("You down the contents and lick your lips.`n`n");
                        output("You feel `2Energetic!`0`n`n");
                        //require_once "modules/staminasystem/lib/lib.php";
                        //addstamina(10000);
                        increment_module_pref("nutrition", 5, "staminafood");
                        apply_buff('pub_newpittsburgh_monstermash', array("name" => "`2Monster Mash", "rounds" => 25, "atkmod" => 1.2, "defmod" => 1.1, "roundmsg" => "`2The Monster Mash burns warmly in your stomach.  Both your attack and defence are increased!", "wearoff" => "`2The Monster Mash warmth has faded.  Oh well.", "schema" => "pub_newpittsburgh"));
                    }
                    break;
                case "specialsauce":
                    $session['user']['gold'] -= 65;
                    output("George pours you a short glass full of something from a thick blue bottle.  It's the only thing on the menu that doesn't mention brains, though you wonder if the odd blue liquid wasn't distilled from them.  It smells vaguely of formaldehyde, but has enough of a tongue-numbing alcoholic kick that you don't regret ordering it.`n`n");
                    output("You feel `2Warm!`0`n`n");
                    apply_buff('pub_newpittsburgh_specialsauce', array("name" => "`2Special Sauce Warmth", "rounds" => 30, "defmod" => 1.25, "atkmod" => 1.25, "roundmsg" => "That Zombie drink was awesome!  It's like time's slowed down!", "wearoff" => "You feel the effects of the Special Sauce fade away.", "schema" => "pub_newpittsburgh"));
                    break;
            }
            break;
    }
    return $args;
}
function referral_bonus_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "newday":
            if (get_module_pref("days") >= get_module_setting("daysperbonus")) {
                increment_module_pref("days");
                $sql = "UPDATE " . db_prefix("accounts") . " SET donation=donation+" . get_module_setting("pointsperbonus") . " WHERE acctid={$session['user']['referer']}";
                db_query($sql);
                clear_module_pref("days");
            }
            break;
    }
    return $args;
}
function pktrack_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "charstats":
            if (get_module_pref("user_showpk") == 1) {
                if (get_module_setting("wo") == 0) {
                    $title = translate_inline("Vital Info");
                }
                if (get_module_setting("wo") == 1) {
                    $title = translate_inline("Personal Info");
                }
                if (get_module_setting("wo") == 2) {
                    $title = translate_inline("Extra Info");
                }
                $name = translate_inline("Player Kills");
                $count = get_module_pref("count");
                setcharstat($title, $name, $count);
            }
            break;
        case "pvpwin":
            debug($args);
            if ($args['options']['type'] == 'pvp') {
                increment_module_pref("count");
            }
            break;
        case "pvploss":
            if (!get_module_setting("losses")) {
                break;
            }
            debug($args);
            if ($args['options']['type'] == 'pvp') {
                increment_module_pref("count", 1, "pktrack", $args['badguy']['acctid']);
            }
            break;
        case "biostat":
            $char = $args['acctid'];
            $cpk = get_module_pref("count", "pktrack", $char);
            output("`^Player Kills: `@%s`0", $cpk);
            output_notl("`n");
            break;
        case "footer-hof":
            addnav("Warrior Rankings");
            addnav("Player Kills", "runmodule.php?module=pktrack&op=hof");
            break;
    }
    return $args;
}
function iitems_edibles_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "iitems-use-item":
            if ($args['master']['edible']) {
                $full = get_module_pref("fullness", "staminafood");
                if ($full >= 100) {
                    output("You pick up the tasty morsel, and eye it for a moment.  Then, you put it right back where it was.  You're `ifar`i too full to eat anything more for now.`n`n");
                    unset($args['master']);
                    unset($args['player']);
                    $args['player']['break_use_operation'] = 1;
                } else {
                    increment_module_pref("fat", $args['master']['edibles_fat'], "staminafood");
                    increment_module_pref("nutrition", $args['master']['edibles_nutrition'], "staminafood");
                    increment_module_pref("fullness", $args['master']['edibles_fullness'], "staminafood");
                }
            }
            break;
        case "iitems-use-item-after":
            if ($args['master']['edible']) {
                $full = get_module_pref("fullness", "staminafood");
                if ($full < 0) {
                    output("You still feel as though you haven't eaten in days.`n`n");
                }
                if ($full >= 0 && $full < 50) {
                    output("You feel a little less hungry.`n`n");
                }
                if ($full >= 50 && $full < 100) {
                    output("You still feel as though you've got room for more!`n`n");
                }
                if ($full >= 100) {
                    output("You're stuffed!  You feel as though you can't possibly eat anything more today.`n`n");
                }
            }
            break;
        case "iitems-superuser":
            output("`bIItems: Edible IItems`b.  Remember to set a value for Stamina as well.  Remember also that this is only for use with simple edible items that can't be used for other purposes - for example, an apple that can be thrown at an enemy or consumed will require an extension script, and the 'edible' param shouldn't be used in cases like this.`n");
            output("`bedible`b - Set this to enable Edible Items functionality.`n");
            output("`bedibles_nutrition`b - Increase player's Nutrition.`n");
            output("`bedibles_fat`b - Increase player's Fat.`n");
            output("`bedibles_fullness`b - Increase player's Fullness.`n`n");
            break;
    }
    return $args;
}
function emilybundle_run()
{
    global $session;
    $op = httpget("op");
    page_header("The Emily Bundle");
    $cost = get_module_setting("cost");
    $stock = get_module_setting("stock");
    $playerpoints = $session['user']['donation'] - $session['user']['donationspent'];
    switch ($op) {
        case "start":
            output("So, Improbable Island has been going for a couple of years now and it's turning into something that can keep me alive and with a roof over my head without me having to do website design.  It's turned from a hobby into a full-time job.`n`nSince then, I've gotten married, and my wife, Emily(*), has gotten increasingly frustrated with her job.  She does database work for a hospital; the pay's good, but the hours and the work itself is pretty depressing.`n`nI've noticed lately that my original goal - \"Hey, I'll write a text adventure game!\" - hasn't quite worked out the way I wanted it to, because I thought it'd be about writing.  I figured I'd have a plot, decent characters, a beginning, middle and end - you know, a story.  But lately I've been doing a lot more building of games and systems than I have building of worlds, and I'm beginning to realise that that's what I'm good at.`n`nThe Island needs a writer.`n`nA dedicated writer, so that I can be a dedicated coder.  Recently I've done all sorts of stuff with Titans, Onslaught, new Commentary, Dwellings, and all that jazz - but the last actual piece of world-building writing that I did was in Common Ground, with its time-sensitive description text.  I believe that was before Christmas.`n`nOh, and there were some lions, too.`n`nTo give you an idea of where I am right now, let's say this: the system is in place to extend that level of time-and-context-sensitive detail to every Outpost.  I just don't have any writing to go in the system.`n`nIt's not that I don't like writing, and forgive me for parping my own horn but I don't think it's that I'm not good at it (although that sentence may have been evidence to the contrary).  It's just that I have so much else to do.`n`nI need help.`n`nHey, you know... my wife is an excellent writer.`n`nHonestly I'd be doing this before too long even if I didn't need Emily to help me with the Island.  She hates her job, I love mine, and that's unfair; it's imperative that the Island support both of us if we ever want to have our own house, or raise a family.`n`nWe've done our maths and figured out how much we need per month on which to survive without Emily's workplace sorting out our health insurance (that's the biggest expense, right there), and from that, based on historical data, we've figured out how much of an advertisement boost we'd need to get the Island up to that sort of level, and from that, how much money we'd need to get together by 'x' if we want Emily to be able to quit her job by 'y', with 'y' being \"Before September.\"`n`nIn a nutshell we need to get some bread together so that we can expand our player base enough that casual everyday donations cover us both without me having to tell you all about it every time my laptop breaks, my car breaks down, or my lion gets into an argument he just can't win.`n`nSo, you can give me money so that the Island can have more juicy plot points and a better sense of place, or you can give me money so that Emily and I can be happier and spend more time together.  Both are excellent reasons.  I've got another reason for you:`n`nIntroducing the `5Emily Bundle`0!`n`nThe `5Emily Bundle`0 costs 2,500 Donator Points, and it's worth well over three times as much.  In the Emily Bundle for 2,500 Donator Points (that's twenty-five bucks, for those of you keeping track), you get:`n`n* Permanent, unlimited free Avatar picture changes (never pay to change your Avatar picture again!)`n* Permanent, unlimited free Custom Weapon changes (custom weaponry now sticks around properly!)`n* Permanent, unlimited free Custom Armour changes (likewise!)`n* Permanent, unlimited free Custom Name Colour changes`n* Permanent, inlimited free Title changes`n* Permanent, unlimited free Mount Name changes`n* Permanent, unlimited free Commentary Race Name changes`n* Ten cigarettes`n* Ten thousand Requisition tokens`n* Two extra Chronospheres`n* All your current Chronospheres refilled`n* Ten Special Comments`n* A special, strictly-limited-and-not-to-be-repeated Medal`n`nAnd if you've not already donated, you'll also get room for a ten-thousand character Extended Bio (players who've already donated already have this).`n`nNow, the Emily Bundle is limited to two hundred players.  That should give Emily and I enough of a financial boost to get this plan underway.  If something stupidly awesome happens like the whole stock running out in a day, then I might add another fifty or a hundred or so, but no more than that (I'm not going to say it's strictly limited just to stimulate demand and then make it as common as muck - I want this to be a bit special).`n`nSo, help us recruit a writer and make the Island more awesome, more quickly - grab the Emily Bundle while it's still around to grab!`n(*) Yes, I named the pickle-wench barmaid after my wife.  Looking back, I could have made a better choice for an homage.");
            addnav("Buy the Emily Bundle!");
            if ($playerpoints >= $cost) {
                addnav("Yes! (2,500 points)", "runmodule.php?module=emilybundle&op=buy");
            } else {
                addnav(array("Just %s more points!", $cost - $playerpoints), "");
            }
            break;
        case "buy":
            set_module_pref("permanent", true, "commentaryicons_customrace");
            set_module_pref("permanent", true, "titlechange");
            set_module_pref("permanent", true, "namedmount");
            set_module_pref("permanent", true, "namecolor");
            set_module_pref("permanent", true, "avatar");
            set_module_pref("permanentarmor", true, "customeq");
            set_module_pref("permanentweapon", true, "customeq");
            $session['user']['gems'] += 10;
            $session['user']['goldinbank'] += 10000;
            $curspheres = get_module_pref("slots", "daysave");
            set_module_pref("slots", $curspheres + 2, "daysave");
            set_module_pref("days", $curspheres + 2, "daysave");
            increment_module_pref("commentsleft", 10, "specialcomments");
            require_once "modules/medals.php";
            medals_award_medal("emilybundle", "Emily Bundle Supporter", "This player bought the Emily Bundle, supporting Improbable Island and its admin!", "medal_emilybundle.png");
            $session['user']['donationspent'] += $cost;
            increment_module_setting("stock", -1);
            set_module_pref("bought", 1);
            output("You've got the Emily Bundle!  Thank you so much for supporting the Island.  Have fun!`n`n");
            //todo: medal, take points, diminish stock, output thankyou
            break;
    }
    addnav("Return");
    addnav("L?Return to the Lodge", "lodge.php");
    page_footer();
}
function monsterkills_dohook($hookname, $args)
{
    global $session, $badguy;
    switch ($hookname) {
        case "dragonkill":
            if (get_module_setting("reset")) {
                set_module_pref("kills", 0, "monsterkills");
            }
            break;
        case "footer-hof":
            addnav("Warrior Rankings");
            addnav("Most Monster Kills", "runmodule.php?module=monsterkills");
            break;
        case "battle-victory":
            if ($args['type'] == "forest") {
                increment_module_pref("kills");
            }
            break;
    }
    return $args;
}
function implantsleepsuppression_dohook($hookname, $args)
{
    global $session, $resline;
    $spec = "SS";
    $name = "Sleep Suppression System";
    $ccode = "`2";
    switch ($hookname) {
        case "choose-specialty":
            if ($session['user']['specialty'] == "" || $session['user']['specialty'] == '0') {
                if ($session['user']['dragonkills'] >= 1) {
                    addnav("Sleep Suppression System", "newday.php?setspecialty=SS{$resline}");
                    output("`5\"This is a `2Sleep Suppression System`5 implant.  This one doesn't have any interactive effects, like other Implants that may be designed for combat or travel or what-have-you - it simply suppresses the release of certain chemicals that cause tiredness.  In a nutshell, you'll start to feel tired much later in the day than you would normally - you'll crash a lot faster, but you'll get more time being fully awake.  It's a tradeoff, really.\"`n`n");
                }
            }
            break;
        case "set-specialty":
            if ($session['user']['specialty'] == "SS") {
                page_header("Sleep Suppression System");
                output("`2Inside your head is an Implant designed to keep you alert for longer.`n`nThe point at which you start eating into Amber stamina has been reduced.");
            }
            break;
        case "specialtycolor":
            $args[$spec] = $ccode;
            break;
        case "specialtynames":
            $args[$spec] = translate_inline($name);
            break;
        case "specialtymodules":
            $args[$spec] = "implantsleepsuppression";
            break;
        case "stamina-newday":
            if ($session['user']['specialty'] == "SS") {
                increment_module_pref("amber", -100000, "staminasystem");
            }
            break;
    }
    return $args;
}
function supplycrate_use($args)
{
    increment_module_pref("cratesopened", 1, "supplycrates");
    $found = get_module_pref("cratesopened", "supplycrates");
    if (is_module_active("medals")) {
        if ($found > 250) {
            require_once "modules/medals.php";
            medals_award_medal("crate1000", "Supreme Crate Finder", "This player has opened more than 250 Supply Crates!", "medal_crategold.png");
        }
        if ($found > 50) {
            require_once "modules/medals.php";
            medals_award_medal("crate500", "Expert Crate Finder", "This player has opened more than 50 Supply Crates!", "medal_cratesilver.png");
        }
        if ($found > 10) {
            require_once "modules/medals.php";
            medals_award_medal("crate100", "Supreme Crate Finder", "This player has opened more than 10 Supply Crates!", "medal_cratebronze.png");
        }
    }
    $crateables = get_items_with_settings("cratefind");
    $randompool = array();
    foreach ($crateables as $item => $prefs) {
        for ($i = 0; $i < $prefs['cratefind']; $i++) {
            $randompool[] = $item;
        }
    }
    output("You spend a few minutes prying open your Supply Crate.`n");
    $giveitems = array();
    $numitems = e_rand(get_module_setting("minitems", "supplycrates"), get_module_setting("maxitems", "supplycrates"));
    $chosenitems = array_rand($randompool, $numitems);
    foreach ($chosenitems as $key => $poolkey) {
        $item = $randompool[$poolkey];
        $name = $crateables[$item]['verbosename'];
        output("You find a %s!`n", $name);
        give_item($item);
    }
    return $args;
}
function timedcombat_teach_dohook($hookname, $args)
{
    global $session, $last_timestamp;
    switch ($hookname) {
        case "newday":
            set_module_pref("taughttoday", 0);
            break;
        case "biostat":
            if (httpget('op') == "teachtimedcombat") {
                set_module_pref("able", true, "timedcombat", $args['acctid']);
                debug(get_module_pref("able", "timedcombat", $args['acctid']));
                set_module_pref("taughttoday", 1);
                increment_module_pref("taught");
                output("`bYou have successfully taught this character how to do Timed Combat!`b`n");
                if (is_module_active("medals")) {
                    require_once "modules/medals.php";
                    medals_award_medal("timedcombat_teach", "Time Tutor", "This player taught another player how to do Timed Combat!", "medal_timeteacher.png");
                }
                require_once "lib/systemmail.php";
                $subj = $session['user']['name'] . " taught you a new skill!";
                $body = "You can now perform Timed Combat in fights!  If you time your fight commands correctly, you'll get a double-attack and double-defence bonus!  The bonus applies to everything you do in combat.  Try timing your five-round auto-fights - one correct hit wins you five rounds of extra power, and the same goes for ten-round auto-fighting too!  If you don't want to muck about with counting under your breath, you can ignore the new skill and carry on fighting as you've always done.  Get four perfect hits in a row and you can teach other players!  Have fun!";
                systemmail($args['acctid'], $subj, $body);
            }
            $ret = httpget('ret');
            if ($args['acctid'] != $session['user']['acctid'] && !get_module_pref("taughttoday") && get_module_pref("maxchain", "timedcombat") >= 4) {
                //get the players' chat locations from commentaryinfo.php - it's handy!
                $tloc = get_module_pref("loc", "commentaryinfo");
                $sloc = get_module_pref("loc", "commentaryinfo", $args['acctid']);
                if ($tloc == $sloc && !get_module_pref("able", "timedcombat", $args['acctid'])) {
                    output("This player doesn't know how to do Timed Combat.  You can teach one student per game day.`n`n");
                    addnav("Teach this player the Timed Combat skill", "bio.php?op=teachtimedcombat&char=" . $args['acctid'] . "&ret=" . urlencode($ret));
                }
            }
            break;
    }
    return $args;
}
function human_loot_run()
{
    global $session;
    page_header("The Procurement of Appurtenances");
    if (get_module_pref("itemstaken") <= 3 && httpget("give")) {
        debug(get_module_pref("itemstaken"));
        give_item(httpget("give"));
        increment_module_pref("itemstaken");
    }
    debug(get_module_pref("itemstaken"));
    switch (get_module_pref("itemstaken")) {
        case 0:
            output("\"`1Ah.  Yes, I don't believe you've had your standard equipment issue today.  Well, let's get started, then.`0\"  The man sets his newspaper down, and counts on his fingers.  \"`1We've got BANG Grenades, ZAP Grenades, WHOOMPH Grenades, Small Medkits and Ration Packs.  You can have any three items you like.`0\"`n`nHe unselfconsciously goes back to reading his newspaper while you make up your mind.");
            break;
        case 1:
            output("\"`1Okay.`0\"  The man reaches under his desk and brings up your chosen item, without taking his hands off the newspaper.  \"`1Two more.`0\"");
            break;
        case 2:
            output("\"`1Right-ho.`0\"  The man once again reaches under his desk and brings up your chosen item.  You wonder if he would even notice if someone else came in and took your place.  \"`1Last one, now.`0\"");
            break;
        case 3:
            output("\"`1Right, there we are.`0\"  The man plonks your chosen item down next to the others.  \"`1Have a nice day, and try not to get killed.`0\"");
            break;
    }
    if (get_module_pref("itemstaken") < 3) {
        addnav("Gimme a...");
        addnav("BANG Grenade", "runmodule.php?module=human_loot&give=banggrenade");
        addnav("WHOOMPH Grenade", "runmodule.php?module=human_loot&give=whoomphgrenade");
        addnav("ZAP Grenade", "runmodule.php?module=human_loot&give=zapgrenade");
        addnav("Small Medkit", "runmodule.php?module=human_loot&give=smallmedkit");
        addnav("Ration Pack", "runmodule.php?module=human_loot&give=rationpack");
    } else {
        addnav("Out you go, then.");
        addnav("Leave", "village.php");
    }
    page_footer();
}
function flawlesscap_dohook($hook, $args)
{
    switch ($hook) {
        case 'battle-victory':
            global $options;
            $runonce = false;
            if ($runonce !== false) {
                break;
            }
            if ($args['type'] == 'forest' && (!isset($args['diddamage']) || $args['diddamage'] != 1)) {
                $runonce = true;
                if (get_module_pref('amount') >= get_module_setting('max')) {
                    $options['denyflawless'] = '`nYou have already received the maximum flawless fight rewards for today.`n`n`0';
                } else {
                    increment_module_pref('amount');
                }
            }
            break;
        case 'newday':
            set_module_pref('amount', 0);
            break;
    }
    return $args;
}
function applebob_run()
{
    require_once 'lib/villagenav.php';
    global $session;
    $op = httpget('op');
    $cost = get_module_setting('cost');
    $eatAllowed = get_module_setting('allowed');
    $eatToday = get_module_pref('ate_today');
    page_header("Sichae's Apple Stand");
    output("`&`c`bApple Bobbing Stand`b`c");
    switch ($op) {
        case 'bob':
            increment_module_pref('ate_today', 1);
            $session['user']['gold'] -= $cost;
            debuglog("spent {$cost} gold on an apple.");
            $appleChance = e_rand(1, 10);
            $color = e_rand(1, 4);
            $colors = [1 => '`4red', 2 => '`2green', 3 => '`^yellow', 4 => '`@green'];
            output("`7You hand Sichae your %s gold, and place your hands on the edge of the barrel.", $cost);
            output("Taking a deep breath, you plunge your head forwards into the chilly water, and vainly attempt to grab hold of an apple with your teeth.");
            output("You finally emerge from the water with a %s`7 coloured apple in your mouth, gasping for breath.", $colors[$color]);
            output("Sichae smiles at your success.`n`n");
            output("`&\"Well done, fair warrior!\"`n`n");
            if ($appleChance == 1) {
                output("`7She grins mischievously, `&\"'Tis a rare warrior that plucks the hallowed blue apple!");
                output("There you have my finest achievement.");
                output("Go forth and slay all in your path, enchanted one!\"`n`n");
                output("`7Your jaw slackens in astonishment at the thought of a blue apple, but you manage to catch the fruit in one hand as it falls.");
                output("As you do, its delicious flavor hits you with surprise.");
                output("Your muscles tingle and a warm buzz flows into your very bones.`n`n");
                output("You feel `5mystical!");
                apply_buff('sichae', ['name' => '`!Blue Apple Mystique', 'rounds' => 20, 'defmod' => 1.03, 'roundmsg' => '`!The Blue Apple\'s power tingles in your bones.']);
                apply_buff('sichae', array("name" => "`!Blue Apple Mystique", "rounds" => 20, "defmod" => 1.03, "roundmsg" => "`!The Blue Apple's power tingles in your bones."));
            } else {
                if ($color == 4) {
                    output("`7As she says this though, you realize that something is very odd about this apple.");
                    output("It looks and tastes just like an ordinary green apple, but you begin to feel very strange.`n`n");
                    output("Bizarre creatures appear before your eyes.");
                    output("You realize that someone has poisoned the apple!`n`n");
                    output("All of the imaginary monsters from your nightmares close in on you, and you feel the terrifying urge to flee this place!");
                    apply_buff('sichae', ['name' => '`@Poisoned Appled', 'rounds' => 20, 'defmod' => 0.97, 'roundmsg' => '`@Strange hallucinations taunt you as you fight.']);
                    blocknav("runmodule.php?module=applebob&op=bob");
                }
            }
            addnav(['Try again (%s gold)', $cost], 'runmodule.php?module=applebob&op=bob');
            villagenav();
            break;
        default:
            output("`7You begin to approach the apple stand, peering into the barrels with interest.");
            output("Inside are apples of red, yellow and green.");
            output("Sichae stands with her hands on her hips, and regards you with a mysterious smile.`n`n");
            output("Her silken garments of jade and blue swish in the cool breeze, and her lithe muscles flex as she pads over to where you stand.`n`n");
            output("`&\"Ah! A visitor to the realms! So you think you can do this, do you?");
            output("It shall be amusing to see you try.\"`n`n");
            output("`7She arches her delicate neck back, and laughs a deep and beautiful sound, that immediately makes you relax.");
            output("She motions to the barrel in front of you.");
            output("`&\"%s gold to show me what talent you posess.", $cost);
            output("And one of the apples is special indeed...\"");
            if ($eatToday >= $eatAllowed) {
                output("`7Much as you'd like to play, your stomach protests fitfully.");
            } else {
                if ($session['user']['gold'] < $cost) {
                    output("`7Unfortunately your pockets do not seem to be full enough to play!");
                } else {
                    addnav(['Try your luck (`^%s gold`0)', $cost], 'runmodule.php?module=applebob&bob=bob');
                }
            }
            villagenav();
            break;
    }
    page_footer();
}
function meatsystem_run()
{
    global $session;
    require_once "modules/staminasystem/lib/lib.php";
    page_header("Meat!");
    addnav("Meat Skills");
    $from = httpget('from');
    switch (httpget('op')) {
        case "devour":
            //special ability for Zombies only - Zombies can eat raw meat, so we're giving them the ability to simply devour the carcass where it lies.
            $carcasses = unserialize(get_module_pref("carcasses"));
            if (!is_array($carcasses)) {
                $carcasses = array();
            }
            debug($carcasses);
            foreach ($carcasses as $carcassnum => $creatureid) {
                $sql = "SELECT creaturename FROM " . db_prefix("creatures") . " WHERE creatureid = " . $creatureid . " ";
                $result = db_query_cached($sql, "creaturename-" . $creatureid, 86400);
                $creature = db_fetch_assoc($result);
                output("Giving in to your primal urges, you lean down and begin ripping meat from the still-twitching %s with your teeth.`n`n", $creature['creaturename']);
                $meat1 = get_module_objpref("creatures", $creatureid, "meat1");
                $meat2 = get_module_objpref("creatures", $creatureid, "meat2");
                $meat3 = get_module_objpref("creatures", $creatureid, "meat3");
                for ($i = 0; $i < $meat1; $i++) {
                    increment_module_pref("nutrition", 1, "staminafood");
                    increment_module_pref("fat", 3, "staminafood");
                    increment_module_pref("fullness", 1, "staminafood");
                    addstamina(1000);
                }
                for ($i = 0; $i < $meat2; $i++) {
                    increment_module_pref("nutrition", 2, "staminafood");
                    increment_module_pref("fat", 2, "staminafood");
                    increment_module_pref("fullness", 1, "staminafood");
                    addstamina(2000);
                }
                for ($i = 0; $i < $meat3; $i++) {
                    increment_module_pref("nutrition", 3, "staminafood");
                    increment_module_pref("fat", 1, "staminafood");
                    increment_module_pref("fullness", 1, "staminafood");
                    addstamina(5000);
                }
                output("For the record, and since it's nice to know these things even if you're too busy tearing cartilage and muscle from the bone to really pay attention to them, in this meal you have eaten %s bite's-worth of Crap Meat, %s bite's-worth of Half-Decent Meat, and %s bite's-worth of Tasty Meat.`n", $meat1, $meat2, $meat3);
                $full = get_module_pref("fullness", "staminafood");
                if ($full < 0) {
                    output("You still feel as though you haven't eaten in days.`n`n");
                }
                if ($full >= 0 && $full < 50) {
                    output("You feel a little less hungry.`n`n");
                }
                if ($full >= 50 && $full < 100) {
                    output("You still feel as though you've got room for more!`n`n");
                }
                if ($full >= 100) {
                    output("You're stuffed!  You feel as though you can't possibly eat anything more today.`n`n");
                }
                unset($carcasses[$carcassnum]);
                set_module_pref("carcasses", serialize($carcasses));
            }
            break;
        case "clean":
            $creatureid = httpget('creatureid');
            $carcass = httpget('carcass');
            $meat1 = get_module_objpref("creatures", $creatureid, "meat1");
            $meat2 = get_module_objpref("creatures", $creatureid, "meat2");
            $meat3 = get_module_objpref("creatures", $creatureid, "meat3");
            $amber = get_stamina();
            $return = process_action("Cleaning the Carcass");
            if ($return['lvlinfo']['levelledup'] == true) {
                output("`n`c`b`0You gained a level in Cleaning Carcasses!  You are now level %s!  This action will cost fewer Stamina points now, so you can butcher more creatures each day!`b`c`n", $return['lvlinfo']['newlvl']);
            }
            $failchance = e_rand(0, 100);
            if ($failchance > $amber) {
                //failure - the nice meat gets turned into Crap Meat
                $meat1 += $meat2;
                $meat1 += $meat3;
                output("`4You sit down to clean the carcass.  Your exhausted, clumsy incisions make a mockery of the choicest cuts - what is left over can only be described as Crap Meat.  %s bite's-worth, to be precise.  It looks like it was hacked into chunks by a blind woodsman.", $meat1);
                //todo
                for ($i = 0; $i < $meat1; $i++) {
                    give_item("meat_low", false, false, true);
                }
                load_inventory();
                $carcasses = unserialize(get_module_pref("carcasses"));
                unset($carcasses[$carcass]);
                $carcasses = array_values($carcasses);
                set_module_pref("carcasses", serialize($carcasses));
            } else {
                //success - all meat is sorted
                output("You spend a few minutes up to your elbows in gore, and getting rather hungry.`n");
                if ($meat1 > 0) {
                    output("You tear off enough to make %s rough bite's-worth of what the locals affectionately call Crap Meat.  It's mostly wobbling chunks of stinking yellow fat, intermingled with the occasional squirmy tendon.`n", $meat1);
                }
                if ($meat2 > 0) {
                    output("You make swift work of the fattier muscle, and before too long you have %s rough bite's-worth of Half-Decent Meat.`n", $meat2);
                }
                if ($meat3 > 0) {
                    output("The red, tender slivers of muscle slide easily from the bone, and you wind up with %s rough bite's-worth of Tasty Meat.`n", $meat3);
                }
                //todo
                for ($i = 0; $i < $meat1; $i++) {
                    give_item("meat_low", false, false, true);
                }
                for ($i = 0; $i < $meat2; $i++) {
                    give_item("meat_medium", false, false, true);
                }
                for ($i = 0; $i < $meat3; $i++) {
                    give_item("meat_high", false, false, true);
                }
                load_inventory();
                $carcasses = unserialize(get_module_pref("carcasses"));
                unset($carcasses[$carcass]);
                $carcasses = array_values($carcasses);
                set_module_pref("carcasses", serialize($carcasses));
                $pmeat1 = has_item("meat_low");
                $pmeat2 = has_item("meat_medium");
                $pmeat3 = has_item("meat_high");
                if (($pmeat1 || $pmeat2 || $pmeat3) && $session['user']['race'] != "Robot") {
                    if (get_module_pref("fullness", "staminafood") < 100) {
                        $cookcost = stamina_getdisplaycost("Cooking");
                        addnav(array("Cook up some meat (`Q%s%%`0)", $cookcost), "runmodule.php?module=meatsystem&op=cook&from=" . $from);
                    } else {
                        addnav("You're too full to cook, let alone eat", "");
                    }
                }
            }
            break;
        case "cook":
            $pmeat1qty = has_item_quantity("meat_low");
            $pmeat2qty = has_item_quantity("meat_medium");
            $pmeat3qty = has_item_quantity("meat_high");
            output("You whip out your camping stove.  It's time to cook!`n`nWhat will you put in the pan?  You can fit up to 20 bite's-worth of meat in there.  Right now you have %s bite's-worth of Crap Meat, %s bite's-worth of Half-Decent Meat, and %s bite's-worth of Tasty Meat.`n`n", $pmeat1qty, $pmeat2qty, $pmeat3qty);
            rawoutput("<form action='runmodule.php?module=meatsystem&op=cookfinal&from=" . $from . "' method='POST'>");
            rawoutput("Put in <input name='meat1' width='2' value='0'> bite's-worth of Crap Meat.<br />");
            rawoutput("Put in <input name='meat2' width='2' value='0'> bite's-worth of Half-Decent Meat.<br />");
            rawoutput("Put in <input name='meat3' width='2' value='0'> bite's-worth of Tasty Meat.<br />");
            rawoutput("<input type='submit' class='button' value='" . translate_inline("Cook!") . "'>");
            rawoutput("</form>");
            addnav("", "runmodule.php?module=meatsystem&op=cookfinal&from=" . $from);
            break;
        case "cookfinal":
            $pmeat1qty = has_item_quantity("meat_low");
            $pmeat2qty = has_item_quantity("meat_medium");
            $pmeat3qty = has_item_quantity("meat_high");
            $meat1 = httppost("meat1");
            $meat2 = httppost("meat2");
            $meat3 = httppost("meat3");
            //check for the dumbass player cooking meat that they don't have
            if ($meat1 > $pmeat1qty || $meat2 > $pmeat2qty || $meat3 > $pmeat3qty) {
                output("You don't `ihave`i that much meat!`n`n");
                addnav("Whoops");
                addnav("Sorry, I forgot how to count for a second there.  Let's try this again.", "runmodule.php?module=meatsystem&op=cook&from=" . $from);
                break;
            }
            //check for the dumbass player inputting a negative number
            if ($meat1 < 0 || $meat2 < 0 || $meat3 < 0) {
                page_header("Either taking vegetarianism to whole new levels, or trying to grow meat from an empty pan");
                output("You want to cook `inegative`i meat?  How very Zen of you.`n`n");
                addnav("You sneaky bugger");
                addnav("Abandon your efforts to produce the opposite of meat and try again, pretending that you weren't just trying to cheat.", "runmodule.php?module=meatsystem&op=cook&from=" . $from);
                break;
            }
            //check for the dumbass player trying to put too much meat in the pan
            $totalmeat = $meat1 + $meat2 + $meat3;
            if ($totalmeat > 20) {
                output("Your pan can't hold that much meat, pal.`n`n");
                addnav("Whoops");
                addnav("Try again, without filling the pan up so much", "runmodule.php?module=meatsystem&op=cook&from=" . $from);
                break;
            }
            //check for the dumbass player trying to cook no meat at all
            $totalmeat = $meat1 + $meat2 + $meat3;
            if ($totalmeat == 0) {
                output("You start the process of cooking up your tasty meat.  After a few minutes of poking around in your pan, growing hungrier by the second, you realise that you've forgotten something.`n`n");
                addnav("Whoops");
                addnav("Try again, with meat this time", "runmodule.php?module=meatsystem&op=cook&from=" . $from);
                break;
            }
            //Stamina interaction, including consequences and level-up details.
            $amber = get_stamina();
            $return = process_action("Cooking");
            if ($return['lvlinfo']['levelledup'] == true) {
                output("`n`c`b`0You gained a level in Cooking!  You are now level %s!  This action will cost fewer Stamina points now, so you can cook more tasty meals each day!`b`c`n", $return['lvlinfo']['newlvl']);
            }
            $failchance = e_rand(0, 100);
            if ($failchance > $amber) {
                output("`4You put your meat into the pan, and sit down to stir-fry it.  The hypnotic motion and white-noise sizzling, combined with your tiredness, sends you staring into space.  While your concentration is impaired, the meat bursts into flames.  You jerk back into awareness, and look down sadly at the flaming chunks.  Bummer.");
                for ($i = 0; $i < $meat1; $i++) {
                    delete_item(has_item("meat_low"));
                }
                for ($i = 0; $i < $meat2; $i++) {
                    delete_item(has_item("meat_medium"));
                }
                for ($i = 0; $i < $meat3; $i++) {
                    delete_item(has_item("meat_high"));
                }
                break;
            }
            //we can now assume that the player is not some sort of cheating reprobate, or trying to cook while dog-tired, and do some cooking!
            for ($i = 0; $i < $meat1; $i++) {
                increment_module_pref("nutrition", 1, "staminafood");
                increment_module_pref("fat", 3, "staminafood");
                increment_module_pref("fullness", 1, "staminafood");
                delete_item(has_item("meat_low"));
                addstamina(1000);
            }
            for ($i = 0; $i < $meat2; $i++) {
                increment_module_pref("nutrition", 2, "staminafood");
                increment_module_pref("fat", 2, "staminafood");
                increment_module_pref("fullness", 1, "staminafood");
                delete_item(has_item("meat_medium"));
                addstamina(2000);
            }
            for ($i = 0; $i < $meat3; $i++) {
                increment_module_pref("nutrition", 3, "staminafood");
                increment_module_pref("fat", 1, "staminafood");
                increment_module_pref("fullness", 1, "staminafood");
                delete_item(has_item("meat_high"));
                addstamina(5000);
            }
            output("You fry up your lovely meaty loveliness, and sit down to eat.  You gain some Stamina!`n`n");
            $full = get_module_pref("fullness", "staminafood");
            if ($full < 0) {
                output("You still feel as though you haven't eaten in days.`n`n");
            }
            if ($full >= 0 && $full < 50) {
                output("You feel a little less hungry.`n`n");
            }
            if ($full >= 50 && $full < 100) {
                output("You still feel as though you've got room for more!`n`n");
            }
            if ($full >= 100) {
                output("You're stuffed!  You feel as though you can't possibly eat anything more today.`n`n");
            }
            break;
    }
    $carcasses = unserialize(get_module_pref("carcasses"));
    if (!is_array($carcasses)) {
        $carcasses = array();
    }
    if (count($carcasses) > 0) {
        output("You look at the spoils of your most recent battle.  They lie bloodied and broken on the ground.  What will you do with them?");
        foreach ($carcasses as $carcassnum => $creatureid) {
            $sql = "SELECT creaturename FROM " . db_prefix("creatures") . " WHERE creatureid = " . $creatureid . " ";
            $result = db_query_cached($sql, "creaturename-" . $creatureid, 86400);
            $creature = db_fetch_assoc($result);
            $cleancost = stamina_getdisplaycost("Cleaning the Carcass");
            addnav(array("Clean the carcass of %s (`Q%s%%`0)", $creature['creaturename'], $cleancost), "runmodule.php?module=meatsystem&op=clean&creatureid=" . $creatureid . "&carcass=" . $carcassnum . "&from=" . $from);
        }
    } else {
        if (httpget('op') != "cook" && httpget('op') != "cookfinal") {
            output("Now only bloody bones lie strewn around the area.`n`n");
        }
    }
    addnav("Ah, screw it.");
    if ($from == "forest") {
        addnav("Return to the Jungle", "forest.php");
    } else {
        if ($from == "world") {
            addnav("Return to the World Map", "runmodule.php?module=worldmapen&op=continue");
        }
    }
    page_footer();
    return true;
}
function iitemcrates_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "donation":
            $amt = $args['amt'];
            $donationbonus = floor($args['amt'] / get_module_setting("donationaddition"));
            require_once "modules/iitems/lib/lib.php";
            $allitems = iitems_get_all_item_details();
            $items = array();
            $cratefind = array();
            foreach ($allitems as $localid => $data) {
                if ($data['cratefind']) {
                    $items[$localid] = $data;
                    for ($i = 0; $i < $data['cratefind']; $i++) {
                        $cratefind[] = $localid;
                    }
                }
            }
            $crates = unserialize(get_module_setting("crates"));
            for ($i = 0; $i < $donationbonus; $i++) {
                $crate = array();
                //set a random location
                $x = e_rand(1, get_module_setting("worldmapsizeX", "worldmapen"));
                $y = e_rand(1, get_module_setting("worldmapsizeY", "worldmapen"));
                $loc = array();
                $loc['x'] = $x;
                $loc['y'] = $y;
                $crate['loc'] = $loc;
                //set crate contents
                $numitems = e_rand(get_module_setting("minitems"), get_module_setting("maxitems"));
                for ($a = 0; $a < $numitems; $a++) {
                    $add = e_rand(1, count($cratefind));
                    $crate['contents'][] = $cratefind[$add - 1];
                }
                $crates[] = $crate;
            }
            set_module_setting("crates", serialize($crates));
            break;
        case "worldnav":
            $crates = unserialize(get_module_setting("crates"));
            //debug($crates);
            $ploc = get_module_pref("worldXYZ", "worldmapen");
            if (!is_array($crates)) {
                $crates = array();
            }
            foreach ($crates as $key => $vals) {
                if ($ploc == $vals['loc']['x'] . "," . $vals['loc']['y'] . ",1") {
                    require_once "modules/iitems/lib/lib.php";
                    output("`bYou found something!`b`nYou come across a wooden crate, with a small parachute attached.  You spend a few minutes prying it open.`n`n");
                    foreach ($vals['contents'] as $ckey => $content) {
                        $itemdetails = iitems_get_item_details($content);
                        output("You found a %s!`n", $itemdetails['verbosename']);
                        iitems_give_item($content);
                    }
                    increment_module_pref("cratesfound");
                    $found = get_module_pref("cratesfound");
                    if (is_module_active("medals")) {
                        if ($found > 250) {
                            require_once "modules/medals.php";
                            medals_award_medal("crate1000", "Supreme Crate Finder", "This player has found more than 1000 Supply Crates!", "medal_crategold.png");
                        }
                        if ($found > 50) {
                            require_once "modules/medals.php";
                            medals_award_medal("crate500", "Expert Crate Finder", "This player has found more than 500 Supply Crates!", "medal_cratesilver.png");
                        }
                        if ($found > 10) {
                            require_once "modules/medals.php";
                            medals_award_medal("crate100", "Supreme Crate Finder", "This player has found more than 100 Supply Crates!", "medal_cratebronze.png");
                        }
                    }
                    unset($crates[$key]);
                    set_module_setting("crates", serialize($crates));
                    modulehook("iitems_findcrate");
                    //Break operation - players cannot find more than one item crate in a single move.
                    break;
                }
            }
            break;
        case "newday-runonce":
            require_once "modules/iitems/lib/lib.php";
            $allitems = iitems_get_all_item_details();
            $items = array();
            $cratefind = array();
            foreach ($allitems as $localid => $data) {
                if ($data['cratefind']) {
                    $items[$localid] = $data;
                    for ($i = 0; $i < $data['cratefind']; $i++) {
                        $cratefind[] = $localid;
                    }
                }
            }
            $crates = unserialize(get_module_setting("crates"));
            for ($i = 0; $i < get_module_setting("dailyadditions"); $i++) {
                $crate = array();
                //set a random location
                $x = e_rand(1, get_module_setting("worldmapsizeX", "worldmapen"));
                $y = e_rand(1, get_module_setting("worldmapsizeY", "worldmapen"));
                $loc = array();
                $loc['x'] = $x;
                $loc['y'] = $y;
                $crate['loc'] = $loc;
                //set crate contents
                $numitems = e_rand(get_module_setting("minitems"), get_module_setting("maxitems"));
                for ($a = 0; $a < $numitems; $a++) {
                    $add = e_rand(1, count($cratefind));
                    $crate['contents'][] = $cratefind[$add - 1];
                }
                $crates[] = $crate;
            }
            set_module_setting("crates", serialize($crates));
            break;
    }
    return $args;
}
function staminafood_run()
{
    global $session;
    $pmeat1 = has_item_quantity("meat_low");
    $pmeat2 = has_item_quantity("meat_medium");
    $pmeat3 = has_item_quantity("meat_high");
    addnav("Eat");
    switch (httpget("op")) {
        case "sellmeat":
            switch ($session['user']['location']) {
                case "NewHome":
                    page_header("Joe's Diner");
                    if (httpget('q') == 1) {
                        delete_item(has_item("meat_medium"));
                        $session['user']['gold'] += 5;
                        output("With a surly grunt, Joe grabs your meat and slaps down five Requisition tokens.`n`n");
                    } else {
                        for ($i = 1; $i <= $pmeat2; $i++) {
                            delete_item(has_item("meat_medium"));
                            $session['user']['gold'] += 5;
                        }
                        output("With a surly grunt, Joe grabs your meat and slaps down %s Requisition tokens.`n`n", $pmeat2 * 5);
                    }
                    break;
                case "New Pittsburgh":
                    page_header("BRAAAAAINS");
                    if (httpget('q') == 1) {
                        delete_item(has_item("meat_medium"));
                        $session['user']['gold'] += 6;
                        output("With a nod, the waiter takes your meat and hands back six Requisition tokens.`n`n");
                    } else {
                        for ($i = 1; $i <= $pmeat2; $i++) {
                            delete_item(has_item("meat_medium"));
                            $session['user']['gold'] += 6;
                        }
                        output("With a nod, the waiter takes your meat and hands back %s Requisition tokens.`n`n", $pmeat2 * 6);
                    }
                    break;
                case "Kittania":
                    page_header("Cool Springs Cafe");
                    if (httpget('q') == 1) {
                        delete_item(has_item("meat_high"));
                        $session['user']['gold'] += 12;
                        output("With a warm smile, the waitress takes your meat and hands back twelve Requisition tokens.`n`n");
                    } else {
                        for ($i = 1; $i <= $pmeat3; $i++) {
                            delete_item(has_item("meat_high"));
                            $session['user']['gold'] += 12;
                        }
                        output("With a warm smile, the waitress takes your meat and hands back %s Requisition tokens.`n`n", $pmeat3 * 12);
                    }
                    break;
                case "Squat Hole":
                    page_header("Kebabs 'N' S***e");
                    if (httpget('q') == 1) {
                        delete_item(has_item("meat_low"));
                        $session['user']['gold'] += 2;
                        output("With a squeaky \"Ta mate,\" the Midget behind the counter relieves you of the stinking yellow meat and hands back two Requisition tokens.`n`n");
                    } else {
                        for ($i = 1; $i <= $pmeat1; $i++) {
                            delete_item(has_item("meat_low"));
                            $session['user']['gold'] += 2;
                        }
                        output("With a squeaky \"Ta mate,\" the Midget behind the counter relieves you of the stinking yellow meat and hands back %s Requisition tokens.`n`n", $pmeat1 * 2);
                    }
                    break;
            }
            break;
        case "start":
            switch (httpget("location")) {
                case "nh":
                    page_header("Joe's Diner");
                    output("`0You head into what presents itself as a 1950's-style diner.  Plastic red and white gingham patterns cover every available surface.  Tomato-shaped ketchup bottles are dotted on tables here and there, dried gunge crusting their nozzles.  Behind the bar can be seen Joe, the owner, who is keeping himself busy wiping down the counter tops with a rag, redistributing the half-inch-thick layer of grease into a more uniform level.  A sign above the counter reads \"`2WE BUY MEAT.  WE PAY 5 REQ PER 120 GRAM'S.`0\"`n`n");
                    if ($session['user']['race'] != "Robot") {
                        output("The smell of fried onions does its wicked work, and you glance up at the menu.`n`n");
                        if (get_module_pref("fullness") <= 100) {
                            if ($session['user']['gold'] >= 10) {
                                addnav("Crisps (10 Req)", "runmodule.php?module=staminafood&op=buy&bought=1");
                            } else {
                                output("After a careful read of the menu, you realise that you can't afford a single thing on it.  Bah.");
                            }
                            if ($session['user']['gold'] >= 40) {
                                addnav("Garden Salad (40 Req)", "runmodule.php?module=staminafood&op=buy&bought=2");
                            }
                            if ($session['user']['gold'] >= 50) {
                                addnav("Plate of Chips (50 Req)", "runmodule.php?module=staminafood&op=buy&bought=3");
                                addnav("Coffee (50 Req)", "runmodule.php?module=staminafood&op=buy&bought=4");
                            }
                            if ($session['user']['gold'] >= 150) {
                                addnav("Bangers & Mash (150 Req)", "runmodule.php?module=staminafood&op=buy&bought=5");
                            }
                            if ($session['user']['gold'] >= 300) {
                                addnav("Cheeseburger (300 Req)", "runmodule.php?module=staminafood&op=buy&bought=6");
                            }
                        } else {
                            output("You are far too full to eat any more today.`n`n");
                        }
                    }
                    if ($pmeat2) {
                        output("You remember that Maiko told you that the NewHome diner will only buy middling-quality meat.  You have %s pieces of average-quality meat to sell.  All of them, quite conveniently - perhaps a little TOO conveniently - weigh exactly a hundred and twenty grams each.`n`n", $pmeat2);
                        addnav("Sell Meat");
                        addnav("Sell one piece", "runmodule.php?module=staminafood&op=sellmeat&q=1");
                        if ($pmeat2 > 1) {
                            addnav("Sell all Meat", "runmodule.php?module=staminafood&op=sellmeat&q=all");
                        }
                    }
                    break;
                case "ki":
                    page_header("Cool Springs Cafe");
                    output("You head into what at first appears to be a little hut.  As you work down the stairs into the rock underneath Kittania, you realise that this place is so much more.`n`nStrings of fairy lights illuminate the cavern, and soft trickling sounds can be heard against the laughter and conversation of KittyMorphs around you.`n`nYou take a seat and a white-furred KittyMorph approaches, a menu in her hand.  \"Welcome to the Cool Springs Cafe,\" she says with a smile.  \"We try to tread on Mother Earth as lightly as we can, in here; all of our produce is locally-grown, you'll find a wonderful selection of vegetarian and vegan meals, and the various waters come from the three springs that run through this very cavern.  Now, what can I get you?\"`n`nYou peruse the menu, your eyes lingering on the last entry, detailing a rare, dripping, bloody steak.  The KittyMorph follows your gaze, and laughs sheepishly.  \"Like I said, we `itry`i,\" she giggles, elongated canines peeking out.  \"We `iare`i carnivores, you know.  Oh, on that note, I should mention that we also buy meat, if you've got any of the good stuff to sell.  We pay twelve Requisition per slice.\"`n`n");
                    if ($session['user']['race'] != "Robot") {
                        if (get_module_pref("fullness") <= 100) {
                            if ($session['user']['gold'] >= 50) {
                                addnav("Hot Chocolate (50 Req)", "runmodule.php?module=staminafood&op=buy&bought=7");
                                addnav("White Spring Water (50 Req)", "runmodule.php?module=staminafood&op=buy&bought=8");
                            } else {
                                output("After a careful read of the menu, you realise that you can't afford a single thing on it.  Bah.");
                            }
                            if ($session['user']['gold'] >= 100) {
                                addnav("Nut and Berry Salad (100 Req)", "runmodule.php?module=staminafood&op=buy&bought=9");
                            }
                            if ($session['user']['gold'] >= 175) {
                                addnav("Turquoise Spring Water (175 Req)", "runmodule.php?module=staminafood&op=buy&bought=10");
                            }
                            if ($session['user']['gold'] >= 250) {
                                addnav("Red Spring Water (250 Req)", "runmodule.php?module=staminafood&op=buy&bought=11");
                            }
                            if ($session['user']['gold'] >= 500) {
                                addnav("Still-Twitching Steak (500 Req)", "runmodule.php?module=staminafood&op=buy&bought=12");
                            }
                        } else {
                            output("You are far too full to eat any more today.`n`n");
                        }
                    }
                    if ($pmeat3) {
                        output("You remember that Maiko told you that the Kittania cafe will only buy the best-quality meat.  You have %s pieces of high-quality meat to sell.`n`n", $pmeat3);
                        addnav("Sell Meat");
                        addnav("Sell one piece", "runmodule.php?module=staminafood&op=sellmeat&q=1");
                        if ($pmeat3 > 1) {
                            addnav("Sell all Meat", "runmodule.php?module=staminafood&op=sellmeat&q=all");
                        }
                    }
                    break;
                case "np":
                    page_header("BRAAAAAINS");
                    output("You head into the local cafe, imaginatively titled \"BRAAAAAINS\".  A waiter comes shuffling over to you, green skin peeling from his face.  \"BRAAAAAINS?\" he asks, holding out a menu.`n`nA sign above the counter says \"We are only too happy to buy your surplus meat.  We pay 6 Requisition tokens per 120 grams.\"`n`n");
                    if ($session['user']['race'] != "Robot") {
                        if (get_module_pref("fullness") <= 100) {
                            if ($session['user']['gold'] >= 50) {
                                addnav("Egg and Brains (50 Req)", "runmodule.php?module=staminafood&op=buy&bought=13");
                            } else {
                                output("After a careful read of the menu, you realise that you can't afford a single thing on it.  Bah.");
                            }
                            if ($session['user']['gold'] >= 100) {
                                addnav("Sausage and Brains (100 Req)", "runmodule.php?module=staminafood&op=buy&bought=14");
                            }
                            if ($session['user']['gold'] >= 150) {
                                addnav("Spam and Brains (150 Req)", "runmodule.php?module=staminafood&op=buy&bought=15");
                            }
                            if ($session['user']['gold'] >= 200) {
                                addnav("Egg, Brains, Sausage and Brains (200 Req)", "runmodule.php?module=staminafood&op=buy&bought=16");
                            }
                            if ($session['user']['gold'] >= 250) {
                                addnav("Brains, Spam, Brains, Sausage and Brains (250 Req)", "runmodule.php?module=staminafood&op=buy&bought=17");
                            }
                            if ($session['user']['gold'] >= 300) {
                                addnav("Brains, Brains, Brains, Brains and Spam (300 Req)", "runmodule.php?module=staminafood&op=buy&bought=18");
                            }
                        } else {
                            output("You are far too full to eat any more today.`n`n");
                        }
                    }
                    if ($pmeat2) {
                        output("You remember that Maiko told you that the New Pittsburgh diner will only buy middling-quality meat.  You have %s pieces of average-quality meat to sell.  All of them, quite conveniently - perhaps a little TOO conveniently - weigh a hundred and twenty grams each.`n`n", $pmeat2);
                        addnav("Sell Meat");
                        addnav("Sell one piece", "runmodule.php?module=staminafood&op=sellmeat&q=1");
                        if ($pmeat2 > 1) {
                            addnav("Sell all Meat", "runmodule.php?module=staminafood&op=sellmeat&q=all");
                        }
                    }
                    break;
                case "sq":
                    page_header("Kebabs 'N' S***e");
                    output("You head into the local kebab house.  As you're studying the menu, a Midget brushes past you, dragging a six-foot blue plastic bag with the words \"INCINERATE ONLY\" stencilled on the side.  He stops, glares up at you, and mutters \"Yer din't see `inuffink.`i\"  Then he resumes his journey, dragging the bag into the back of the shop.  You're sure you saw a bit of steering wheel poking out.`n`nA sign above the counter reads \"WE BY MEET 2 REK PER BIT\"`n`n");
                    if ($session['user']['race'] != "Robot") {
                        if (get_module_pref("fullness") <= 100) {
                            if ($session['user']['gold'] >= 20) {
                                addnav("Crisps (20 Req)", "runmodule.php?module=staminafood&op=buy&bought=25");
                            } else {
                                output("After a careful read of the menu, you realise that you can't afford a single thing on it.  Bah.");
                            }
                            if ($session['user']['gold'] >= 50) {
                                addnav("Skinheads on a Raft (50 Req)", "runmodule.php?module=staminafood&op=buy&bought=26");
                            }
                            if ($session['user']['gold'] >= 75) {
                                addnav("Doner Kebab (75 Req)", "runmodule.php?module=staminafood&op=buy&bought=27");
                                addnav("Crimson Pitbull (75 Req)", "runmodule.php?module=staminafood&op=buy&bought=28");
                            }
                            if ($session['user']['gold'] >= 150) {
                                addnav("C**k Nuggets (150 Req)", "runmodule.php?module=staminafood&op=buy&bought=29");
                            }
                            if ($session['user']['gold'] >= 200) {
                                addnav("Sausage Feast Pizza (200 Req)", "runmodule.php?module=staminafood&op=buy&bought=30");
                            }
                        } else {
                            output("You are far too full to eat any more today.`n`n");
                        }
                    }
                    if ($pmeat1) {
                        output("You remember that Maiko told you that the Squat Hole kebab shop only buys the sort of meat that the dog food factory would throw away.  You have %s wobbling chunks of Crap Meat to sell.`n`n", $pmeat1);
                        addnav("Sell Meat");
                        addnav("Sell one piece", "runmodule.php?module=staminafood&op=sellmeat&q=1");
                        if ($pmeat1 > 1) {
                            addnav("Sell all Meat", "runmodule.php?module=staminafood&op=sellmeat&q=all");
                        }
                    }
                    break;
                case "pl":
                    page_header("Mutated Munchies");
                    if ($session['user']['race'] != "Robot") {
                        output("You head into the local cafe.  The stench of vomit and disinfectant hangs in the air.  Bravely, you sit down at a table and peruse the menu.`n`n");
                        if (get_module_pref("fullness") <= 100) {
                            if ($session['user']['gold'] >= 100) {
                                addnav("Wriggly Biscuits (100 Req)", "runmodule.php?module=staminafood&op=buy&bought=19");
                            } else {
                                output("After a careful read of the menu, you realise that you can't afford a single thing on it.  Bah.");
                            }
                            if ($session['user']['gold'] >= 200) {
                                addnav("Phallic Nuts (200 Req)", "runmodule.php?module=staminafood&op=buy&bought=20");
                            }
                            if ($session['user']['gold'] >= 300) {
                                addnav("Noodly Noodles (300 Req)", "runmodule.php?module=staminafood&op=buy&bought=21");
                            }
                            if ($session['user']['gold'] >= 400) {
                                addnav("Three-Eyed Fish (400 Req)", "runmodule.php?module=staminafood&op=buy&bought=22");
                            }
                            if ($session['user']['gold'] >= 500) {
                                addnav("Magical Mystery Meatloaf (500 Req)", "runmodule.php?module=staminafood&op=buy&bought=23");
                            }
                            if ($session['user']['gold'] >= 750) {
                                addnav("Mutant Steak (750 Req)", "runmodule.php?module=staminafood&op=buy&bought=24");
                            }
                        } else {
                            output("You are far too full to eat any more today.`n`n");
                        }
                    } else {
                        output("You are a robot, and this place doesn't buy meat.  You have no business here.  Out with you!`n`n");
                    }
                    break;
            }
            break;
        case "buy":
            page_header("Om nom nom");
            require_once "modules/staminasystem/lib/lib.php";
            switch (httpget("bought")) {
                case 1:
                    output("You munch happily on your crisps, reflecting that they're probably not too good for you - but hell, at least they're cheap.`n`nYou gain some Stamina!");
                    $st = 5000;
                    $nu = 5;
                    $fa = 10;
                    $fu = 5;
                    $co = 10;
                    break;
                case 2:
                    output("You pick the snails out of your Garden Salad, and tuck in.`n`nYou gain some Stamina!");
                    $st = 18000;
                    $nu = 15;
                    $fa = 0;
                    $fu = 10;
                    $co = 40;
                    break;
                case 3:
                    output("You wolf down your plate of chips.  They're like little brown paper bags filled with pus, but damn it, you paid good money for these and you're going to eat them come Hell or high water.`n`nYou gain some Stamina!");
                    $st = 25000;
                    $nu = 20;
                    $fa = 30;
                    $fu = 25;
                    $co = 50;
                    break;
                case 4:
                    output("The coffee swirls grittily down your throat.  You feel like you have more energy!");
                    apply_stamina_buff('newhomedinercoffee', array("name" => "Caffeine Rush", "action" => "Global", "costmod" => 0.8, "expmod" => 1, "rounds" => 20, "roundmsg" => "Your Caffeine Rush makes everything a little bit easier!", "wearoffmsg" => "The effects of the caffeine seem to have worn off."));
                    $co = 50;
                    break;
                case 5:
                    output("It's not so much Bangers and Mash as Mingers and Mush, but you get stuck in anyway.`n`nYou gain some Stamina!");
                    $st = 105000;
                    $nu = 40;
                    $fa = 30;
                    $fu = 40;
                    $co = 150;
                    break;
                case 6:
                    output("You can has cheeseburger!  Well, it's not so much \"cheese\" as \"unidentifiable bright orange goo\", but I'm sure you'll live.`n`nYou gain some Stamina!");
                    $st = 225000;
                    $nu = 60;
                    $fa = 40;
                    $fu = 25;
                    $co = 300;
                    break;
                case 7:
                    output("You sip your hot chocolate, listening to the babbling brooks.  Life ain't so bad.`n`nYou gain some Stamina!");
                    $st = 25000;
                    $nu = 10;
                    $fa = 10;
                    $fu = 15;
                    $co = 50;
                    break;
                case 8:
                    output("There's something very odd about the water from the White Spring.  You feel light on your feet.  It seems to make everything easier, somehow.");
                    apply_stamina_buff('whitespringwater', array("name" => "White Spring Lightness", "action" => "Global", "costmod" => 0.8, "expmod" => 1, "rounds" => 20, "roundmsg" => "The waters of the White Spring seem to be making everything a little easier.", "wearoffmsg" => "The White Spring effects seem to have worn off."));
                    $co = 50;
                    break;
                case 9:
                    output("You scarf down your salad of nuts and berries, secretly wishing for a nice juicy steak.`n`nYou gain some Stamina!");
                    $st = 65000;
                    $nu = 25;
                    $fa = 5;
                    $fu = 10;
                    $co = 100;
                    break;
                case 10:
                    output("The water from the Turquoise Spring is served at room temperature, but somehow tastes very cold.  After a few moments, your eyesight improves; you can make out individual facets of a crystal buried in the far wall of the cavern.  This should make it a bit easier to hunt down monsters!");
                    apply_stamina_buff('turquoisespringwater', array("name" => "Turquoise Sight", "class" => "Hunting", "costmod" => 0.5, "expmod" => 1, "rounds" => 3, "roundmsg" => "Thanks to your heightened senses granted by the waters of the Turquoise Spring, hunting for monsters seems a lot easier now.", "wearoffmsg" => "The effects of the Turquoise Spring water have worn off, and your senses return to their usual state."));
                    $co = 175;
                    break;
                case 11:
                    output("You down the water from the Red Spring.  There's a distinct taste of iron in there.  After a few moments, you become anxious - surely there must be something around here that you can engage in combat...");
                    apply_stamina_buff('redspringwater', array("name" => "Red Haze", "class" => "Combat", "costmod" => 0.5, "expmod" => 1, "rounds" => 20, "roundmsg" => "The waters of the Red Spring make fighting seem more natural and fluid.  You're not expending nearly as much Stamina as usual.", "wearoffmsg" => "The effects of the Red Spring water have worn off, and your senses return to their natural state."));
                    $co = 250;
                    break;
                case 12:
                    output("The menu described a still-twitching steak, and boy, it delivered.  Steam rises from the plate of raw muscle in front of you.  The meat jerks and spasms as it reacts to the sudden flood of oxygen, slapping gently against the plate.  Your mouth waters, and you can see some nearby KittyMorphs glancing jealously in your direction.  You wolf it down before they get any ideas.`n`nYou gain some Stamina!");
                    $st = 385000;
                    $nu = 100;
                    $fa = 10;
                    $fu = 80;
                    $co = 500;
                    break;
                case 13:
                    output("You scarf down your braaaaainy meal, hoping that there will be no complications from the frankly ridiculous amounts of braaaaains that you're eating.`n`nYou gain some Stamina!");
                    $st = 25000;
                    $nu = 10;
                    $fa = 10;
                    $fu = 10;
                    $co = 50;
                    break;
                case 14:
                    output("You scarf down your braaaaainy meal, hoping that there will be no complications from the frankly ridiculous amounts of braaaaains that you're eating.`n`nYou gain some Stamina!");
                    $st = 65000;
                    $nu = 20;
                    $fa = 20;
                    $fu = 20;
                    $co = 100;
                    break;
                case 15:
                    output("You scarf down your braaaaainy meal, hoping that there will be no complications from the frankly ridiculous amounts of braaaaains that you're eating.`n`nYou gain some Stamina!");
                    $st = 105000;
                    $nu = 30;
                    $fa = 30;
                    $fu = 30;
                    $co = 150;
                    break;
                case 16:
                    output("You scarf down your braaaaainy meal, hoping that there will be no complications from the frankly ridiculous amounts of braaaaains that you're eating.`n`nYou gain some Stamina!");
                    $st = 145000;
                    $nu = 40;
                    $fa = 40;
                    $fu = 40;
                    $co = 200;
                    break;
                case 17:
                    output("You scarf down your braaaaainy meal, hoping that there will be no complications from the frankly ridiculous amounts of braaaaains that you're eating.`n`nYou gain some Stamina!");
                    $st = 185000;
                    $nu = 50;
                    $fa = 50;
                    $fu = 50;
                    $co = 250;
                    break;
                case 18:
                    output("You scarf down your braaaaainy meal, hoping that there will be no complications from the frankly ridiculous amounts of braaaaains that you're eating.`n`nYou gain some Stamina!");
                    $st = 225000;
                    $nu = 60;
                    $fa = 60;
                    $fu = 60;
                    $co = 300;
                    break;
                case 19:
                    output("You chew thoughtfully on your Wriggly Biscuits.  They live up to their name quite adequately.`n`nYou gain some Stamina!");
                    $st = 65000;
                    $nu = 20;
                    $fa = 10;
                    $fu = 10;
                    $co = 100;
                    break;
                case 20:
                    output("You run your tongue lovingly up, down and around the extremely phallic nuts, savouring their delightfully salty flavour.`n`nYou gain some Stamina!");
                    $st = 145000;
                    $nu = 40;
                    $fa = 10;
                    $fu = 20;
                    $co = 200;
                    break;
                case 21:
                    output("The Noodly Noodles jerk and spasm, each bite releasing a sticky yellow goo.  Tasty!`n`nYou gain some Stamina!");
                    $st = 225000;
                    $nu = 40;
                    $fa = 10;
                    $fu = 20;
                    $co = 300;
                    break;
                case 22:
                    output("You stare down at your three-eyed fish.  It stares back up at you, in ways that you can only imagine.  After a few moments of depressed contemplation, you tuck in - and hey, it's actually not that bad.`n`nYou gain some Stamina!");
                    $st = 305000;
                    $nu = 50;
                    $fa = 25;
                    $fu = 40;
                    $co = 400;
                    break;
                case 23:
                    output("As your fork sinks into your Magical Mystery Meatloaf, a hundred pairs of eyes open on its crispy skin.  They close again almost instantly, and you try your hardest to persuade yourself that you were hallucinating from the disinfectant fumes - it beats reality, that's for damn sure.`n`nYou gain some Stamina!");
                    $st = 385000;
                    $nu = 50;
                    $fa = 25;
                    $fu = 50;
                    $co = 500;
                    break;
                case 24:
                    output("The Mutant Steak is lean, delicious, nutritious and as big as your head!  What a pleasant surprise!`n`nYou gain some Stamina!");
                    $st = 585000;
                    $nu = 150;
                    $fa = 10;
                    $fu = 80;
                    $co = 750;
                    break;
                case 25:
                    output("You grimace, and call over to the midget behind the counter.  \"These taste like someone tried to make bacon flavour crisps and failed, badly.\"`n`n\"Read the fookin' packet, dick'ead!\"`n`nYou do as he says.  Ah.  Tumour flavour.  Nice.`n`nYou gain some Stamina!");
                    $st = 10000;
                    $nu = 5;
                    $fa = 10;
                    $fu = 5;
                    $co = 20;
                    break;
                case 26:
                    output("Skinheads on a Raft turned out to be beans on toast.  You're not sure whether to be relieved.`n`nYou gain some Stamina!");
                    $st = 25000;
                    $nu = 20;
                    $fa = 20;
                    $fu = 15;
                    $co = 50;
                    break;
                case 27:
                    //Potential for expansion: have the kebab taste better if the player's drunk, have the player find a wedding ring that he can sell for Req, etc.
                    output("You scarf down your doner kebab, stopping occasionally to pick out the occasional toenail or piece of car dashboard.  It's pretty fatty, and would taste a lot better if you were drunk, but you make do.`n`nYou gain some Stamina!");
                    $st = 65000;
                    $nu = 20;
                    $fa = 40;
                    $fu = 20;
                    $co = 75;
                    break;
                case 28:
                    output("You knock back your Crimson Pitbull, which turned out to be some sort of energy drink.`n`nYou feel aggressive!");
                    apply_stamina_buff('crimsonpitbull', array("name" => "Bark of the Crimson Pitbull", "class" => "Combat", "costmod" => 0.5, "expmod" => 1, "rounds" => 20, "roundmsg" => "The harsh, chemically-sweet taste of the Crimson Pitbull lurks in the back of your throat.  You're not expending nearly as much Stamina as usual.", "wearoffmsg" => "The effects of the Crimson Pitbull have worn off, and your senses return to their natural state."));
                    $co = 75;
                    break;
                case 29:
                    output("C**k Nuggets turned out to be chicken nuggets, only with a little more fowl language.`n`n...`n`n...sorry.`n`nYou gain some Stamina!");
                    $st = 145000;
                    $nu = 30;
                    $fa = 60;
                    $fu = 25;
                    $co = 150;
                    break;
                case 30:
                    output("The Sausage Feast turned out to be less sausage, and more fat, but hey, it's cheap and it tastes halfway decent.`n`nYou gain some Stamina!");
                    $st = 185000;
                    $nu = 40;
                    $fa = 80;
                    $fu = 50;
                    $co = 200;
                    break;
            }
            addstamina($st);
            increment_module_pref("nutrition", $nu);
            increment_module_pref("fat", $fa);
            increment_module_pref("fullness", $fu);
            $full = get_module_pref("fullness");
            if ($full < 0) {
                output("`n`nYou still feel as though you haven't eaten in days.");
            }
            if ($full >= 0 && $full < 50) {
                output("`n`nYou feel a little less hungry.");
            }
            if ($full >= 50 && $full < 100) {
                output("`n`nYou still feel as though you've got room for more!");
            }
            if ($full >= 100) {
                output("`n`nYou're stuffed!  You feel as though you can't possibly eat anything more today.");
            }
            $session['user']['gold'] -= $co;
            break;
    }
    debug(get_module_pref("fat"));
    debug(get_module_pref("nutrition"));
    addnav("Exit");
    addnav("Return to the Outpost", "village.php");
    page_footer();
}
function iitems_catcher_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "iitems-use-item":
            if ($args['player']['itemid'] == "zapgrenade") {
                apply_buff('zapgrenade', array("startmsg" => "`#You pull the pin on your grenade and toss it at {badguy}`#, shielding your eyes.  After a blinding flash, your foe is left dazed and confused!", "name" => "`^ZAP Grenade", "rounds" => e_rand(3, 7), "badguyatkmod" => 0.1, "badguydefmod" => 0.1, "roundmsg" => "{badguy} is blinded, deafened and thoroughly confused, and flails wildly while you pummel it!", "wearoff" => "{badguy}`# feels some coherence return, and lunges at you!", "expireafterfight" => 1, "schema" => "iitems-catcher"));
            }
            if ($args['player']['itemid'] == "nicotinegum") {
                $addiction = get_module_pref("addiction", "smoking");
                $betweensmokes = 250 - $addiction;
                set_module_pref("betweensmokes", $betweensmokes, "smoking");
                apply_buff("smoking", array("allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-smoking"));
            }
            if ($args['player']['itemid'] == "oneshotteleporter") {
                require_once "modules/iitems/lib/lib.php";
                iitems_discard_item($args['player']['inv_key']);
                redirect("runmodule.php?module=iitems_catcher&item=oneshotteleporter");
            }
            if ($args['player']['itemid'] == "energydrink") {
                //handle Nutrition adding without invoking extra Edibles functionality
                increment_module_pref("nutrition", 5, "staminafood");
            }
            if ($args['player']['itemid'] == "monsterrepellentspray") {
                if (httpget('skill') == "iitems") {
                    //handle using the item in a fight
                    apply_buff('rspray_fight', array("startmsg" => "`#You pull out a can of Monster Repellent Spray, and spray it liberally on the enemy!`n", "name" => "`^Repellent Spray Attack", "rounds" => 10, "badguyatkmod" => 0.4, "badguydefmod" => 0.4, "roundmsg" => "{badguy} is coughing, choking and all runny-nosed, and cannot attack or defend as effectively!", "wearoff" => "The effects of your Monster Repellent Spray seem to have worn off...`n", "expireafterfight" => 1, "schema" => "iitems-catcher"));
                } else {
                    //handle using the item outside of a fight
                    apply_buff('rspray_normal', array("name" => "`^Repellent Spray", "rounds" => -1, "badguyatkmod" => 0.8, "badguydefmod" => 0.8, "roundmsg" => "{badguy} can't stand the smell of your Monster Repellent Spray, and doesn't want to get too close!", "schema" => "iitems-catcher"));
                    set_module_pref("encounterchance", 50, "worldmapen");
                    output("You liberally douse yourself with an entire can of Monster Repellent Spray.  For the rest of this game day, your chances of encountering a monster on the Island Map have been halved, and monsters you do encounter will be reluctant to attack you as hard.`n`n");
                }
            }
            if ($args['player']['itemid'] == "improbabilitybomb") {
                $effect = e_rand(1, 8);
                if (has_buff("ibomb7a") && $effect == 7) {
                    $effect = 3;
                }
                if (has_buff("ibomb8") && $effect == 8) {
                    $effect = 3;
                }
                apply_buff('startmsg', array("rounds" => 1, "atkmod" => 1, "startmsg" => "`0You light the fuse on the Improbability Bomb and toss it towards your opponent.", "schema" => "iitems-catcher"));
                switch ($effect) {
                    case 1:
                        apply_buff('ibomb1', array("rounds" => 1, "atkmod" => 1, "startmsg" => "`0The bomb bursts into a shower of Requisition tokens!  Blimey, there must be about a thousand of them!  What's more, all these tokens are swirling into the air and nose-diving straight into your pocket.  Result!", "schema" => "iitems-catcher"));
                        $gold = e_rand(900, 1100);
                        $session['user']['gold'] += $gold;
                        break;
                    case 2:
                        apply_buff('ibomb2', array("rounds" => 1, "atkmod" => 1, "startmsg" => "`0The fuse fizzes and sparks, until eventually... it goes out.  The bomb is gone.  However, there's a tasty, tasty cigarette in its place!  You grab it before your enemy gets the chance.", "schema" => "iitems-catcher"));
                        $session['user']['gems']++;
                        break;
                    case 3:
                        apply_buff('ibomb3', array("rounds" => 1, "minioncount" => 1, "minbadguydamage" => "5+round(<attack>*1.0,0);", "maxbadguydamage" => "5+round(<attack>*3.0,0);", "effectmsg" => "`4The bomb explodes close enough to {badguy}`4 to do `^{damage}`4 damage!", "schema" => "iitems-catcher"));
                        break;
                    case 4:
                    case 5:
                        apply_buff('ibomb6', array("rounds" => 1, "atkmod" => 1, "startmsg" => "`0The Improbability Bomb breaks open, bathing you in a cool white light.  When it fades, you feel calm, self-confident and somehow more attractive.  Pretty useless in a combat situation, but hey, it's nice to be feel good about yourself.  You gain some Charm.", "schema" => "iitems-catcher"));
                        $session['user']['charm'] += 1;
                        break;
                    case 6:
                        apply_buff('ibomb7a', array("rounds" => 4, "minioncount" => 8, "minbadguydamage" => 0, "maxbadguydamage" => 5, "startmsg" => "The bomb begins to roll around the theater of combat, bouncing off rocks like a pinball - and firing out showers of white-hot sparks!", "effectmsg" => "`2A glowing spark leaps onto {badguy}, burning it for {damage} points!", "schema" => "iitems-catcher", "expireafterfight" => 1));
                        apply_buff('ibomb7b', array("rounds" => 4, "minioncount" => 8, "mingoodguydamage" => 0, "maxgoodguydamage" => 5, "effectmsg" => "`4A white-hot spark attaches to you, burning you for {damage} points!", "schema" => "iitems-catcher", "wearoff" => "The bomb fizzles out and sends out one last dying volley of sparks.", "expireafterfight" => 1));
                        break;
                    case 7:
                        apply_buff('ibomb8', array("startmsg" => "`0The bomb uncurls, revealing a little `5Purple Monster!`0", "rounds" => -1, "name" => "`5Purple Monster`0", "minioncount" => 1, "minbadguydamage" => 5, "maxbadguydamage" => 50, "effectmsg" => "`5The Purple Monster leaps towards {badguy} and bites down hard for {damage} damage!`0", "schema" => "iitems-catcher", "wearoff" => "`5The Purple Monster, seeing its business here concluded, disappears with a faint 'pop.'", "expireafterfight" => 1));
                        break;
                    case 8:
                        $maxdmg = $session['user']['maxhitpoints'] * 2;
                        if ($maxdmg < 500) {
                            $maxdmg = 500;
                        }
                        $mindmg = $session['user']['hitpoints'] * 0.5;
                        if ($maxdmg < 200) {
                            $maxdmg = 200;
                        }
                        apply_buff('ibomb9', array("rounds" => 1, "minioncount" => 1, "mingoodguydamage" => $mindmg, "maxgoodguydamage" => $maxdmg, "effectmsg" => "`4Before the bomb even leaves your hand, it blows up in your face!  The explosion causes {damage} points!", "schema" => "iitems-catcher", "expireafterfight" => 1));
                        break;
                }
            }
            if ($args['player']['itemid'] == "cratesniffer") {
                output("`0You thumb the switch on your Crate Sniffer.  It buzzes and hisses for a moment, exhausting its primitive battery sending out a radio ping to nearby Crates.`n`n");
                $crates = unserialize(get_module_setting("crates", "iitemcrates"));
                debug($crates);
                $ploc = get_module_pref("worldXYZ", "worldmapen");
                list($px, $py, $pz) = explode(",", $ploc);
                $pxlow = $px - 3;
                $pxhigh = $px + 3;
                $pylow = $py - 3;
                $pyhigh = $py + 3;
                if (!is_array($crates)) {
                    $crates = array();
                }
                $count = 0;
                foreach ($crates as $key => $vals) {
                    if ($vals['loc']['x'] >= $pxlow && $vals['loc']['x'] <= $pxhigh && $vals['loc']['y'] >= $pylow && $vals['loc']['y'] <= $pyhigh) {
                        $count++;
                    }
                }
                output("It displays, weakly, the number `\$`b%s`b`0 in dull red LED's before its radio module catches fire.`n`n", $count);
            }
            break;
        case "newday":
            set_module_pref("encounterchance", 100, "worldmapen");
            break;
    }
    return $args;
}
function commentaryicons_customrace_run()
{
    require_once "lib/sanitize.php";
    require_once "lib/names.php";
    global $session;
    $op = httpget("op");
    page_header("Custom Races");
    $costfirst = get_module_setting("initialpoints");
    $costsub = get_module_setting("extrapoints");
    $costperm = get_module_setting("permanent");
    $hasperm = get_module_pref("permanent");
    $playerpoints = $session['user']['donation'] - $session['user']['donationspent'];
    switch ($op) {
        case "change":
            output("Want to change your Custom Race?  No problem.  Enter your desired race in the box below.  You've got 25 characters to play around with.`n(leave this blank to disable custom race naming and return to default, game-supplied race names)`n`n");
            rawoutput("<form action='runmodule.php?module=commentaryicons_customrace&op=confirm&sub=change' method='POST'>");
            $race = get_module_pref("customrace");
            rawoutput("<input id='input' name='newrace' width='25' maxlength='25' value='" . htmlentities($race, ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "'>");
            rawoutput("<input type='submit' class='button' value='Preview'>");
            rawoutput("</form>");
            addnav("", "runmodule.php?module=commentaryicons_customrace&op=confirm&sub=change");
            break;
        case "firstchange":
            output("Changing your Custom Race will affect how other players see you.  In commentary areas, your race will show up as whatever you select here (the icon will be a little silver question mark, with the name of your race embedded in hover text like the other Race icons).  In the game mechanics, your race will be unchanged.  Think of it like a costume; you'll still be a %s inside, but your friends will think of you as whatever you enter in the box below.  You've got 25 characters to play around with.`n(leave this blank to disable custom race naming and return to default, game-supplied race names)`n`n", $session['user']['race']);
            rawoutput("<form action='runmodule.php?module=commentaryicons_customrace&op=confirm&sub=firstchange' method='POST'>");
            $race = get_module_pref("customrace");
            rawoutput("<input id='input' name='newrace' width='25' maxlength='25' value='" . htmlentities($race, ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "'>");
            rawoutput("<input type='submit' class='button' value='Preview'>");
            rawoutput("</form>");
            addnav("", "runmodule.php?module=commentaryicons_customrace&op=confirm&sub=firstchange");
            break;
        case "permanent":
            output("Buying permanent free changes means you'll pay %s points now, and then you can change your custom race as often as you like without paying again.`n`n", $costperm);
            addnav("Unlimited Custom Race changes");
            if ($playerpoints >= $costperm) {
                addnav(array("Buy permanent access (%s Points)", $costperm), "runmodule.php?module=commentaryicons_customrace&op=set&type=perm");
            } else {
                addnav(array("Sorry, but you need %s more points to do that.", $costperm - $playerpoints), "");
            }
            addnav("Cancel", "lodge.php");
            break;
        case "confirm":
            $newrace = httppost("newrace");
            $sub = httpget("sub");
            $newrace = str_replace("`", "", $newrace);
            $newrace = comment_sanitize($newrace);
            $newrace = substr($newrace, 0, 25);
            output("Your new custom race is:`n%s`nWould you like to set your new Race now?", $newrace);
            addnav("Confirm");
            switch ($sub) {
                case "change":
                    if ($hasperm) {
                        addnav("Set Custom Race (free)", "runmodule.php?module=commentaryicons_customrace&op=set&newrace=" . rawurlencode($newrace) . "&type=change");
                    } else {
                        addnav(array("Set Custom Race (%s Points)", $costsub), "runmodule.php?module=commentaryicons_customrace&op=set&newrace=" . rawurlencode($newrace) . "&type=change");
                    }
                    break;
                case "firstchange":
                    if ($hasperm) {
                        addnav("Set Custom Race (free)", "runmodule.php?module=commentaryicons_customrace&op=set&newrace=" . rawurlencode($newrace) . "&type=change");
                    } else {
                        addnav(array("Set Custom Race (%s Points)", $costfirst), "runmodule.php?module=commentaryicons_customrace&op=set&newrace=" . rawurlencode($newrace) . "&type=firstchange");
                    }
                    break;
            }
            break;
        case "set":
            $newrace = rawurldecode(httpget("newrace"));
            switch (httpget("type")) {
                case "change":
                    output("Your custom race has been set to %s!`n`n", $newrace);
                    set_module_pref("customrace", $newrace);
                    increment_module_pref("numchanges");
                    if (!get_module_pref("permanent")) {
                        $session['user']['donationspent'] += $costsub;
                        increment_module_setting("totalpoints", $costsub);
                    }
                    break;
                case "firstchange":
                    output("Your custom race has been set to %s!`n`n", $newrace);
                    set_module_pref("customrace", $newrace);
                    increment_module_pref("numchanges");
                    if (!get_module_pref("permanent")) {
                        $session['user']['donationspent'] += $costfirst;
                        increment_module_setting("totalpoints", $costfirst);
                    }
                    break;
                case "perm":
                    output("You've got permanent free custom race changes!  Woo!`n`n");
                    set_module_pref("permanent", 1);
                    $session['user']['donationspent'] += $costperm;
                    break;
            }
            break;
    }
    addnav("Return");
    addnav("L?Return to the Lodge", "lodge.php");
    page_footer();
}
function daysave_run()
{
    global $session;
    $op = httpget('op');
    $return = httpget('return');
    if ($return == "house") {
        $hid = httpget('hid');
        $rid = httpget('rid');
        $sid = httpget('sid');
    }
    //handle new players
    if (!get_module_pref("initsetup")) {
        set_module_pref("slots", get_module_setting("startslots"));
        set_module_pref("days", get_module_setting("startdays"));
        set_module_pref("initsetup", 1);
    }
    $days = get_module_pref("days");
    $slots = get_module_pref("slots");
    $startdays = get_module_setting("startdays");
    $startslots = get_module_setting("startslots");
    //$boughttoday = get_module_pref("instantbuys");
    $boughttoday = 0;
    $buyslotcost = get_module_setting("buyslotcost");
    $buydaycost = get_module_setting("buydaycost");
    $fillslotcost = get_module_setting("fillslotcost");
    $maxbuyday = get_module_setting("maxbuyday");
    $dps = $session['user']['donation'] - $session['user']['donationspent'];
    page_header("Saved Days");
    switch ($op) {
        case "start":
            output("Here are your Chronospheres.  Each coloured sphere represents one saved-up game day.`n`n");
            if ($startdays && $session['user']['dragonkills'] < 1) {
                output("New players start the game with some days already saved up, so that they can get a feel for how this works.`n`n");
            }
            for ($full = 1; $full <= $days; $full++) {
                rawoutput("<img src=\"images/daysphere-full.png\" alt=\"Saved Day\" title=\"Saved Day\">");
            }
            for ($empty = $full; $empty <= $slots; $empty++) {
                rawoutput("<img src=\"images/daysphere-empty.png\" alt=\"Empty Day Slot\" title=\"Empty Day Slot\">");
            }
            if ($days == 1) {
                $daydisp = "Day";
            } else {
                $daydisp = "Days";
            }
            output("`n`nChronospheres essentially allow you to save up game days for later play, simply by not logging in.  As you can see, you have %s Game %s saved up, out of a maximum of %s.`n`n", $days, $daydisp, $slots);
            addnav("Chronofiddling");
            if ($days) {
                addnav("Use a saved day", "runmodule.php?module=daysave&op=useday&hid=" . $hid . "&rid=" . $rid . "&sid=" . $sid);
            } else {
                addnav("You have no saved days", "");
            }
            addnav("Refresh this page", "runmodule.php?module=daysave&op=start&return=" . $return . "&hid=" . $hid . "&rid=" . $rid . "&sid=" . $sid);
            if ($maxbuyday == 1) {
                $maxdisp = "Day";
            } else {
                $maxdisp = "Days";
            }
            addnav("Donator Options");
            output("Site supporters have several extra options.  As a site supporter, you can instantly start a new Game Day for your character at any time in exchange for %s Donator Points.  You can also add more Chronospheres, allowing you to save up more days to play later.  Each additional Chronosphere costs %s Donator Points, and come pre-filled.  When adding Chronospheres, you have the option of refilling your empty Spheres for a discount cost of %s Donator Points per empty Sphere.`n`nYou currently have %s Donator Points available.  See the Hunter's Lodge in any Outpost for a more detailed explanation of how to get Donator Points, and other cool things you can do with them.`n`n`c`b`4Careful!`0`b`cAlways check the time to the next Game Day (displayed under your Stats) before you use a Chronosphere or buy an Instant New Day!  Nothing sucks worse than paying for a new day and then finding out that you would have gotten one in five minutes anyway.`n`nA quick point to note - if you leave the Island without logging out, and then log back in to arrive at this page, the number of Chronospheres displayed may be out of date.  To fix this, click the Refresh link.`n`nAlso be aware that if you've just logged in to see this page after being logged out for a while, you might have a natural New Day (IE one that won't affect your Chronospheres) waiting for you anyway, which will be triggered when you leave this page.", $buydaycost, $buyslotcost, $fillslotcost, number_format($dps));
            if ($dps >= $buydaycost && $boughttoday < $maxbuyday) {
                addnav(array("Buy an Instant New Day for %s Donator Points", $buydaycost), "runmodule.php?module=daysave&op=buyday&hid=" . $hid . "&rid=" . $rid . "&sid=" . $sid);
            } else {
                if ($dps < $buydaycost) {
                    addnav("Not enough Donator Points for an Instant New Day", "");
                } else {
                    addnav("Instant New Day limit reached", "");
                }
            }
            if ($dps >= $buyslotcost) {
                addnav(array("Buy an extra Chronosphere for %s Donator Points", $buyslotcost), "runmodule.php?module=daysave&op=buyslot&return=" . $return . "&hid=" . $hid . "&rid=" . $rid . "&sid=" . $sid);
            } else {
                addnav("Not enough Donator Points for a new Chronosphere", "");
            }
            addnav("Exit");
            if ($return == "village") {
                tlschema('nonav');
                villagenav();
            } else {
                if ($return == "shades") {
                    tlschema('nonav');
                    addnav("Back to the FailBoat", "shades.php");
                } else {
                    if ($return == "worldmapen") {
                        tlschema('nonav');
                        addnav("Return to the World Map", "runmodule.php?module=worldmapen&op=continue");
                    } else {
                        if ($return == "house") {
                            addnav("Return to the Dwelling", "runmodule.php?module=improbablehousing&op=sleep&sub=sleep&hid=" . $hid . "&rid=" . $rid . "&slot=" . $sid);
                        } else {
                            addnav("Your navs are corrupted!", "badnav.php");
                        }
                    }
                }
            }
            break;
        case "useday":
            $days -= 1;
            if ($days < 0) {
                $days = 0;
            }
            set_module_pref("days", $days);
            output("You have used one of your Chronospheres.  Now go forth and have fun!`n`n");
            for ($full = 1; $full <= $days; $full++) {
                rawoutput("<img src=\"images/daysphere-full.png\" alt=\"Saved Day\" title=\"Saved Day\">");
            }
            for ($empty = $full; $empty <= $slots; $empty++) {
                rawoutput("<img src=\"images/daysphere-empty.png\" alt=\"Empty Day Slot\" title=\"Empty Day Slot\">");
            }
            debug($session['user']['restorepage']);
            addnav("It is a New Day!", "newday.php");
            break;
        case "buyday":
            output("You have bought one new Game Day in exchange for %s Donator Points, leaving you with %s points left to spend.  Your Chronospheres are unaffected.  Now go forth and have fun!`n`n", $buydaycost, number_format($dps - $buydaycost));
            for ($full = 1; $full <= $days; $full++) {
                rawoutput("<img src=\"images/daysphere-full.png\" alt=\"Saved Day\" title=\"Saved Day\">");
            }
            for ($empty = $full; $empty <= $slots; $empty++) {
                rawoutput("<img src=\"images/daysphere-empty.png\" alt=\"Empty Day Slot\" title=\"Empty Day Slot\">");
            }
            addnav("It is a New Day!", "newday.php");
            $session['user']['donationspent'] += $buydaycost;
            increment_module_pref("instantbuys");
            break;
        case "buyslot":
            $session['user']['donationspent'] += $buyslotcost;
            increment_module_pref("days");
            increment_module_pref("slots");
            $days = get_module_pref("days");
            $slots = get_module_pref("slots");
            $dps = $session['user']['donation'] - $session['user']['donationspent'];
            output("You have bought one additional Chronosphere in exchange for %s Donator Points, leaving you with %s points left to spend.`n`n", $buyslotcost, number_format($dps));
            for ($full = 1; $full <= $days; $full++) {
                rawoutput("<img src=\"images/daysphere-full.png\" alt=\"Saved Day\" title=\"Saved Day\">");
            }
            for ($empty = $full; $empty <= $slots; $empty++) {
                rawoutput("<img src=\"images/daysphere-empty.png\" alt=\"Empty Day Slot\" title=\"Empty Day Slot\">");
            }
            if ($days < $slots && $dps >= $fillslotcost) {
                addnav("Fill up Chronospheres", "");
                output("`n`nYou now have the option of refilling your empty Chronospheres for %s Donator Points each.`n`n", $fillslotcost);
                $empty = $slots - $days;
                for ($i = 1; $i <= $empty; $i++) {
                    $cost = $i * $fillslotcost;
                    if ($dps >= $cost) {
                        if ($i == 1) {
                            $p = "Sphere";
                        } else {
                            $p = "Spheres";
                        }
                        addnav(array("Fill up %s %s for %s Donator Points", $i, $p, $cost), "runmodule.php?module=daysave&op=fillup&fill=" . $i . "&return=" . $return . "&hid=" . $hid . "&rid=" . $rid . "&sid=" . $sid);
                    }
                }
            }
            addnav("Return");
            addnav("Back to the menu", "runmodule.php?module=daysave&op=start&return=" . $return . "&hid=" . $hid . "&rid=" . $rid . "&sid=" . $sid);
            break;
        case "fillup":
            $fill = httpget('fill');
            $session['user']['donationspent'] += $fill * $fillslotcost;
            $dps = $session['user']['donation'] - $session['user']['donationspent'];
            increment_module_pref("days", $fill);
            $days = get_module_pref("days");
            if ($fill == 1) {
                $p = "Chronosphere";
            } else {
                $p = "Chronospheres";
            }
            output("You have filled up %s %s in exchange for %s Donator Points, leaving you with %s points left to spend.`n`n", $fill, $p, number_format($fill * $fillslotcost), number_format($dps));
            for ($full = 1; $full <= $days; $full++) {
                rawoutput("<img src=\"images/daysphere-full.png\" alt=\"Saved Day\" title=\"Saved Day\">");
            }
            for ($empty = $full; $empty <= $slots; $empty++) {
                rawoutput("<img src=\"images/daysphere-empty.png\" alt=\"Empty Day Slot\" title=\"Empty Day Slot\">");
            }
            addnav("Return", "");
            addnav("Back to the menu", "runmodule.php?module=daysave&op=start&return=" . $return . "&hid=" . $hid . "&rid=" . $rid . "&sid=" . $sid);
            break;
    }
    page_footer();
}
function newhomemuseum_run()
{
    global $session;
    page_header("NewHome Museum");
    switch (httpget("op")) {
        case "lobby":
            $exhibitsseen = get_module_pref("exhibitsseen");
            debug($exhibitsseen);
            output("You spy a house-sized hut with the sign \"NewHome Museum of Improbable Things\" proudly displayed above the door.  You decide to head inside and have a look around.`n`n");
            output("It's refreshingly cool inside the hut, although it does smell rather dusty.  Your eyes take a moment to adjust to the gloom.`n`n");
            modulehook("newhomemuseum");
            output("A sign hangs in the lobby, pointing out what lies through each of the doors leading off from the small room.`n`n");
            addnav("Museum Halls");
            addnav("Head for the Main Hall", "runmodule.php?module=newhomemuseum&op=mainhall");
            addnav("Head for the Hall of Diversity", "runmodule.php?module=newhomemuseum&op=racehall");
            addnav("Head for the Hall of Relics", "runmodule.php?module=newhomemuseum&op=relichall");
            addnav("Head for the Hall of Revolutions", "runmodule.php?module=newhomemuseum&op=revolutionhall");
            break;
        case "mainhall":
            if (httpget("examine") == "") {
                output("You step into the Main Hall.  For something called a \"Main Hall,\" you expected something a little larger.  This is barely bigger than your living room back home.`n`nTo your left, you can see a series of windowed indentations in the wall, with crinkly, yellowed pieces of paper sitting inside.  To your right you see a similar array of windows, this time with far less scruffy-looking papers inside.");
                addnav("Left Side");
                addnav("Examine the first window", "runmodule.php?module=newhomemuseum&op=mainhall&examine=diary1");
                addnav("Examine the second window", "runmodule.php?module=newhomemuseum&op=mainhall&examine=diary2");
                addnav("Examine the third window", "runmodule.php?module=newhomemuseum&op=mainhall&examine=diary3");
                addnav("Examine the fourth window", "runmodule.php?module=newhomemuseum&op=mainhall&examine=diary4");
                addnav("Examine the fifth window", "runmodule.php?module=newhomemuseum&op=mainhall&examine=diary5");
                addnav("Examine the sixth window", "runmodule.php?module=newhomemuseum&op=mainhall&examine=diary6");
                addnav("Right Side");
                addnav("Examine the first window", "runmodule.php?module=newhomemuseum&op=mainhall&examine=memo1");
                addnav("Examine the second window", "runmodule.php?module=newhomemuseum&op=mainhall&examine=memo2");
                addnav("Examine the third window", "runmodule.php?module=newhomemuseum&op=mainhall&examine=memo3");
            }
            switch (httpget("examine")) {
                case "diary1":
                    output("A plaque below the window informs you that this diary entry is taken from the journal of David Abraham, assistant to Doktor Improbable.`n`n`n");
                    output("`Q11th February, 2072`n`nAfter a hell of a flight, I finally arrived on Island Four this morning! Professor Hawton - Joseph, he insisted - is a massive, wobbling pudding of a man, nothing like his photos. He's the stereotype of a jolly fat bloke, with a crushing handshake and a hearty laugh. I took a liking to him instantly.`n`nAfter a lunch of roast boar and home-brewed real ale - which was delicious, by the way - he showed me his progress on the Improbability Drive, showing off the enhancements and modifications he's created, pointing out the deviations from the original plan, all of which met with my enthusiastic approval.`n`nThe Improbability Drive has the potential to eliminate all of mankind's margins of error. Imagine what we could do with Absolute Certainty! If we could inflate the slimmest chance to the highest mathematical probability! Professor Hawton - Joseph, sorry - highlighted some of the things I hadn't even thought of... what if our soldiers never missed their targets? What if we could easily affect the rate at which cancer cells divide and subdivide? What if we could determine, for ourselves, the chances of being struck by lightning, or hit by a bus, or dying of AIDS?`n`nJoseph seems a little eccentric, but a terribly nice chap - he has been here for twenty years on his own, so it's only natural he should be a tad \"touched.\" I'm sure he'll regain his senses - that's what I'm here for, after all, to keep him company and stop him from going completely off the deep end.`n`nI think this could be the start of a beautiful friendship!");
                    addnav("Continue");
                    addnav("Back to the Main Hall", "runmodule.php?module=newhomemuseum&op=mainhall");
                    addnav("Move on to the next diary entry", "runmodule.php?module=newhomemuseum&op=mainhall&examine=diary2");
                    if (get_module_pref("seendiary1") == 0) {
                        set_module_pref("seendiary1", 1);
                        increment_module_pref("exhibitsseen", 1);
                    }
                    break;
                case "diary2":
                    output("A plaque below the window informs you that this diary entry is taken from the journal of David Abraham, assistant to Doktor Improbable.`n`n`n");
                    output("`Q12th February, 2072`n`nJoseph walked in on me while I was having a shower, stripped off his clothes, and jumped in. The presence of his ample frame didn't give me enough room to stand up straight in the shower, and I was constantly buffeted by the folds and valleys of his soapy belly. I found it all a little odd, but what really struck me was that he left his socks on. When I quizzed him about it, he told me that his socks were vital to the Plan. `n`n\"What plan,\" I asked him. `n`n\"PlanplanplanPLANplanplanplan,\" he laughed, enthusiastically rubbing his belly, and then he grabbed my head and rubbed it between his soapy man-boobs.`n`nYup, he's nuts.");
                    addnav("Continue");
                    addnav("Back to the Main Hall", "runmodule.php?module=newhomemuseum&op=mainhall");
                    addnav("Move on to the next diary entry", "runmodule.php?module=newhomemuseum&op=mainhall&examine=diary3");
                    if (get_module_pref("seendiary2") == 0) {
                        set_module_pref("seendiary2", 1);
                        increment_module_pref("exhibitsseen", 1);
                    }
                    break;
                case "diary3":
                    output("A plaque below the window informs you that this diary entry is taken from the journal of David Abraham, assistant to Doktor Improbable.`n`n`n");
                    output("`Q14th February, 2072`n`nJoseph gave me a Valentine's Day card. He'd drawn it himself, in crayon, and signed it \"Doktor Improbable.\" I asked him about the name - he told me he spelt Doktor with a K because he wasn't actually, strictly speaking, a real doctor. Fantastic.`n`nWe rolled dice and flipped coins for the rest of the day, while Joseph fine-tuned the Improbability Drive.");
                    addnav("Continue");
                    addnav("Back to the Main Hall", "runmodule.php?module=newhomemuseum&op=mainhall");
                    addnav("Move on to the next diary entry", "runmodule.php?module=newhomemuseum&op=mainhall&examine=diary4");
                    if (get_module_pref("seendiary3") == 0) {
                        set_module_pref("seendiary3", 1);
                        increment_module_pref("exhibitsseen", 1);
                    }
                    break;
                case "diary4":
                    output("A plaque below the window informs you that this diary entry is taken from the journal of David Abraham, assistant to Doktor Improbable.`n`n`n");
                    output("`Q20th February, 2072`n`nI have a feeling we're getting closer. We rolled ten dice this morning, and got ten sixes. After subsequent rolls, we got ten sixes again, then nine sixes and a five, then ten ones, then nine ones and a six, and then five sixes and five ones. They were all supposed to be sets of ten sixes, but it's plain to see that we're making progress.");
                    addnav("Continue");
                    addnav("Back to the Main Hall", "runmodule.php?module=newhomemuseum&op=mainhall");
                    addnav("Move on to the next diary entry", "runmodule.php?module=newhomemuseum&op=mainhall&examine=diary5");
                    if (get_module_pref("seendiary4") == 0) {
                        set_module_pref("seendiary4", 1);
                        increment_module_pref("exhibitsseen", 1);
                    }
                    break;
                case "diary5":
                    output("A plaque below the window informs you that this diary entry is taken from the journal of David Abraham, assistant to Doktor Improbable.`n`n`n");
                    output("`Q1st March, 2072`n`nI think we've cracked it! Ten rolls, of ten dice, and sixes across the board!`n`nJoseph, for some reason, isn't happy with the result! He frowned, muttered that he'd have to fine-tune it a little more, and then went back to the computers.`n`nI have no idea what more he'd want to do with this. We've done the basic experiments as an illustration of principle, and that's all we were supposed to do.");
                    addnav("Continue");
                    addnav("Back to the Main Hall", "runmodule.php?module=newhomemuseum&op=mainhall");
                    addnav("Move on to the next diary entry", "runmodule.php?module=newhomemuseum&op=mainhall&examine=diary6");
                    if (get_module_pref("seendiary5") == 0) {
                        set_module_pref("seendiary5", 1);
                        increment_module_pref("exhibitsseen", 1);
                    }
                    break;
                case "diary6":
                    output("A plaque below the window informs you that this diary entry is taken from the journal of David Abraham, assistant to Doktor Improbable.`n`n`n");
                    output("`Q7th March, 2072`n`nI'm going to leave this journal where you can find it. I don't have much time. It's all gone wrong. We threw ten dice, which came up nine sixes and a seven, and then five zeroes and five nines, and then ten ones and a Z, and then three parrots, five monkeys, seven cakes and the Ace of Spades. Joseph was laughing and wobbling like a madman the entire time.`n`nImprobability is leaking out into the island like radiation, and everything's going very strange. If you read this, GET OFF THE ISLAND - and if you survive without being turned into something, give my love to my wife, and tell the world that Doktor Improbable is coming.`n`nI don't know what you, as outsiders, can do about this place. If you try to nuke it, then the missile will probably change into a sperm whale or something. If you send soldiers, their weapons might backfire, or not work at all, or turn into bananas. I guess you could make some sick Reality TV show where you launch unarmed people indiscriminately at the Island and see whether or not they survive - note, THIS IS A JOKE, DON'T ACTUALLY DO THIS.`n`nDoktor Improbable, and the Improbability Drive, aren't your only problems. There are other things here, too - some are nice, some not so nice, all insane.`n`nThis is David Abraham, signing off - and I apologise for my part in all this. Forgive me. I knew not what I did.`n`nIf you read this, get away. Get away FAST.");
                    addnav("Continue");
                    addnav("Back to the Main Hall", "runmodule.php?module=newhomemuseum&op=mainhall");
                    if (get_module_pref("seendiary6") == 0) {
                        set_module_pref("seendiary6", 1);
                        increment_module_pref("exhibitsseen", 1);
                    }
                    break;
                case "memo1":
                    output("A plaque below the window informs you that this is an internal memo sent from Professor Woodcock of Oxford University.`n`n`n");
                    output("`1 14th September, 2074`n`nTo Whom it May Concern;`n`nWhile browsing through some old correspondance in a somewhat vain attempt to organise my predecessor's filing system, I came across a most interesting letter.  I'll keep this brief, as I know you'd like me to get straight to the point - it appears as though there may still be at least one functional computer left in the world.  Further, it may even belong to us.`n`nFrom what I managed to gather from various old letters and memos, we apparently dispatched some poor sap to an island in the middle of nowhere in the late 50's, to work on some sort of quantum-mechanics experiment.  From the letters, he seems a rather eccentric and boisterous sort, which is probably why we offered him this \"opportunity\" in the first place.  Anyway, the poor wretch never came back, and it seems that someone else was going through some old letters as I do now, as there are some more memos sent - like this one - to the department head, asking whatever happened to the man.  Then - please see enclosed - it appears we sent another promising yet disappointingly intolerable young man after Professor Hawton, to keep him company.`n`nNow, I don't know whether these documents were forgotten on purpose or as part of some greater beauracratic gaffe, but it seems to me that the island in question might just be remote enough for our equipment to have been unaffected by the EMP bombs detonated this spring.`n`nGentlemen, I propose that we set sail immediately to Island Four, and see for ourselves whether we now own the last functional computers in the world.  Please meet me in the pub this evening to discuss.`n`nYours faithfully,`n`nPercival Woodcock, B.S.C.");
                    addnav("Continue");
                    addnav("Move on to the next letter", "runmodule.php?module=newhomemuseum&op=mainhall&examine=memo2");
                    addnav("Back to the Main Hall", "runmodule.php?module=newhomemuseum&op=mainhall");
                    if (get_module_pref("seenmemo1") == 0) {
                        set_module_pref("seenmemo1", 1);
                        increment_module_pref("exhibitsseen", 1);
                    }
                    break;
                case "memo2":
                    output("A plaque below the window informs you that this is a letter sent from Professor Kempston of Oxford University, to the British Foreign and Commonwealth Office, carbon-copied to the Ministry of Defence.`n`n`n");
                    output("`1 11th June, 2075`n`nDear Sir or Madam,`n`nI hope this letter finds you well.  My name is professor Peter Kempston and I am writing on behalf of the quantum physics department of Oxford University.`n`nWe find ourselves in a most unusual predicament.  Over the course of the past twenty-odd years, we've sent two expeditions to a particular island (please see enclosed map for exact co-ordinates.)  We considered calling the local police when our second expedition failed to come back, but we felt that this remote place may well be beyond their baliwick, and decided to take the matter higher.  I'm ashamed to say we simply forgot about the first expedition.`n`nThe enclosed letters and internal memos will, I hope, explain the matter far more succinctly than I could.`n`nPlease respond by letter or carrier pigeon as soon as you can.`n`nYours sincerely,`n`nProfessor P. Kempston, B.S.C.");
                    addnav("Continue");
                    addnav("Move on to the next letter", "runmodule.php?module=newhomemuseum&op=mainhall&examine=memo3");
                    addnav("Back to the Main Hall", "runmodule.php?module=newhomemuseum&op=mainhall");
                    if (get_module_pref("seenmemo2") == 0) {
                        set_module_pref("seenmemo2", 1);
                        increment_module_pref("exhibitsseen", 1);
                    }
                    break;
                case "memo3":
                    output("A plaque below the window informs you that this is a transcript of a radio conversation between a helicopter pilot and base.  The name of the pilot, and date of the transmission, are lost.`n`nIt goes on to explain, in boring detail, about how the radio and helicopter worked in a post-EMP world.  You give it a quick scan and get the gist of it - the squadron went equipped with the best hardware that the National Army Museum in Chelsea could provide, including a fly-by-wire helicoper, valve radio, optical binoculars, mechanical rifles and so on.  You feel briefly sorry for the poor bastards.`n`n`n");
                    output("`4PILOT: The rotors.  Oh my God, the rotors are.  The rotors are flying away.`nBASE: Repeat please.`nPILOT: The rotors are going away from the helicopter.  They are flying away.`nBASE: Do you mean the rotors are broken?  Which ones?`nPILOT: No, they have flown away.  Little wings.`nBASE: Give up command of the helicopter.  Have someone take over.  Fit your gas mask, sit down and breathe.  Confirm.`nPILOT: Little wings.`nSOUND OF RUSHING AIR.  MALE SCREAMS.  MALE LAUGHTER.  QUACKING DUCK.`nEND.");
                    addnav("Continue");
                    addnav("Back to the Main Hall", "runmodule.php?module=newhomemuseum&op=mainhall");
                    if (get_module_pref("seenmemo3") == 0) {
                        set_module_pref("seenmemo3", 1);
                        increment_module_pref("exhibitsseen", 1);
                    }
                    break;
            }
            break;
        case "racehall":
            if (httpget("examine") == "") {
                output("You step into the Hall of Diversity.  An array of lifelike mannequins stand before you, depicting various strange-looking humanoid creatures.");
                addnav("Examine mannequins");
                addnav("Examine the human-looking mannequin", "runmodule.php?module=newhomemuseum&op=racehall&examine=human");
                addnav("Examine the unhealthy-looking mannequin", "runmodule.php?module=newhomemuseum&op=racehall&examine=zombie");
                addnav("Examine the furry mannequin", "runmodule.php?module=newhomemuseum&op=racehall&examine=kittymorph");
                addnav("Examine the short mannequin", "runmodule.php?module=newhomemuseum&op=racehall&examine=midget");
                addnav("Examine the mannequin with extra limbs", "runmodule.php?module=newhomemuseum&op=racehall&examine=mutant");
                addnav("Examine the metal and glass mannequin", "runmodule.php?module=newhomemuseum&op=racehall&examine=robot");
                addnav("Examine the mannequin with tyres where its legs should be", "runmodule.php?module=newhomemuseum&op=racehall&examine=gobot");
                addnav("Examine the very well-dressed mannequin", "runmodule.php?module=newhomemuseum&op=racehall&examine=joker");
            }
            switch (httpget("examine")) {
                case "human":
                    output("The mannequin depicts a determined-looking man in his mid to late twenties, bearing healthy stubble and a cocky grin.  Biceps seem to strain against the confines of his camouflaged jacket, his rather large pistol aimed towards the shorter mannequin.  Despite being a wax-and-resin dummy, he seems to ooze testosterone.`n`nStanding in front of him, you feel a little inadequate.`n`n`n");
                    output("A sign at his feet reads:`n`nHUMAN`nThe brave, determined heroes of the War on Improbability.`n`nSomeone has written in pencil underneath the sign:`nNearly all of them so new they're still wet behind the ears.  Cocky and overconfident.  Beware.");
                    addnav("Continue");
                    addnav("Back to the Hall of Diversity", "runmodule.php?module=newhomemuseum&op=racehall");
                    if (get_module_pref("seenrace1") == 0) {
                        set_module_pref("seenrace1", 1);
                        increment_module_pref("exhibitsseen", 1);
                    }
                    break;
                case "zombie":
                    output("The mannequin depicts a gaunt man with green, rotting skin, wearing an army jacket smeared with blood.  His arms are upraised and he appears to be taking a step forward, as though shambling drunkenly towards you for a hug.`n`n`n");
                    output("A sign at his feet reads:`n`nZOMBIE`nIt is believed that these poor creatures have been infected with the results of one of Doktor Improbable's other experiments.  Common traits include a shambling gait, lack of social sophistication and table manners, unpleasant odour, involuntary use of the word 'brains' and frequent vomiting-up of their own entrails.`nUnable to feel pain or exhaustion, Zombies can take a lot of punishment in combat over a long period of time.  However, their slowness and general clumsiness means that they cannot attack as effectively.  Their keen eye for shiny objects means that they always seem to have slightly more wealth than other races.`n`nSomeone has written in rusty brown ink - at least, you hope it's rusty brown ink and not dried blood- underneath the sign:`nBRAAAAAAAAAAAAAAAAAAAAIIIIIIIIIIIIIINNNNNNNNNNS.  Kilroy was 'ere.");
                    addnav("Continue");
                    addnav("Back to the Hall of Diversity", "runmodule.php?module=newhomemuseum&op=racehall");
                    if (get_module_pref("seenrace2") == 0) {
                        set_module_pref("seenrace2", 1);
                        increment_module_pref("exhibitsseen", 1);
                    }
                    break;
                case "kittymorph":
                    output("The mannequin depicts an obviously - perhaps you could even say 'abundantly' - female humanoid creature, covered from head to toe in thick, sandy fur.  Her ears are pointy and sit on the top of her head, her nose is a little smaller and her eyes a little larger than would be considered natural, and she bears a tail that reaches to the back of her knees.  She has one knee raised as though running and appears to be in the process of disrobing as she does so, showing a considerable amount of bare fur and a wide-eyed, toothy grin.`n`n`n");
                    output("A sign at her feet reads:`n`nKITTYMORPH`nNobody knows exactly how these creatures came to exist on the Island.  They appear to be a genetic mutation of sorts.  Common traits include an easygoing attitude to life, an almost complete lack of modesty, comfort in laziness and a tendency to become distracted easily.`nThese creatures' toned and slender bodies cannot cope with heavy blows in combat, but do allow for fast counterattacks and an ability to travel further in a day than most races.  However, Kittymorphs are generally disinclined towards prolonged combat, and become distracted easily.`n`nSomeone has added in pencil:`nShameless exhibitionists.  Bloody unstable personalities too.  Lazy buggers.  Usually list \"carnivore\" as their job titles, despite giving the appearance of being a bunch of vegan hippy types.  Beware.");
                    addnav("Continue");
                    addnav("Back to the Hall of Diversity", "runmodule.php?module=newhomemuseum&op=racehall");
                    if (get_module_pref("seenrace3") == 0) {
                        set_module_pref("seenrace3", 1);
                        increment_module_pref("exhibitsseen", 1);
                    }
                    break;
                case "midget":
                    output("You look down at the mannequin before you.  Its head reaches to just below your bellybutton.  You almost mistook it for a child, until you saw the five-o'clock shadow and can of White Lightning cider clutched in one tiny hand.  It wears a filthy grey T-shirt with sweat rings around the armpits and tomato sauce stains down the front.  It sneers up at you, cider can in one hand, the other raised in your direction, middle finger outstretched.`n`n`n");
                    output("A sign at his feet reads:`n`nMIDGET`nThese creatures were not born this way, but were in fact changed to their current forms via an overdose of a particular strain of Improbability.  It is important to show real midgets the same respect you would show any other human being, and this can cause awkward situations sometimes - to tell a midget apart from a Midget, simply ask them if they have the time.  If they respond with a belch and a kick to your crotch and then rob you, then they're a Midget, not a midget.`nCommon traits include laziness, foul odour, hygiene problems, lack of communication skills, lack of financial skills, lack of any sort of skills, and extreme violence.  It is often difficult to tell male Midgets from female Midgets, due to the facial hair on both genders.  Midgets of either gender should be considered extremely dangerous.`nMidgets excel in all areas of combat.  Their small size makes them both difficult to hit and likely to fly into a blinding rage at any moment.  However, their stubby little legs give them a notable disadvantage in travelling, and also ensure that they cannot fight as many foes over a long period.`n`nSomeone has added in pencil:`nfuk u! dat dummy maks me luk short! u fukin dik!`n`nSomeone else has added:`nQuiet, you, or I'll step on you.");
                    addnav("Continue");
                    addnav("Back to the Hall of Diversity", "runmodule.php?module=newhomemuseum&op=racehall");
                    if (get_module_pref("seenrace4") == 0) {
                        set_module_pref("seenrace4", 1);
                        increment_module_pref("exhibitsseen", 1);
                    }
                    break;
                case "mutant":
                    output("The mannequin depicts a sad-faced man with three extra arms, all of varying sizes.  An extra miniature head grows from his left shoulder, and seems to be a little happier - that may be because it's depicted biting the main head's ear.`n`n`n");
                    output("A sign at his feet reads:`n`nMUTANT`nThese contestants were understood to be human at one point, but have been exposed to significant amounts of Improbability, causing these mutations.  Every Mutant is different, and may be endowed with extra appendages of any description.  Mutants tend to be rather sensitive about their condition, and will often take time out of their day to educate other contestants on the challenges of being Mutant.`nIn combat, Mutants are formidable opponents.  Their typically leathery hide allows them to take a lot of damage, while their extra appendages can be used to strike or parry.  However, the relative newness of their mutated bodies, combined with the residual mental image of their former selves, makes it hard for a Mutant to learn from their mistakes and successes.  As a result, they will need to fight more than other races in order to achieve similar skill.`n`nSomeone has written below the sign in pencil:`nDon't let one of these whiny tosspots corner you.  They'll talk your bloody ear off about their noodly protuberances.");
                    addnav("Continue");
                    addnav("Back to the Hall of Diversity", "runmodule.php?module=newhomemuseum&op=racehall");
                    if (get_module_pref("seenrace5") == 0) {
                        set_module_pref("seenrace5", 1);
                        increment_module_pref("exhibitsseen", 1);
                    }
                    break;
                case "robot":
                    output("The mannequin in front of you shows a humanoid creature seemingly constructed of metal and glass.  Inside, you can see traces of veins and a nervous system twisting around a wiring harness.  The creature appears to be female, although it's rather difficult to tell.  She stands with her head cocked downwards, as though shy.  Her face is a chrome mask, and behind it reflected light shines back at you from her black, camera-lens eyes.  Sharp-looking spikes extend from her fingertips.`n`n`n");
                    output("A sign at her feet reads:`n`nROBOT`nTechnically cyborgs, these creatures are understood to have some human elements.  They are typically rather shy and peaceful life forms, curious about human emotion.  They are capable of simulating human behaviour to a certain extent, although they are incapable of ingesting food or drink.`nRobots are a complicated race, and work very differently from most others.  As their inner workings are too complex to be comprehended by our healers in the Hospital Tent, they have evolved an automatic repair procedure that continually heals them as a background process.  Through redistribution of power and system resources, they can accelerate their self-repairing properties at the expense of combat efficiency, or vice-versa.  In combat, they are glass cannons - their attacks are devastating, but their bodies are very fragile.  Their lightweight frame, efficient power cells and lack of any sensation of exhaustion all combine to create a race that can travel further and fight longer than any organic race.  In short, Robots are delicate, complex, and thoughtful creatures.`n`nSomeone has added in pencil:`nThey're also bloody hilarious.  Try telling them that Pi is exactly three.  That freaks 'em RIGHT out!");
                    addnav("Continue");
                    addnav("Back to the Hall of Diversity", "runmodule.php?module=newhomemuseum&op=racehall");
                    if (get_module_pref("seenrace6") == 0) {
                        set_module_pref("seenrace6", 1);
                        increment_module_pref("exhibitsseen", 1);
                    }
                    break;
                case "gobot":
                    output("The display in front of you - you hesitate to call it a mannequin - depicts what appears to be a Robot contestant from the waist up, its lower half replaced by a set of four knobbly tyres and a large diesel-powered engine.  The torso of the machine appears to be even more lightweight and frail-looking than the one on the Robot mannequin.`n`n`n");
                    output("A sign at its feet reads:`n`nGOBOT`nGobots are Robots that have modified themselves for faster speeds and longer uptimes.  The addition of a diesel-powered generator and larger battery packs means that this race can travel even further and fight more in a single day.`nGoBots share many of the traits of Robots, but the addition of heavy locomotion equipment necessitates cutting back on armour plating, making them even more susceptible to damage than Robots.  This gives them a not unsignificant disadvantage in combat, as a trade-off against the ability to travel further and fight longer than even their Robot counterparts.`n`nSomeone has added in pencil:`nDon't bother trying to strike up a conversation with them.  They're somewhat hyperactive, and will tear-arse off into the Jungle before you're halfway through saying 'hello,' leaving you coughing on their dust and exhaust fumes.");
                    addnav("Continue");
                    addnav("Back to the Hall of Diversity", "runmodule.php?module=newhomemuseum&op=racehall");
                    if (get_module_pref("seenrace7") == 0) {
                        set_module_pref("seenrace7", 1);
                        increment_module_pref("exhibitsseen", 1);
                    }
                    break;
                case "joker":
                    output("The mannequin is dressed in an impeccable light cream Victorian suit, complete with top hat and cane.  He bears a rather sinister grin, and looks human for all extents and purposes.  A set of LED's mounted carefully in the brim of his hat highlight his eyes with a bright green glow.`n`n`n");
                    output("A sign by his feet reads:`n`nJOKER`nJokers are Humans who have been infused with vast amounts of Improbability.  They are easily recognised by their glowing green eyes.  Jokers react to the happenings in their lives in ways that other races simply cannot understand.  They are often seen as unpredictable, or even insane.  It is commonly believed that Jokers have the power to manipulate reality itself, making them extremely dangerous.  They tend to enjoy games of chance and mind-altering substances, and their interactions with other races range from playful to deadly.`nIn combat, and in every other area of performance, Jokers are unpredictable.  Each day they wake up different to how they went to sleep.  Their bodies are continually changing in shape, size and strength, so it's entirely impossible to gauge their efficacy as soldiers.  Due to their unpredictable nature, Jokers should be treated with extreme caution.`n`nSomeone has added in pencil:`nIf you see them roll a die, just run.");
                    addnav("Continue");
                    addnav("Back to the Hall of Diversity", "runmodule.php?module=newhomemuseum&op=racehall");
                    if (get_module_pref("seenrace8") == 0) {
                        set_module_pref("seenrace8", 1);
                        increment_module_pref("exhibitsseen", 1);
                    }
                    break;
            }
            break;
        case "relichall":
            if (httpget("examine") == "") {
                output("You step into the Hall of Relics.  A selection of familiar equipment brings a lump to your throat, making you nostalgic for a time when life was easier.");
                addnav("Examine machines");
                addnav("Examine the computer", "runmodule.php?module=newhomemuseum&op=relichall&examine=computer");
                addnav("Examine the Google", "runmodule.php?module=newhomemuseum&op=relichall&examine=google");
            }
            switch (httpget("examine")) {
                case "computer":
                    output("A computer terminal sits in front of you, behind a glass case.  It looks quite old, but it would have been fairly high-spec in its time - the ReBoard is a folding model, the projection eye is housed seperately to the chassis, and the ThinkCard - or, as some techies call them, the 'Large Dandruff Flake,' or LDF - can be seen through a little window on the side, complete with air holes and nutrient gel.`n`n`n");
                    output("There's a little plaque below it.  It reads:`n`nThis is an early 50's computer, thought to have been used by Doktor Improbable himself.  The ReBoard is an early model which was comparable to low-end portable computers at the time.  In later years, the ReBoard would take over from laptops and sub-laptops, providing a foldable VDU-Keyboard device with non-volatile storage memory.`n`nThe attached monitor is a comparatively primitive low-resolution projection apparatus, and would have required special goggles to use.  Thus, these particular types of monitor never really saw commercial success.`n`nThe computer itself is a post-performance-ceiling model by Commodore, featuring the 'ThinkCard' analogue-digital interpreter developed and engineered by Ikawa Laboratories.`n`nThe ThinkCard is an organic attachment that attempted to assess a human being's actions in contrast to their actual intent.  Since their inception, computers have become more intuitive and user-friendly.  The problem as marketed by Ikawa Laboratories was that computers did what you told them to do, which is not necessarily what you actually wanted them to do; the ThinkCard, being more animal than processor, had genuine analogue intelligence and could consequently form a more natural logical interface between human and machine.`n`nThinkCards are generally believed to be at least partially responsible for the technological singularity which led to the EMP bombings, and have consequently been outlawed.");
                    addnav("Back to the Hall of Relics", "runmodule.php?module=newhomemuseum&op=relichall");
                    if (get_module_pref("seenrelic1") == 0) {
                        set_module_pref("seenrelic1", 1);
                        increment_module_pref("exhibitsseen", 1);
                    }
                    break;
                case "google":
                    output("A little red Google sits inside a dusty glass case.  It's a smaller model with a body about the size of two fingers.  Its IO assembly is extended, adding another few inches in the form of a skinny rod.`n`n`n");
                    output("A plaque below it reads:`n`nThis is a Google from the early 60's.  These models were designed to be worn on the ear.  The IO assembly - shown here extended, containing directional microphone, projector, camera, antennae and accelerometer - records images, remembers shapes, faces and landmarks, and projects directions and information directly onto the retina, allowing the user to receive an answer to the immortal question used in advertising campaigns across the world - 'Google, where did I put my keys?'`n`nOf course, early Googles were prone to rather embarrassing quirks.  Quite a few users asked their Googles to find some possession, arrows denoting the direction of the item would be superimposed over their vision, and the user would follow the arrows all the way home - only to find that the last place the Google saw it was in a mirror, in the user's hand.`nDespite these drawbacks, by the 70's Googles had all but replaced mobile phones, netbooks and PDA's as communications and mobile computing equipment.");
                    addnav("Back to the Hall of Relics", "runmodule.php?module=newhomemuseum&op=relichall");
                    if (get_module_pref("seenrelic2") == 0) {
                        set_module_pref("seenrelic2", 1);
                        increment_module_pref("exhibitsseen", 1);
                    }
                    break;
            }
            break;
        case "revolutionhall":
            if (httpget("examine") == "") {
                output("You step into the Hall of Revolutions.  A selection of bulky, heavy-looking equipment stands around you.  Many of the displays look half-finished - perhaps this area is still under construction.  There only appears to be one functional exhibit.");
                addnav("Examine machines");
                addnav("Examine the computer", "runmodule.php?module=newhomemuseum&op=revolutionhall&examine=computer");
            }
            switch (httpget("examine")) {
                case "computer":
                    output("A modern computer terminal sits in front of you, behind a glass case.  It's at once oddly beautiful and hideously ugly - its design speaks of combined despair and hope, the rebuilding of an age lost to fear and anger.`n`nIts keyboard - computers have keyboards again, who'd have thought it? - is a DVORAK-layout, microswitched monstrosity reminiscent of a Victorian typewriter, connected to the main chassis with a wiring harness as thick as three fingers.  The display is turned on and running - a large, round blur that appears to hang in midair, displaying bright green text in a fixed-width font, generated by a spinning rod with mounted LED's and powered by your own persistence of vision.  It gives off a pleasant breeze.  It too is connected to the chassis with an enormous wiring harness, the individual wires held in place with cable ties.`n`nThe chassis itself is built into the desk on which the computer sits.  It is a thing of clicking relays and humming vacuum tubes and fizzing electrical valves and clacking mechanical sequencers and shining brass and deep dark wood and polished glass.  It's oddly beautiful, if very, very loud.`n`n`n");
                    output("The plaque below it reads:`n`nThis is a modern computer.  It contains no integrated circuitry whatsoever, and thus cannot be damaged by an electromagnetic pulse.  Its design was influenced by several factors; firstly, the very real, very urgent need to rebuild civilisation, particularly with regard to information and communications.  Secondly, the fact that since processors have not been designed or built by unaided human beings for over fifty years, recreating a modern silicon-based computer, even from plans, was impossible.  Thirdly, paranoia about a possible repeat of the EMP incident meant that consumers demanded equipment that could withstand a surge, and were prepared to give up some bells and whistles for it.`nNote the three brass memory allocation pedals beneath the desk, and the throttle lever.  A skilled operator can make this computer perform up to five times as many calculations in one minute as an unskilled operator.  Due to the death of the ThinkCard, computers no longer understand either humans or themselves - they are simply machines again, and must be told explicitly what to do.");
                    addnav("Continue");
                    addnav("Back to the Hall of Revolutions", "runmodule.php?module=newhomemuseum&op=revolutionhall");
                    if (get_module_pref("seenrevo1") == 0) {
                        set_module_pref("seenrevo1", 1);
                        increment_module_pref("exhibitsseen", 1);
                    }
                    break;
            }
    }
    addnav("Return");
    if (httpget("op") != "lobby") {
        addnav("Back to the Lobby", "runmodule.php?module=newhomemuseum&op=lobby");
    }
    addnav("Leave the Museum", "village.php");
    page_footer();
}
function example_run()
{
    //Yup, we're still gonna need that $session array!
    global $session;
    //If we don't declare a page header - IE a title for the page - then the page simply won't load.  At all.  The player will be left staring at a blank white screen and muttering "What muppet coded this?"  Never forget!
    page_header("Do the Three-Door Shuffle!");
    //We need to retrieve, from the database, the pref for whether or not the player's played today.  We'll need it soon.  Let's assign it to a variable - it'll save typing later on, and make the size of this file smaller.  While we're at it, let's get the other pref as well.
    $playedtoday = get_module_pref("playedtoday");
    $playedtotal = get_module_pref("playedtotal");
    //httpget lets us grab a part of the page's URL.  The first time the player encounters this module, they'll go to "improbableisland.com/runmodule.php?module=example[which is the filename of the module without the .php bit, remember]" - note the conspicuous absence of 'op' in there.  As they move through the pages, they'll go to "improbableisland.com/runmodule.php?module=example&op=[something]".  It's that [something] that we want to get!  We traditionally call the variable 'op' which is short for 'operation,' but you can call it whatever you like.  You can even get fancy and use multiple httpget requests for more complex modules with addresses like "improbableisland.com/runmodule.php?module=breaktheserver&action=breakitagain&weapon=axe&target=harddrive&force=allofitbabyyeah", but this module's just about the basics.
    //Oh, and you remember "switch", right?  You met earlier.
    switch (httpget('op')) {
        default:
            //We're talking now about an instance where there is no 'op' in the page's URL.  This must mean that the player's on the first page of the module.  let's set the scene!
            //Our first output statement!  This is like echo, but it's actually a special function built into Legend of the Green Dragon which will put in our colour codes and make sure we're not doing anything silly.
            output("`0Some old Joker geezer shows you three doors, and says that there's something nice or nasty behind each one.  Whatever, we'll put some proper flavour text in here later.  This module would `inever`i have gotten past CavemanJoe with flavour text this lame.  God, he's such an asshole.  Good thing he won't be reading this.`n`nAnyway, we're using tilde-n for new lines.  Just testin' that.  And when we want to output something in quotation marks, we have to escape it with a slash, like this:`n`n\"`3Come and look in my doors!`0\" shouts the old geezer.  Traditionally characters' colour codes will change only inside their quotation marks, descriptive text will usually be black, and the player's text will usually have colourcode #.  So, you've got three doors in front of you; now whatcha gonna do about it?  HUH?`n`n");
            //Now, let's see how to add in a variable in an output statement... Damn, I'm making this sound a lot more complicated than it actually is.  Just read it, it'll be quicker than me trying to explain it.  We use %s as placeholders for our variables.
            output("You've played a total of %s times.`n`n", $playedtotal);
            //If we want to do more than one variable in an output statement, we basically just use more %s's and more commas:
            output("I SAID, you've played a total of %s times.  That's %s times!`n`n", $playedtotal, $playedtotal);
            //You remember if statements, right?  Of course you do.
            if ($playedtoday == 0) {
                //They haven't played today, so let's give them some links to click.
                addnav("Open the first door!", "runmodule.php?module=example&op=door1");
                addnav("Open the second door!", "runmodule.php?module=example&op=door2");
                addnav("Open the third door!", "runmodule.php?module=example&op=door3");
            } else {
                //give them an unclickable link that goes nowhere!
                addnav("I'm not gonna do jack, pal.  I've already done this today.", "");
            }
            break;
        case "door1":
            //The player went for the first door.  Now, let's give the first door a fifty-fifty chance of something nice versus something nasty.
            //Gimme a random number between one and a hundred, and we'll call it $chance:
            $chance = e_rand(1, 100);
            //is the random number less than or equal to fifty?
            if ($chance <= 50) {
                //yes, the random number is less than or equal to fifty.  Output some flavour text!
                output("You've won some gold OH MY GOODNESS I MEAN REQUISITION.  Proper flavour text for that picky bastard Admin CavemanJoe.`n`n");
                //Give the player five gold pieces, because the game doesn't know that we call gold Requisition!  That'll help them in their quest to slay the dragon I MEAN THE IMPROBABILITY DRIVE
                $session['user']['gold'] += 5;
            } else {
                //$chance is NOT equal to or less than fifty.  In other words, it's 51 or more!
                output("A midget steals some Requisition or something.`n`n");
                //Oh dear - what happens if the player has LESS than 5 Requisition?  They'll get a negative number showing in their stats bar!  It'll get sorted out back to zero on their next page load, but in the meantime it just looks ugly!  So, we'll do another IF statement.  This one's fairly self-explanatory:
                if ($session['user']['gold'] >= 5) {
                    $session['user']['gold'] -= 5;
                } else {
                    $session['user']['gold'] = 0;
                }
            }
            //What are we forgetting?  The player has played today, so we must update their pref so they can't play again!
            set_module_pref("playedtoday", 1);
            //Now, we'll increase the number of times they've played by one.
            increment_module_pref("playedtotal", 1);
            //There isn't a decrement_module_pref function - if we wanted to take one away, we'd do the same as we've just done, but make the final argument -1 instead.
            //and that's the end of door number one!
            break;
        case "door2":
            //door one was a bit boring.  A bit low-stakes.  A bit dull.  Let's play with the numbers and liven things up a bit.
            $chance = e_rand(1, 100);
            if ($chance <= 10) {
                output("You open the door and a cigarette falls out, followed by two hundred and fifty Requisition tokens!  How very Improbable.`n`n");
                $session['user']['gems']++;
                $session['user']['gold'] += 250;
                //Yes, cigarettes were originally gems in Legend of the Green Dragon!
            } else {
                //Since getting a cigarette AND a couple of hundred Req is a pretty awesome prize, we're only giving it a ten per cent chance of appearing.  The other ninety times out of a hundred, the Cake or Death guy shows up and gives you some poisoned cake.  This code is lifted pretty well straight out of the code for Cake or Death.
                //The Cake or Death man doesn't exactly KO the player.  When you KO a player, you have to mess about with taking away all their navs and making sure they end up on the FailBoat's Daily News page, and it's a bit of a pain in the bum.  So I like to just poison the crap out of them instead! :D
                output("You open the door to find a green-eyed gentleman standing behind it.  He hands you a slice of cake, on a paper plate!  You thank him, and walk away merrily wolfing down your prize.`n`nYou feel `5Full Of Cake!`0`n`nMoments later, the slow-acting poison starts to take effect.  The world begins to melt in front of you.  Grey spots dance on the edges of your vision.  Behind you, a green-eyed monster offers you another slice of cake, laughing and pointing.`n`nYou curse your luck as the hallucinations begin to kick in.");
                //We're gonna do an example buff now.  I could type about this all night, but you can learn more about buffs at http://wiki.dragonprime.net/index.php?title=Buffs.
                apply_buff('failcake', array("name" => "`5Full Of FailCake`0", "rounds" => -1, "regen" => -10, "startmsg" => "`5You are walking on pink icing.  The sky is made of jam.  Your eyes are two cherries.  That cake was awesome.`0`n", "roundmsg" => "`5The poisoned cake saps your strength, and you lose ten hitpoints!`0`n", "schema" => "module-cakeordeath"));
            }
            //What are we forgetting?  The player has played today, so we must update their pref so they can't play again!
            set_module_pref("playedtoday", 1);
            //Now, we'll increase the number of times they've played by one.
            increment_module_pref("playedtotal", 1);
            //There isn't a decrement_module_pref function - if we wanted to take one away, we'd do the same as we've just done, but make the final argument -1 instead.
            //We're done with Door Two!
            break;
        case "door3":
            //in Door 3 we'll be interacting with my Stamina system.  The Stamina system isn't part of Legend of the Green Dragon - in LotGD, and in Improbable Island prior to Season Two, we used Turns instead.  I've designed the Stamina system to be very easy to use!  Adding and removing Stamina is a piece of cake - just use the functions addstamina(x); or removestamina(x);, where x is the number of Stamina points to add or remove.
            //since the Stamina system is in itself a (rather large) module and not part of the core, whenever we want to use it we've got to tell the game to find its lib file so it knows what we're talking about when we use its functions.  So, let's do that:
            require_once "modules/staminasystem/lib/lib.php";
            //Now we can get on with it, knowing that our functions for interacting with Stamina are already loaded.
            $chance = e_rand(1, 100);
            //We'll make this door rather a nice door.  Most of the time, anyway.
            if ($chance <= 90) {
                output("You open the door and a soft white light envelopes you.  You feel mildly energized.  You gain some Stamina!`n`n");
                addstamina(5000);
                //See how easy that was?
            } else {
                //But every now and then, this door will be an absolute bastard.
                output("You open the door and a huge round boulder comes rolling out!  You lose a whole load of Stamina running away from it, until you gain the common sense to just step out of its way!`n`n");
                removestamina(50000);
                //We don't even need to check if the player has 50,000 Stamina points to take away, because the Stamina system is clever and checks for us!
            }
            //What are we forgetting?  The player has played today, so we must update their pref so they can't play again!
            set_module_pref("playedtoday", 1);
            //Now, we'll increase the number of times they've played by one.
            increment_module_pref("playedtotal", 1);
            //There isn't a decrement_module_pref function - if we wanted to take one away, we'd do the same as we've just done, but make the final argument -1 instead.
            //And that's it for door number three!
            break;
    }
    //Now, we're at the end of our possible decisions and outcomes.  Because we're out of the switch, we can add in some things that we'll always need, in this module anyway.  We'll give the player a link to take them back to the player-created modules area, so that they can get out of this module, and we'll call page_footer so that all of this information is displayed to the player.
    addnav("Go back where you came from", "runmodule.php?module=labs");
    //If we don't call page_footer, none of what we've just coded up will be shown to the player!  This is just as important as page_header!
    page_footer();
    //...and we're done!  I hope you've enjoyed reading along in this module and learning about programming for Improbable Island and Legend of the Green Dragon!
    //So, what can you do with what you already know?  Well, how about modifying this very file?  Here are some things for you to try:
    //1.  (easy) Add a fourth door.  That should be pretty easy!  But what to put behind it?  Maybe it can give different sorts of buffs?  The Buffs page in the DragonPedia will help you.  Use your imagination!
    //2.  (easyish) Right now, that counter is just a counter, nothing more.  Surely we could do something interesting with that!  Maybe, after playing the game more than x number of times, a fifth or even sixth door will become available?
    //3.  (harder) Maybe the number of times the game has been played can affect the player's luck?  How would you do that?
    //4.  (harder) By adding another pref in the moduleinfo function, we can make this module more complex and exciting.  A simple boolean pref could, for example, determine whether a player has an item or not - a key to the seventh door, for example...
    //Have fun!
}
function mementos_run()
{
    global $session;
    page_header("Memento Forge");
    $op = httpget('op');
    $pointsavailable = $session['user']['donation'] - $session['user']['donationspent'];
    require_once "modules/wcgpoints.php";
    $cstones = wcgpoints_getpoints();
    switch (httpget('op')) {
        case "start":
            $moulds = load_inventory("mementomoulds_" . $session['user']['acctid'], true);
            if (count($moulds)) {
                output("Here are the original prototypes of Mementos you have made.`n`n");
                rawoutput("<table width=100% style='border: dotted 1px #000000;'>");
                $classcount = 1;
                $moulds = modulehook("mementos", $moulds);
                foreach ($moulds as $id => $prefs) {
                    $classcount++;
                    $class = $classcount % 2 ? "trdark" : "trlight";
                    rawoutput("<tr class='{$class}'><td>");
                    output("`b%s`b`0`n", stripslashes($prefs['verbosename']));
                    output("%s`0`n`n", stripslashes($prefs['description']));
                    output("`bUse Text`b:%s`0`n`n", stripslashes($prefs['usetext']));
                    if ($prefs['mouldusesleft']) {
                        output("You can make another %s of these, at `6`b250`b CobbleStones`0 and `5`b1`b Supporter Point`0 each.`n", $prefs['mouldusesleft']);
                        rawoutput("<a href='runmodule.php?module=mementos&op=makecopy&itemid=" . $id . "'>Make a copy</a><br />");
                    } else {
                        if (!isset($prefs['mouldusesleft'])) {
                            output("You can make a mould for this Memento, enabling you to make copies using `6CobbleStones`0.  It'll cost you `5500 Supporter Points`0.`n");
                            rawoutput("<a href='runmodule.php?module=mementos&op=makecopy&itemid=" . $id . "'>Make a mould</a><br />");
                        } else {
                            output("This mould is too old and knackered to make any more Mementos, but you can re-forge it for `5500 Supporter Points`0.`n");
                            rawoutput("<a href='runmodule.php?module=mementos&op=makecopy&itemid=" . $id . "'>Make a mould</a><br />");
                        }
                    }
                    addnav("", "runmodule.php?module=mementos&op=makecopy&itemid=" . $id);
                    if (is_array($prefs['memento_forge_actions']) && count($prefs['memento_forge_actions'])) {
                        foreach ($prefs['memento_forge_actions'] as $action) {
                            rawoutput($action);
                        }
                    }
                    rawoutput("</td></tr>");
                }
                rawoutput("</table>");
            } else {
                //if there are no moulds
                output("You're about to ask the grinning Joker proprietor about these Memento things you've been hearing about, when suddenly the knowledge rushes into your head unbidden.`n`nMementos are player-created objects that can be given to other players.  They grant no in-game advantages, but are fun for roleplaying.  Players often roleplay giving items to each other, but with Mementos, those items can appear in Inventories and act like 'real' in-game items.`n`n`n`bWhat you need to know about Mementos`b`nMementos are weightless, and occupy the 'Shoebox' portion of the player's Inventory.  Mementos survive Drive Kills, and don't go away when 'used.'  They can only be destroyed by being discarded by the player.  They can also be put down and picked up on map squares, and gifted to other players for free (anonymously if desired) via Common Ground's Gifting Station.`n`nYou can specify the Name (shown in the Inventory) of the Memento, the Plural form of the name, the Description (shown in the Inventory), and the Use Text (shown when the player 'uses' the Memento).`n`n`n`bCosts`b`nYou can create a single Memento at a flat cost of `550 Supporter Points`0.  You can also create Memento Moulds, at a cost of `5500 Supporter Points`0 for the mould and the first Memento, plus `5one Supporter Point`0 and `6250 CobbleStones`0 for each of up to fifty copies of that Memento.  Single Mementos can be upgraded to Memento Moulds later on if you like.`n`n`n`bExample Memento`b`n`bName:`b Red Music Box`n`bPlural:`b Red Music Boxes`n`bDescription:`b An ornate red wooden music box, decorated with cut garnets and shiny stainless-steel edging.`n`bUse Text`b: You open up the music box.  Inside is a tiny demon, smoking a cigarette.  Noticing that his house is open, he hurriedly stamps out his smoke and launches into a stirring rendition of 'NewHome is Full of Noobs.'  You close the lid quickly.`n`nEach Memento can have 100 characters for the Name, 100 characters for the Plural name, 255 characters for the Description, and 1,000 characters for the Use Text.`n`n");
            }
            addnav("Memento Stuff");
            if ($pointsavailable >= 50) {
                addnav("Create new single Memento", "runmodule.php?module=mementos&op=new&type=single");
            } else {
                addnav("You need 50 Supporter Points for a single Memento", "");
            }
            if ($pointsavailable >= 500) {
                addnav("Create new Memento Mould", "runmodule.php?module=mementos&op=new&type=mould");
            } else {
                addnav("You need 500 Supporter Points for a Memento Mould", "");
            }
            break;
        case "makecopy":
            $giveitem = false;
            $itemid = httpget("itemid");
            $name = get_item_pref("verbosename", $itemid);
            $plural = get_item_pref("plural", $itemid);
            $desc = get_item_pref("description", $itemid);
            $usetext = get_item_pref("usetext", $itemid);
            $moulduses = get_item_pref("mouldusesleft", $itemid);
            if ($moulduses > 0) {
                if ($cstones >= $cscost) {
                    output("You've bought a new %s`0 using `6CobbleStones`0!  Would you like to buy another, or head back to the Memento Forge menu?`n`n", $name);
                    $giveitem = true;
                    increment_module_pref("spent", 250, "wcgpoints");
                    $cstones = wcgpoints_getpoints();
                    $session['user']['donationspent'] += 1;
                    //log purchase
                    $logsql = "INSERT INTO " . db_prefix("purchaselog") . " (acctid,purchased,amount,data,giftwrap,timestamp) VALUES ('" . $session['user']['acctid'] . "','memento_copy_cobblestone','1','none','0','" . date("Y-m-d H:i:s") . "')";
                    db_query($logsql);
                } else {
                    output("`4You don't have enough `6CobbleStones`0 to make another copy of that Memento, I'm afraid.`n`n");
                }
            }
            $pointsavailable = $session['user']['donation'] - $session['user']['donationspent'];
            if ($giveitem) {
                $prefs = get_item_prefs($itemid);
                unset($prefs["mouldusesleft"]);
                $prefs['memento_originalitem'] = $itemid;
                give_item("memento", $prefs);
                $moulduses--;
                set_item_pref("mouldusesleft", $moulduses, $itemid);
            }
            if ($moulduses > 0) {
                output("You're about a make a new copy of the Memento called `b%s`b`0.  This will cost `6250 CobbleStones`0 and `5one Supporter Point`0.  You now have `5%s Supporter Points`0 and `6%s CobbleStones`0, and this mould will make `b%s`0 more Mementos.`n`n", $name, number_format($pointsavailable), number_format($cstones), $moulduses);
                addnav("Buy");
                if ($cstones >= $cscost && $pointsavailable) {
                    addnav("Buy a copy", "runmodule.php?module=mementos&op=makecopy&itemid=" . $itemid);
                } else {
                    addnav("Not enough `6CobbleStones`0 (or you don't have a `5Supporter Point`0 left)", "");
                }
            } else {
                output("Either this mould is knackered, or this is a unique Memento.  You can't make any more copies.  However, you can make a new mould if you like, for `5500 Supporter Points`0.  This will enable you to make further copies of the Memento for `5one Supporter Point`0 plus `6250 CobbleStones`0 each.`n`n", $originalcost);
                addnav("Buy");
                if ($pointsavailable >= 500) {
                    addnav("Make a new mould", "runmodule.php?module=mementos&op=reforge&itemid=" . $itemid);
                } else {
                    addnav("Not enough `5Supporter Points`0 to make a new mould", "");
                }
            }
            addnav("Return");
            addnav("Memento Forge", "runmodule.php?module=mementos&op=start");
            break;
        case "reforge":
            $itemid = httpget("itemid");
            output("You've successfully recreated the mould for your Memento.`n`n");
            set_item_pref("mouldusesleft", 50, $itemid);
            addnav("Return");
            addnav("Memento Forge", "runmodule.php?module=mementos&op=start");
            $session['user']['donationspent'] += 500;
            $logsql = "INSERT INTO " . db_prefix("purchaselog") . " (acctid,purchased,amount,data,giftwrap,timestamp) VALUES ('" . $session['user']['acctid'] . "','memento_mould','500','none','0','" . date("Y-m-d H:i:s") . "')";
            db_query($logsql);
            break;
        case "new":
            $type = httpget('type');
            if ($type == 'single') {
                output("You're making a new unique Memento now.  Create your desired item and hit Submit.  You can use colour codes and italics just like in commentary, and you can use bold too, using the ``b switch (remember to close your bolds and italics with another ``b or ``i!).`n`nRemember to use ``n for a new line rather than pressing Enter.  Use ``n``n for a line break between paragraphs.`n`n");
                rawoutput("<form action='runmodule.php?module=mementos&op=check&type=single' method='POST'>Memento Name (maximum 100 characters): <input name='name' id='name'><br /><br />Plural (maximum 100 characters): <input name='plural' id='plural'><br /><br />Memento Description (maximum 255 characters):<br />");
                addnav("", "runmodule.php?module=mementos&op=check&type=single");
            } else {
                if ($type == 'mould') {
                    output("You're making a new Memento Mould now.  Create your desired item and hit Submit.  You can use colour codes and italics just like in commentary, and you can use bold too, using the ``b switch (remember to close your bolds and italics with another ``b or ``i!).`n`nRemember to use ``n for a new line rather than pressing Enter.  Use ``n``n for a line break between paragraphs.`n`n");
                    rawoutput("<form action='runmodule.php?module=mementos&op=check&type=mould' method='POST'>Memento Name (maximum 100 characters): <input name='name' id='name'><br /><br />Plural (maximum 100 characters): <input name='plural' id='plural'><br /><br />Memento Description (maximum 255 characters):<br />");
                    addnav("", "runmodule.php?module=mementos&op=check&type=mould");
                }
            }
            require_once "lib/forms.php";
            previewfield_countup("description");
            rawoutput("<br /><br />Text shown when using the Memento (maximum 1,000 characters):<br />");
            previewfield_countup("usetext");
            rawoutput("<br /><input type=submit>");
            addnav("Start Again");
            addnav("Memento Forge", "runmodule.php?module=mementos&op=start");
            break;
        case "check":
            output("Here's a preview of your Memento:`n`n");
            $rname = httppost("name");
            $rplural = httppost("plural");
            $rdesc = httppost("description");
            $rusetext = httppost("usetext");
            $type = httpget("type");
            $dname = stripslashes($rname);
            $dplural = stripslashes($rplural);
            $ddesc = stripslashes($rdesc);
            $dusetext = stripslashes($rusetext);
            output("`bName:`b %s`0 (%s`0)`n`bDescription:`b %s`0`n`bUse Text:`b %s`0`n`n", $dname, $dplural, $ddesc, $dusetext);
            if (strlen($dname) <= 100 && strlen($dplural) <= 100 && strlen($ddesc) <= 255 && strlen($dusetext) <= 1000) {
                addnav("Confirm");
                if ($type == "single") {
                    addnav("Buy it! (`550 Supporter Points`0)", "runmodule.php?module=mementos&op=confirm&name=" . urlencode($rname) . "&plural=" . urlencode($rplural) . "&desc=" . urlencode($rdesc) . "&usetext=" . urlencode($rusetext) . "&type=single");
                } else {
                    if ($type == "mould") {
                        addnav("Buy it! (`5500 Supporter Points`0)", "runmodule.php?module=mementos&op=confirm&name=" . urlencode($rname) . "&plural=" . urlencode($rplural) . "&desc=" . urlencode($rdesc) . "&usetext=" . urlencode($rusetext) . "&type=mould");
                    }
                }
            } else {
                output("`4`bError: Something is too long.  Titles can be up to 100 characters, descriptions up to 255 characters, and usage texts up to 1,000 characters.`b`0`n`n");
                rawoutput("<form action='runmodule.php?module=mementos&op=check&type=" . $type . "' method='POST'>Memento Name (maximum 100 characters): <input name='name' id='name' value={$rname}><br /><br />Plural (maximum 100 characters): <input name='plural' id='plural' value={$rplural}><br /><br />Memento Description (maximum 255 characters):<br />");
                require_once "lib/forms.php";
                previewfield_countup("description", 255, $rdesc);
                rawoutput("<br /><br />Text shown when using the Memento (maximum 1,000 characters):<br />");
                previewfield_countup("usetext", 1000, $rusetext);
                rawoutput("<br /><input type=submit>");
                addnav("", "runmodule.php?module=mementos&op=check&type=" . $type);
            }
            addnav("Start Again");
            addnav("Memento Forge", "runmodule.php?module=mementos&op=start");
            break;
        case "confirm":
            $type = httpget("type");
            $name = urldecode(httpget("name"));
            $plural = urldecode(httpget("plural"));
            $desc = urldecode(httpget("desc"));
            $usetext = urldecode(httpget("usetext"));
            $prefs = array("verbosename" => $name, "plural" => $plural, "description" => $desc, "usetext" => $usetext, "memento_author" => $session['user']['acctid']);
            if ($type == "single") {
                $cost = 50;
                output("You've made a new Memento.  You can find it in your Inventory!");
            } else {
                if ($type == "mould") {
                    $cost = 500;
                    output("You've made a mould for your new Memento, and the first Memento from that mould is now in your Inventory!");
                    $prefs['mouldusesleft'] = 50;
                }
            }
            $session['user']['donationspent'] += $cost;
            //log purchase
            $logsql = "INSERT INTO " . db_prefix("purchaselog") . " (acctid,purchased,amount,data,giftwrap,timestamp) VALUES ('" . $session['user']['acctid'] . "','memento_" . $type . "','" . $cost . "','none','0','" . date("Y-m-d H:i:s") . "')";
            db_query($logsql);
            //create the mould, track its id
            $id = give_item("memento", $prefs, "mementomoulds_" . $session['user']['acctid'], true);
            //debug($id);
            $prefs['memento_originalitem'] = $id;
            set_item_pref("memento_originalitem", $id, $id);
            //give the player the initial memento
            give_item("memento", $prefs);
            addnav("Return");
            addnav("Memento Forge", "runmodule.php?module=mementos&op=start");
            break;
    }
    addnav("Return");
    addnav("Back to the Hunter's Lodge", "runmodule.php?module=iitems_hunterslodge&op=start");
    page_footer();
}
function improbablestuff_run()
{
    global $session;
    $from = httpget("from");
    $use = httpget("use");
    page_header("Using Supplies");
    if ($use == "smallmedkit") {
        $session['user']['hitpoints'] += 20;
        if ($session['user']['hitpoints'] > $session['user']['maxhitpoints']) {
            $session['user']['hitpoints'] = $session['user']['maxhitpoints'];
        }
        output("You take a few moments to patch yourself up using a Small Medkit.  Your hitpoints have been restored to %s.", $session[user][hitpoints]);
        set_module_pref("item1number", get_module_pref("item1number") - 1);
    }
    if ($use == "largemedkit") {
        $session['user']['hitpoints'] += 60;
        if ($session['user']['hitpoints'] > $session['user']['maxhitpoints']) {
            $session['user']['hitpoints'] = $session['user']['maxhitpoints'];
        }
        output("You take a few moments to patch yourself up using a Large Medkit.  Your hitpoints have been restored to %s.", $session[user][hitpoints]);
        set_module_pref("item2number", get_module_pref("item2number") - 1);
    }
    if ($use == "energydrink") {
        increment_module_pref("nutrition", 5, "staminafood");
        require_once "modules/staminasystem/lib/lib.php";
        addstamina(25000);
        set_module_pref("item3number", get_module_pref("item3number") - 1);
        output("You unscrew the cap on your Energy Drink and gulp it down.`n`nYou gain some Stamina!");
    }
    if ($use == "nicotinegum") {
        $addiction = get_module_pref("addiction", "smoking");
        $betweensmokes = 250 - $addiction;
        set_module_pref("betweensmokes", $betweensmokes, "smoking");
        apply_buff("smoking", array("allowinpvp" => 1, "allowintrain" => 1, "rounds" => -1, "schema" => "module-smoking"));
        set_module_pref("item4number", get_module_pref("item4number") - 1);
        output("You chomp down on your Nicotine Gum, and you feel the addiction shakes fade away.");
    }
    if ($use == "repellantspray") {
        $encounter = get_module_pref("encounterchance", "worldmapen");
        $buffvalue = get_module_pref("repellantbuff");
        $encounter -= 25;
        $buffvalue -= 10;
        $buffvalue = $buffvalue / 100;
        if ($encounter < 0) {
            $encounter = 0;
        }
        apply_buff('is5', array("name" => "`^Repellant Spray", "rounds" => -1, "badguyatkmod" => $buffvalue, "badguydefmod" => $buffvalue, "roundmsg" => "{badguy} can't stand the smell of your Monster Repellant Spray, and doesn't want to get too close!", "wearoff" => "The effects of your Monster Repellant Spray seem to have worn off...`n", "schema" => "module-improbablestuff"));
        set_module_pref("encounterchance", $encounter, "worldmapen");
        set_module_pref("repellantbuff", $buffvalue);
        set_module_pref("item10number", get_module_pref("item10number") - 1);
        output("You liberally douse yourself with an entire can of Monster Repellant Spray.  For the rest of this game day, your chances of encountering a monster on the Island Map have been reduced by twenty-five per cent, and monsters you do encounter will be reluctant to attack you.  Your current encounter rate is %s percent of normal, which can be affected by terrain type and other factors.  You can continue soaking your skin and clothes in more cans of the stuff if you like!", $encounter);
    }
    if ($use == "potentpill") {
        apply_buff('is4', array("startmsg" => "`#After swallowing your Power Pill, you feel immediately revitalised!  You gain some Stamina and you are now regenerating some hitpoints!`n", "name" => "`^Power Pill", "rounds" => 10, "regen" => "ceil(<maxhitpoints>/10)+1;", "effectmsg" => "The effects of the Power Pill heal you for {damage} points.", "wearoff" => "The Power Pill effects have worn off.`n", "schema" => "module-improbablestuff"));
        set_module_pref("item5number", get_module_pref("item5number") - 1);
        output("After swalling your Power Pill, you feel immediately revitalised!  You gain some Stamina and will regenerate hitpoints for the next ten rounds of battle!`n");
        require_once "modules/staminasystem/lib/lib.php";
        addstamina(250000);
    }
    if ($use == "rationpack") {
        require_once "modules/staminasystem/lib/lib.php";
        output("You tear open the foil packaging and look inside.`n`nAfter a few moments' contemplation, you let out the heartbroken sigh of every soldier with an empty belly and a full Rat Pack.`n`nThe material inside has been designed to withstand being thrown out of a plane, bounced down a mountain, encased in snow and ice, left out in the sun and/or buried in a swamp for up to three years.  It contains all the essential nutrients required for a soldier to live on for several weeks without dying of malnutrition.  It even comes with dessert in the form of a chocolate bar - one that, according to rumour, has saved the lives of several contestants.  Not for its nutritional value, of which there is none, but for its remarkable bullet-stopping tensile strength.`n`nYou suck thoughtfully on the corner of the material.  Before long it begins to react with your saliva, breaking up and yielding to your teeth, and rewarding you some Stamina as you begin the arduous process of digestion.`n`nIt beats starving.  Just.");
        increment_module_pref("item11number", -1);
        increment_module_pref("fullness", 40, "staminafood");
        increment_module_pref("nutrition", 30, "staminafood");
        increment_module_pref("fat", 10, "staminafood");
        addstamina(100000);
        $full = get_module_pref("fullness", "staminafood");
        if ($full < 0) {
            output("`n`nYou still feel as though you haven't eaten in days.");
        }
        if ($full >= 0 && $full < 50) {
            output("`n`nYou feel a little less hungry.");
        }
        if ($full >= 50 && $full < 100) {
            output("`n`nYou still feel as though you've got room for more!");
        }
        if ($full >= 100) {
            output("`n`nYou're stuffed!  You feel as though you can't possibly eat anything more today.");
        }
    }
    if ($use == "teleporter") {
        $to = httpget("to");
        if ($to == "") {
            if (httpget("bomb") == 1) {
                output("You light the fuse on your Improbability Bomb.  Before you have the chance to toss it at your enemy, it writhes and shifts in your hand, turning into a One-Shot Teleporter - with its relocation matrix already enabled!  ");
            } else {
                output("You press the Big Red Button on your One-Shot Teleporter.  ");
            }
            output("One obligatory blinding flash of light and pain later, you find yourself floating around in empty black nothingness!`n`nA flashing red light and an annoying BEEPing noise from your device insists that you select a destination, and quickly, before you find yourself stuck here or imploded.");
            set_module_pref("item6number", get_module_pref("item6number") - 1);
            $vloc = array();
            $vname = getsetting("villagename", LOCATION_FIELDS);
            $vloc[$vname] = "village";
            $vloc = modulehook("validlocation", $vloc);
            ksort($vloc);
            reset($vloc);
            foreach ($vloc as $loc => $val) {
                addnav(array("Go to %s", $loc), "runmodule.php?module=improbablestuff&use=teleporter&to=" . htmlentities($loc));
            }
        } else {
            output("You quickly select an outpost from the list.  With a sudden jolt, you find yourself standing in the middle of your chosen outpost!  You look around for your teleporting device, but realise that it must have only teleported you, not itself.  What a piece of junk.");
            $session['user']['location'] = $to;
            $session['user']['specialinc'] = "";
            addnav("Back to the Outpost", "village.php");
        }
    }
    if ($use == "kittencard") {
        //expansion, possibly for S3 - more types of kittens for variable Favour rewards.  Ginger ones are her favourite.
        output("`0You nervously hold out the greetings card.  `\$The Watcher`0 looks down at your offering.`n`nShe smiles, taking the card and placing it neatly on her desk with the others.  \"`7Aren't you just `iadorable`i?`0\" she says.  You're not sure whether she's talking about you or the kitten.`n`nYou gain `\$30`0 Favour with `\$The Watcher!`0`n`n");
        $session['user']['deathpower'] += 30;
        increment_module_pref("item13number", -1);
        addnav("Yay for kittens!", "graveyard.php?op=question");
    }
    //Send them back where they came from
    if ($from == "village") {
        addnav("Back to the Outpost", "village.php");
    }
    if ($from == "forest") {
        addnav("Back to the Jungle", "forest.php");
    }
    if ($from == "worldnav") {
        addnav("Back to the World Map", "runmodule.php?module=worldmapen&op=continue");
    }
    page_footer();
    return $args;
}
function ranksystem_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "forest":
            if ($session['user']['dragonkills'] > 0 && get_module_pref("rank") == 0) {
                redirect("runmodule.php?module=ranksystem&op=offer", "Rank System kicking in");
            }
            ranksystem_applyrankbuff();
            break;
        case "dragonkill":
            $i = get_module_pref("rank");
            increment_module_pref("rank" . $i, 1);
            set_module_pref("rank", 0);
            break;
        case "ramiusfavors":
            if (get_module_pref("rank") > 1) {
                addnav("Ask The Watcher to lower your Rank", "runmodule.php?module=ranksystem&op=change");
            }
            break;
        case "newday":
            ranksystem_applyrankbuff();
            break;
        case "alter-gemchance":
            global $options;
            if ($options['type'] == "forest") {
                $modifier = get_module_pref("rank") * get_module_pref("rank");
                $chancereduction = $args['chance'] / 100 * $modifier;
                $args['chance'] -= $chancereduction;
            }
            break;
        case "healmultiply":
            switch (get_module_pref("rank")) {
                case 8:
                    $args['alterpct'] = 2.0;
                    break;
            }
            break;
        case "biostat":
            output("`0This player has defeated the Improbability Drive on the following difficulty ranks:`n`n");
            $totalrank = 0;
            for ($i = 1; $i <= 8; $i++) {
                $victories = get_module_pref("rank" . $i, "ranksystem", $args['acctid']);
                if ($i < 8) {
                    output("Rank %s: %s time(s)`n", $i, $victories);
                }
                $totalrank += $victories * $i;
            }
            output("`4Bastard Rank`0: %s time(s)`n", get_module_pref("rank8", "ranksystem", $args['acctid']));
            if (get_module_pref("rank", "ranksystem", $args['acctid']) < 8) {
                output("They are currently attempting a Rank %s Drive Kill.`n", get_module_pref("rank", "ranksystem", $args['acctid']));
            } else {
                output("This player is currently attempting a `4Bastard Rank`0 Drive Kill!`n");
            }
            $acctid = $args['acctid'];
            $sql = "SELECT dragonkills FROM " . db_prefix("accounts") . " WHERE acctid = {$acctid}";
            $result = db_fetch_assoc(db_query($sql));
            if ($result['dragonkills'] > 0) {
                $averagerank = round($totalrank / $result['dragonkills'], 2);
                output("Their average rank is %s.`n`n", $averagerank);
            }
            break;
        case "village":
            // if (get_module_pref("rank")>7){
            // blocknav("lodge.php");
            // addnav("You can't use the Hunter's Lodge while you're on a Bastard Rank Drive Kill!","");
            // }
            if ($session['user']['dragonkills'] > 0 && get_module_pref("rank") == 0) {
                redirect("runmodule.php?module=ranksystem&op=offer", "Rank System kicking in");
            }
            ranksystem_applyrankbuff();
            break;
    }
    return $args;
}
function quester_finish()
{
    global $session;
    increment_module_pref("questpoints", get_module_pref("questlevel"));
    set_module_pref("questlevel", 0);
    set_module_pref("leveltype", 0);
    set_module_pref("levelname", "");
    set_module_pref("completed", 0);
    set_module_pref("queststage", 1);
    if (is_module_active("cities")) {
        set_module_pref("levelloc", getsetting('villagename', LOCATION_FIELDS));
    }
    $session['user']['gold'] += get_module_setting("bossreward");
    output("`4`bYou have completed this quest!`b`0`n`n");
}
function specialcomments_run()
{
    global $session;
    page_header("The Hunter's Lodge");
    $config = unserialize($session['user']['donationconfig']);
    if (!is_array($config)) {
        $config = array();
    }
    if (httpget('op') == "buy1") {
        $session['user']['donationspent'] += 25;
        increment_module_pref("commentsleft", 1);
        $config = array_push($config, "spent 25 points for 1 Special Comment in the lodge.");
    }
    if (httpget('op') == "buy5") {
        $session['user']['donationspent'] += 100;
        increment_module_pref("commentsleft", 5);
        $config = array_push($config, "spent 100 points for 5 Special Comments in the lodge.");
    }
    if (httpget('op') == "buy60") {
        $session['user']['donationspent'] += 1000;
        increment_module_pref("commentsleft", 60);
        $config = array_push($config, "spent 1000 points for 60 Special Comments in the lodge.");
    }
    if (httpget('op') == "buy200") {
        $session['user']['donationspent'] += 2000;
        increment_module_pref("commentsleft", 200);
        $config = array_push($config, "spent 2000 points for 200 Special Comments in the lodge.");
    }
    $session['user']['donationconfig'] = $config;
    output("You now have %s Special Comments stored up.  To use them, simply use the /special switch, like this:`n/special Admin CavemanJoe saunters through town, oblivious to the fact that he's stark bollock naked.`n/special A cold wind blows through the Outpost, carrying with it a somewhat chilling sense of foreboding.`n/special The clock at the center of AceHigh strikes thirteen, and the Jokers' eyes flash `4red`0 for a second.`n`nColour codes can be used within Special Comments.`n`n`bA quick note on the etiquette of using Special Comments:`b`nThe cost of posting a Special Comment is deliberately high, to ensure that players think carefully about what they want to say.  By all means, use them for mischief, but keep it playful rather than malicious.  If a group of players is engaging in a roleplaying exercise in a given Outpost, try to avoid stepping on the toes of their plotline.  Special Comments are anonymous, but are subject to the same rules of the rest of the Island (the two rules being \"Dont be a dick\" and \"Don't take it seriously\"), and drama-inducing comments will be deleted without refund.  If in doubt, ask a moderator.  Have fun!`n`n", get_module_pref("commentsleft"));
    addnav("Return to the Lodge", "lodge.php");
    page_footer();
}