… | |
… | |
12 | |
12 | |
13 | # prices in plat. |
13 | # prices in plat. |
14 | my %prices = ( |
14 | my %prices = ( |
15 | pen => [ |
15 | pen => [ |
16 | 40, 'stylus', |
16 | 40, 'stylus', |
17 | sub { $_[0]->name ('IPO Writing Pen'); $_[0]->value (40 * $price_fact); } |
17 | sub { $_[0]->name ('IPO Writing Pen'); $_[0]->value (0); } |
18 | ], |
18 | ], |
19 | literacy => [ |
19 | literacy => [ |
20 | 1000, 'scroll_literacy', |
20 | 1000, 'scroll_literacy', |
21 | sub { $_[0]->value (1000 * $price_fact) } |
21 | sub { $_[0]->value (0) } |
22 | ], |
22 | ], |
23 | mailscroll => [ |
23 | mailscroll => [ |
24 | 1, 'scroll', |
24 | 1, 'mailscroll_empty', |
25 | sub { |
25 | sub { |
26 | $_[0]->name ("mailscroll T: $_[2] F: $_[1]"); |
26 | $_[0]->name ("mailscroll T: $_[2] F: $_[1]"); |
27 | $_[0]->name_pl ("mailscrolls T: $_[2] F: $_[1]"); |
27 | $_[0]->name_pl ("mailscrolls T: $_[2] F: $_[1]"); |
28 | $_[0]->value (1 * $price_fact); |
28 | $_[0]->value (0); |
29 | }, |
29 | }, |
30 | 'plarg' |
30 | 'plarg' |
31 | ], |
31 | ], |
32 | bag => [ 1, 'r_sack', sub { set_package (@_, bag => 5000) }, 'plarg' ], |
32 | bag => [ 1, 'r_sack', sub { set_package (@_, bag => 5000) }, 'plarg' ], |
33 | package => [ 5, 'r_sack', sub { set_package (@_, package => 50000) }, 'plarg' ], |
33 | package => [ 5, 'r_sack', sub { set_package (@_, package => 50000) }, 'plarg' ], |
… | |
… | |
68 | |
68 | |
69 | sub create_object { |
69 | sub create_object { |
70 | my ($name, $map, $x, $y, $cb, @a) = @_; |
70 | my ($name, $map, $x, $y, $cb, @a) = @_; |
71 | my $o = cf::object::new $name; |
71 | my $o = cf::object::new $name; |
72 | my $r = $cb->($o, @a); |
72 | my $r = $cb->($o, @a); |
73 | $map->insert_object ($o, $x, $y); |
73 | $map->insert ($o, $x, $y); |
74 | $r |
74 | $r |
75 | } |
75 | } |
76 | |
76 | |
77 | # this handler notifies the player of new mail |
77 | # this handler notifies the player of new mail |
78 | cf::player->attach ( |
78 | cf::player->attach ( |
… | |
… | |
175 | if (my $pr = $prices{$cmd}) { |
175 | if (my $pr = $prices{$cmd}) { |
176 | if ($cmd eq 'mailwarning' and !$who->flag (cf::FLAG_WIZ)) { |
176 | if ($cmd eq 'mailwarning' and !$who->flag (cf::FLAG_WIZ)) { |
177 | return 1; |
177 | return 1; |
178 | } |
178 | } |
179 | |
179 | |
180 | $who->pay_amount ($pr->[0] * $price_fact); |
180 | if ($who->pay_amount ($pr->[0] * $price_fact)) { |
181 | if ($pr->[3] && not cf::player::exists $arguments) { |
181 | if ($pr->[3] && not cf::player::exists $arguments) { |
182 | $who->reply ($npc, "Sorry, there is no '$arguments'"); |
182 | $who->reply ($npc, "Sorry, there is no '$arguments'"); |
|
|
183 | } else { |
|
|
184 | create_object ($pr->[1], $who->map, $x, $y, $pr->[2], $who->name, $arguments); |
|
|
185 | $who->reply ($npc, "Here is your $cmd"); |
|
|
186 | } |
183 | } else { |
187 | } else { |
184 | create_object ($pr->[1], $who->map, $x, $y, $pr->[2], $who->name, $arguments); |
188 | $who->reply ($npc, "Sorry, you don't have enough money."); |
185 | $who->reply ($npc, "Here is your $cmd"); |
|
|
186 | } |
189 | } |
187 | |
190 | |
188 | } elsif ($cmd eq 'receive') { |
191 | } elsif ($cmd eq 'receive') { |
189 | cf::async { |
192 | cf::async { |
|
|
193 | $Coro::current->{desc} = "ipo receive"; |
|
|
194 | |
190 | my $storage = cf::map::find ("/planes/IPO_storage"); |
195 | my $storage = cf::map::find ("/planes/IPO_storage"); |
191 | unless ($storage) { |
196 | unless ($storage) { |
192 | $who->reply ($npc, "Sorry, our package delivery service is currently in strike. Please come back later."); |
197 | $who->reply ($npc, "Sorry, our package delivery service is currently in strike. Please come back later."); |
193 | return 1; |
198 | return 1; |
194 | } |
199 | } |
|
|
200 | $storage->load; |
195 | |
201 | |
196 | my $plname = $who->name; |
202 | my $plname = $who->name; |
197 | my $cnt; |
203 | my $cnt; |
198 | for ($storage->at (2, 2)) { |
204 | for ($storage->at (2, 2)) { |
199 | if ($_->name () =~ /^\S+ F: \S+ T: \Q$plname\E$/) { |
205 | if ($_->name () =~ /^\S+ F: \S+ T: \Q$plname\E$/) { |
… | |
… | |
201 | $cnt++; |
207 | $cnt++; |
202 | } |
208 | } |
203 | } |
209 | } |
204 | |
210 | |
205 | if ($cnt) { |
211 | if ($cnt) { |
206 | $who->reply ($npc, $cnt == 1 ? "Here is your pakage." : "Here are your packages."); |
212 | $who->reply ($npc, $cnt == 1 ? "Here is your package." : "Here are your packages."); |
207 | } else { |
213 | } else { |
208 | $who->reply ($npc, "Sorry, no deliverys for you sir."); |
214 | $who->reply ($npc, "Sorry, no deliveries for you sir."); |
209 | } |
215 | } |
210 | } |
216 | } |
211 | |
217 | |
212 | } elsif ($cmd eq 'send') { |
218 | } elsif ($cmd eq 'send') { |
213 | unless ($arguments =~ /^\S+$/) { |
219 | unless ($arguments =~ /^\S+$/) { |
214 | $who->reply ($npc, "Send to who?"); |
220 | $who->reply ($npc, "Send to who?"); |
215 | return 1; |
221 | return 1; |
216 | } |
222 | } |
217 | |
223 | |
218 | cf::async { |
224 | cf::async { |
|
|
225 | $Coro::current->{desc} = "ipo send"; |
|
|
226 | |
219 | my $storage = cf::map::find ("/planes/IPO_storage"); |
227 | my $storage = cf::map::find ("/planes/IPO_storage"); |
220 | unless ($storage) { |
228 | unless ($storage) { |
221 | $who->reply ($npc, "Sorry, our package delivery service is currently in strike. Please come back later."); |
229 | $who->reply ($npc, "Sorry, our package delivery service is currently in strike. Please come back later."); |
222 | return 1; |
230 | return 1; |
223 | } |
231 | } |
|
|
232 | $storage->load; |
224 | |
233 | |
225 | my $cnt; |
234 | my $cnt; |
226 | for ($who->inv) { |
235 | for ($who->inv) { |
227 | if ($_->name () =~ /^(bag|package|carton) T: \Q$arguments\E F: (\S+)$/) { |
236 | if ($_->name () =~ /^(bag|package|carton) T: \Q$arguments\E F: (\S+)$/) { |
228 | $_->name ("$1 F: $2 T: $arguments"); |
237 | $_->name ("$1 F: $2 T: $arguments"); |
229 | $_->teleport ($storage, 2, 2); |
238 | $storage->insert ($_, 2, 2); |
|
|
239 | $who->esrv_del_item ($_->count); |
230 | $cnt++; |
240 | $cnt++; |
231 | } |
241 | } |
232 | } |
242 | } |
233 | |
243 | |
234 | if ($cnt) { |
244 | if ($cnt) { |
… | |
… | |
262 | package CFMail; |
272 | package CFMail; |
263 | |
273 | |
264 | use POSIX qw/strftime/; |
274 | use POSIX qw/strftime/; |
265 | use CFDB; |
275 | use CFDB; |
266 | |
276 | |
267 | my $MAILDB = CFDB->new (db_file => cf::localdir . "/crossfiremail"); |
277 | my $MAILDB = CFDB->new (db_file => "$LOCALDIR/crossfiremail"); |
268 | |
278 | |
269 | sub get_mail { |
279 | sub get_mail { |
270 | my ($toname) = @_; |
280 | my ($toname) = @_; |
271 | $MAILDB->get ($toname); |
281 | $MAILDB->get ($toname); |
272 | } |
282 | } |