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

Comparing deliantra/server/ext/rent.ext (file contents):
Revision 1.10 by root, Tue Jun 26 04:56:10 2007 UTC vs.
Revision 1.28 by elmex, Wed Mar 31 14:12:29 2010 UTC

1#! perl 1#! perl
2 2
3use List::Util; 3use List::Util;
4 4
5my %apartment = ( 5our %apartment = (
6 "/scorn/apartment/apartments" => [ 1, "scorn", "skorn"], 6 "/scorn/apartment/apartments" => [ 1, "scorn", "skorn"],
7 "/santo_dominion/sdomino_appartment" => [ 10, "santo dominion", "domino"], 7 "/santo_dominion/sdomino_appartment" => [ 10, "santo dominion", "domino"],
8 "/darcap/darcap/apartment" => [ 30, "darcap", "thecap"], 8 "/darcap/darcap/apartment" => [ 30, "darcap", "thecap"],
9 "/gotischerbereich/steinwandstadt/sapartment1" => [ 100, "steinwandstadt", "konkret"],
9 "/navar_city/apartments/apartment" => [ 250, "navar", "navar"], 10 "/navar_city/apartments/apartment" => [ 250, "navar", "navar"],
11 "/celvear_port/tower2/tower2" => [ 300, "celvear port", "kevlar"],
10 "/azumauindo/ranbounagisatoshi/apartments/sapartment" => [ 100, "乱暴渚都市", "benjo"], 12 "/azumauindo/ranbounagisatoshi/apartments/sapartment" => [ 100, "乱暴渚都市", "benjo"],
11 "/azumauindo/suno-yamatoshi/apartments/lapartment1" => [ 1000, "スノー大和島根", "sama"], 13 "/azumauindo/suno-yamatoshi/apartments/lapartment1" => [ 1000, "スノー大和島根", "sama"],
14 "/valleynoy/jewelertown/jeweler_inn_upper" => [ 500, "jeweler town", "jewelor"],
12 "/pup_land/nurnberg/apartment/main" => [ 300, "nürnberg", "sauerkraut"], 15 "/pup_land/nurnberg/apartment/main" => [ 300, "nürnberg", "sauerkraut"],
16 "/lostwages/petapartment" => [ 5000, "lostwages", "losvegas"],
17 "/gotischerbereich/towerapartment/tower1" => [10000, "gotisch", "retreat"],
18 "/lake_country/Butakis/apartment" => [25000, "castle butakis", "expandor"],
19 "/brest/apartments/brest_town_house" => [30000, "brest", "brecht"],
13 "/pup_land/lone_town/apartment/groundfloor" => [50000, "lone town", "looney"], 20 "/pup_land/lone_town/apartment/groundfloor" => [50000, "lone town", "looney"],
14 "/brest/apartments/brest_town_house" => [30000, "brest", "brecht"],
15); 21);
16 22
17# we have to special case some special cases :) 23# we have to special case some special cases :)
18sub reject_entry { 24sub reject_entry {
19 my ($pl) = @_; 25 my ($pl) = @_;
44 $pl->{rent}{balance} += $offline + $online; 50 $pl->{rent}{balance} += $offline + $online;
45} 51}
46 52
47sub pay_balance { 53sub pay_balance {
48 my ($pl) = @_; 54 my ($pl) = @_;
55
56 cf::cede_to_tick;
49 57
50 update_balance $pl; 58 update_balance $pl;
51 59
52 return unless $pl->{rent}{balance} > 0; 60 return unless $pl->{rent}{balance} > 0;
53 61
89 my ($pl, $types) = @_; 97 my ($pl, $types) = @_;
90 98
91 while (my ($k, $v) = each %apartment) { 99 while (my ($k, $v) = each %apartment) {
92 my $type = exists $pl->{rent}{apartment}{$k} ? 1 : 2; 100 my $type = exists $pl->{rent}{apartment}{$k} ? 1 : 2;
93 101
94 $pl->ob->reply (undef, "model \"$v->[2]\", situated in $v->[1] (" 102 $pl->ob->reply (undef, "model \"$v->[2]\", located in $v->[1] ("
95 . (cf::cost_string_from_value $v->[0]) . "/hr)\n") 103 . (cf::cost_string_from_value $v->[0]) . "/hr)\n")
96 if $type & $types; 104 if $type & $types;
97 } 105 }
98}; 106};
99 107
143 $pl->{rent}{last_offline_check} ||= time; 151 $pl->{rent}{last_offline_check} ||= time;
144 152
145 if ($pl->{rent}{last_online_check}) { 153 if ($pl->{rent}{last_online_check}) {
146 $pl->{rent}{last_online_check} = time 154 $pl->{rent}{last_online_check} = time
147 - List::Util::min 3600, 155 - List::Util::min 3600,
148 $pl->ob->get_ob_key_value ("schmorplog_last_save") - $pl->{rent}{last_online_check}; 156 $pl->ob->kv_get ("schmorplog_last_save") - $pl->{rent}{last_online_check};
149 } else { 157 } else {
150 $pl->{rent}{last_online_check} = time; 158 $pl->{rent}{last_online_check} = time;
151 } 159 }
152 160
153 update_balance $pl; 161 update_balance $pl;
155); 163);
156 164
157cf::map::attachment rent => 165cf::map::attachment rent =>
158 on_enter => sub { 166 on_enter => sub {
159 my ($map, $pl, $x, $y) = @_; 167 my ($map, $pl, $x, $y) = @_;
168
169 return if $pl->ob->flag (cf::FLAG_WIZ);
160 170
161 my $pfx = sprintf "~%s/", $pl->ob->name; 171 my $pfx = sprintf "~%s/", $pl->ob->name;
162 172
163 # only do something if entering ones own apartment 173 # only do something if entering ones own apartment
164 if ($pfx eq substr $map->path, 0, length $pfx) { 174 if ($pfx eq substr $map->path, 0, length $pfx) {
175 185
176 return; 186 return;
177 } 187 }
178 } 188 }
179 189
180 $pl->ob->reply (undef, "Your highness, you have to rent this apartment in The Apartment Shop in Scorn first!"); 190 $pl->ob->reply (undef, "Your highness, you have to rent this apartment in The Apartment Shop in Scorn or other apartment shops first!");
181 reject_entry $pl; 191 reject_entry $pl;
182 } 192 }
183 }, 193 },
184; 194;
185 195
186our $RENT_TIMER = Event->timer ( 196our $RENT_TIMER = cf::periodic 3600, Coro::unblock_sub {
187 reentrant => 0,
188 after => 60,
189 interval => 3600,
190 data => cf::WF_AUTOCANCEL,
191 cb => sub {
192 pay_balance $_ for cf::player::list; 197 pay_balance $_ for cf::player::list;
193 }, 198};
194);
195 199

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines