#!/usr/local/bin/perl
#
#	CircleMUD CGI/Perl Room creator.
#	Ailbhe deFaoite/Albert White 04/1999
#	albertw@netsoc.ucd.ie
#	
#	Disclaimer: I take no responsibility for whatever happs to you, 
#	your mud or your server as a result of using this script. :)
#
#	No docs for this, though its fairly easy to work out what it does
#	If anyone is interested in this and would like it expanded in some
#	way let me know.
#
#	I havent made this secure (havent read the secure-cgi-faq yet!), 
#	so please think before putting it on an important server...
#
#	v 0.001a	Initial script.


use CGI qw(:standard);

# Make hashes for bitvectors etc
%bitvectors = (
        a	=>	DARK,	
        b	=>	DEATH,
        c	=>	NOMOB, 
        d	=>	INDOORS,
        e	=>	PEACEFUL,
        f	=>	SOUNDPROOF,
        g	=>	NOTRACK,  
        h	=>	NOMAGIC, 
        i	=>	TUNNEL, 
        j	=>	PRIVATE,
        k	=>	GODROOM
);

%sectorsa = (
	0	=>      INSIDE, 
        1	=>	CITY,  
        2	=>	FIELD,
        3	=>	FOREST,
        4	=>	HILLS,
        5	=>	MOUNTAIN,
        6	=>	WATERSWIM,
        7	=>	WATERNOSWIM,
        8	=>	UNDERWATER, 
        9	=>	FLYING    
);
@sectorsl = ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);


%doors = (
	0	=>	unrestricted,
	1	=>	normal,
	2	=>	nonpickable
);

@doorsl= ( 0, 1, 2);

$current = CGI->new();
print header;
print start_html('CircleMUD room creator');
print h1('CircleMUD room creator'),h3('alberw@netsoc.ucd.ie'),hr();

if ($vnumroom=$current->param('VNUM')){
print ($vnumroom);
print br(),$current->param('name'),'~';
print br(),$current->param('desc'),br(),'~';
print br(),'0 ',$current->param('Bitvectors'),' ',$current->param('Sector');
if ($exitnorth=param('lnorth')){
	print br(),'D0';
	print br(),$current->param('dnorth'),br(),' ~';
	print br(),$current->param('knorth'),' ~';
	print br(),$current->param('ndflag'), ' ',$current->param('nnorth'), $exitnorth;
}
if ($exitsouth=param('lsouth')){
        print br(),'D0';
        print br(),$current->param('dsouth'),br(),' ~';
        print br(),$current->param('ksouth'),' ~';
        print br(),$current->param('sdflag'),' ', $current->param('nsouth'), $exitsouth;
}
if ($exitnorth=param('least')){
        print br(),'D0';
        print br(),$current->param('deast'),br(),' ~';
        print br(),$current->param('keast'),' ~';
        print br(),$current->param('edflag'), ' ',$current->param('neast'), $exiteast;
}
if ($exitnorth=param('lwest')){
        print br(),'D0';
        print br(),$current->param('dwest'),br(),' ~';
        print br(),$current->param('kweat'),' ~';
        print br(),$current->param('wdflag'), ' ',$current->param('nwest'), $exitwest;
}
if ($exitnorth=param('lup')){
        print br(),'D0';
        print br(),$current->param('dup'),br(),' ~';
        print br(),$current->param('kup'),' ~';
        print br(),$current->param('udflag'), ' ',$current->param('nup'), $exitup;
}
if ($exitnorth=param('ldown')){
        print br(),'D0';
        print br(),$current->param('ddown'),br(),' ~';
        print br(),$current->param('kdown'),' ~';
        print br(),$current->param('ddflag'),' ', $current->param('ndown'),$exitdown;
}
if ($ed1=param('ed1keys')){
	print br(),'E',br(),$ed1,'~',br(),$current->param('ed1text'),br(),' ~';
}
if ($ed2=param('ed2keys')){
        print br(),'E',br(),$ed2,'~',br(),$current->param('ed2text'),br(),' ~';
}
if ($ed3=param('ed3keys')){
        print br(),'E',br(),$ed3,'~',br(),$current->param('ed3text'),br(),' ~';
}
print br(),'S';

}else{

print startform();	

print p('Please enter the VNUM of the room:',$current->textfield(-name=>'VNUM'));
print p('Please enter the room name:',textfield(-name=>'name', -default=>'Room Name'));
print p('Please enter the room description:',textarea(-name=>'desc', -default=>'Room Description', -rows=>10, -columns=>80));

print p('Select the Rooms Bitvectors:',checkbox_group( 	-name=>'Bitvectors', 
							-values=>\%bitvectors, 
							-default=>d,
							-labels=>\%bitvectors,
							-rows=>2));


print p('Select the rooms setor type:',radio_group(-name=>'Sector', -values=>\@sectorsl,-labels=>\%sectorsa,-rows=>2));


print hr(),p('Room Linked North to (leave blank if no exit):',textfield(-name=>'lnorth',size=>6)),
	p('General Description',textfield(-name=>'dnorth',-default=>'An Exit to the North')),
	('Keywords:',textfield(-name=>'knorth')),
	p('Door Flag:',radio_group(-name=>'ndflag', 
		-values=>\@doorsl,  -labels=>\%doors)),
	p('Key number:',textfield(-name=>'nnorth', -default=>'-1',size=>6));

print hr(),p('Room Linked South to (leave blank if no exit):',textfield(-name=>'lsouth',size=>6)),
        p('General Description',textfield(-name=>'dsouth',-default=>'An Exit to the South')),
        ('Keywords:',textfield(-name=>'ksouth')),
        p('Door Flag:',radio_group(-name=>'sdflag',      
		-values=>\@doorsl,  -labels=>\%doors)),
        p('Key number:',textfield(-name=>'nsouth', -default=>'-1',size=>6));

print hr(),p('Room Linked East to (leave blank if no exit):',textfield(-name=>'least',size=>6)),
        p('General Description',textfield(-name=>'deast',-default=>'An Exit to the East')),
        ('Keywords:',textfield(-name=>'keast')),
        p('Door Flag:',radio_group(-name=>'edflag',      
		-values=>\@doorsl,  -labels=>\%doors)),
        p('Key number:',textfield(-name=>'neast', -default=>'-1',size=>6));

print hr(),p('Room Linked West to (leave blank if no exit):',textfield(-name=>'lwest',size=>6)),
        p('General Description',textfield(-name=>'dwest',-default=>'An Exit to the West')),
        ('Keywords:',textfield(-name=>'kwest')),
        p('Door Flag:',radio_group(-name=>'ndflag',      
		-values=>\@doorsl,  -labels=>\%doors)),
        p('Key number:',textfield(-name=>'nwest', -default=>'-1',size=>6));

print hr(),p('Room Linked Up to (leave blank if no exit):',textfield(-name=>'lup',size=>6)),
        p('General Description',textfield(-name=>'dup',-default=>'An Exit Up')),
        ('Keywords:',textfield(-name=>'kup')),
        p('Door Flag:',radio_group(-name=>'udflag',      
		-values=>\@doorsl,  -labels=>\%doors)),
        p('Key number:',textfield(-name=>'nup', -default=>'-1',size=>6));

print hr(),p('Room Linked Up to (leave blank if no exit):',textfield(-name=>'ldown',size=>6)), 
        p('General Description',textfield(-name=>'ddown',-default=>'An Exit Down')),
        ('Keywords:',textfield(-name=>'kdown')),
        p('Door Flag:',radio_group(-name=>'ddflag',      
		-values=>\@doorsl,  -labels=>\%doors)),
        p('Key number:',textfield(-name=>'ndown', -default=>'-1',size=>6));


print hr(),('Can\'t think of a good way to do this so Ill let you enter 3 Extra descriptions, you can edit more in easily from an olc...');

print	p('Extra Description 1 keywords:',textfield(-name=>'ed1keys',size=>6)), textarea(-name=>'ed1text', -rows=>5, -columns=>80, -maxlength=>80,-default=>'Extra Description for 1');
	
print   p('Extra Description 2 keywords:',textfield(-name=>'ed2keys',size=>6)), textarea(-name=>'ed2text', -rows=>5, -columns=>80, -maxlength=>80,-default=>'Extra Description for 2');

print   p('Extra Description 3 keywords:',textfield(-name=>'ed3keys',size=>6)), textarea(-name=>'ed3text', -rows=>5, -columns=>80, -maxlength=>80, -default=>'Extra Description for 3');

print submit(-name=>'Create Room', -value=>'create'),defaults('Restore Defaults');

print endform();	
}
print end_html;




