function rail_collector_runevent($type, $link) { global $session; if (rail_hascard("cardcase")) { // yes, findcard also calls hascard, but here they are going to get a different message // to give them a clue that they should go get a cardcase to start playing the collecting game if (rail_collector_findcard()) { output("`2Half-hidden in damp leaves under a bush you notice a smudged, battered old playing card. Who knows, perhaps it might be worth something to a collector. Carefully you wipe it off and tuck it away in your fine leather card case.`0`n`n"); } else { // The event was triggered, but they didn't qualify for a card. Have to do something... // this is a bad message, but they're still going to get a 'Something Improbable!' page. // Leave as is for now. To-do: change this some other card-related event. output("`2Preoccupied with more important matters, you fail to notice a smudged, battered old playing card half-hidden in the damp leaves under a bush.`0`n`n"); } } else { output("`2Half-hidden in damp leaves under a bush you notice a smudged, battered old playing card. You can't think what use it could be -- and anyway, you have no place to keep it -- so you don't trouble to pick it up.`0`n`n"); } }
function rail_luckydip_run() { global $session; $op = httpget('op'); $hid = httpget('hid'); $rid = httpget('rid'); $cost = get_module_setting("cost"); $lcost = get_module_setting("lcost"); $tryallowed = get_module_setting("tryallowed"); $trytoday = get_module_pref("trytoday"); page_header("Roving Lucky Dip"); output("`&`c`bElias and his `2Lucky Dip`b`c`n"); switch ($op) { case "start": if ($trytoday >= $tryallowed) { output("`2Much as you'd like to play again, Elias only gives you a friendly nod and turns to the child beside you.`0`n`n"); addnav("Thank him"); } elseif ($session['user']['gold'] < $cost) { output("`n`2Much as you'd like to play, your wallet doesn't hold enough to pay for the privilege. Still, there's always time to exchange a few words.`0`n`n"); addnav("Smile and"); } else { output("`2You peer at the small colored packages with interest."); output("Elias stands behind the brightly-colored bins.`n`n"); output("`2\"`&Hello traveller! "); output("So you think yourself lucky? "); output("There are many treasures in these boxes!`2\"`n`n"); output("`2He motions to the smaller box, and then to the larger one. "); output("`&\"%s requisition for the small, %s for the large. ", $cost, $lcost); output("Who knows what you will find?`2\"`0`n`n"); addnav("Dip your hand"); addnav(array("Small (%s req)", $cost), "runmodule.php?module=rail_luckydip&op=small&hid={$hid}&rid={$rid}"); if ($session['user']['gold'] >= $lcost) { addnav(array("Large (%s req)", $lcost), "runmodule.php?module=rail_luckydip&op=large&hid={$hid}&rid={$rid}"); } } break; case "small": $binsize = "small"; case "large": if ($trytoday >= $tryallowed) { output("`2Much as you'd like to play again, Elias only gives you a friendly nod and turns to the child beside you.`0`n`n"); addnav("Thank him"); } elseif ($session['user']['gold'] < $cost) { output("`n`2Much as you'd like to play, your wallet doesn't hold enough to pay for the privilege. Still, there's always time to exchange a few words.`0`n`n"); addnav("Smile"); } else { $trytoday++; set_module_pref("trytoday", $trytoday); $gift = e_rand(1, 4); if ($binsize == "small") { $dipchance = e_rand(1, 25); $session['user']['gold'] -= $cost; // debuglog("spent $cost gold on a lucky dip."); output("`7You hand Elias your %s requisition, and reach one arm into the blue and white box. ", $cost); } else { $dipchance = e_rand(1, 50); // Elias has a warped sense of humour $session['user']['gold'] -= $lcost; // debuglog("spent $lcost gold on a lucky dip."); output("`2You hand Elias your %s requisition, and reach one arm into the red and white box. ", $lcost); } output("Dragging a package out, you unwrap it with excitement. "); output("Elias smiles.`n`n"); output("`2\"`&So you see, a treasure! "); if ($dipchance == 1) { output("A treasure indeed! "); output("I hope you shall keep it safe!`2\"`n`n"); if (rail_collector_findcard()) { output("`2In your hands is a `6playing card`2!"); } else { output("`2In your hands is a `6calle shell`2!"); $callecount = get_module_pref("callecount", "calletrader"); $callecount++; set_module_pref("callecount", $callecount, "calletrader"); } output("`7You're rather amazed to find such a treasure in a simple lucky dip!"); } elseif ($gift == 4) { output("I hope you shall keep it safe!\"`n`n"); output("`2In your hands is a `5cigarette`2!"); $session['user']['gems']++; } elseif ($gift == 3) { output("I hope you shall spend it wisely!`2\"`n`n"); output("`2You look down to find `610 requisition`2."); $session['user']['gold'] += 10; } elseif ($gift == 2) { output("You shall have hours of joy playing with such a treasure!`2\"`n`n"); output("`2You look down to find a cheap `6children's toy`2."); output("`2You grin -- and play with it amusedly for a few minutes before handing it to the nearest small child, who is delighted."); } else { output("I hope you enjoy it!\""); output("`n`n`7You look down to find a small iced cookie."); output("`n`n`^You bite into it with joy!"); // Don't let it heal them too far if ($session['user']['hitpoints'] <= $session['user']['maxhitpoints'] * 1.1) { $session['user']['hitpoints'] *= 1.05; output("`@You feel healthy!"); $addstam = e_rand(1, 4); if ($addstam == 1) { require_once "modules/staminasystem/lib/lib.php"; addstamina(25000); output("`@You feel `@vigorous!"); } } } addnav("Try again"); addnav(array("Small (%s req)", $cost), "runmodule.php?module=rail_luckydip&op=small&hid={$hid}&rid={$rid}"); if ($session['user']['gold'] >= $lcost) { addnav(array("Large (%s req)", $lcost), "runmodule.php?module=rail_luckydip&op=large&hid={$hid}&rid={$rid}"); } } break; } // end switch addnav("Leave", "runmodule.php?module=rail_ironhorse&op=board&hid={$hid}&rid={$rid}"); page_footer(); }