function druid_runevent($type, $link)
{
    global $session;
    $session['user']['specialinc'] = "module:druid";
    $op = httpget('op');
    if ($op == "" || $op == "search") {
        output("`n`2You enter a meadow, dominated by the largest `@Oak Tree `2you have ever seen.`n`n");
        output("`6Beneath the tree is a small cottage, an ancient figure standing before it.`n");
        output("`6Despite his elfin features, you instinctively know him to be a `%Druid Priest.`n`n");
        output("`@He offers you a bowl of `^Hearty Broth.");
        output("`@Unsure of his benevolence, what do you do?");
        addnav("Accept the Broth", "forest.php?op=take");
        addnav("Refuse the Broth", "forest.php?op=dont");
    } elseif ($op == "take") {
        $session['user']['specialinc'] = "";
        output("`n`@You take the `^Bowl of Broth`@ and raise it to your lips.");
        output("After a brief hesitation, you drink deeply.");
        output("`@ You feel the `^Broth `@burning within you.`n`n ");
        switch (e_rand(1, 10)) {
            case 1:
                output("`6The broth fills you with ENERGY.`n`n");
                output("You gain some Stamina!`n");
                $session['user']['turns'] += 2;
                break;
            case 2:
                output("`6The broth enhances your vision.`n`n");
                output("You find `^2 Gems `6on the ground!`n");
                debuglog("gained 2 Gems from Druid");
                $session['user']['gems'] += 2;
                break;
            case 3:
                output("`6The broth must have had some oysters in it!`n`n");
                output("`^You gain `^5 charm!");
                $session['user']['charm'] += 5;
                break;
            case 4:
                output("`6The broth fills you with strength!`n`n");
                $hptype = "permanently";
                if (!get_module_setting("carrydk") || is_module_active("globalhp") && !get_module_setting("carrydk", "globalhp")) {
                    $hptype = "temporarily";
                }
                $hptype = translate_inline($hptype);
                output("`6Your maximum hitpoints are `b%s`b `&increased`6 by 1!", $hptype);
                $session['user']['maxhitpoints'] += 1;
                $session['user']['hitpoints'] += 1;
                set_module_pref("extrahps", get_module_pref("extrahps") + 1);
                break;
            case 5:
            case 6:
                output("`6You gag on the foul tasting liquid!`n`n");
                $dkhp = 0;
                while (list($key, $val) = each($session['user']['dragonpoints'])) {
                    if ($val == "hp") {
                        $dkhp++;
                    }
                }
                $maxhitpoints = 10 * $session['user']['level'] + $dkhp * 5;
                suspend_temp_stats();
                if ($session['user']['maxhitpoints'] > $maxhitpoints) {
                    $hptype = "permanently";
                    if (!get_module_setting("carrydk") || is_module_active("globalhp") && !get_module_setting("carrydk", "globalhp")) {
                        $hptype = "temporarily";
                    }
                    $hptype = translate_inline($hptype);
                    $session['user']['maxhitpoints'] -= 1;
                    set_module_pref("extrahps", get_module_pref("extrahps") - 1);
                    output("`6Your maximum hitpoints are `b%s`b `\$decreased`6 by 1!`n", $hptype);
                }
                if ($session['user']['hitpoints'] > 3) {
                    $session['user']['hitpoints'] -= 2;
                    output("`6You `\$lose 2 `6hitpoints and gain some rather bad breath!");
                }
                restore_temp_stats();
                break;
            case 7:
                $expgain = round($session['user']['experience'] * 0.1, 0);
                if ($expgain < 10) {
                    $expgain = 10;
                }
                $session['user']['experience'] += $expgain;
                output("`6 Your faith was well placed, pilgrim!`n`n");
                output("`6You gain `^%s experience`6!`n", $expgain);
                break;
            case 8:
                if ($session['user']['charm'] > 3) {
                    output("`6The broth spills down your new tunic, detracting from your charm!`n`n");
                    output("`6You `\$lose 2 `6charm!");
                    $session['user']['charm'] -= 2;
                } else {
                    output("`6The Elvish broth warms your body and gives your skin a healthy glow.");
                    output("You `^gain 2 `6charm!");
                    $session['user']['charm'] += 2;
                }
                break;
            case 9:
                $loss = round($session['user']['hitpoints'] * 0.7, 0);
                if ($loss > 0 && $session['user']['hitpoints'] > $loss) {
                    output("`6The broth leaves you feeling weakened.`n`n");
                    output("You `\$lose `^%s `6hitpoints!", $loss);
                    $session['user']['hitpoints'] -= $loss;
                    break;
                }
            case 10:
                if ($session['user']['turns'] >= 1) {
                    output("`6The broth drains your ENERGY.`n`n");
                    output("You `\$lose`6 some Stamina!`n");
                    $session['user']['turns'] -= 1;
                } else {
                    output("`6Strangely, the broth has no effect on your tired body.`n`n");
                }
                break;
        }
    } else {
        $session['user']['specialinc'] = "";
        output("`n`@You simply don't trust the old druid and you decline his offer.");
        switch (e_rand(1, 4)) {
            case 1:
                $expgain = round($session['user']['experience'] * 0.05, 0);
                if ($expgain < 3) {
                    $expgain = 3;
                }
                $session['user']['experience'] += $expgain;
                output("As you turn to walk away, the old man begins to take a great offense.");
                output("Before he can fume about your refusal, you act quickly to ease the tension.");
                output("You humbly bow to the Druid, offering soft words of praise and peace as you back away from his sacred place.");
                output("You certainly don't want to upset him and you make your exit as polite as possible!`n`n");
                output("`6You gain `^%s`6 experience from avoiding danger!`n", $expgain);
                break;
            case 2:
                if ($session['user']['charm'] > 3) {
                    output("As you turn to walk away, the Druid is insulted by your refusal and throws the bowl of scalding soup after you.");
                    output("You can almost hear the trees laughing as your clothing is stained with the foul broth.`n`n");
                    output("`6You `\$lose 2 `6charm!");
                    $session['user']['charm'] -= 2;
                } else {
                    output("As you turn to walk away, the Druid goes back to enjoying his broth and simply ignores your passing.");
                }
                break;
            case 3:
                $loss = round($session['user']['hitpoints'] * 0.1, 0);
                output("As you turn to walk away, a loud voice booms in the air around you.");
                output("You dash into the forest, not waiting to see what powers you've offended.");
                if ($loss > 0 && $loss < $session['user']['hitpoints']) {
                    $session['user']['hitpoints'] -= $loss;
                    output("Recklessly trying to escape, you trip on some roots and injure yourself in a graceless fall.");
                    output("`n`6You `\$lose `^%s`6 hitpoints!`n", $loss);
                }
                break;
            case 4:
                output("`n`n`6Fearful for your safety, you run for hours.");
                if ($session['user']['turns'] > 0) {
                    output("`n`nYou `\$lose`6 some Stamina!`n");
                    $session['user']['turns'] -= 1;
                }
                break;
        }
    }
}
function ella_run()
{
    global $session;
    $op = httpget("op");
    require_once "lib/partner.php";
    $partner = get_partner();
    $candance = get_module_pref("candance");
    $dkhp = 0;
    while (list($key, $val) = each($session['user']['dragonpoints'])) {
        if ($val == "hp") {
            $dkhp++;
        }
    }
    $maxhitpoints = 10 * $session['user']['level'] + $dkhp * 5;
    suspend_temp_stats();
    if ($session['user']['maxhitpoints'] < $maxhitpoints + get_module_setting("hitpointcost")) {
        $notenough = true;
    } else {
        $notenough = false;
    }
    restore_temp_stats();
    page_header("Dance Studio");
    output("`&`c`bLady Ella's Dance Studio`b`c");
    if (!$candance) {
        output("`7Your muscles are still too stiff and sore from your last lesson.`n");
        output("`7Perhaps in a day or so, you'll feel up to another lesson.");
    } elseif ($notenough) {
        output("`7You don't feel like you could take a lesson with Ella today.`n");
        output("`7Perhaps if your constitution has risen a bit.");
    } elseif ($op == "") {
        output("`7A statuesque teacher in intricately-beaded garb stands at one end of a small studio, intently watching the movements of the  dancers in the room.");
        output("Partnered and solo dancers sway and spin in fast rhythms, matching their movements to the piano that sings from one side of the room, where a delicate Felyne moves her paws to create the sound.`n`n");
        output("Noting your interest, Lady Ella smiles at you as she walks towards you.`n`n");
        output("\"`&Lovely movement, everyone, keep going, I'll have you all as polished performers yet!`7\"`n`n");
        output("`7She approaches you and beckons you into her office.");
        $cost = get_module_setting("turncost");
        if ($session['user']['turns'] >= $cost) {
            output("Once there, she explains what she can offer.");
            output("\"`&You'll like our lessons very much.");
            output("We pride ourselves in making sure it's fun AND helpful.");
            output("Who knows, you might land the %s of your dreams!`n`n", translate_inline($session['user']['sex'] ? "man" : "girl"));
            output("Now, it takes a lot of time and effort to learn to dance, so you can't expect to have nearly as much time for galivanting around the forest.");
            if ($session['user']['sex']) {
                output("So, are you sure you want to make that commitment and learn to make the men chase you?`7\"");
            } else {
                output("So, are you sure you want to make that commitment and learn to sweep the ladies off their feet?`7\"");
            }
            output("`qYou realize she's asking for a sacrifice of time you would normally spend hunting in the forest.");
            output("`qYou ponder for a moment on whether you want to make that large a commitment.");
            addnav(array("Take Lesson (%s %s)", $cost, translate_inline($cost == 1 ? "turn" : "turns")), "runmodule.php?module=ella&op=dance");
        } else {
            output("Once there, she regards you gravely.");
            output("\"`&Darling, there's nothing I love more than teaching someone the love of the dance.");
            output("I'd be more than happy to let you watch, but by the looks of how tired out you are, you'd fall over from the exertion of actually dancing with us today.`7\"`n`n");
            output("You nod your understanding, that you perhaps need more free time to get the most out of the strenuous training she has to offer.");
        }
    } else {
        output("`7You agree to take a dancing lesson today, and eagerly move forward to join the other dancers.`n`n");
        output("The music begins slowly, giving you the chance to start gradually, but it quickly becomes difficult and tiring.");
        output("You're not sure how impressed %s`7 would be with your efforts, but you're determined not to give up too easily.`n`n", $partner);
        output("After the lesson concludes, you feel weary, and wonder whether you have the strength to keep this up for many weeks to come.");
        output("You sure hope %s`7 appreciates your efforts today.`n`n", $partner);
        output("You feel `5charming!`n");
        $turncost = (int) get_module_setting("turncost");
        $hitpointcost = (int) get_module_setting("hitpointcost");
        if ($turncost > 0 && $hitpointcost > 0) {
            output("Your efforts had their price.");
            output("You feel a little tired and not that enduring anymore.");
        } else {
            if ($turncost > 0) {
                output("Your efforts had their price.");
                output("You feel a little tired.");
            } else {
                if ($hitpointcost > 0) {
                    output("Your efforts had their price.");
                    output("You feel not that enduring anymore.");
                }
            }
        }
        debuglog("lost {$turncost} turns and {$hitpointcost} maxhitpoints for taking a dancing lesson.");
        $session['user']['turns'] -= $turncost;
        $session['user']['maxhitpoints'] -= $hitpointcost;
        if ($session['user']['maxhitpoints'] < $session['user']['level'] * 10) {
            $session['user']['maxhitpoints'] = $session['user']['level'] * 10;
        }
        $session['user']['charm'] += get_module_setting("charmgain");
        set_module_pref("candance", 0);
        $danceday = get_module_setting("danceday");
        set_module_pref("dayswait", $danceday);
    }
    villagenav();
    page_footer();
}