function get_tradables() { global $inventory; if (!isset($inventory)) { load_inventory(); } $sortorder = get_module_pref('shuffle'); // debug($sortorder); $tradables = array(); $found = false; $itemsheld = group_items($inventory); foreach ($itemsheld as $key => $itemdetails) { if (isset($itemdetails['tradable'])) { $tradables[] = $itemdetails; $found = true; } } if ($found) { switch ($sortorder) { case 0: usort($tradables, 'itemcompare'); break; case 1: usort($tradables, 'qtyitemcompare'); break; } return $tradables; } else { return false; } }
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); // switch ($sort){ // case "key": // arsort($gr); // usort($gr, 'sortcarriers'); // break; // case "alpha": // usort($gr,'alphacompare'); // usort($gr, 'sortcarriers'); // break; // case "qty": // usort($gr,'qtycompare'); // usort($gr, 'sortcarriers'); // break; // }
exit; } if (isset($_GET["group-js"])) { group_js(); exit; } if (isset($_GET["group-popup"])) { group_popup(); exit; } if (isset($_GET["group-tabs"])) { group_tabs(); exit; } if (isset($_GET["group-items"])) { group_items(); exit; } if (isset($_GET["group-items-list"])) { group_items_list(); exit; } if (isset($_POST["group-save"])) { group_save(); exit; } if (isset($_POST["group-enable"])) { group_enable(); exit; } if (isset($_POST["group-delete"])) {
function mementos_dohook($hookname, $args) { global $session; switch ($hookname) { case "hunterslodge": addnav("Custom Items"); addnav("Memento Forge", "runmodule.php?module=mementos&op=start"); break; case "inventory": $inv = $args['inventory']; $sort = $args['sort']; foreach ($inv as $itemid => $prefs) { if ($prefs['item'] == "memento") { //debug($prefs); addnav("", "inventory.php?items_context=" . $args['context'] . "&memento_togglebioshow=" . $prefs['itemid'] . "&items_sort={$sort}"); // if (!isset($prefs['memento_showinbio'])){ // $prefs['memento_showinbio'] = 0; // } if (!$prefs['memento_showinbio']) { $args['inventory'][$itemid]['inventoryactions'] .= appoencode("`4Hidden from Bio`0 (<a href=\"inventory.php?items_context=" . $args['context'] . "&memento_togglebioshow=" . $prefs['itemid'] . "&items_sort={$sort}\">show</a>) | ", true); } else { $args['inventory'][$itemid]['inventoryactions'] .= appoencode("`2Visible in Bio`0 (<a href=\"inventory.php?items_context=" . $args['context'] . "&memento_togglebioshow=" . $prefs['itemid'] . "&items_sort={$sort}\">hide</a>) | ", true); } } } break; case "inventory-predisplay": $id = httpget("memento_togglebioshow"); if ($id) { if (get_item_pref("memento_showinbio", $id)) { output("`\$You have chosen to hide this Memento from your Bio.`0`n"); set_item_pref("memento_showinbio", "", $id); } else { output("`@You have chosen to show this Memento in your Bio.`0`n"); set_item_pref("memento_showinbio", "1", $id); } output("Multiple Mementos of the same type are only shown once on your Bio page.`n`n"); } break; case "bioinfo": $inv = load_inventory($args['acctid'], true); $gr = group_items($inv, false); $mem = array(); foreach ($gr as $id => $prefs) { if ($prefs['memento_showinbio']) { $mem[$id] = $prefs; } } if (count($mem)) { output("`bMementos`b`n"); rawoutput("<table width=100% style='border: dotted 1px #000000;'>"); foreach ($mem as $id => $prefs) { $classcount += 1; $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'])); rawoutput("</td></tr>"); } rawoutput("</table>"); output("`n`n"); } break; } return $args; }
function giftstation_run() { global $session; page_header("The Gifting Station"); $op = httpget('op'); $points = $session['user']['donation'] - $session['user']['donationspent']; switch ($op) { case "start": if (httpget("subop") == "continue") { output("The KittyMorph shows you a big smile. \"`1Okay, that'll be delivered first thing in the morning. Should make for a nice surprise when they wake up. Anyone else you'd like to send a gift to?`0\"`n`n"); $player = httpget('player'); $itemid = httpget('item'); $box = httpget('box'); $free = httpget('free'); $anonymous = httpget('anonymous'); $boxid = give_item($box, false, "giftstation_" . $player); // debug($boxid); // debug($itemid); change_item_owner($itemid, $boxid); set_item_pref("giftbox_contains", $itemid, $boxid); if (!$anonymous) { $desc = get_item_pref("description", $boxid); $desc .= "`nThere's a gift tag attached to the box, telling you that this present came from " . $session['user']['name'] . "`0."; set_item_pref("description", $desc, $boxid); } //notify player that they've got something awesome waiting for them require_once "lib/systemmail.php"; $body = "Someone has used the Gifting Station in Common Ground to send you something. Whatever it is, it'll turn up on your next new Game Day."; systemmail($player, "Someone sent you something awesome!", $body); if (!$free) { $session['user']['donationspent'] += 1; //log purchase $sql = "INSERT INTO " . db_prefix("purchaselog") . " (acctid,purchased,amount,data,giftwrap,timestamp) VALUES ('" . $session['user']['acctid'] . "','giftstation_giftwrap','1','none','0','" . date("Y-m-d H:i:s") . "')"; $points = $session['user']['donation'] - $session['user']['donationspent']; } addnav("No, I think that'll do, thanks.", "gardens.php"); } else { if (httpget("subop") == "searchagain") { output("The KittyMorph nods, scratching out the contestant's name on his clipboard. \"`1No problem. Let's take it from the top.`0\"`n`n"); addnav("Actually, forget the whole thing.", "gardens.php"); } else { output("`0You head into the Gift Exchange. A black-furred KittyMorph stands behind a counter.`n`n\"`1Hey there!`0\" he says. \"`1As part of our continued diplomatic efforts, we provide a gift-wrapping service for items you'd like to send to your fellow contestants. Interested?`0\"`n`n"); output("It costs one Supporter Point to gift-wrap and transfer (nearly) any item to any player. Some items can be transferred for free. You currently have %s Supporter Points.`n`n", number_format($points)); addnav("No thanks.", "gardens.php"); } } if ($points > 0) { output("Search below for a player to send a present to."); rawoutput("<form action='runmodule.php?module=giftstation&op=findplayer' method='post'>"); rawoutput("<input name='name'>"); rawoutput("<input type='submit' class='button' value='" . translate_inline("search") . "'>"); rawoutput("</form>"); addnav("", "runmodule.php?module=giftstation&op=findplayer"); } else { output("You don't have any Supporter Points!`n`n"); } break; case "findplayer": $search = "%"; $n = httppost('name'); for ($x = 0; $x < strlen($n); $x++) { $search .= substr($n, $x, 1) . "%"; } $search = " AND name LIKE '" . addslashes($search) . "' "; $uid = $session['user']['uniqueid']; $lastip = $session['user']['lastip']; $sql = "SELECT uniqueid, acctid, name FROM " . db_prefix("accounts") . " WHERE locked=0 {$search} ORDER BY name DESC "; $result = db_query($sql); output("The KittyMorph nods. \"`1Okay, let's have a look at who I've got written down here whose name sounds like that...`0\"`n`n"); $matches = 0; for ($i = 0; $i < db_num_rows($result); $i++) { $row = db_fetch_assoc($result); if ($row['uniqueid'] != $session['user']['uniqueid']) { addnav("", "runmodule.php?module=giftstation&op=chooseitem&player=" . $row['acctid']); output_notl("<a href='runmodule.php?module=giftstation&op=chooseitem&player=" . $row['acctid'] . "'>" . $row['name'] . "</a>", true); output("`n"); $matches++; } } if ($matches == 0) { output("He looks down at his list. \"`1Oh. Actually, it doesn't look like there's `ianyone`i matching that description who you can send a present to. Bummer. Wanna try that again?`0\""); } addnav("Return to Common Ground", "gardens.php"); addnav("Search Again", "runmodule.php?module=giftstation&op=start"); break; case "chooseitem": $player = httpget('player'); output("The KittyMorph reaches below his counter and brings up a clipboard on which he writes down the name of your nominated contestant. \"`1Okay, I've got the name - now, what would you like to send?`0\"`n`n"); $giftables = get_items_with_prefs("giftable"); if ($giftables) { $giftables = group_items($giftables); foreach ($giftables as $sortid => $prefs) { $itemid = $prefs['itemid']; if ($prefs['freegift']) { addnav("Send for free"); addnav(array("%s (%s available)", $prefs['verbosename'], $prefs['quantity']), "runmodule.php?module=giftstation&op=choosewrapping&item={$itemid}&player={$player}&free=1"); } else { addnav("Send for one Supporter Point"); addnav(array("%s (%s available)", $prefs['verbosename'], $prefs['quantity']), "runmodule.php?module=giftstation&op=choosewrapping&item={$itemid}&player={$player}&free=0"); } } addnav("Cancel?"); addnav("Wait, I've changed my mind. Let's back up a step.", "runmodule.php?module=giftstation&op=start&subop=searchagain"); addnav("Actually, forget the whole thing.", "gardens.php"); } else { output("You realise that you have nothing that you can give away. You shrug your shoulders and give the KittyMorph a big, silly grin.`n`n"); addnav("This is awkward."); addnav("Run out of the shop. Just run.", "gardens.php"); } break; case "choosewrapping": $player = httpget('player'); $itemid = httpget('item'); $free = httpget('free'); output("The KittyMorph nods, taking the item from you and beginning to wrap it in tissue paper. \"`1They should be pleased with that. Care to choose a box, while I wrap this up?`0\"`n`nClick on any box to confirm the gift.`n`n"); $boxes = get_items_with_settings("giftwrap"); foreach ($boxes as $boxid => $prefs) { $img = $prefs['image']; rawoutput("<a href='runmodule.php?module=giftstation&op=chooseanonymous&player={$player}&item={$itemid}&box={$boxid}&free={$free}'><img src='images/items/{$img}'></a>"); addnav("", "runmodule.php?module=giftstation&op=chooseanonymous&player={$player}&item={$itemid}&box={$boxid}&free={$free}"); } addnav("Cancel?"); addnav("Wait, I've changed my mind. Let's back up a step.", "runmodule.php?module=giftstation&op=start&subop=searchagain"); addnav("Actually, forget the whole thing.", "gardens.php"); break; case "chooseanonymous": $player = httpget('player'); $itemid = httpget('item'); $free = httpget('free'); $box = httpget('box'); output("The KittyMorph ties a ribbon around the box before reaching below the counter and bringing up a gift tag and a preposterously flamboyant quill pen.`n`n\"`1So, is this an anonymous gift, or would you like your name on it?`0\"`n`n"); addnav("Anonymous or not?"); addnav("Tell them who it's from", "runmodule.php?module=giftstation&op=start&subop=continue&player={$player}&item={$itemid}&box={$box}&free={$free}"); addnav("Give anonymously", "runmodule.php?module=giftstation&op=start&subop=continue&player={$player}&item={$itemid}&box={$box}&free={$free}&anonymous=true"); break; } page_footer(); return true; }
function show_item_fightnavs($script) { global $session, $inventory; //TODO: Define links for these if (!isset($inventory)) { load_inventory(); } $gr = group_items($inventory); foreach ($gr as $sortid => $vals) { $itemid = $vals['itemid']; addnav("Use Fight Items"); if ($vals['context_fight'] && $vals['inventorylocation'] == "fight" && !$vals['blockuse']) { if ($vals['quantity'] > 1) { addnav(array("%s (%s)", $vals['verbosename'], $vals['quantity']), $script . "op=fight&items_useitem={$itemid}"); } else { addnav(array("%s", $vals['verbosename']), $script . "op=fight&items_useitem={$itemid}"); } } } }
function worldmap_items_getsquare($xyz, $group = true) { global $itemprefs, $itemsettings; $ret = array(); $sql = "SELECT id,owner FROM " . db_prefix("items_prefs") . " WHERE setting='worldmap_location' AND value='{$xyz}'"; $result = db_query($sql); $load = array(); while ($row = db_fetch_assoc($result)) { if (!$row['owner']) { $load[] = $row['id']; } } $ret = load_non_player_inventory($load); if (count($ret) > 1 && $group) { $ret = group_items($ret); } return $ret; }
function rail_collector_emptyhand() { // returns the number of cards that have been removed global $session, $inventory; if (!isset($inventory)) { load_inventory(); } $items = group_items($inventory); $qty = 0; foreach ($items as $ptr => $details) { $itemname = $details['item']; $pos = strpos($itemname, "railcard"); if ($pos === 0) { // Boolean false if not found; pos 0 if found in, eg, "railcard01" $qty = $qty + delete_all_items_of_type($itemname); } } return $qty; }