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.9 by root, Sun Jun 17 13:56:09 2007 UTC vs.
Revision 1.15 by root, Sat Oct 24 11:08:14 2009 UTC

4 4
5my %apartment = ( 5my %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 "/celvear_port/tower2/tower2" => [ 100, "celvear port", "kevlar"],
9 "/navar_city/apartments/apartment" => [ 250, "navar", "navar"], 10 "/navar_city/apartments/apartment" => [ 250, "navar", "navar"],
10 "/azumauindo/ranbounagisatoshi/apartments/sapartment" => [ 100, "乱暴渚都市", "benjo"], 11 "/azumauindo/ranbounagisatoshi/apartments/sapartment" => [ 100, "乱暴渚都市", "benjo"],
11 "/azumauindo/suno-yamatoshi/apartments/lapartment1" => [ 1000, "スノー大和島根", "sama"], 12 "/azumauindo/suno-yamatoshi/apartments/lapartment1" => [ 1000, "スノー大和島根", "sama"],
13 "/elmex/jeweler/jeweler_inn_upper" => [ 500, "jeweler town", "jewelor"],
12 "/pup_land/nurnberg/apartment/main" => [ 300, "nürnberg", "sauerkraut"], 14 "/pup_land/nurnberg/apartment/main" => [ 300, "nürnberg", "sauerkraut"],
13 "/pup_land/lone_town/apartment/groundfloor" => [50000, "lone town", "looney"], 15 "/pup_land/lone_town/apartment/groundfloor" => [50000, "lone town", "looney"],
14 "/brest/apartments/brest_town_house" => [30000, "brest", "brecht"], 16 "/brest/apartments/brest_town_house" => [30000, "brest", "brecht"],
15); 17);
16 18
45} 47}
46 48
47sub pay_balance { 49sub pay_balance {
48 my ($pl) = @_; 50 my ($pl) = @_;
49 51
52 cf::cede_to_tick;
53
50 update_balance $pl; 54 update_balance $pl;
51 55
52 return unless $pl->{rent}{balance} > 0; 56 return unless $pl->{rent}{balance} > 0;
53 57
54 my $deduct = cf::ceil $pl->{rent}{balance}; 58 my $deduct = cf::ceil $pl->{rent}{balance};
57 61
58 if ($deduct <= $pl->ob->{bank_balance}) { 62 if ($deduct <= $pl->ob->{bank_balance}) {
59 cf::db_put rent => balance => $deduct + cf::db_get rent => "balance"; 63 cf::db_put rent => balance => $deduct + cf::db_get rent => "balance";
60 $pl->ob->{bank_balance} -= $deduct; 64 $pl->ob->{bank_balance} -= $deduct;
61 $pl->{rent}{balance} -= $deduct; 65 $pl->{rent}{balance} -= $deduct;
62 $pl->ob->reply (undef, "Something whispers into your ear:\n" 66 $pl->ob->reply (undef, "Something whispers into your ear: "
63 . "Your highness, we deducted your apartment rent ($deduct_string) from your bank account."); 67 . "Your highness, we deducted your apartment rent ($deduct_string) from your bank account.");
64 } else { 68 } else {
65 $pl->ob->reply (undef, "Something whispers into your ear:\n" 69 $pl->ob->reply (undef, "Something whispers into your ear: "
66 . "Your highness, we want to deduct the apartment rent ($deduct_string), but the bank informed us that they cannot perform the transaction. " 70 . "Your highness, we want to deduct the apartment rent ($deduct_string), but the bank informed us that they cannot perform the transaction. "
67 . "Please even out your balance so we can deduct the fees, otherwise we will be forced to shut down your access to the apartment."); 71 . "Please even out your balance so we can deduct the fees, otherwise we will be forced to shut down your access to the apartment.");
68 } 72 }
69} 73}
70 74
90 94
91 while (my ($k, $v) = each %apartment) { 95 while (my ($k, $v) = each %apartment) {
92 my $type = exists $pl->{rent}{apartment}{$k} ? 1 : 2; 96 my $type = exists $pl->{rent}{apartment}{$k} ? 1 : 2;
93 97
94 $pl->ob->reply (undef, "model \"$v->[2]\", situated in $v->[1] (" 98 $pl->ob->reply (undef, "model \"$v->[2]\", situated in $v->[1] ("
95 . (cf::cost_string_from_value $v->[0]) . "/hr)") 99 . (cf::cost_string_from_value $v->[0]) . "/hr)\n")
96 if $type & $types; 100 if $type & $types;
97 } 101 }
98}; 102};
99 103
100cf::register_script_function "rent::status" => sub { 104cf::register_script_function "rent::status" => sub {
143 $pl->{rent}{last_offline_check} ||= time; 147 $pl->{rent}{last_offline_check} ||= time;
144 148
145 if ($pl->{rent}{last_online_check}) { 149 if ($pl->{rent}{last_online_check}) {
146 $pl->{rent}{last_online_check} = time 150 $pl->{rent}{last_online_check} = time
147 - List::Util::min 3600, 151 - List::Util::min 3600,
148 $pl->ob->get_ob_key_value ("schmorplog_last_save") - $pl->{rent}{last_online_check}; 152 $pl->ob->kv_get ("schmorplog_last_save") - $pl->{rent}{last_online_check};
149 } else { 153 } else {
150 $pl->{rent}{last_online_check} = time; 154 $pl->{rent}{last_online_check} = time;
151 } 155 }
152 156
153 update_balance $pl; 157 update_balance $pl;
175 179
176 return; 180 return;
177 } 181 }
178 } 182 }
179 183
180 $pl->ob->reply (undef, "Your highness, you have to rent this apartment in The Apartment Shop in Scorn first!"); 184 $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; 185 reject_entry $pl;
182 } 186 }
183 }, 187 },
184; 188;
185 189
186our $RENT_TIMER = Event->timer ( 190our $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; 191 pay_balance $_ for cf::player::list;
193 }, 192};
194);
195 193

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines