/
CDC-1.2b/
CDC-1.2b/src/
parent $utilities
object $places

var $root dbref 'places
var $root child_index 0
var $root fertile 0
var $root manager $places
var $root owned [$places]
var $root owners [$places]
var $root writable []
var $root readable ['parameters, 'methods, 'code]
var $root inited 1
var $places default_place $nowhere
var $places exit_starting_place $void
var $root info ["Utility object for all 'Places' and items relating to places (such as exits)"]
var $places starting_place $creation
var $places default_new_place $place
var $places coordinate_shortcuts #[["n?orth", [0, 0]], ["s?outh", [180, 0]], ["e?ast", [90, 0]], ["w?est", [270, 0]], ["ne|northeast", [45, 0]], ["se|southeast", [135, 0]], ["nw|northwest", [225, 0]], ["sw|southwest", [315, 0]], ["d?own", [-1, -90]], ["u?p", [-1, 90]]]
var $places known_realms [$, $realm_of_creation, $, $]
var $places build_hints #[[1, ["This is the do-it-all system for extending locations.  At any time you can enter @abort to abort the process (if you are still in the creation stage this will automatically clean up half-created objects).  To turn off these hints use `@set -build-hints` at a normal prompt."]], [2, ["Since a destination was not specified, a new one will be created with the name you specify."]], [3, ["Name aliases can be specified on the same line as the name, if they are seperated by comma's.  Any number of aliases can be specified.  Proper and unique names can be defined by including -proper or -unique at the end of the line (default is proper)."]], [4, ["Realms are used to keep locations in relation with each other.  To get a list of commonly known realms type `@realms`."]], [5, ["Coordinates are used to define a basic relational physicality between rooms, by pointing in the direction each room lies.  They are set using the radial/azimuth system.  A quick explanation would be to think of a sphere.  There are 360 degree's for the horizontal plane (radial) and +/-90 degree's for the vertical plane (azimuth).  This is the same system used to define the direction of objects in astronomy.  To get a list of coordinate shortcuts use `@shortcuts` or `@build -shortcuts` at the regular prompt.  Coordinates are automatically inverted for return exits (with @build)."]], [6, ["Short prose is the text seen when one \"looks\" at a room.  By convention only this text should usually be under 3-4 lines (80 column display) long.  For longer more detailed descriptions set the long prose (seen via \"examine\")."]]]

method place
    arg which;
    
    which = tosym(tostr(which) + "_place");
    return (> get_var(which) <);
.

method is_place
    arg obj;
    
    if (!(obj.has_ancestor($place)))
        throw(~place, ("Object \"" + (obj.namef('ref))) + "\" is not a place.");
.

method set_place
    arg which, obj;
    
    .perms(sender(), 'manager);
    (> .is_place(obj) <);
    if (!(which in (.parameters())))
        throw(~place, (toliteral(which) + " is not a valid entry try one of: ") + toliteral(.parameters()));
    set_var(which, obj);
.

method coordinates
    arg str;
    var x;
    
    for x in (coordinate_shortcuts) {
        if (match_template(x[1], str))
            return x[2];
    }
    throw(~coordnf, ("Unable to find coordinate shortcut for \"" + str) + "\".");
.

method coordinate_shortcuts
    return coordinate_shortcuts;
.

method valid_coordinates
    arg radial, azimuth;
    
    if ((radial > 360) || (radial < (-1)))
        throw(~invcoord, "Radial coordinate must be from -1 to 360 degrees.");
    if ((azimuth > 90) || (azimuth < (-90)))
        throw(~invcoord, "Azimuth coordinate must be from 90 to -90 degrees.");
.

method invert_coordinates
    arg radial, azimuth;
    
    radial = radial + 180;
    if (radial > 360)
        radial = radial - 360;
    if (azimuth > 0)
        azimuth = -azimuth;
    else
        azimuth = abs(azimuth);
    return [radial, azimuth];
.

method known_realms
    return known_realms;
.

method match_realm
    arg str;
    var r;
    
    for r in (known_realms) {
        if (r.match_name(str))
            return r;
    }
    return (| $object.to_dbref(str) |) || 0;
.

method add_known_realm
    arg obj;
    
    (> .perms(sender()) <);
    known_realms = [@known_realms, obj];
.

method del_known_realm
    arg obj;
    
    (> .perms(sender()) <);
    known_realms = setremove(known_realms, obj);
.

method del_build_hint
    arg hint_key;
    
    (> .perms(sender()) <);
    build_hints = dict_add(build_hints, hint_key);
.

method build_hint
    arg hint;
    
    return build_hints[hint];
.

method build_hints
    return build_hints;
.

method add_build_hint
    arg hint_key, hint_text;
    
    (> .perms(sender()) <);
    build_hints = dict_add(build_hints, hint_key, hint_text);
.