i used to have kung fu.

Apr 06, 2017 14:52

/* Crystal Heart Dispenser Toy
abuiy
2002 */

#include "hinge.h"
inherit "/std/object";
object heart;
nosave mapping describe;

/**
* This method adds details for an item.
* @param d_name the name(s) of the detail
* @param mess the descripton of the item
*/
void add_detail( mixed d_name, string mess ) {
if( pointerp(d_name) ) {
foreach( string detail in d_name )
add_detail( detail, mess );
return;
}

if( !describe )
describe = ([ ]);

describe += ([ d_name: mess ]);

} /* add_detail() */

/**
* This method returns the current value of the detail for an item.
* @param str the detail to get
* @return the detail for an item
*/
string query_detail( string str ) {
string key, name, *bits, *adjs;

if( !mapp(describe) )
return 0;

if( describe[str] )
return describe[str];

bits = explode( str, " ");
adjs = bits[0..<2];
str = bits[<1];

foreach( key in keys(describe) ) {
bits = explode( key, " ");
name = bits[<1];
if( str == name || str == pluralize(name) ) {
if( !sizeof(adjs) )
return describe[key];
if( !sizeof( bits = bits[0..<2] ) )
continue;
if( !sizeof( filter( adjs, (: member_array( $1, $2 ) == -1 :),
bits ) ) )
return describe[key];
}
}

return 0;

} /* query_detail() */

void setup() {

set_name("device");
set_short("strange mechanical device");
add_adjective(({"strange","mechanical"}));

set_long("This is a small strange-looking mechanical contrivance. "
"It's mostly sealed, although here and there a few gears and "
"screws and ratchet arms can be seen. The metal is old "
"brushed brass and is patina'd and scratched with age. "
"There is a handle on the side with a small knob just above "
"it, and an array of buttons with letters printed on them "
"on the top. At the bottom of the front of the device is a "
"small chute with a metal door.\n");

set_material("metal");
set_weight(25);
add_read_mess("\n%^YELLOW%^ACME Crystal Heart Dispenser®\n%^RESET%^"
"To use simply: \"make\" a heart. \n"
"Then type a name on the lettered buttons, \n"
"turn the knob to the desired intensity \n"
"(1 for friendship, 5 for True Love®), then \n"
"rotate the handle.", "neatly engraved "
"letters:\n","common");

add_detail("button","The top of the device is covered with several "
"small squarish buttons, each with a letter of the "
"common alphabet printed on it.");

add_detail("knob","This small knob just above the handle appears to "
"turn to any of five settings labelled: I,II,III,IV, "
"and V.");

add_detail("handle","This roughly S-shaped handle sicks out from the "
"side of the device. It looks like turning it will "
"engage various gears and ratchets inside.");

add_detail(({"gear","ratchet","screw"}),"Various mechanical bits are "
"visible through small openings in the device, but it's "
"anybody's gueass as to what they do.");

add_detail(({"chute","door"}),"There is a small chute at the front "
"of the device for something to come out of. A small "
"one-way door has been fitted so no foreign objects "
"can get inside.");
}

void init(){

add_command("make", "heart");

}
void do_level(string level, string person) {
string colour, letters;
int h_light;

if ( level == "q" ) { tell_object(TP,"Aborting...\n");
return;
}
if ( level == "") {
tell_object(TP,"You have to select a level between 1 and 5!\nWhat level "
"do you want to set it to? (q to quit)\n");
input_to( (: do_level :), person );
return;
}

switch(level) {

case "1": colour = "%^BOLD%^", letters = "faint", h_light = 0;
break;
case "2": colour = "%^BLUE%^", letters = "pale", h_light = 10;
break;
case "3": colour = "%^YELLOW%^", letters = "softly glowing",
h_light = 15;
break;
case "4": colour = "%^RED%^", letters = "shimmering", h_light = 20;
break;
case "5": colour = "%^MAGENTA%^", letters = "bright sparkling",
h_light = 25;
break;
default: tell_object(TP,"You have to select a level between 1 and 5!\n"
"What level do you want to set it to? "
"(must be a number from 1 to 5. q to quit)\n");
input_to( (: do_level :), person );
return;
}

tell_room(TO,TP->query_name()+" turns the knob on the strange "
"mechanical device.\n",TP);
tell_object(TP,"You set the knob to "+level+".\n");

heart = clone_object("/std/object");
heart->set_name("heart");
heart->set_short("small crystal heart");
heart->add_adjective(({"small","crystal"}));
heart->set_long("This small crystal heart is beautiful in it's "
"simplicity. It is fashioned of the purest crystal and faceted "
"exquisitely. The name \""+colour+person+"%^RESET%^\" can be seen "
"inside in "+letters+" letters.\n");
heart->set_light(h_light);
heart->move(TP);
tell_room(TO,TP->query_name()+"rotates the handle on the "
"side of the strange mechanical device slowly. After a complete "
"rotation a small crystal heart falls out into $p hand.\n",TP);
tell_object(TP,"You rotate the handle on the "
"side of the strange mechanical device slowly. After a complete "
"rotation a small crystal heart falls out into your hand.\n");
return;
}

void do_name2(string person) {

if ( person == "q" ) { tell_object(TP,"Aborting...\n");
return;
}
if ( person == "" ) { tell_object(TP,"You have to enter a name!\n");
tell_object(TP,"Who would you like to make a heart for? (q to quit)\n");
input_to( (: do_name2 :) );
return;
}
if ( person == "me" || person == TP->query_name() )
{ tell_object(TP,"What? Forget it, Jack. Either input a name or stop "
"messing with me.\n");
return;
}
tell_room(TO,TP->query_name()+" types something on the keys on top of "
"the strange mechanical device.\n",TP);
tell_object(TP,"You type the name "+person+" on the keys on top of the "
"strange mechanical device.\n");
tell_object(TP,"What level do you want to set it to? (must be a "
"number from 1 to 5. q to quit)\n");
input_to( (: do_level :), person );
return;
}

void do_narcissus(string ans, string person) {

if ( ans == "q" ) { tell_object(TP,"Aborting...\n");
return;
}
if ( ans == "y" || ans == "yes" || ans == "yeah" ) {
tell_object(TP,"Okay, Narcissus... we'll make a heart for you...\n");
tell_room(TO,TP->query_name()+" types something on the keys on top of "
"the strange mechanical device.\n",TP);
tell_object(TP,"You type the name "+person+" on the keys on top of the "
"strange mechanical device.\n");
tell_object(TP,"What level do you want to set it to? (must be a "
"number from 1 to 5. q to quit)\n");
input_to( (: do_level :), person );
return;

tell_object(TP,"Who would you like to make a heart for? "
"(q to quit)\n");
input_to( (: do_name2 :), person );
return;
}
}

void do_name(string person) {

if ( person == "q" ) { tell_object(TP,"Aborting...\n");
return;
}
if ( person == "" ) { tell_object(TP,"You have to enter a name!\n");
tell_object(TP,"Who would you like to make a heart for? (q to quit)\n");
input_to( (: do_name :) );
return;
}
if ( person == "me" || person == TP->query_name() )
{ tell_object(TP,"You *really* want to make a heart for yourself?!\n"
"y or n? (q to quit)\n");
input_to( (: do_narcissus :), person );
return;
}
tell_room(TO,TP->query_name()+" types something on the keys on top of "
"the strange mechanical device.\n",TP);
tell_object(TP,"You type the name "+person+" on the keys on top of the "
"strange mechanical device.\n");
tell_object(TP,"What level do you want to set it to? (must be a "
"number from 1 to 5. q to quit)\n");
input_to( (: do_level :), person );
return;
}
void do_make(){

tell_object(TP,"Who would you like to make a heart for? (q to quit)\n");
input_to( (: do_name :) );
notify_fail("");
return;
}
Previous post
Up