Subject: Full names

From: [email-masked] (Clay Luther)
Date: Fri, 5 Feb 1993 15:58:40 -0800

Here again is another completely unsolicitedly code section.

Fullnames in (lambda)moo.  Toot-toot.

Some muds allow the users to have full names for their characters. 
Unfortunately, (lambda)moo is not one of them, forcing players who want to
have english-like multiple names to do ugly things like use no spaces or
add underscores for spaces.  Ugh.

Consider, if I want my character's name to be Lancelot du Lac, which looks
more aesthetically pleasing, and, indeed, more readable?

LancelotDuLac
Lancelot_du_Lac
Lancelot du Lac

It's as plain as blancmange.

However, never fret.  Feat of Clay(tm) Software presents Moo fullnames.
Toot-toot.

Moo fullnames require a few modifications to the core db, all for the
better of course.  The first modification is to add the :name() method to
#1.  Following Better Object Oriented Programming Practices(tm), or BOOPP,
you should avoid accessing object properties directly anyway (such as using
player.name).  Instead, you should always think about adding appropriate
access methods for properties, such as player:name().  (lambda)Moo makes a
half-hearted stab at this.  For instance, the :description() access method
is provided for .description but not for, say, .name.  

But it's never too late to start.

However, as we will see, there are times when using the access method is
perhaps less desirable than using the property itself.

STEP 1 - Create the name access method on #1.

@list #1:name without numbers
#1:"name"   this none this
return this.name;

Immediately modify #1:title() so that it is

@list #1:title without numbers
#1:"title"   this none this
return this:name();

(instead of returning this.name)

STEP 2 - Create the ability to assign, remember, and keep fullnames on $player.

Moo uses the player's name property as a sort of account id.  This
implementation doesn't wish to change that, since that would require a
major overhaul to the server login functions.  Instead, we will add (YA)
property to $player which will hold the player's full name.

@prop $player.fullname ""

Next, we must modify $player:name() so that it will use the fullname when set.

@list $player:name without numbers
#6:"name"   this none this
return this.fullname ? this.fullname | this.name;

That's fine.  Any method which calls player:name() now (instead of
accessing player.name) will get either the player's userid name or his full
name.

Next, player's need some way of setting their name.  Again, in this
implementation we assume that the player's .name is a sort of userid. 
Therefore, to keep the division obvious and to add complexity, always a
good thing you know, we add a new $player verb, @fullname.

The Rules of @fullname:
        Only a wizard or the player himself may set the player's fullname.
        The fullname is limited to three names.
        Each name is limited to 16 characters.
        Names may not contain punctuation.
        At least one of the names must match exactly the player's userid name.
        Each name, excluding obvious prepositions/articles like "the" are
                made aliases to the player.

Syntax (code follows examples)
@fullname <this> is <any>

Examples:
        
Ballard tries @fullname me is "Mister Ballard"
        
This works.  Ballard's .fullname is set to "Mister Ballard" and his aliases
are set to {"Mister Ballard","Mister","Ballard"}.

Ballard tries @fullname me is "Mister Johnson"

This does not work "Mister Johnson" does not contain the name "Ballard."

Ballard tries @fullname "Ballard from Dingly Dell"

This does not work - 4 names.

Ballard tries @fullname "Ballard from London"

This works, and his aliases are set to {"Ballard from London", "Ballard",
"London"}.

THE CODE FOR @FULLNAME

@list $player:@fullname without numbers
#6:"@fullname"   this is any
"** Allow a player to set his fullname property.";
"** USAGE: @fullname <who> is <Name>";
if (!player.wizard && player != this)
  player:tell("I don't understand.");
  return;
endif
punc = {".", "!", ",", ":", ";"};
for p in (punc)
  if (index(iobjstr, p))
    player:tell("You cannot have punctuation in your name.");
    return;
  endif
endfor
"** OK, we might have a pretty good name here.";
names = $string_utils:explode(iobjstr, " ");
if (length(names) > 3)
  player:tell("You may only enter up to three names.");
  return;
endif
for n in (names)
  if (length(n) > 16)
    player:tell("A name may only be up to 16 characters long.");
    return;
  endif
endfor
oldfname = this.fullname;
this.fullname = "";
oldaliases = this.aliases;
this.aliases = {};
found = 0;
for n in (names)
  if (n == this:name())
    found = 1;
  endif
endfor
if (!found)
  player:tell("Your name did not match any sub-name of that full name.  Try
again, please.");
  this.fullname = oldfname;
  this.aliases = oldaliases;
  return;
endif
prepositions = {"a", "the", "an", "of", "from"};
for n in (names)
  if (!(n in this.aliases))
    if (!(n in prepositions))
      this.aliases = [email-masked], n};
    endif
  endif
endfor
if (iobjstr == this:name())
  this.fullname = "";
  player:tell(this:name(), "'s fullname is reset.");
else
  this.fullname = iobjstr;
  this.aliases = [email-masked], this.fullname};
  player:tell("You have set the fullname to \"", iobjstr, "\".");
endif

USING FULLNAMES:

There are several places in (lambda)moo where fullnames increase the
aesthetic quality of the moo.  Says and emotes are the obvious start; for
instance

Jean Malraux thinks it is time to go.

is nicer than

Malraux thinks it is time to go.

Especially if my name is indeed "Jean Malraux."

The above is handled by changing player.name to player:name() in
$room:emote(). A similar change to $room:say would produce similar results.

Because we have handily thought ahead and changed #1:title(), room
descriptions will now automatically include the player's fullname in the
description, ala...

Lying on the ground you see a copy of the London Times, besmudged by mud
and heavily trampled.  To the left of the revolving door is the ticket
booth, inhabited by a tired and tawdy woman dressed like a Gallic empress. 
She looks very bored.  Beneath her window is a sign which reads "Adults
1/-."

Mister Ballard is here.

As you find .name statements in moo-code, you could change them, if
required by the purpose of the verb, to :name() calls.  It is dangerous to
do this automatically with substitution, however, since many player.name
statements are *assignments*.  Uncareful substitution would give you
something like

player:name() = some_string;

which would be a Very Bad Thing(tm).

In general, FOC Software has determined that any place where the
player/object's name is displayed as part of the virtual reality of the
moo, it is best to call :name().  In other verbs, mainly maintenance verbs
used by programmers and wizards, accessing the player.name directly is
sufficient.

After all, wizards do not care about fluffy things like this.

Enjoy.

---
Clay W. Luther                                 [email-masked]
Software Engineer                             Vortech Data, Inc
Office (214) 994-1377                        Fax (214) 994-1310
                             Also [email-masked]

Well, it had been 987 years in outer space time when I got back.
Couldn't seem to find any of my friends to tell my interesting
stories to.