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

Comparing deliantra/maps/perl/rent.ext (file contents):
Revision 1.5 by root, Tue Sep 19 18:51:38 2006 UTC vs.
Revision 1.10 by root, Fri Dec 15 19:06:29 2006 UTC

21 21
22 $portal->slaying ($map); 22 $portal->slaying ($map);
23 $portal->stats->hp ($x); 23 $portal->stats->hp ($x);
24 $portal->stats->sp ($y); 24 $portal->stats->sp ($y);
25 $portal->apply ($pl->ob); 25 $portal->apply ($pl->ob);
26 $portal->free; 26 $portal->destroy;
27} 27}
28 28
29# we have to special case some special cases :) 29# we have to special case some special cases :)
30sub reject_entry { 30sub reject_entry {
31 my ($pl) = @_; 31 my ($pl) = @_;
69 my $deduct = cf::ceil $pl->{rent}{balance}; 69 my $deduct = cf::ceil $pl->{rent}{balance};
70 70
71 my $deduct_string = cf::cost_string_from_value $deduct; 71 my $deduct_string = cf::cost_string_from_value $deduct;
72 72
73 if ($deduct <= $pl->ob->{bank_balance}) { 73 if ($deduct <= $pl->ob->{bank_balance}) {
74 cf::db_put rent => balance => $deduct + cf::db_get rent => "balance";
74 $pl->ob->{bank_balance} -= $deduct; 75 $pl->ob->{bank_balance} -= $deduct;
75 $pl->{rent}{balance} -= $deduct; 76 $pl->{rent}{balance} -= $deduct;
76 $pl->ob->reply (undef, "Something whispers into your ear:\n" 77 $pl->ob->reply (undef, "Something whispers into your ear:\n"
77 . "Sir, we deducted your apartment rent ($deduct_string) from your bank account."); 78 . "Sir, we deducted your apartment rent ($deduct_string) from your bank account.");
78 } else { 79 } else {
149 $pl->ob->reply (undef, "I am sorry to hear that, we will immediately stop charging you for your apartment, of course."); 150 $pl->ob->reply (undef, "I am sorry to hear that, we will immediately stop charging you for your apartment, of course.");
150}; 151};
151 152
152cf::attach_to_players prio => 100, 153cf::attach_to_players prio => 100,
153 on_login => sub { 154 on_login => sub {
154 return;
155 my ($pl) = @_; 155 my ($pl) = @_;
156
157 use Data::Dumper;
158 warn Dumper $pl;
159 156
160 $pl->{rent}{last_offline_check} ||= time; 157 $pl->{rent}{last_offline_check} ||= time;
161 158
162 if ($pl->{rent}{last_online_check}) { 159 if ($pl->{rent}{last_online_check}) {
163 $pl->{rent}{last_online_check} = time 160 $pl->{rent}{last_online_check} = time
172 169
173cf::register_map_attachment rent => 170cf::register_map_attachment rent =>
174 on_enter => sub { 171 on_enter => sub {
175 my ($map, $pl, $x, $y) = @_; 172 my ($map, $pl, $x, $y) = @_;
176 173
174 # can freely enter homes of other people
175 {
176 my $path = sprintf "%s/%s/%s/",
177 cf::localdir, cf::playerdir, $pl->ob->name;
178
179 return if $path ne substr $map->path, 0, length $path;
180 }
181
177 for my $path (keys %{ $pl->{rent}{apartment} }) { 182 for my $path (keys %{ $pl->{rent}{apartment} }) {
178 $path =~ y/\//_/; 183 $path =~ y/\//_/;
179 $path = sprintf "%s/%s/%s/%s", 184 $path = sprintf "%s/%s/%s/%s",
180 cf::localdir, cf::playerdir, $pl->ob->name, $path; 185 cf::localdir, cf::playerdir, $pl->ob->name, $path;
181 186
194 $pl->ob->reply (undef, "Sir, you have to rent this apartment in The Apartment Shop in Scorn first!"); 199 $pl->ob->reply (undef, "Sir, you have to rent this apartment in The Apartment Shop in Scorn first!");
195 reject_entry $pl; 200 reject_entry $pl;
196 }, 201 },
197; 202;
198 203
199Event->timer (after => 60, interval => 3600, cb => sub { 204Event->timer (after => 60, interval => 3600, data => cf::WF_AUTOCANCEL, cb => sub {
200 pay_balance $_ for cf::player::list; 205 pay_balance $_ for cf::player::list;
201}); 206});
202 207

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines