当前位置: 首页>>代码示例>>PHP>>正文


PHP e_rand函数代码示例

本文整理汇总了PHP中e_rand函数的典型用法代码示例。如果您正苦于以下问题:PHP e_rand函数的具体用法?PHP e_rand怎么用?PHP e_rand使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了e_rand函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: drunkard_runevent

function drunkard_runevent($type)
{
    global $session;
    require_once "lib/partner.php";
    $partner = get_partner();
    $chance = get_module_setting("spillchance");
    $roll = e_rand(1, 100);
    $seen = get_module_pref("seen");
    set_module_pref("seen", $seen + 1);
    output("`5A very drunk patron stumbles into you as you make your way across the crowded room.`n`n");
    if ($roll < $chance) {
        // He spills on you
        output("`5He is carrying a nearly full glass of ale.");
        output("As he collides with you, it spills all over your nearly clean clothes!");
        output("As you look up, you notice %s`5 watching you and become acutely embarrassed.", $partner);
        output("You notice %s`5 is trying to keep from laughing out loud at your mishap.", $partner);
        output("`n`n`&You `\$lose 1`& charm point.");
        if ($session['user']['charm'] > 0) {
            $session['user']['charm']--;
        }
    } else {
        // You're safe
        output("`5Fortunately his glass was already empty.");
        output("You escort him over to a chair where he can sit without running into everyone else.");
        output("As you stand up, you catch %s's`5 eye and receive a big smile for your kindness.", $partner);
        output("`n`n`&You gain `^1`& charm.");
        $session['user']['charm']++;
    }
}
开发者ID:CavemanJoe,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:29,代码来源:drunkard.php

示例2: creatureaddon_dohook

function creatureaddon_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "gravefight-start":
            if (get_module_objpref("creatures", $args['creatureid'], "description")) {
                output(stripslashes(get_module_objpref("creatures", $args['creatureid'], "description")));
            }
            break;
        case "creatureencounter":
            $args['creaturegold'] += get_module_objpref("creatures", $args['creatureid'], "addgold");
            $args['creaturehealth'] += get_module_objpref("creatures", $args['creatureid'], "addhit");
            $args['creatureattack'] += get_module_objpref("creatures", $args['creatureid'], "addattack");
            $args['creaturedefense'] += get_module_objpref("creatures", $args['creatureid'], "adddefense");
            if (get_module_objpref("creatures", $args['creatureid'], "image")) {
                rawoutput("<table width = \"100%\"><tr><td width=\"100%\" align = \"center\"><img src=\"./images/" . get_module_objpref("creatures", $args['creatureid'], "image") . "\"></td></tr></table>");
            }
            if (get_module_objpref("creatures", $args['creatureid'], "description") && !httpget("nodesc")) {
                output(stripslashes(get_module_objpref("creatures", $args['creatureid'], "description")));
            }
            break;
        case "battle-victory":
            if ($session['user']['level'] < 15 && e_rand(1, 100) <= get_module_objpref("creatures", $args['creatureid'], "gemchance") && get_module_objpref("creatures", $args['creatureid'], "gemmessage")) {
                $message = get_module_objpref("creatures", $args['creatureid'], "gemmessage");
                output($message);
                debug("Creature Addon module is awarding a gem.");
                $session['user']['gems']++;
                debuglog("found a gem when slaying a " . $args['creaturename']);
            }
            break;
    }
    return $args;
}
开发者ID:Beeps,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:33,代码来源:creatureaddon.php

示例3: forestturn_runevent

function forestturn_runevent($type)
{
    global $session;
    // The only type of event we care about are the forest.
    $chance = get_module_setting("percentgain");
    $roll = e_rand(1, 100);
    if ($roll <= $chance) {
        output("`^You discover a skin of liquid hanging over the limb of a tree.");
        output("Since the sigils inscribed on the skin are those of someone you recognize as a very powerful warrior from the village, you decide that it would be safe to take a sip.`n`n`n");
        output("Man is that stuff potent!");
        output("You feel `!hyper`^.`n`n");
        output("You `%receive one`^ extra turn!`0");
        $session['user']['turns']++;
    } else {
        output("`^Walking along a path in the forest, you come upon a field of flowers.");
        output("Stopping to pick one, you inhale its scent.`n`n");
        output("`\$Yawn!");
        output("`^Man, that flower scent made you really sleepy.");
        output("You stumble off the path to take a nap.`n`n");
        if ($session['user']['turns'] > 0) {
            output("You `%lose one `^turn!`0");
            $session['user']['turns']--;
        }
    }
}
开发者ID:CavemanJoe,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:25,代码来源:forestturn.php

示例4: binarypuzzle_run

function binarypuzzle_run()
{
    global $session;
    page_header("Binary Puzzle Thing!");
    addnav("O?Back to the Outpost", "village.php");
    switch (httpget('op')) {
        case "start":
            //first set up the board
            $switches = array(1 => array("val" => 1, "status" => 0), 2 => array("val" => 2, "status" => 0), 3 => array("val" => 4, "status" => 0), 4 => array("val" => 8, "status" => 0), 5 => array("val" => 16, "status" => 0), 6 => array("val" => 32, "status" => 0), 7 => array("val" => 64, "status" => 0), 8 => array("val" => 128, "status" => 0));
            shuffle($switches);
            set_module_pref("switches", serialize($switches));
            //Now set up the clues
            $clues = array();
            for ($i = 1; $i <= 8; $i++) {
                $toprange = $i * 32;
                $bottomrance = $toprange - 32;
                $clues[$i] = e_rand($bottomrange, $toprange);
            }
            $goal = e_rand(129, 255);
            set_module_pref("clues", serialize($clues));
            binarypuzzle_show($switches, $goal);
            break;
        case "switch":
            $sw = httpget('switch');
            $goal = httpget('goal');
            $switches = binarypuzzle_switch($sw);
            binarypuzzle_show($switches, $goal);
            break;
    }
    page_footer();
}
开发者ID:CavemanJoe,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:31,代码来源:binarypuzzle.php

示例5: pubjokes_runevent

function pubjokes_runevent($type)
{
    global $session;
    $jokenum = e_rand(1, 8);
    $landlord = getsetting("barkeep", "`)Cedrik");
    switch ($jokenum) {
        case 1:
            output("A tall, hairy man enters the pub and strolls over to the bar.  The frog sulking on the top of his bald head draws some stares.  %s looks him up and down, and after a moment's thought, nods up at the frog and asks \"So, mate - where did you get that?\"`n\"Well, it started off as a wart on my arse,\" says the frog.`n`n", $landlord);
            break;
        case 2:
            output("A small, mottled brown duck walks into the pub.  He waddles over to the bar, hops onto a stool, and fixes %s with an intense stare.  You watch closely, knowing that the two are about to face off in a battle of wits.`n\"Got any bread?\" asks the duck.`n\"No,\" replies %s.`n\"Got any bread?\" asks the duck.`n\"No,\" replies %s.`n\"Got any bread?\"`n\"No.\"`n\"Got any bread?\"`n\"No.\"`n\"Got any bread?\"`n\"No.\"`n\"Got any bread?\"`n\"`iNo.`i\"`n\"Got any bread?\"`n\"NO!\"`n\"Got any bread?\"`n\"No, and the next time you ask, I'm going to nail your damned beak to this bar.\"`nThe duck looks up at %s's fierce expression, and appears to reach a decision.`n\"Got any nails?\"`n\"No.\"`n\"Got any bread?\"`n%s's hands move too fast for you to see, but the loud hammering sound and the squeals of indignant quacking pain serve to paint you a pretty good picture.`n\"I lied about the nails,\" says %s with a smile, and goes back to serving drinks.`n`n", $landlord, $landlord, $landlord, $landlord, $landlord, $landlord);
            break;
        case 3:
            output("A severely drunk man blunders past you, laughing and slurring \"ALL MIDGETS ARE BASTARDS!\"`nA figure lurking in the shadows at the corners of the pub calls after him: \"Hey, I take offense at that!\"`nThe drunkard turns around and slurs back, \"Why, mate, 're you a Midget or summat?\"`n\"No, I'm a bastard.\"`n`n");
            break;
        case 4:
            output("A very attractive woman walks up to the bar. She gestures alluringly to Mick, the assistant bartender, who comes over immediately.  When he arrives, she seductively signals that he should bring his face closer to hers. When he does so, she begins to gently caress his full beard.`n\"Are you %s?\", she asks, softly stroking his face with both hands.`n\"Actually, no,\" he replies.\"Can you get him for me? I need to speak to him,\" she says, running her hands beyond his beard and into his hair.`n\"He's just downstairs changing the barrels,\" breathes Mick. \"Is there anything I can do?\"`n\"Yes, there is. I need you to give him a message,\" she continues, slyly popping a couple of her fingers into his mouth and allowing him to suck them gently.`n\"Wh-what should I tell him?\" Mick somehow manages to stammer, his ears as red as emergency flares.`n\"Tell him,\" she whispers, \"There is no toilet paper or hand soap in the ladies room.\"`n`n", $landlord);
            break;
        case 5:
            output("A wriggling SpiderKitty prances over to the bar, climbs up onto a stool and asks for a beer.  %s begins to pour, chuckling.  \"You know,\" he says, \"I named this pub after you.\"`n\"What,\" says the prancing SpiderKitty, \"You named your pub Dave?\"`n`n", $landlord);
            break;
        case 6:
            output("A horse walks into the pub and up to the bar.  %s says, \"Why the long face?\"`nThe horse shrugs. \"Crap jokes, mainly.\"`n\"Ah.\"`n`n", $landlord);
            break;
        case 7:
            output("A man walks in to the pub.  %s, seeing him, pulls his shotgun from under the bar.  \"OUT!\" he shouts.  \"YOU BLOODY WELL KNOW YOU'VE BEEN BARRED!\"`nAs the man sheepishly leaves, you ask %s what the problem was.  He turns to you, shaking his head.`n\"The sign that said \"Wet Floor\" was supposed to be a `icaution`i, not a request.\"`nYou wondered why your boots were sticking so bad.`n`n", $landlord, $landlord);
            break;
        case 8:
            output("You notice a man quite the worse for wear, staggering out of the pub with his pet giraffe in tow - similarly inebriated, the giraffe falls over onto its side, and the man keeps walking.  %s calls after him - \"Hey!  You can't leave that lyin' there!\"`nThe man turns around and gets as far as \"It's not a lion, it's a...\" before the lion bursts from its disguise and drags him screaming into the jungle.  The regulars shrug and go back to their pints.`n`n", $landlord);
            break;
    }
}
开发者ID:CavemanJoe,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:32,代码来源:pubjokes.php

示例6: zapgrenade_use

function zapgrenade_use($args)
{
    global $session;
    debug("Applying Zap Grenade buff");
    apply_buff('zapgrenade', array("startmsg" => "`3You pull the pin on your grenade and toss it at {badguy}`3, 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}`3 feels some coherence return, and lunges at you!", "expireafterfight" => 1, "schema" => "iitems-catcher"));
    return $args;
}
开发者ID:CavemanJoe,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:7,代码来源:zapgrenade.php

示例7: worldmapen_defaultcityloc

function worldmapen_defaultcityloc()
{
    global $session;
    $i = 0;
    $citylocX = 0;
    $citylocY = 0;
    $citylocations = array();
    $citylocations[][] = "";
    $vloc = array();
    $vname = getsetting("villagename", LOCATION_FIELDS);
    $vloc[$vname] = "village";
    $vloc = modulehook("validlocation", $vloc);
    foreach ($vloc as $loc => $val) {
        $k = 0;
        while ($k == 0) {
            foreach ($citylocations as $val1) {
                if ($val1[0] == $citylocX && $val1[1] == $citylocY) {
                    $k = 0;
                    $citylocX = e_rand(1, get_module_setting("worldmapsizeX"));
                    $citylocY = e_rand(1, get_module_setting("worldmapsizeY"));
                } else {
                    $k++;
                    $citylocations[$i][0] = $citylocX;
                    $citylocations[$i][1] = $citylocY;
                    set_module_setting($loc . 'X', $citylocX);
                    set_module_setting($loc . 'Y', $citylocY);
                    set_module_setting($loc . 'Z', "1");
                }
            }
        }
        $i++;
    }
}
开发者ID:CavemanJoe,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:33,代码来源:lib.php

示例8: lovers_chat_seth

function lovers_chat_seth()
{
    global $session;
    if (httpget("act") == "") {
        output("You make your way over to where %s`0 is sitting, ale in hand.", getsetting("bard", "`^Seth"));
        output("Sitting down, and waiting for %s`0 to finish a song, you light your pipe.", getsetting("bard", "`^Seth"));
        addnav("Ask about your manliness", "runmodule.php?module=lovers&op=chat&act=armor");
        addnav("Discuss Sports", "runmodule.php?module=lovers&op=chat&act=sports");
    } elseif (httpget("act") == "sports") {
        output("You and %s`0 spend some time talking about the recent dwarf tossing competition.", getsetting("bard", "`^Seth"));
        output("Not wanting to linger around another man for too long, so no one \"wonders\", you decide you should find something else to do.");
    } else {
        $charm = $session['user']['charm'] + e_rand(-1, 1);
        output("%s`0 looks you up and down very seriously.", getsetting("bard", "`^Seth"));
        output("Only a friend can be truly honest, and that is why you asked him.");
        switch ($charm) {
            case -3:
            case -2:
            case -1:
            case 0:
                $msg = translate_inline("You make me glad I'm not gay!");
                break;
            case 1:
            case 2:
            case 3:
                $msg = translate_inline("I've seen some handsome men in my day, but I'm afraid you aren't one of them.");
                break;
            case 4:
            case 5:
            case 6:
                $msg = translate_inline("I've seen worse my friend, but only trailing a horse.");
                break;
            case 7:
            case 8:
            case 9:
                $msg = translate_inline("You're of fairly average appearance my friend.");
                break;
            case 10:
            case 11:
            case 12:
                $msg = translate_inline("You certainly are something to look at, just don't get too big of a head about it, eh?");
                break;
            case 13:
            case 14:
            case 15:
                $msg = translate_inline("You're quite a bit better than average!");
                break;
            case 16:
            case 17:
            case 18:
                $msg = translate_inline("Few women would be able to resist you!");
                break;
            default:
                $msg = translate_inline("I hate you, why, you are simply the most handsome man ever!");
        }
        output("Finally he reaches a conclusion and states, \"%s`0\"", $msg);
    }
}
开发者ID:CavemanJoe,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:58,代码来源:lovers_chat_seth.php

示例9: lottery_dohook

function lottery_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "newday":
            $numbers = get_module_setting("todaysnumbers");
            $n = $numbers;
            output("`n`@Today's lottery numbers are `^%s-%s-%s-%s`0`n", $n[0], $n[1], $n[2], $n[3]);
            $roundnum = get_module_setting("roundnum");
            $pround = get_module_pref("roundnum");
            if ($roundnum > $pround) {
                if (get_module_pref("pick") === $numbers) {
                    $prize = get_module_setting("prize");
                    if ($prize > "" && $pround < $roundnum) {
                        rawoutput("<font size='+1'>");
                        output("`\$You won today's lottery!`0`n");
                        rawoutput("</font>");
                        output("`\$The jackpot is `^^%s`\$ gold, money that has been deposited in to your bank account!`n", $prize);
                        $session['user']['goldinbank'] += $prize;
                        debuglog("won {$prize} gold on lottery");
                        addnews("`@%s`@ won `^%s`@ gold in the lottery!`0", $session['user']['name'], $prize);
                    }
                }
                set_module_pref("pick", "");
            }
            break;
        case "newday-runonce":
            $numbers = array();
            for ($i = 0; $i < 4; $i++) {
                $numbers[$i] = e_rand(0, 9);
            }
            sort($numbers);
            set_module_setting("todaysnumbers", join("", $numbers));
            $sql = "SELECT count(*) AS c FROM " . db_prefix("module_userprefs") . " WHERE modulename='lottery' AND setting='pick' AND value='" . join("", $numbers) . "'";
            $result = db_query($sql);
            $row = db_fetch_assoc($result);
            if ($row['c'] > 0) {
                //split the jackpot among winners.
                $prize = round(get_module_setting("currentjackpot") / $row['c'], 0);
                set_module_setting("prize", $prize);
                set_module_setting("currentjackpot", get_module_setting("basepot"));
                set_module_setting("howmany", $row['c']);
            } else {
                //the jackpot rolls over.
                set_module_setting("prize", 0);
                set_module_setting("howmany", 0);
            }
            set_module_setting("roundnum", get_module_setting("roundnum") + 1);
            break;
        case "inn":
            addnav("Things to do");
            addnav(array("%s`0's Lottery", getsetting('barkeep', '`tCedrik')), "runmodule.php?module=lottery&op=store");
            break;
    }
    return $args;
}
开发者ID:CavemanJoe,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:56,代码来源:lottery.php

示例10: lights_out_run

function lights_out_run()
{
    global $session;
    page_header("Lights Out!");
    addnav("O?Back to the Outpost", "village.php");
    //playtesting
    $numlights = 9;
    $lightsperrow = 3;
    $startlights = 5;
    $maxchangesperlight = 4;
    switch (httpget('op')) {
        case "start":
            $lights = array();
            for ($lamp = 1; $lamp <= 9; $lamp++) {
                $lights[$lamp]['status'] = 0;
                $numberofchanges = e_rand(2, 4);
                $lampstochange = array(1 => "1", 2 => "2", 3 => "3", 4 => "4", 5 => "5", 6 => "6", 7 => "7", 8 => "8", 9 => "9");
                unset($lampstochange[$lamp]);
                $switches = array();
                for ($c = 1; $c <= $numberofchanges; $c++) {
                    $sw = array_rand($lampstochange);
                    $switches[] = $sw;
                    unset($lampstochange[$sw]);
                }
                $lights[$lamp]['changes'] = $switches;
            }
            debug($lights);
            //Now randomly poke some lights
            for ($i = 1; $i <= $startlights; $i++) {
                $sw = e_rand(1, $numlights);
                $lights = lights_out_switch($sw, $lights);
            }
            $spref = serialize($lights);
            set_module_pref("lights", $spref);
            $moves = 0;
            $jackpot = 200;
            lights_out_show($lights, $moves, $jackpot);
            break;
        case "switch":
            $moves = httpget('moves');
            $moves++;
            $jackpot = httpget('jackpot');
            output("Current jackpot: %s`n", $jackpot);
            $lights = lights_out_switch(httpget('switch'));
            $jackpot += 5;
            lights_out_show($lights, $moves, $jackpot);
            $lit = lights_out_check($lights);
            if (!$lit) {
                output("Congratulations!  You won %s Req, for your stake of %s!", $jackpot, $moves * 10);
            } else {
                output("There are %s lights left to turn off.  You have made %s moves.`n", $lit, $moves);
            }
            break;
    }
    page_footer();
}
开发者ID:Beeps,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:56,代码来源:lights_out.php

示例11: findgold_runevent

function findgold_runevent($type, $link)
{
    global $session;
    $min = $session['user']['level'] * get_module_setting("mingold");
    $max = $session['user']['level'] * get_module_setting("maxgold");
    $gold = e_rand($min, $max);
    output("`^Fortune smiles on you and you find %s gold!`0", $gold);
    $session['user']['gold'] += $gold;
    debuglog("found {$gold} gold in the dirt");
}
开发者ID:CavemanJoe,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:10,代码来源:findgold.php

示例12: drinks_drunkenize

function drinks_drunkenize($commentary, $level)
{
    if (get_module_pref("noslur")) {
        return $commentary;
    }
    $straight = $commentary;
    $replacements = 0;
    while ($replacements / strlen($straight) < $level / 500) {
        $slurs = array("a" => "aa", "e" => "ee", "f" => "ff", "h" => "hh", "i" => "iy", "l" => "ll", "m" => "mm", "n" => "nn", "o" => "oo", "r" => "rr", "s" => "sss", "u" => "oo", "v" => "vv", "w" => "ww", "y" => "yy", "z" => "zz");
        if (e_rand(0, 9)) {
            $letter = array_rand($slurs);
            $x = strpos(strtolower($commentary), $letter);
            if ($x !== false && substr($commentary, $x, 5) != "*hic*" && substr($commentary, max($x - 1, 0), 5) != "*hic*" && substr($commentary, max($x - 2, 0), 5) != "*hic*" && substr($commentary, max($x - 3, 0), 5) != "*hic*" && substr($commentary, max($x - 4, 0), 5) != "*hic*") {
                if (substr($commentary, $x, 1) != strtolower($letter)) {
                    $slurs[$letter] = strtoupper($slurs[$letter]);
                } else {
                    $slurs[$letter] = strtolower($slurs[$letter]);
                }
                $commentary = substr($commentary, 0, $x) . $slurs[$letter] . substr($commentary, $x + 1);
                $replacements++;
            }
        } else {
            $x = e_rand(0, strlen($commentary));
            // Skip the ` followed by a letter
            if (substr($commentary, $x - 1, 1) == "`") {
                $x += 1;
            }
            if (substr($commentary, $x, 5) == "*hic*") {
                $x += 5;
            }
            if (substr($commentary, max($x - 1, 0), 5) == "*hic*") {
                $x += 4;
            }
            if (substr($commentary, max($x - 2, 0), 5) == "*hic*") {
                $x += 3;
            }
            if (substr($commentary, max($x - 3, 0), 5) == "*hic*") {
                $x += 2;
            }
            if (substr($commentary, max($x - 4, 0), 5) == "*hic*") {
                $x += 1;
            }
            $commentary = substr($commentary, 0, $x) . "*hic*" . substr($commentary, $x);
            $replacements++;
        }
        //end if
    }
    //end while
    //get rid of spare *'s in *hic**hic*
    while (strpos($commentary, "*hic**hic*")) {
        $commentary = str_replace("*hic**hic*", "*hic*hic*", $commentary);
    }
    return $commentary;
}
开发者ID:CavemanJoe,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:54,代码来源:drunkenize.php

示例13: quest_rohit_dohook

function quest_rohit_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "worldnav":
            if (get_module_pref("plotpoint1") && !get_module_pref("plotpoint2") && e_rand(0, 100) < 10 && $session['user']['race'] != "Robot") {
                redirect("runmodule.php?module=quest_rohit&op=plotpoint2", "Redirecting to Rohit Plot Point 2 from World Map");
            }
            break;
    }
    return $args;
}
开发者ID:CavemanJoe,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:12,代码来源:quest_rohit.php

示例14: mountrarity_dohook

function mountrarity_dohook($hookname, $args)
{
    switch ($hookname) {
        case "newday-runonce":
            $sql = "SELECT mountid FROM " . db_prefix("mounts") . " WHERE mountactive=1";
            $result = db_query($sql);
            while ($row = db_fetch_assoc($result)) {
                $id = $row['mountid'];
                $rarity = get_module_objpref("mounts", $id, "rarity");
                if (e_rand(1, 100) > $rarity) {
                    set_module_objpref("mounts", $id, "unavailable", 1);
                } else {
                    // You need to reset the availability if it's not unavailable
                    // otherwise, it never becomes available again!
                    set_module_objpref("mounts", $id, "unavailable", 0);
                }
            }
            break;
        case "mountfeatures":
            $rarity = get_module_objpref("mounts", $args['id'], "rarity");
            $args['features']['Rarity'] = $rarity;
            break;
        case "stables-desc":
            if (get_module_setting("showout")) {
                $sql = "SELECT mountid, mountname FROM " . db_prefix("mounts") . " WHERE mountactive=1";
                $result = db_query($sql);
                output("`nA sign by the door proclaims that the following mounts are out of stock for today:");
                while ($row = db_fetch_assoc($result)) {
                    $out = get_module_objpref("mounts", $row['mountid'], "unavailable");
                    if ($out) {
                        output("`n%s", $row['mountname']);
                    }
                }
            } else {
                output("`nIf you don't see something you like today, perhaps you should check again tomorrow.");
            }
            break;
        case "stables-nav":
            $sql = "SELECT mountid FROM " . db_prefix("mounts") . " WHERE mountactive=1";
            $result = db_query($sql);
            while ($row = db_fetch_assoc($result)) {
                $id = $row['mountid'];
                $out = get_module_objpref("mounts", $id, "unavailable");
                if ($out) {
                    blocknav("stables.php?op=examine&id={$id}");
                }
            }
            break;
    }
    return $args;
}
开发者ID:CavemanJoe,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:51,代码来源:mountrarity.php

示例15: heidi_dohook

function heidi_dohook($hookname, $args)
{
    global $session;
    switch ($hookname) {
        case "village":
            $allowgift = get_module_setting("allowgift");
            $allowdp = get_module_setting("allowdp");
            $changeallowed = get_module_setting("changeallowed");
            // disable for farmies lower than level 10
            if (($allowgift || $allowdp || $changeallowed > 0) && ($session['user']['dragonkills'] > 0 || $session['user']['level'] >= 10)) {
                tlschema($args['schemas']['marketnav']);
                addnav($args['marketnav']);
                tlschema();
                addnav("H?Heidi's Place", "runmodule.php?module=heidi");
            }
            break;
        case "newday":
            if ($args['resurrection'] != 'true') {
                set_module_pref("pvpchange", 0);
            }
            set_module_pref("pendingdp", 0);
            $turns = getsetting("turns", 10) + $session['user']['spirits'];
            reset($session['user']['dragonpoints']);
            while (list($key, $val) = each($session['user']['dragonpoints'])) {
                if ($val == "ff") {
                    $turns++;
                }
            }
            set_module_pref("newdayturns", $turns);
            $echance = e_rand(0, 100);
            $mult = e_rand(200, 400);
            $addgold = round($mult * ($session['user']['level'] / max(10, $session['user']['dragonkills'])));
            if ($session['user']['dragonkills'] < 6) {
                $addgold * 1.5;
            }
            if ($echance >= get_module_setting("findperc")) {
                $addgold = 0;
            }
            set_module_pref("addgold", $addgold);
            if ($addgold > 1) {
                // they are a recipient
                $session['user']['gold'] += $addgold;
                output("`n`5Beside your pillow is a small leather bag containing %s gold, and a note: `^Blessings to ye, child, for someone cared enough to send ye a gift.", $addgold);
                output("`5Wondering who it is from, you add it to your purse.`n");
                debuglog("gained {$addgold} gold from an anonymous gift.");
            }
            break;
    }
    return $args;
}
开发者ID:CavemanJoe,项目名称:Improbable-Island---DragonScales---DragonBones---LotGD-2.0---Season-Three,代码行数:50,代码来源:heidi.php


注:本文中的e_rand函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。