function hunterslodge_healthinsurance_run()
{
    global $session;
    page_header("Hospital Tent");
    output("The mechanic growls at you.  \"`6So you think you've got a certificate that gives you free healing, do you?`0\"  He snatches the certificate out of your hand.  \"`6Well, we'll just see about that, won't we?  RAFAEL!`0\"`n`nThe top drawer of the mechanic's filing cabinet rattles open and a nose peeks out, followed by a pair of bespectacled eyes and an oily black haircut.  The lawyer oozes out of the filing cabinet, scuttles over to the mechanic and takes the certificate.  He sniffs it, then cautiously nibbles on a corner, before pressing his greasy nose to the paper.`n`n\"`7Let's see, here...`0\" he mutters, in an annoying, nasal tone.  \"`7...an agreement between CavemanJoe, hereafter referred to as His Royal Awesomeness, and the bearer's posterior, hereafter referred to as Your Butt...  Hmm, hmm, I see...  agrees to not bend, fold, spindle or mutilate Your Butt...  yes, yes, all very official, all very legal...  valid for a period of one \"Real World\" week after first use...  oh, no.  Oh, dear.`0\"  He looks towards the mechanic, eyes filling with tears.  \"`7It's airtight!  We can't get out of it!`0\"`n`nThe mechanic snatches the certificate back and gives it a once-over.  The colour leavs his face.  \"`6My God,`0\" he whispers, staring into space.`n`nHe turns to you.  \"`6Get on the table,`0\" he mumbles.  \"`6And tell `ino-one`i about this.`0\"`n`nYou have been fully healed!`n`n");
    $session['user']['hitpoints'] = $session['user']['maxhitpoints'];
    use_item("hunterslodge_healthinsurance");
    addnav("Exit");
    addnav("Back to the Jungle", "forest.php");
    page_footer();
}
require_once "common.php";
global $session, $inventory;
page_header("Inventory");
//$op = httpget("op");
$items_useitem = httpget("items_useitem");
$items_discarditem = httpget("items_discarditem");
$items_transferitem = httpget("items_transferitem");
$items_transferto = httpget("items_transferto");
$context = httpget("items_context");
//handle moving, using, discarding, and contexts
if ($items_transferitem && $items_transferto) {
    move_item($items_transferitem, $items_transferto);
}
if ($items_useitem) {
    use_item($items_useitem, $context);
}
if ($items_discarditem) {
    delete_item($items_discarditem);
}
load_inventory();
//debug($inventory);
$hook = array('inventory' => $inventory, 'context' => $context);
$hook = modulehook("inventory-predisplay", $hook);
addnav("Sort by...");
addnav("Recently Acquired", "inventory.php?items_sort=key&items_context={$context}");
addnav("Alphabetical", "inventory.php?items_sort=alpha&items_context={$context}");
addnav("Quantity", "inventory.php?items_sort=qty&items_context={$context}");
$sort = httpget("items_sort");
$gr = group_items($inventory, $sort);
//debug($gr);
             if ($house['data']['store'][$iitem] > 0) {
                 $house['data']['store'][$iitem]--;
                 if ($house['data']['store'][$iitem]) {
                     output("You decide to use the materials that are already hanging around.  There's still %s of these left.`n`n", $house['data']['store'][$iitem]);
                 } else {
                     output("You decide to use the materials that are already hanging around.  That was the last one.`n`n");
                 }
             } else {
                 output("Before you can get started, you realise someone has already depleted the materials store!`n`n");
                 improbablehousing_bottomnavs($house, $rid);
                 page_footer();
                 $interrupt = true;
             }
         } else {
             //determine iitems to use, and use them - assume we're using iitems from the Main inventory
             use_item($iitem);
             if ($iitem != "toolbox_carpentry" && $iitem != "toolbox_masonry") {
                 $qleft = has_item_quantity($iitem);
                 if ($qleft == 1) {
                     $iname = get_item_setting("verbosename", $iitem);
                 } else {
                     $iname = get_item_setting("plural", $iitem);
                 }
                 if (!$qleft) {
                     $qleft = "no";
                 }
                 output("You have %s %s left.`n`n", $qleft, $iname);
             }
         }
     }
 }
function items_world_map_gathering_run()
{
    global $session;
    page_header("Gathering Materials");
    $type = httpget('mat');
    $item = httpget('item');
    require_once "modules/staminasystem/lib/lib.php";
    if ($type == "wood") {
        $lv = process_action("Logging");
        $stam = get_stamina();
        $rstam = get_stamina(0);
        $failchance = e_rand(0, 99);
        if ($failchance < $stam) {
            give_item("wood");
            use_item($item, "logging");
            output("`0You hack away until you have what can only be described as a bloody enormous log, suitable as a part of a quaint little cabin.  It couldn't possibly fit into your backpack, but you stuff it in anyway.`n");
            if ($lv['lvlinfo']['levelledup'] == true) {
                output("`n`c`b`0You gained a level in Logging!  You are now level %s!  This action will cost fewer Stamina points now, so you can lumberjack more lumber each day!`b`c`n", $lv['lvlinfo']['newlvl']);
            }
        } else {
            if ($failchance < $rstam) {
                output("You hack away until you have what can only be described as a whole shitload of matchsticks.  The wood just splintered into barely more than pulp under your clumsy, half-asleep paws.`n`nMaybe it'd be a good idea to rest a bit before you try this again.`n`n");
            } else {
                $fail = 1;
                output("You hack away at the tree, your half-asleep mind blissfully ignorant of its wild swaying.  Ignorant, that is, until it falls on you.`n`nYou wake up, naturally, on the FailBoat.`n`n");
            }
        }
    } else {
        if ($type == "stone") {
            $lv = process_action("Stonecutting");
            $stam = get_stamina();
            $rstam = get_stamina(0);
            $failchance = e_rand(0, 99);
            if ($failchance < $stam) {
                $success = 1;
                give_item("stone");
                use_item($item, "stonecutting");
                output("`0You hack away until you have what can only be described as a huge-ass lump of stone, very heavy and cumbersome.  For some reason your backpack seems like a really good place to put it.`n");
                if ($lv['lvlinfo']['levelledup'] == true) {
                    output("`n`c`b`0You gained a level in Stonecutting!  You are now level %s!  This action will cost fewer Stamina points now, so you can break more rocks each day!`b`c`n", $lv['lvlinfo']['newlvl']);
                }
            } else {
                if ($failchance < $rstam) {
                    output("You hack away until you have what can only be described as a whole shitload of gravel.  The rock just smashed into splinters under your clumsy, half-asleep paws.`n`nMaybe it'd be a good idea to rest a bit before you try this again.`n`n");
                } else {
                    $fail = 1;
                    output("You hack away at the rock, blissfully unaware that another, larger rock is being gently dislodged by your half-asleep ministrations.  Another, larger rock that happens to be balanced precariously on an outcrop just above your head.`n`nYou wake up, naturally, on the FailBoat.`n`n");
                }
            }
        }
    }
    if (!$fail) {
        items_world_map_gathering_showgather();
        addnav("Other");
        addnav("Show Inventory", "inventory.php?items_context=worldmap");
        addnav("Return to the World Map", "runmodule.php?module=worldmapen&op=continue");
    } else {
        $session['user']['hitpoints'] = 0;
        $session['user']['gold'] = 0;
        $session['user']['alive'] = 0;
        //set the user's location to the last place on the map they touched
        $session['user']['location'] = get_module_pref("lastCity", "worldmapen");
        addnav("Guess what happens now?");
        addnav("That's right.", "shades.php");
    }
    page_footer();
}
コード例 #5
0
ファイル: Inventory.php プロジェクト: galadie/Caranille-RPG
                					{					
                						retire_equipement($type);
                						
                						$baseline= "Déséquipement effectué";
                					}
                **/
            }
            // jeter
            if (request_confirm('Drop')) {
                use_item($Item_ID, $inventory_ID);
                $baseline = "Item jeté";
            }
            // vente immédiate
            if (request_confirm('Sale')) {
                if ($Inventory_ID == $_SESSION['Armor_Inventory_ID'] || $Inventory_ID == $_SESSION['Boots_Inventory_ID'] || $Inventory_ID == $_SESSION['Gloves_Inventory_ID'] || $Inventory_ID == $_SESSION['Helmet_Inventory_ID'] || $Inventory_ID == $_SESSION['Weapon_Inventory_ID']) {
                    $baseline = 'Vous ne pouvez pas vendre cet objet car il est actuellement équipé<br />';
                } else {
                    use_item($Item_ID, $inventory_ID);
                    exec_db("UPDATE Caranille_Accounts SET Account_Golds = (Account_Golds + " . intval($Item_Sale_Price) . ") WHERE Account_ID = " . intval($ID) . " limit 1");
                    $baseline = "Vente effectuée";
                }
            }
            //Module of Parchement
            if (request_confirm('Use')) {
                use_item($Item_ID, $inventory_ID);
                exec_db("UPDATE Caranille_Accounts\n\t\t\t\t\t\tSET\n\t\t\t\t\t\t\tAccount_HP_Bonus = Account_HP_Bonus + " . intval($Item_HP_Effect) . "\n\t\t\t\t\t\t, \tAccount_MP_Bonus = Account_MP_Bonus + " . intval($Item_MP_Effect) . "\n\t\t\t\t\t\t, \tAccount_Strength_Bonus = Account_Strength_Bonus + " . intval($Item_Strength_Effect) . "\n\t\t\t\t\t\t, \tAccount_Magic_Bonus = Account_Magic_Bonus + " . intval($Item_Magic_Effect) . "\n\t\t\t\t\t\t, \tAccount_Agility_Bonus = Account_Agility_Bonus + " . intval($Item_Agility_Effect) . "\n\t\t\t\t\t\t, \tAccount_Defense_Bonus = Account_Defense_Bonus + " . intval($Item_Defense_Effect) . "\n\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\tAccount_ID = {$ID}\n\t\t\t\t\t\tLimit 1");
                $baseline = "Le parchemin à bien été utilisé ";
            }
        }
    }
}
}
$enemycounter = count($enemies);
$enemies = autosettarget($enemies);
$op = httpget("op");
$skill = httpget("skill");
$item = httpget("items_useitem");
$l = httpget("l");
$newtarget = httpget('newtarget');
if ($newtarget != "") {
    $op = "newtarget";
}
//if (!$targetted) $op = "newtarget";
if ($op == "fight") {
    apply_skill($skill, $l);
    if ($item) {
        use_item($item, "fight");
    }
} else {
    if ($op == "newtarget") {
        foreach ($enemies as $index => $badguy) {
            if ($index == (int) $newtarget) {
                if (!isset($badguy['cannotbetarget']) || $badguy['cannotbetarget'] === false) {
                    $enemies[$index]['istarget'] = 1;
                } else {
                    if (is_array($badguy['cannotbetarget'])) {
                        $msg = sprintf_translate($badguy['cannotbetarget']);
                        $msg = substitute($msg);
                        output_notl($msg);
                        //Here it's already translated
                    } else {
                        if ($badguy['cannotbetarget'] === true) {
function improbablehousing_furnitureshop_run()
{
    global $session;
    page_header("Cadfael's Furniture");
    //have the beds and such allowed to be carried in backpack (insert suitable hundred-kilo-bed-in-backpack-lols) or carried by a secondary character in a new Inventory space (we'll call it Delivery Boy - will need a suitably silly photo).
    switch (httpget('op')) {
        case "start":
            output("Cadfael greets you with a preposterously strong Welsh accent.  \"`3Well hey there!  Take a look around, all one 'undred per cent natural and me own work!`0\"`n`n");
            //find items that are furniture!
            $furniture = get_items_with_settings("furniture");
            //debug($furniture);
            usort($furniture, 'sortbyprice');
            rawoutput("<table width=100% style='border: dotted 1px #000000;'>");
            foreach ($furniture as $sort => $vals) {
                $key = $vals['item'];
                $classcount += 1;
                $class = $classcount % 2 ? "trdark" : "trlight";
                rawoutput("<tr class='{$class}'><td>");
                if ($vals['image']) {
                    rawoutput("<table width=100% cellpadding=0 cellspacing=0><tr><td width=100px align=center><img src=\"images/items/" . $vals['image'] . "\"></td><td>");
                }
                output("`b%s`b`n", stripslashes($vals['verbosename']));
                output("%s`0`n", stripslashes($vals['description']));
                if ($vals['weight']) {
                    output("Weight: %s kg`n`0", $vals['weight']);
                }
                rawoutput("<table width=100%><tr><td width=50%>");
                if ($vals['goldcost'] && $vals['gemcost']) {
                    $disp = "`b" . number_format($vals['goldcost']) . "`b Requisition and `b" . number_format($vals['gemcost']) . "`b Cigarettes";
                    $sdisp = $vals['goldcost'] . " Req, " . $vals['gemcost'] . " Cigs";
                } else {
                    if ($vals['goldcost']) {
                        $disp = "`b" . number_format($vals['goldcost']) . "`b Requisition";
                        $sdisp = $vals['goldcost'] . " Req";
                    } else {
                        $disp = "`b" . number_format($vals['goldcost']) . "`b Cigarettes";
                        $sdisp = $vals['goldcost'] . " Cigs";
                    }
                }
                if ($session['user']['gold'] >= $vals['goldcost'] && $session['user']['gems'] >= $vals['gemcost']) {
                    addnav("Buy Items");
                    addnav(array("%s (%s)", $vals['verbosename'], $sdisp), "runmodule.php?module=improbablehousing_furnitureshop&op=buy&item=" . $key, true);
                    addnav("", "runmodule.php?module=improbablehousing_furnitureshop&op=buy&item=" . $key);
                    rawoutput("<a href=\"runmodule.php?module=improbablehousing_furnitureshop&op=buy&item=" . $key . "\">Buy for " . appoencode($disp) . "</a><br />");
                } else {
                    output("Price: %s`n", $disp);
                    output("`&You can't afford this item right now.`0`n");
                }
                rawoutput("</td></tr></table>");
                if ($vals['image']) {
                    rawoutput("</td></tr></table>");
                }
                rawoutput("</td></tr>");
            }
            rawoutput("</td></tr></table>");
            break;
        case "buy":
            $item = httpget("item");
            $goldcost = get_item_setting("goldcost", $item);
            $gemcost = get_item_setting("gemcost", $item);
            $name = get_item_setting("verbosename", $item);
            if ($goldcost && $gemcost) {
                $disp = "`b" . number_format($goldcost) . "`b Requisition and `b" . number_format($gemcost) . "`b Cigarettes";
            } else {
                if ($goldcost) {
                    $disp = "`b" . number_format($goldcost) . "`b Requisition";
                } else {
                    $disp = "`b" . number_format($goldcost) . "`b Cigarettes";
                }
            }
            output("Cadfael nods.  \"`3So, you're after a %s then, are ye?  That'll be %s, please.`0\"`n`n", $name, $disp);
            addnav("Confirmation");
            addnav("Confirm sale", "runmodule.php?module=improbablehousing_furnitureshop&op=confirmbuy&item=" . $item);
            addnav("Wait, I've changed my mind!", "runmodule.php?module=improbablehousing_furnitureshop&op=start");
            break;
        case "confirmbuy":
            $item = httpget("item");
            $goldcost = get_item_setting("goldcost", $item);
            $gemcost = get_item_setting("gemcost", $item);
            $name = get_item_setting("verbosename", $item);
            $session['user']['gold'] -= $goldcost;
            $session['user']['gems'] -= $gemcost;
            give_item($item);
            output("You hand over your hard-won currency to Cadfael, who grins and says \"`3Ah, much obliged!  Pleasure doin' business... with...`0\" he stops, bemused.  \"`3Are... are you trying to fit that into a `ibackpack?`i`0\"`n`nAfter several minutes of grunting and sweating, your backpack now resembles a... well, a barely-held-together layer of canvas stretched drum-tight into the shape of a %s.  With a very small %s bent double underneath.  Cadfael shakes his head and mutters something about it taking all sorts.`n`n", $name, $session['user']['race']);
            break;
        case "drop":
            page_header("");
            $itemid = httpget('item');
            debug($itemid);
            $hid = httpget('hid');
            require_once "modules/improbablehousing/lib/lib.php";
            $house = improbablehousing_gethousedata($hid);
            $rid = httpget('rid');
            $slot = httpget('slot');
            $house['data']['rooms'][$rid]['sleepslots'][$slot]['stamina'] = get_item_pref("sleepslot_stamina", $itemid);
            $house['data']['rooms'][$rid]['sleepslots'][$slot]['name'] = get_item_pref("sleepslot_name", $itemid);
            $house['data']['rooms'][$rid]['sleepslots'][$slot]['desc'] = get_item_pref("sleepslot_desc", $itemid);
            use_item($itemid);
            improbablehousing_sethousedata($house);
            addnav("Continue");
            addnav(array("Return to %s", $house['data']['rooms'][$rid]['name']), "runmodule.php?module=improbablehousing&op=interior&hid=" . $hid . "&rid=" . $rid);
            break;
    }
    if (httpget('op') != "drop") {
        addnav("Exit");
        addnav("Back to the Outpost", "village.php");
    }
    page_footer();
    return true;
}
<?php

page_header("Stake a Claim");
require_once "modules/improbablehousing/lib/lib.php";
global $session;
//first make sure someone didn't already fill up the space between this player's pageloads
$list = improbablehousing_getnearbyhouses($loc);
$nlist = count($list);
//todo: make this a setting
$maxhousespersquare = 4;
if ($nlist < $maxhousespersquare) {
    //get rid of the stake - make sure it's set to destroy itself after a single use
    use_item("housing_stake");
    //now make a house with a size of zero, set the owner, and so on and so forth
    $ownedby = $session['user']['acctid'];
    $loc = get_module_pref("worldXYZ", "worldmapen");
    list($worldmapX, $worldmapY, $worldmapZ) = explode(",", $loc);
    $data = array("rooms" => array(), "name" => "Empty Plot belonging to " . $session['user']['name'], "buildjobs" => array(0 => array("name" => "Initial Dwelling Construction", "jobs" => array(0 => array("name" => "Add wood", "iitems" => array("wood" => 1, "toolbox_carpentry" => 1), "actions" => array("Carpentry" => 1), "req" => 100, "done" => 0, "desc" => "You set about hammering and sawing.  Before too long, the dwelling's one step closer to completion."), 1 => array("name" => "Add stone", "iitems" => array("stone" => 1, "toolbox_masonry" => 1), "actions" => array("Masonry" => 1), "req" => 25, "done" => 0, "desc" => "You set about chiseling and tinkering.  Before too long, the dwelling's one step closer to completion.")), "completioneffects" => array("changes" => array("name" => "One-room dwelling belonging to " . $session['user']['name'], "desc_exterior" => "You see a single-room dwelling belonging to " . $session['user']['name']), "newrooms" => array(0 => array("name" => "Main Room", "size" => 1, "desc" => "You're standing in a small, undecorated room.", "sleepslots" => array())), "msg" => "The dwelling is now complete!"))), "desc_exterior" => "You see a sign indicating that a plot of land has been reserved for " . $session['user']['name']);
    $bsql = "INSERT INTO " . db_prefix("buildings") . " (ownedby,location) VALUES ('{$ownedby}','{$loc}')";
    db_query($bsql);
    $key = mysql_insert_id();
    $buildjobs = $data['buildjobs'];
    $buildjobs = serialize($buildjobs);
    $buildjobs = addslashes($buildjobs);
    $bpsql = "INSERT INTO " . db_prefix("building_prefs") . " (hid,pref,value) VALUES ('{$key}','name','Empty Plot belonging to " . $session['user']['name'] . "'),('{$key}','desc_exterior','You see a sign indicating that a plot of land has been reserved for " . $session['user']['name'] . "'),('{$key}','buildjobs','{$buildjobs}')";
    db_query($bpsql);
    $data = serialize($data);
    $data = addslashes($data);
    $sql = "INSERT INTO " . db_prefix("improbabledwellings") . " (ownedby,location,data) VALUES ('{$ownedby}','{$loc}','{$data}')";
    db_query($sql);
    //invalidate cache
コード例 #9
0
ファイル: QuestBoard.php プロジェクト: galadie/Caranille-RPG
// l'utilisateur peut ajouter un titre pour chaque module different de Caranille -Accueil
//$title ="";
$baseline = "Tableaux des Quetes";
if (verif_connect()) {
    if (verif_town()) {
        /** questboard.php => map.php/towns **/
        if (request_confirm('return_quest')) {
            if (verifier_token(600, get_link('QuestBoard', 'Game'), 'return_quest-' . $_POST['Quest_ID'])) {
                $quest = get_db('request_quest', $_POST);
                if (!empty($quest)) {
                    // first we need to check if the user has the appropriate item for the quest to be completed
                    $find = get_db('item_quest_inventaire', $quest + user_data());
                    // print_r($find);
                    if (!empty($find)) {
                        // now lets first remove the item from the inventory, give the reward, and mark the quest as completed.
                        use_item($quest['Quest_Item'], $find['inventory_ID']);
                        if ($quest['Quest_Gold_Gift'] > 0) {
                            // update with the new gold in the database
                            update_db('Caranille_Account', array('Account_ID' => user_data('Account_ID'), 'Account_Golds' => user_data('Account_Golds') + $quest['Quest_Gold_Gift']));
                        }
                        if ($quest['Quest_Item_Gift'] > 0) {
                            gain_item($quest['Quest_Item_Gift']);
                        }
                        // mark the quest as complete
                        update_db('Caranille_Inventory_Quests', array('Inventory_Quest_Account_ID' => user_data('Account_ID'), 'Inventory_Quest_Quest_ID' => $quest['Quest_ID'], 'Inventory_Quest_Status' => 'complete'));
                        add_diary("Vous avez rendu une quete : " . $quest['Quest_Name']);
                    }
                }
            }
        }
        if (request_confirm('accept_quest')) {
function improbablehousing_furnitureshop_run()
{
    global $session;
    page_header("Cadfael's Furniture");
    //have the beds and such allowed to be carried in backpack (insert suitable hundred-kilo-bed-in-backpack-lols) or carried by a secondary character in a new Inventory space (we'll call it Delivery Boy - will need a suitably silly photo).
    switch (httpget('op')) {
        case "start":
            output("Cadfael greets you with a preposterously strong Welsh accent.  \"`3Well hey there!  Take a look around, all one 'undred per cent natural and me own work!`0\"`n`n");
            //find items that are furniture!
            $furniture = get_items_with_settings("furniture");
            //debug($furniture);
            usort($furniture, 'sortbyprice');
            rawoutput("<table width=100% style='border: dotted 1px #000000;'>");
            foreach ($furniture as $sort => $vals) {
                $key = $vals['item'];
                $classcount += 1;
                $class = $classcount % 2 ? "trdark" : "trlight";
                rawoutput("<tr class='{$class}'><td>");
                if ($vals['image']) {
                    rawoutput("<table width=100% cellpadding=0 cellspacing=0><tr><td width=100px align=center><img src=\"images/items/" . $vals['image'] . "\"></td><td>");
                }
                output("`b%s`b`n", stripslashes($vals['verbosename']));
                output("%s`0`n", stripslashes($vals['description']));
                if ($vals['weight']) {
                    output("Weight: %s kg`n`0", $vals['weight']);
                }
                rawoutput("<table width=100%><tr><td width=50%>");
                if ($vals['goldcost'] && $vals['gemcost']) {
                    $disp = "`b" . number_format($vals['goldcost']) . "`b Requisition and `b" . number_format($vals['gemcost']) . "`b Cigarettes";
                    $sdisp = $vals['goldcost'] . " Req, " . $vals['gemcost'] . " Cigs";
                } else {
                    if ($vals['goldcost']) {
                        $disp = "`b" . number_format($vals['goldcost']) . "`b Requisition";
                        $sdisp = $vals['goldcost'] . " Req";
                    } else {
                        $disp = "`b" . number_format($vals['goldcost']) . "`b Cigarettes";
                        $sdisp = $vals['goldcost'] . " Cigs";
                    }
                }
                if ($session['user']['gold'] >= $vals['goldcost'] && $session['user']['gems'] >= $vals['gemcost']) {
                    addnav("Buy Items");
                    addnav(array("%s (%s)", $vals['verbosename'], $sdisp), "runmodule.php?module=improbablehousing_furnitureshop&op=buy&item=" . $key, true);
                    addnav("", "runmodule.php?module=improbablehousing_furnitureshop&op=buy&item=" . $key);
                    rawoutput("<a href=\"runmodule.php?module=improbablehousing_furnitureshop&op=buy&item=" . $key . "\">Buy for " . appoencode($disp) . "</a><br />");
                } else {
                    output("Price: %s`n", $disp);
                    output("`&You can't afford this item right now.`0`n");
                }
                rawoutput("</td></tr></table>");
                if ($vals['image']) {
                    rawoutput("</td></tr></table>");
                }
                rawoutput("</td></tr>");
            }
            rawoutput("</td></tr></table>");
            addnav("Custom Furniture");
            addnav("Enquire about Custom Furniture", "runmodule.php?module=improbablehousing_furnitureshop&op=custom&sub=start");
            break;
        case "buy":
            $item = httpget("item");
            $goldcost = get_item_setting("goldcost", $item);
            $gemcost = get_item_setting("gemcost", $item);
            $name = get_item_setting("verbosename", $item);
            if ($goldcost && $gemcost) {
                $disp = "`b" . number_format($goldcost) . "`b Requisition and `b" . number_format($gemcost) . "`b Cigarettes";
            } else {
                if ($goldcost) {
                    $disp = "`b" . number_format($goldcost) . "`b Requisition";
                } else {
                    $disp = "`b" . number_format($goldcost) . "`b Cigarettes";
                }
            }
            output("Cadfael nods.  \"`3So, you're after a %s then, are ye?  That'll be %s, please.`0\"`n`n", $name, $disp);
            addnav("Confirmation");
            addnav("Confirm sale", "runmodule.php?module=improbablehousing_furnitureshop&op=confirmbuy&item=" . $item);
            addnav("Wait, I've changed my mind!", "runmodule.php?module=improbablehousing_furnitureshop&op=start");
            break;
        case "confirmbuy":
            $item = httpget("item");
            $goldcost = get_item_setting("goldcost", $item);
            $gemcost = get_item_setting("gemcost", $item);
            $name = get_item_setting("verbosename", $item);
            $session['user']['gold'] -= $goldcost;
            $session['user']['gems'] -= $gemcost;
            give_item($item);
            output("You hand over your hard-won currency to Cadfael, who grins and says \"`3Ah, much obliged!  Pleasure doin' business... with...`0\" he stops, bemused.  \"`3Are... are you trying to fit that into a `ibackpack?`i`0\"`n`nAfter several minutes of grunting and sweating, your backpack now resembles a... well, a barely-held-together layer of canvas stretched drum-tight into the shape of a %s.  With a very small %s bent double underneath.  Cadfael shakes his head and mutters something about it taking all sorts.`n`n", $name, $session['user']['race']);
            break;
        case "drop":
            page_header("");
            $itemid = httpget('item');
            debug($itemid);
            $hid = httpget('hid');
            require_once "modules/improbablehousing/lib/lib.php";
            $house = improbablehousing_gethousedata($hid);
            $rid = httpget('rid');
            $slot = httpget('slot');
            $house['data']['rooms'][$rid]['sleepslots'][$slot]['stamina'] = get_item_pref("sleepslot_stamina", $itemid);
            $house['data']['rooms'][$rid]['sleepslots'][$slot]['name'] = get_item_pref("sleepslot_name", $itemid);
            $house['data']['rooms'][$rid]['sleepslots'][$slot]['desc'] = get_item_pref("sleepslot_desc", $itemid);
            $house['data']['rooms'][$rid]['sleepslots'][$slot]['multicapacity'] = get_item_pref("sleepslot_multicapacity", $itemid);
            use_item($itemid);
            improbablehousing_sethousedata($house);
            addnav("Continue");
            addnav(array("Return to %s", $house['data']['rooms'][$rid]['name']), "runmodule.php?module=improbablehousing&op=interior&hid=" . $hid . "&rid=" . $rid);
            break;
        case "custom":
            $sub = httpget('sub');
            switch ($sub) {
                case "start":
                    output("\"`3Oh yeah, I get lots of custom orders,`0\" says Cadfael, grinning.  \"`3Mostly for Mutants and Robots.  Interestin' stuff, really, tryin' to figure out where all the extra arms and legs would go.  I can make any of my furniture pieces look like just about anythin'.  Custom work'll set ye back five ciggies as a startin' price, an' goes up from there according to complexity.  You got somethin' in mind?`0\"`n`n`JCadfael can take any piece of furniture intended for sleeping on and assign a new name and description to the sleeping slot that it'll take up.  If you want your houseguests to be able to sleep on top of a bookcase, or inside a cleverly-concealed secret foldaway bed, or in a zero-gravity chamber (yes, Cadfael's carpentry skills are `ijust that good`i), then bring one of his furniture pieces here.`0`n`n");
                    $furniture = get_items_with_prefs("furniture");
                    if (is_array($furniture)) {
                        addnav("Customize Furniture");
                        foreach ($furniture as $key => $vals) {
                            addnav(array("Customize %s", $vals['verbosename']), "runmodule.php?module=improbablehousing_furnitureshop&op=custom&sub=desc&item=" . $key);
                        }
                    }
                    addnav("Return");
                    addnav("Back to the Furniture List", "runmodule.php?module=improbablehousing_furnitureshop&op=start");
                    break;
                case "desc":
                    //get the descriptions from the player
                    $item = httpget('item');
                    output("\"`3Right, then - what'll this be called?`0\"`n`n`0Enter a title for the furniture piece here.  This is what's displayed in the nav links in your Dwelling - it'll read something like \"(your title) Available\" or \"(your title) Occupied by Admin CavemanJoe\" - you've got 25 characters to play about with, and no colour or formatting codes are allowed here.`n`n");
                    $oldtitle = get_item_pref("sleepslot_name", $item);
                    $olddesc = get_item_pref("sleepslot_desc", $item);
                    rawoutput("<form action='runmodule.php?module=improbablehousing_furnitureshop&op=custom&sub=confirm&item=" . $item . "' method='POST'>");
                    rawoutput("<input id='newtitle' name='newtitle' width='25' maxlength='25' value='" . $oldtitle . "'>");
                    output("`n`nNow enter a description for the new furniture piece.  This is what's displayed to players when they settle down for a good night's kip.  The longer the description, the more it'll cost.  You can use colour and formatting codes here - remember to use ``n for new lines.`n`n");
                    rawoutput("<textarea name='newdesc' id='newdesc' rows='6' cols='60'>" . $olddesc . "</textarea><input type=submit></form>");
                    addnav("Return");
                    addnav("Back to the Furniture List", "runmodule.php?module=improbablehousing_furnitureshop&op=start");
                    addnav("", "runmodule.php?module=improbablehousing_furnitureshop&op=custom&sub=confirm&item=" . $item);
                    break;
                case "confirm":
                    $newtitle = httppost('newtitle');
                    $newdesc = httppost('newdesc');
                    $item = httpget('item');
                    $newdesc = str_replace("\n", "`n", $newdesc);
                    $newtitle = str_replace("`", "", $newtitle);
                    $newtitle = substr($newtitle, 0, 25);
                    $newtitle = stripslashes($newtitle);
                    $newdesc = stripslashes($newdesc);
                    //show the descriptions
                    output("Your new title is:`n%s`0`n`nYour new description is:`n%s`0`n`n", $newtitle, $newdesc);
                    $cigcost = 5 + floor(strlen($newdesc) / 50);
                    output("This much work will cost %s cigarettes.`n`n", $cigcost);
                    set_item_pref("proposed_sleepslot_name", $newtitle, $item);
                    set_item_pref("proposed_sleepslot_desc", $newdesc, $item);
                    if ($session['user']['gems'] >= $cigcost) {
                        addnav("Continue");
                        addnav("Pay the man!", "runmodule.php?module=improbablehousing_furnitureshop&op=custom&sub=confirmfinal&item=" . $item . "&cost=" . $cigcost);
                    } else {
                        output("You don't have enough cigarettes for that!`n`n");
                    }
                    addnav("Return");
                    addnav("Back to the Furniture List", "runmodule.php?module=improbablehousing_furnitureshop&op=start");
                    break;
                case "confirmfinal":
                    //take the cigaretes, change the prefs
                    $item = httpget('item');
                    $cost = httpget('cost');
                    $session['user']['gems'] -= $cost;
                    output("Cadfael takes your cigarettes and furniture with a smile, and disappears into the back of the shop.  You hear muffled sounds of sawing, hammering, swearing and so forth, and after half an hour or so he returns.  \"`3Here you go - might not look much different `inow,`i but wait 'til you get it in yer house.`0\"`n`nYour furniture is now customized!");
                    $newtitle = get_item_pref("proposed_sleepslot_name", $item);
                    $newdesc = get_item_pref("proposed_sleepslot_desc", $item);
                    set_item_pref("verbosename", "Customized Furniture (" . $newtitle . ")", $item);
                    set_item_pref("sleepslot_name", $newtitle, $item);
                    set_item_pref("sleepslot_desc", $newdesc, $item);
                    set_item_pref("description", "This furniture was modified at Cadfael's shop in Improbable Central.", $item);
                    addnav("Return");
                    addnav("Back to the Furniture List", "runmodule.php?module=improbablehousing_furnitureshop&op=start");
                    break;
            }
            break;
    }
    if (httpget('op') != "drop") {
        addnav("Exit");
        addnav("Back to the Outpost", "village.php");
    }
    page_footer();
    return true;
}