ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/maps/perl/minesweeper.ext
(Generate patch)

Comparing deliantra/maps/perl/minesweeper.ext (file contents):
Revision 1.5 by root, Sat Mar 25 04:47:56 2006 UTC vs.
Revision 1.10 by root, Fri Aug 25 15:07:43 2006 UTC

1#! perl 1#! perl
2#CONVERSION: NONE
2 3
3use Scalar::Util; 4use Scalar::Util;
4 5
5# minesweeper extension. dumb. 6# minesweeper extension. dumb.
6 7
7sub result { 8sub result {
8 my ($ob, $status) = @_; 9 my ($ob, $status) = @_;
9 10
10 if (my $teleport = $ob->{options}{"teleport_$status"}) { 11 if (my $teleport = $ob->{options}{"teleport_$status"}) {
11 my ($x, $y) = split /,/, $teleport; 12 my ($x, $y, $damned) = split /,/, $teleport;
13 my $pl = cf::player::find $ob->{player};
12 14
13 (cf::player::find $ob->{player})->ob->transfer ($x, $y); 15 $pl->ob->transfer ($x, $y);
16 $pl->set_savebed ($pl->ob->map->path, $x, $y)
17 if $ob->{options}{"set_savebed_$status"};
14 } 18 }
15} 19}
16 20
17sub apply { 21sub apply {
18 my ($who) = @_; 22 my ($who) = @_;
25 my ($x, $y) = ($who->x - $meta->x, $who->y - $meta->y); 29 my ($x, $y) = ($who->x - $meta->x, $who->y - $meta->y);
26 30
27 $who->{visible} = 1; 31 $who->{visible} = 1;
28 32
29 if ($who->{bomb}) { 33 if ($who->{bomb}) {
30 result $meta, "failure"; 34 result $meta, "failure"
35 if $meta->{todo};
31 } else { 36 } else {
32 $meta->{todo}--; 37 $meta->{todo}--;
33 # if zero, finished 38 # if <= 0, finished
34 39
35 my @neigh; 40 my @neigh;
36 41
37 for my $y ($y - 1 .. $y + 1) { 42 for my $y ($y - 1 .. $y + 1) {
38 next if $y < 0 || $y > $#{$map->[0]}; 43 next if $y < 0 || $y > $#{$map->[0]};
53 unless $bombs; 58 unless $bombs;
54 59
55 $who->remove; 60 $who->remove;
56 $who->free; 61 $who->free;
57 } 62 }
63
64 1
58} 65}
59 66
60sub on_time { 67sub on_time {
61 my ($event) = @_; 68 my ($event, $who) = @_;
62
63 my $who = $event->{who};
64 69
65 if (my $queue = $who->{queue}) { 70 if (my $queue = $who->{queue}) {
66 my $count = 4; 71 my $count = 4;
67 72
68 while (@$queue) { 73 while (@$queue) {
80 $count-- 85 $count--
81 or last; 86 or last;
82 } 87 }
83 } else { 88 } else {
84 # generate minesweeper field 89 # generate minesweeper field
85 my %arg = split /(?:\s+|=)/, $event->{options}; 90 my %arg = split /(?:\s+|=)/, $event->options;
86 91
87 $who->{options} = \%arg; 92 $who->{options} = \%arg;
88 $who->{queue} = []; 93 $who->{queue} = [];
89 94
90 my $map = $who->{map} = []; 95 my $map = $who->{map} = [];
118 } 123 }
119 } 124 }
120} 125}
121 126
122sub on_apply { 127sub on_apply {
123 my ($event) = @_; 128 my ($event, $ob, $who) = @_;
124 129
125 my $who = $event->{who};
126 my $activator = $event->{activator};
127
128 $who->{meta}{player} = $activator->name; 130 $ob->{meta}{player} = $who->name;
129 push @{$who->{meta}{queue}}, $who; 131 push @{$ob->{meta}{queue}}, $ob;
130 132
131 1 133 1
132} 134}
133 135
134 136

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines