ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/maps/perl/minesweeper.ext
Revision: 1.1
Committed: Sun Mar 5 00:27:28 2006 UTC (18 years, 3 months ago) by root
Branch: MAIN
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #! perl
2    
3     use Scalar::Util;
4    
5     # minesweeper extension. dumb.
6    
7     sub on_time {
8     my ($event) = @_;
9    
10     my $who = $event->{who};
11    
12     unless ($who->{map}) {
13     my %arg = split /(?:\s+|=)/, $event->{options};
14    
15     warn join ":", %arg;
16    
17     my $map = $who->{map} = [];
18    
19     for my $x ($who->x .. $who->x + $arg{width} - 1) {
20     for my $y ($who->y .. $who->y + $arg{height} - 1) {
21     my $ob = $map->[$x][$y] = cf::object::new "minesweeper-unknown";
22     $ob->set_name ("apply to try your luck and intelligence");
23     Scalar::Util::weaken ($ob->{meta} = $who);
24    
25     my $ev = cf::object::new "event_apply";
26     $ev->set_title ("perl");
27     $ev->set_slaying ("minesweeper");
28     $ev->insert_in_ob ($ob);
29    
30     $ob->insert_ob_in_map_at ($who->map, undef, cf::INS_ABOVE_FLOOR_ONLY, $x, $y);
31     }
32     }
33     }
34    
35     # $who->remove;
36     # $who->free;
37     }
38    
39     sub apply {
40     my ($meta, $x, $y) = @_;
41    
42     warn "$meta $x $y\n";#d#
43     }
44    
45     sub on_apply {
46     my ($event) = @_;
47    
48     my $who = $event->{who};
49    
50     apply $who->{meta}, $who->x, $who->y;
51    
52     $who->remove;
53     $who->free;
54     }
55    
56