Acme-MUDLike

 view release on metacpan or  search on metacpan

lib/Acme/MUDLike.pm  view on Meta::CPAN

}

sub _give {
    my $self = shift;
    my @args = @_;
    if(@args != 3 or $args[1] ne 'to') {
        $self->tell_object(qq{Give what to whom?});
        return;
    }
    my $item = $self->inventory->named($args[0]) or do { $self->tell_object("You have no ``$args[0]''."); return; };
    my $container = $floor->named($args[2]) or do { $self->tell_object("There is no ``$args[2]'' here."); return; };
    $self->inventory->delete($args[0]);
    $container->inventory->insert($item);
    $self->tell_object("Ok.");
}

sub _clone {
    my $self = shift;
    my $ob = shift;
    if(! $ob) {
        $self->tell_object(qq{Clone what?});
        return;
    }
    my $item = eval { $ob->new() };
    if(! $item ) {
        $self->tell_object("Failed to load object: ``$@''.");
        return;
    }
    # XXX force an inheritance of object onto it if it doesn't already have one?
    $self->inventory->insert($item);
    $self->tell_object("Ok.");
}

sub _dest {
    my $self = shift;
    my @args = @_;
    if(@args != 1) {
        $self->tell_object(qq{Dest what?});
        return;
    }
    $self->inventory->delete($args[0]) or do { $self->tell_object("You don't have a ``$args[0]''."); return; };
    $self->tell_object("Dest: Ok.");
}


=head1 NAME

Acme::MUDLike - Hang out inside of your application

=head1 SYNOPSIS

    use Acme::MUDLike; 
    my $server = Acme::MUDLike->new;

    # ... your code here

    $server->loop;  # or call the Event or AnyEvent event loop

Connect to the URL provided and cut and paste into the text box:

    /eval package sword; our @ISA = qw/Acme::MUDLike::object/; sub new { my $pack = shift; $pack->SUPER::new(name=>"sword", @_); }
    /clone sword
    /i
    /call sword name
    wee, fun!  oh, hai everyone!
    /eval no strict "refs"; join '', map "$_\n", keys %{"main::"};
    /call Acme::MUDLike::player=HASH(0x8985e10) name

=head1 DESCRIPTION

Multi user chat, general purpose object tracer, eval, and give/drop/take/clone/dest/look.

Adds a social element to software development and develop it from within.
Chat within the application, eval code inside of it (sort of like a simple Read-Eval-Parse Loop).
Call methods in objects from the command line.
Create instances of objects, give them to people, drop them on the floor.

The idea is take the simple command line interface and extend it with more commands,
and to create tools and helper objects that inspect and modify the running program from within.

It fires up a Continuity/HTTP::Daemon based Web server on port 2000 and prints out a login
URL on the command line.
Paste the URL into your browser.
Chat with other users logged into the app.
Messages beginning with a slash, C</>, are interpreted as commands:

=over 2

=item C<< /look >> 

See who else and what else is in the room.

=item C<< /mark >>

  /mark 1

  /mark torch

  /mark foo::bar

  /mark 0x812ea54

Select an object as the logical current object by name, package name, number (as a position in your
inventory list, which is useful for when you've cloned an object that does not define an C<id> or C<name> function),
or by memory address (as in C<< Foo::Bar=HASH(0x812ea54) >>).

=item C<< /call >> 

Call a function in an object; eg, if you're holding a C<toaster>, you can write:

  /call toaster add_bread 1

The special name "current" refers to the current object, as marked with mark.

=item C<< /eval >>

Executes Perl.
C<< $self >> is your own player object.
C<< $self->inventory >> is an C<< Acme::MUDLike::inventory >> object with C<delete>, C<insert>, C<named>,
C<apply>, and C<contents> methods.
C<< $self->environment >> is also an C<< Acme::MUDLike::inventory >> object holding you and other players 



( run in 0.920 second using v1.01-cache-2.11-cpan-acf6aa7dc9e )