break;
         case "thorn":
             $text = translate_inline("`!`breflect damage.");
             break;
         case "regen":
             $text = translate_inline("`!`bregenerate your life.");
             break;
         case "ult":
             $text = translate_inline("be `!`bpermanently active!");
             break;
     }
     $price = get_module_setting($type . "aprice");
     $gems = get_module_objpref("clans", $session['user']['clanid'], "gems");
     if ($gems >= $price) {
         $gems -= $price;
         increment_module_objpref("clans", $session['user']['clanid'], "catsactive");
         set_module_objpref("clans", $session['user']['clanid'], $type . "active", 1);
         set_module_objpref("clans", $session['user']['clanid'], "gems", $gems);
         output("You can feel the power of your clan's aura gathering around you.  Your clan's buff will now %s`b`0", $text);
         apply_clan_buff();
     } else {
         output("`\$Your clan bank doesn't have enough gems to purchase the activation!`0");
     }
     break;
 case "upgrade":
     addnav("Return to Clan Buffs", "runmodule.php?module=clanbuffs&op=enter");
     switch ($type) {
         case "atk":
             $text = translate_inline("attack power");
             break;
         case "def":
function improbablestufftrading_run()
{
    global $session;
    $op = httpget("op");
    //city prefs
    //God this is gonna be a mess, would be much better with a serialized item system, perhaps for S3...
    require_once "modules/cityprefs/lib.php";
    $cityid = get_cityprefs_cityid("location", $session['user']['location']);
    $smallmedkitcurrent = get_module_objpref("city", $cityid, "smallmedkit-current");
    $smallmedkitmax = get_module_objpref("city", $cityid, "smallmedkit-max");
    $smallmedkitmin = get_module_objpref("city", $cityid, "smallmedkit-min");
    $smallmedkitbuypct = get_module_objpref("city", $cityid, "smallmedkit-buypct");
    $smallmedkitbuy = round($smallmedkitcurrent / 100 * $smallmedkitbuypct);
    $smallmedkitavail = get_module_objpref("city", $cityid, "smallmedkit-avail");
    $largemedkitcurrent = get_module_objpref("city", $cityid, "largemedkit-current");
    $largemedkitmax = get_module_objpref("city", $cityid, "largemedkit-max");
    $largemedkitmin = get_module_objpref("city", $cityid, "largemedkit-min");
    $largemedkitbuypct = get_module_objpref("city", $cityid, "largemedkit-buypct");
    $largemedkitbuy = round($largemedkitcurrent / 100 * $largemedkitbuypct);
    $largemedkitavail = get_module_objpref("city", $cityid, "largemedkit-avail");
    $energydrinkcurrent = get_module_objpref("city", $cityid, "energydrink-current");
    $energydrinkmax = get_module_objpref("city", $cityid, "energydrink-max");
    $energydrinkmin = get_module_objpref("city", $cityid, "energydrink-min");
    $energydrinkbuypct = get_module_objpref("city", $cityid, "energydrink-buypct");
    $energydrinkbuy = round($energydrinkcurrent / 100 * $energydrinkbuypct);
    $energydrinkavail = get_module_objpref("city", $cityid, "energydrink-avail");
    $nicotinegumcurrent = get_module_objpref("city", $cityid, "nicotinegum-current");
    $nicotinegummax = get_module_objpref("city", $cityid, "nicotinegum-max");
    $nicotinegummin = get_module_objpref("city", $cityid, "nicotinegum-min");
    $nicotinegumbuypct = get_module_objpref("city", $cityid, "nicotinegum-buypct");
    $nicotinegumbuy = round($nicotinegumcurrent / 100 * $nicotinegumbuypct);
    $nicotinegumavail = get_module_objpref("city", $cityid, "nicotinegum-avail");
    $powerpillcurrent = get_module_objpref("city", $cityid, "powerpill-current");
    $powerpillmax = get_module_objpref("city", $cityid, "powerpill-max");
    $powerpillmin = get_module_objpref("city", $cityid, "powerpill-min");
    $powerpillbuypct = get_module_objpref("city", $cityid, "powerpill-buypct");
    $powerpillbuy = round($powerpillcurrent / 100 * $powerpillbuypct);
    $powerpillavail = get_module_objpref("city", $cityid, "powerpill-avail");
    $teleportercurrent = get_module_objpref("city", $cityid, "teleporter-current");
    $teleportermax = get_module_objpref("city", $cityid, "teleporter-max");
    $teleportermin = get_module_objpref("city", $cityid, "teleporter-min");
    $teleporterbuypct = get_module_objpref("city", $cityid, "teleporter-buypct");
    $teleporterbuy = round($teleportercurrent / 100 * $teleporterbuypct);
    $teleporteravail = get_module_objpref("city", $cityid, "teleporter-avail");
    $banggrenadecurrent = get_module_objpref("city", $cityid, "banggrenade-current");
    $banggrenademax = get_module_objpref("city", $cityid, "banggrenade-max");
    $banggrenademin = get_module_objpref("city", $cityid, "banggrenade-min");
    $banggrenadebuypct = get_module_objpref("city", $cityid, "banggrenade-buypct");
    $banggrenadebuy = round($banggrenadecurrent / 100 * $banggrenadebuypct);
    $banggrenadeavail = get_module_objpref("city", $cityid, "banggrenade-avail");
    $whoomphgrenadecurrent = get_module_objpref("city", $cityid, "whoomphgrenade-current");
    $whoomphgrenademax = get_module_objpref("city", $cityid, "whoomphgrenade-max");
    $whoomphgrenademin = get_module_objpref("city", $cityid, "whoomphgrenade-min");
    $whoomphgrenadebuypct = get_module_objpref("city", $cityid, "whoomphgrenade-buypct");
    $whoomphgrenadebuy = round($whoomphgrenadecurrent / 100 * $whoomphgrenadebuypct);
    $whoomphgrenadeavail = get_module_objpref("city", $cityid, "whoomphgrenade-avail");
    $zapgrenadecurrent = get_module_objpref("city", $cityid, "zapgrenade-current");
    $zapgrenademax = get_module_objpref("city", $cityid, "zapgrenade-max");
    $zapgrenademin = get_module_objpref("city", $cityid, "zapgrenade-min");
    $zapgrenadebuypct = get_module_objpref("city", $cityid, "zapgrenade-buypct");
    $zapgrenadebuy = round($zapgrenadecurrent / 100 * $zapgrenadebuypct);
    $zapgrenadeavail = get_module_objpref("city", $cityid, "zapgrenade-avail");
    $repellentspraycurrent = get_module_objpref("city", $cityid, "repellentspray-current");
    $repellentspraymax = get_module_objpref("city", $cityid, "repellentspray-max");
    $repellentspraymin = get_module_objpref("city", $cityid, "repellentspray-min");
    $repellentspraybuypct = get_module_objpref("city", $cityid, "repellentspray-buypct");
    $repellentspraybuy = round($repellentspraycurrent / 100 * $repellentspraybuypct);
    $repellentsprayavail = get_module_objpref("city", $cityid, "repellentspray-avail");
    $rationpackcurrent = get_module_objpref("city", $cityid, "rationpack-current");
    $rationpackmax = get_module_objpref("city", $cityid, "rationpack-max");
    $rationpackmin = get_module_objpref("city", $cityid, "rationpack-min");
    $rationpackbuypct = get_module_objpref("city", $cityid, "rationpack-buypct");
    $rationpackbuy = round($rationpackcurrent / 100 * $rationpackbuypct);
    $rationpackavail = get_module_objpref("city", $cityid, "rationpack-avail");
    $improbabilitybombcurrent = get_module_objpref("city", $cityid, "improbabilitybomb-current");
    $improbabilitybombmax = get_module_objpref("city", $cityid, "improbabilitybomb-max");
    $improbabilitybombmin = get_module_objpref("city", $cityid, "improbabilitybomb-min");
    $improbabilitybombbuypct = get_module_objpref("city", $cityid, "improbabilitybomb-buypct");
    $improbabilitybombbuy = round($improbabilitybombcurrent / 100 * $improbabilitybombbuypct);
    $improbabilitybombavail = get_module_objpref("city", $cityid, "improbabilitybomb-avail");
    $kittencardcurrent = get_module_objpref("city", $cityid, "kittencard-current");
    $kittencardmax = get_module_objpref("city", $cityid, "kittencard-max");
    $kittencardmin = get_module_objpref("city", $cityid, "kittencard-min");
    $kittencardbuypct = get_module_objpref("city", $cityid, "kittencard-buypct");
    $kittencardbuy = round($kittencardcurrent / 100 * $kittencardbuypct);
    $kittencardavail = get_module_objpref("city", $cityid, "kittencard-avail");
    $bribe = get_module_objpref("city", $cityid, "bribe");
    $acceptingbribes = get_module_objpref("city", $cityid, "acceptingbribes");
    page_header("eBoy's Trading Station");
    switch (httpget("op")) {
        case "start":
            output("Already fearing the worst, you head into eBoy's Trading Station.`n`nYour fears are well-founded.  The place is packed with the heaving, sweaty bodies of the hardcore capitalist, shouting \"`iBuy, buy!`i\" and \"`iSell, sell!`i\" and \"`iPut down the chainsaw and let's talk about this!`i\"`n`neBoy himself - although you suspect that this place, like Mike's Chop Shop, is a franchise of which you'll find one in every outpost, so is his name really eBoy?  Whoever he is, he stands on an elevated section of floor behind a tall mahogany counter, grabbing money with one hand and tossing grenades and ration packs over his shoulder with the other.  His arms are a blur.  His speech is the unintelligible, rapid-fire gabble of a professional auctioneer.  His eyes bulge and swivel.  You know he's loving this.`n`n");
            break;
        case "buy":
            $item = httpget("item");
            if (get_module_objpref("city", $cityid, "" . $item . "-avail") <= 0) {
                output("eBoy turns to you and gibbers.`n`n\"Sorrymatejustsoldthelastoneyougottabefasteritsthequickandthedeadaroundherepal.\"  He turns to the next customer in line, leaving you trying to piece together whatever it is that he just said.`n`n");
                break;
            }
            switch ($item) {
                case "smallmedkit":
                    increment_module_pref("item1number", 1, "improbablestuff");
                    $session['user']['gold'] -= $smallmedkitcurrent;
                    increment_module_objpref("city", $cityid, "smallmedkit-avail", -1);
                    break;
                case "largemedkit":
                    increment_module_pref("item2number", 1, "improbablestuff");
                    $session['user']['gold'] -= $largemedkitcurrent;
                    increment_module_objpref("city", $cityid, "largemedkit-avail", -1);
                    break;
                case "energydrink":
                    increment_module_pref("item3number", 1, "improbablestuff");
                    $session['user']['gold'] -= $energydrinkcurrent;
                    increment_module_objpref("city", $cityid, "energydrink-avail", -1);
                    break;
                case "nicotinegum":
                    increment_module_pref("item4number", 1, "improbablestuff");
                    $session['user']['gold'] -= $nicotinegumcurrent;
                    increment_module_objpref("city", $cityid, "nicotinegum-avail", -1);
                    break;
                case "powerpill":
                    increment_module_pref("item5number", 1, "improbablestuff");
                    $session['user']['gold'] -= $powerpillcurrent;
                    increment_module_objpref("city", $cityid, "powerpill-avail", -1);
                    break;
                case "teleporter":
                    increment_module_pref("item6number", 1, "improbablestuff");
                    $session['user']['gold'] -= $teleportercurrent;
                    increment_module_objpref("city", $cityid, "teleporter-avail", -1);
                    break;
                case "banggrenade":
                    increment_module_pref("item7number", 1, "improbablestuff");
                    $session['user']['gold'] -= $banggrenadecurrent;
                    increment_module_objpref("city", $cityid, "banggrenade-avail", -1);
                    break;
                case "whoomphgrenade":
                    increment_module_pref("item8number", 1, "improbablestuff");
                    $session['user']['gold'] -= $whoomphgrenadecurrent;
                    increment_module_objpref("city", $cityid, "whoomphgrenade-avail", -1);
                    break;
                case "zapgrenade":
                    increment_module_pref("item9number", 1, "improbablestuff");
                    $session['user']['gold'] -= $zapgrenadecurrent;
                    increment_module_objpref("city", $cityid, "zapgrenade-avail", -1);
                    break;
                case "repellentspray":
                    increment_module_pref("item10number", 1, "improbablestuff");
                    $session['user']['gold'] -= $repellentspraycurrent;
                    increment_module_objpref("city", $cityid, "repellentspray-avail", -1);
                    break;
                case "rationpack":
                    increment_module_pref("item11number", 1, "improbablestuff");
                    $session['user']['gold'] -= $rationpackcurrent;
                    increment_module_objpref("city", $cityid, "rationpack-avail", -1);
                    break;
                case "improbabilitybomb":
                    increment_module_pref("item12number", 1, "improbablestuff");
                    $session['user']['gold'] -= $improbabilitybombcurrent;
                    increment_module_objpref("city", $cityid, "improbabilitybomb-avail", -1);
                    break;
                case "kittencard":
                    increment_module_pref("item13number", 1, "improbablestuff");
                    $session['user']['gold'] -= $kittencardcurrent;
                    increment_module_objpref("city", $cityid, "kittencard-avail", -1);
                    break;
            }
            output("You fight your way to the front of the crowd and shout your order up to eBoy, slapping your Requisition tokens down on the counter.  Before you can blink, your money is gone and the item you desired sits in its place.  You grab it hastily and stuff it into your backpack as eBoy turns to deal with the next customer.`n`n");
            break;
        case "sell":
            $item = httpget("item");
            switch ($item) {
                case "smallmedkit":
                    increment_module_pref("item1number", -1, "improbablestuff");
                    $session['user']['gold'] += $smallmedkitbuy;
                    increment_module_objpref("city", $cityid, "smallmedkit-avail", 1);
                    break;
                case "largemedkit":
                    increment_module_pref("item2number", -1, "improbablestuff");
                    $session['user']['gold'] += $largemedkitbuy;
                    increment_module_objpref("city", $cityid, "largemedkit-avail", 1);
                    break;
                case "energydrink":
                    increment_module_pref("item3number", -1, "improbablestuff");
                    $session['user']['gold'] += $energydrinkbuy;
                    increment_module_objpref("city", $cityid, "energydrink-avail", 1);
                    break;
                case "nicotinegum":
                    increment_module_pref("item4number", -1, "improbablestuff");
                    $session['user']['gold'] += $nicotinegumbuy;
                    increment_module_objpref("city", $cityid, "nicotinegum-avail", 1);
                    break;
                case "powerpill":
                    increment_module_pref("item5number", -1, "improbablestuff");
                    $session['user']['gold'] += $powerpillbuy;
                    increment_module_objpref("city", $cityid, "powerpill-avail", 1);
                    break;
                case "teleporter":
                    increment_module_pref("item6number", -1, "improbablestuff");
                    $session['user']['gold'] += $teleporterbuy;
                    increment_module_objpref("city", $cityid, "teleporter-avail", 1);
                    break;
                case "banggrenade":
                    increment_module_pref("item7number", -1, "improbablestuff");
                    $session['user']['gold'] += $banggrenadebuy;
                    increment_module_objpref("city", $cityid, "banggrenade-avail", 1);
                    break;
                case "whoomphgrenade":
                    increment_module_pref("item8number", -1, "improbablestuff");
                    $session['user']['gold'] += $whoomphgrenadebuy;
                    increment_module_objpref("city", $cityid, "whoomphgrenade-avail", 1);
                    break;
                case "zapgrenade":
                    increment_module_pref("item9number", -1, "improbablestuff");
                    $session['user']['gold'] += $zapgrenadebuy;
                    increment_module_objpref("city", $cityid, "zapgrenade-avail", 1);
                    break;
                case "repellentspray":
                    increment_module_pref("item10number", -1, "improbablestuff");
                    $session['user']['gold'] += $repellentspraybuy;
                    increment_module_objpref("city", $cityid, "repellentspray-avail", 1);
                    break;
                case "rationpack":
                    increment_module_pref("item11number", -1, "improbablestuff");
                    $session['user']['gold'] += $rationpackbuy;
                    increment_module_objpref("city", $cityid, "rationpack-avail", 1);
                    break;
                case "improbabilitybomb":
                    increment_module_pref("item12number", -1, "improbablestuff");
                    $session['user']['gold'] += $improbabilitybombbuy;
                    increment_module_objpref("city", $cityid, "improbabilitybomb-avail", 1);
                    break;
                case "kittencard":
                    increment_module_pref("item13number", -1, "improbablestuff");
                    $session['user']['gold'] += $kittencardbuy;
                    increment_module_objpref("city", $cityid, "kittencard-avail", 1);
                    break;
            }
            increment_module_pref("soldtoday", 1);
            output("You barge your way through the crowd like a battleship through an ice flow, and toss your item up to eBoy.  eBoy snatches the item out of the air with his left hand while tossing your Requisition tokens back at you with his right, and goes on to serve the next customer.`n`n");
            break;
    }
    //get the latest availability data
    $smallmedkitavail = get_module_objpref("city", $cityid, "smallmedkit-avail");
    $largemedkitavail = get_module_objpref("city", $cityid, "largemedkit-avail");
    $energydrinkavail = get_module_objpref("city", $cityid, "energydrink-avail");
    $nicotinegumavail = get_module_objpref("city", $cityid, "nicotinegum-avail");
    $powerpillavail = get_module_objpref("city", $cityid, "powerpill-avail");
    $teleporteravail = get_module_objpref("city", $cityid, "teleporter-avail");
    $banggrenadeavail = get_module_objpref("city", $cityid, "banggrenade-avail");
    $whoomphgrenadeavail = get_module_objpref("city", $cityid, "whoomphgrenade-avail");
    $zapgrenadeavail = get_module_objpref("city", $cityid, "zapgrenade-avail");
    $repellentsprayavail = get_module_objpref("city", $cityid, "repellentspray-avail");
    $rationpackavail = get_module_objpref("city", $cityid, "rationpack-avail");
    $improbabilitybombavail = get_module_objpref("city", $cityid, "improbabilitybomb-avail");
    $kittencardavail = get_module_objpref("city", $cityid, "kittencard-avail");
    //show info board
    output("You look up above eBoy's head at the trading board, the values of each commodity hastily scrawled in chalk early this morning:`n`n");
    output("`0Small Medkits:`n");
    output("Stock available: %s`n", $smallmedkitavail);
    output("`2Selling at: %s Requisition`n", $smallmedkitcurrent);
    output("`7Buying at: %s Requisition`0`n`n", $smallmedkitbuy);
    output("`0Large Medkits:`n");
    output("Stock available: %s`n", $largemedkitavail);
    output("`2Selling at: %s Requisition`n", $largemedkitcurrent);
    output("`7Buying at: %s Requisition`0`n`n", $largemedkitbuy);
    output("`0Energy Drinks:`n");
    output("Stock available: %s`n", $energydrinkavail);
    output("`2Selling at: %s Requisition`n", $energydrinkcurrent);
    output("`7Buying at: %s Requisition`0`n`n", $energydrinkbuy);
    output("`0Nicotine Gum:`n");
    output("Stock available: %s`n", $nicotinegumavail);
    output("`2Selling at: %s Requisition`n", $nicotinegumcurrent);
    output("`7Buying at: %s Requisition`0`n`n", $nicotinegumbuy);
    output("`0Power Pills:`n");
    output("Stock available: %s`n", $powerpillavail);
    output("`2Selling at: %s Requisition`n", $powerpillcurrent);
    output("`7Buying at: %s Requisition`0`n`n", $powerpillbuy);
    output("`0One-Shot Teleporters:`n");
    output("Stock available: %s`n", $teleporteravail);
    output("`2Selling at: %s Requisition`n", $teleportercurrent);
    output("`7Buying at: %s Requisition`0`n`n", $teleporterbuy);
    output("`0BANG Grenades:`n");
    output("Stock available: %s`n", $banggrenadeavail);
    output("`2Selling at: %s Requisition`n", $banggrenadecurrent);
    output("`7Buying at: %s Requisition`0`n`n", $banggrenadebuy);
    output("`0WHOOMPH Grenades:`n");
    output("Stock available: %s`n", $whoomphgrenadeavail);
    output("`2Selling at: %s Requisition`n", $whoomphgrenadecurrent);
    output("`7Buying at: %s Requisition`0`n`n", $whoomphgrenadebuy);
    output("`0ZAP Grenades:`n");
    output("Stock available: %s`n", $zapgrenadeavail);
    output("`2Selling at: %s Requisition`n", $zapgrenadecurrent);
    output("`7Buying at: %s Requisition`0`n`n", $zapgrenadebuy);
    output("`0Monster Repellent Spray:`n");
    output("Stock available: %s`n", $repellentsprayavail);
    output("`2Selling at: %s Requisition`n", $repellentspraycurrent);
    output("`7Buying at: %s Requisition`0`n`n", $repellentspraybuy);
    output("`0Ration Packs:`n");
    output("Stock available: %s`n", $rationpackavail);
    output("`2Selling at: %s Requisition`n", $rationpackcurrent);
    output("`7Buying at: %s Requisition`0`n`n", $rationpackbuy);
    output("`0Improbability Bombs:`n");
    output("Stock available: %s`n", $improbabilitybombavail);
    output("`2Selling at: %s Requisition`n", $improbabilitybombcurrent);
    output("`7Buying at: %s Requisition`0`n`n", $improbabilitybombbuy);
    output("`0Kitten Greetings Cards:`n");
    output("Stock available: %s`n", $kittencardavail);
    output("`2Selling at: %s Requisition`n", $kittencardcurrent);
    output("`7Buying at: %s Requisition`0`n`n", $kittencardbuy);
    //buying navs
    addnav("Buying");
    if ($session['user']['gold'] >= $smallmedkitcurrent && $smallmedkitavail > 0) {
        addnav(array("Buy a Small Medkit (%s Requisition)", $smallmedkitcurrent), "runmodule.php?module=improbablestufftrading&op=buy&item=smallmedkit");
    }
    if ($session['user']['gold'] >= $largemedkitcurrent && $largemedkitavail > 0) {
        addnav(array("Buy a Large Medkit (%s Requisition)", $largemedkitcurrent), "runmodule.php?module=improbablestufftrading&op=buy&item=largemedkit");
    }
    if ($session['user']['gold'] >= $energydrinkcurrent && $energydrinkavail > 0) {
        addnav(array("Buy an Energy Drink (%s Requisition)", $energydrinkcurrent), "runmodule.php?module=improbablestufftrading&op=buy&item=energydrink");
    }
    if ($session['user']['gold'] >= $nicotinegumcurrent && $nicotinegumavail > 0) {
        addnav(array("Buy a piece of Nicotine Gum (%s Requisition)", $nicotinegumcurrent), "runmodule.php?module=improbablestufftrading&op=buy&item=nicotinegum");
    }
    if ($session['user']['gold'] >= $powerpillcurrent && $powerpillavail > 0) {
        addnav(array("Buy a Power Pill (%s Requisition)", $powerpillcurrent), "runmodule.php?module=improbablestufftrading&op=buy&item=powerpill");
    }
    if ($session['user']['gold'] >= $teleportercurrent && $teleporteravail > 0) {
        addnav(array("Buy a One-Shot Teleporter (%s Requisition)", $teleportercurrent), "runmodule.php?module=improbablestufftrading&op=buy&item=teleporter");
    }
    if ($session['user']['gold'] >= $banggrenadecurrent && $banggrenadeavail > 0) {
        addnav(array("Buy a Bang Grenade (%s Requisition)", $banggrenadecurrent), "runmodule.php?module=improbablestufftrading&op=buy&item=banggrenade");
    }
    if ($session['user']['gold'] >= $whoomphgrenadecurrent && $whoomphgrenadeavail > 0) {
        addnav(array("Buy a WHOOMPH Grenade (%s Requisition)", $whoomphgrenadecurrent), "runmodule.php?module=improbablestufftrading&op=buy&item=whoomphgrenade");
    }
    if ($session['user']['gold'] >= $zapgrenadecurrent && $zapgrenadeavail > 0) {
        addnav(array("Buy a ZAP Grenade (%s Requisition)", $zapgrenadecurrent), "runmodule.php?module=improbablestufftrading&op=buy&item=zapgrenade");
    }
    if ($session['user']['gold'] >= $repellentspraycurrent && $repellentsprayavail > 0) {
        addnav(array("Buy a can of Monster Repellent Spray (%s Requisition)", $repellentspraycurrent), "runmodule.php?module=improbablestufftrading&op=buy&item=repellentspray");
    }
    if ($session['user']['gold'] >= $rationpackcurrent && $rationpackavail > 0) {
        addnav(array("Buy a Ration Pack (%s Requisition)", $rationpackcurrent), "runmodule.php?module=improbablestufftrading&op=buy&item=rationpack");
    }
    if ($session['user']['gold'] >= $improbabilitybombcurrent && $improbabilitybombavail > 0) {
        addnav(array("Buy an Improbability Bomb (%s Requisition)", $improbabilitybombcurrent), "runmodule.php?module=improbablestufftrading&op=buy&item=improbabilitybomb");
    }
    if ($session['user']['gold'] >= $kittencardcurrent && $kittencardavail > 0) {
        addnav(array("Buy a Kitten Card (%s Requisition)", $kittencardcurrent), "runmodule.php?module=improbablestufftrading&op=buy&item=kittencard");
    }
    //player prefs
    $playersmallmedkit = get_module_pref("item1number", "improbablestuff");
    $playerlargemedkit = get_module_pref("item2number", "improbablestuff");
    $playerenergydrink = get_module_pref("item3number", "improbablestuff");
    $playernicotinegum = get_module_pref("item4number", "improbablestuff");
    $playerpowerpill = get_module_pref("item5number", "improbablestuff");
    $playerteleporter = get_module_pref("item6number", "improbablestuff");
    $playerbanggrenade = get_module_pref("item7number", "improbablestuff");
    $playerwhoomphgrenade = get_module_pref("item8number", "improbablestuff");
    $playerzapgrenade = get_module_pref("item9number", "improbablestuff");
    $playerrepellentspray = get_module_pref("item10number", "improbablestuff");
    $playerrationpack = get_module_pref("item11number", "improbablestuff");
    $playerimprobabilitybomb = get_module_pref("item12number", "improbablestuff");
    $playerkittencard = get_module_pref("item13number", "improbablestuff");
    //selling navs
    addnav("Selling");
    if ($playersmallmedkit > 0) {
        addnav(array("Sell a Small Medkit (%s remaining)", $playersmallmedkit), "runmodule.php?module=improbablestufftrading&op=sell&item=smallmedkit");
    }
    if ($playerlargemedkit > 0) {
        addnav(array("Sell a Large Medkit (%s remaining)", $playerlargemedkit), "runmodule.php?module=improbablestufftrading&op=sell&item=largemedkit");
    }
    if ($playerenergydrink > 0) {
        addnav(array("Sell an Energy Drink (%s remaining)", $playerenergydrink), "runmodule.php?module=improbablestufftrading&op=sell&item=energydrink");
    }
    if ($playernicotinegum > 0) {
        addnav(array("Sell a piece of Nicotine Gum (%s remaining)", $playernicotinegum), "runmodule.php?module=improbablestufftrading&op=sell&item=nicotinegum");
    }
    if ($playerpowerpill > 0) {
        addnav(array("Sell a Power Pill (%s remaining)", $playerpowerpill), "runmodule.php?module=improbablestufftrading&op=sell&item=powerpill");
    }
    if ($playerteleporter > 0) {
        addnav(array("Sell a One-Shot Teleporter (%s remaining)", $playerteleporter), "runmodule.php?module=improbablestufftrading&op=sell&item=teleporter");
    }
    if ($playerbanggrenade > 0) {
        addnav(array("Sell a Bang Grenade (%s remaining)", $playerbanggrenade), "runmodule.php?module=improbablestufftrading&op=sell&item=banggrenade");
    }
    if ($playerwhoomphgrenade > 0) {
        addnav(array("Sell a WHOOMPH Grenade (%s remaining)", $playerwhoomphgrenade), "runmodule.php?module=improbablestufftrading&op=sell&item=whoomphgrenade");
    }
    if ($playerzapgrenade > 0) {
        addnav(array("Sell a ZAP Grenade (%s remaining)", $playerzapgrenade), "runmodule.php?module=improbablestufftrading&op=sell&item=zapgrenade");
    }
    if ($playerrepellentspray > 0) {
        addnav(array("Sell a can of Monster Repellent Spray (%s remaining)", $playerrepellentspray), "runmodule.php?module=improbablestufftrading&op=sell&item=repellentspray");
    }
    if ($playerrationpack > 0) {
        addnav(array("Sell a Ration Pack (%s remaining)", $playerrationpack), "runmodule.php?module=improbablestufftrading&op=sell&item=rationpack");
    }
    if ($playerimprobabilitybomb > 0) {
        addnav(array("Sell an Improbability Bomb (%s remaining)", $playerimprobabilitybomb), "runmodule.php?module=improbablestufftrading&op=sell&item=improbabilitybomb");
    }
    if ($playerkittencard > 0) {
        addnav(array("Sell a Kitten Card (%s remaining)", $playerkittencard), "runmodule.php?module=improbablestufftrading&op=sell&item=kittencard");
    }
    addnav("Other");
    // todo: add eBoy bribery
    // addnav("Ask eBoy if he's got any insider tips...","runmodule.pnp?module=improbablestufftrading&op=bribe");
    addnav("Return to the Outpost", "village.php");
    page_footer();
    return $args;
}
function clanmembercap_run()
{
    global $session;
    $op = httpget('op');
    $clanid = $session['user']['clanid'];
    switch ($op) {
        case "bounce":
            page_header("Clan Full");
            $clanid = httpget("clanid");
            output("This Clan has reached full capacity at %s members.", get_module_objpref("clans", $clanid, "limit", "clanmembercap"));
            addnav("Back to Clan hall", "clan.php");
            villagenav();
            break;
        case "start":
            page_header("Increase Member Cap");
            if (!get_module_objpref("clans", $clanid, "limit", "clanmembercap")) {
                $startlimit = get_module_setting("lim", "clanmembercap");
                $costfornext = get_module_setting("cost", "clanmembercap");
                set_module_objpref("clans", $clanid, "limit", $startlimit, "clanmembercap");
                set_module_objpref("clans", $clanid, "costfornext", $costfornext, "clanmembercap");
            }
            $currentlimit = get_module_objpref("clans", $clanid, "limit", "clanmembercap");
            $costfornext = get_module_objpref("clans", $clanid, "costfornext", "clanmembercap");
            $bank = get_module_objpref("clans", $clanid, "bank", "clanmembercap");
            output("Using a preposterous amount of cigarettes, you can increase the number of members allowed in your Clan.  You can currently have up to %s members - to add another member slot, it'll cost you %s cigarettes.`n`nYou currently have %s cigarettes in your Member Cap bank.  Remember that this is different to the Clan Buffs bank, and you can't transfer cigarettes from one to the other.  Your member cap will be automatically increased once the bank has enough cigarettes in it.`n`nHow many cigarettes will you deposit?`n`n", $currentlimit, $costfornext, $bank);
            $dep = translate_inline("Deposit");
            rawoutput("<form action='runmodule.php?module=clanmembercap&op=deposit' method='POST'>");
            rawoutput("<input id='input' name='amount' width=5 > <input type='submit' class='button' value='{$dep}'>");
            output("`bEnter 0 or nothing to deposit all of your cigarettes.`b`n`n");
            rawoutput("</form>");
            rawoutput("<script language='javascript'>document.getElementById('input').focus();</script>", true);
            addnav("", "runmodule.php?module=clanmembercap&op=deposit");
            addnav("Back to Clan hall", "clan.php");
            break;
        case "deposit":
            page_header("Depositing Cigarettes");
            $amount = abs((int) httppost('amount'));
            if ($amount == 0) {
                $amount = $session['user']['gems'];
            }
            if ($amount > $session['user']['gems']) {
                output("`4That's more cigarettes than you have.`0`n`n");
                addnav("Back to Clan hall", "clan.php");
                break;
            }
            debuglog("deposited " . $amount . " cigarettes in the clan's member cap bank");
            $session['user']['gems'] -= $amount;
            increment_module_objpref("clans", $clanid, "bank", $amount, "clanmembercap");
            $currentlimit = get_module_objpref("clans", $clanid, "limit", "clanmembercap");
            $costfornext = get_module_objpref("clans", $clanid, "costfornext", "clanmembercap");
            $bank = get_module_objpref("clans", $clanid, "bank", "clanmembercap");
            if ($bank > $costfornext) {
                //level up the member cap
                $currentlimit += 1;
                set_module_objpref("clans", $clanid, "limit", $currentlimit, "clanmembercap");
                //take the cigs out of the bank
                $newbank = $bank - $costfornext;
                set_module_objpref("clans", $clanid, "bank", $newbank, "clanmembercap");
                //figure out the cost of the next member cap increase
                $inc = get_module_setting("costincrease", "clanmembercap");
                $costfornext = round($costfornext * $inc);
                set_module_objpref("clans", $clanid, "costfornext", $costfornext, "clanmembercap");
                output("`bYour clan's Member Cap has been increased!`b`n`nThere are now %s cigarettes in the bank.`n`n", $newbank);
            } else {
                output("There are now %s cigarettes in this clan's Member Cap bank, out of %s needed for the next level-up.`n`n", $bank, $costfornext);
            }
            addnav("Back to Clan hall", "clan.php");
            break;
    }
    page_footer();
}