1 | #! perl |
1 | #! perl |
2 | |
2 | |
3 | use List::Util; |
3 | use List::Util; |
4 | |
4 | |
5 | my %apartment = ( |
5 | our %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"], |
|
|
10 | "/lake_country/Butakis/apartment" => [ 200, "valdor", "expandor"], |
9 | "/navar_city/apartments/apartment" => [ 250, "navar", "navar"], |
11 | "/navar_city/apartments/apartment" => [ 250, "navar", "navar"], |
|
|
12 | "/celvear_port/tower2/tower2" => [ 300, "celvear port", "kevlar"], |
10 | "/azumauindo/ranbounagisatoshi/apartments/sapartment" => [ 100, "乱暴渚都市", "benjo"], |
13 | "/azumauindo/ranbounagisatoshi/apartments/sapartment" => [ 100, "乱暴渚都市", "benjo"], |
11 | "/azumauindo/suno-yamatoshi/apartments/lapartment1" => [ 1000, "スノー大和島根", "sama"], |
14 | "/azumauindo/suno-yamatoshi/apartments/lapartment1" => [ 1000, "スノー大和島根", "sama"], |
|
|
15 | "/elmex/jeweler/jeweler_inn_upper" => [ 500, "jeweler town", "jewelor"], |
12 | "/pup_land/nurnberg/apartment/main" => [ 300, "nürnberg", "sauerkraut"], |
16 | "/pup_land/nurnberg/apartment/main" => [ 300, "nürnberg", "sauerkraut"], |
|
|
17 | "/lostwages/petapartment" => [ 5000, "lostwages", "losvegas"], |
|
|
18 | "/gotischerbereich/towerapartment/tower1" => [10000, "gotisch", "retreat"], |
|
|
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 :) |
18 | sub reject_entry { |
24 | sub reject_entry { |
19 | my ($pl) = @_; |
25 | my ($pl) = @_; |
… | |
… | |
91 | my ($pl, $types) = @_; |
97 | my ($pl, $types) = @_; |
92 | |
98 | |
93 | while (my ($k, $v) = each %apartment) { |
99 | while (my ($k, $v) = each %apartment) { |
94 | my $type = exists $pl->{rent}{apartment}{$k} ? 1 : 2; |
100 | my $type = exists $pl->{rent}{apartment}{$k} ? 1 : 2; |
95 | |
101 | |
96 | $pl->ob->reply (undef, "model \"$v->[2]\", situated in $v->[1] (" |
102 | $pl->ob->reply (undef, "model \"$v->[2]\", located in $v->[1] (" |
97 | . (cf::cost_string_from_value $v->[0]) . "/hr)\n") |
103 | . (cf::cost_string_from_value $v->[0]) . "/hr)\n") |
98 | if $type & $types; |
104 | if $type & $types; |
99 | } |
105 | } |
100 | }; |
106 | }; |
101 | |
107 | |
… | |
… | |
145 | $pl->{rent}{last_offline_check} ||= time; |
151 | $pl->{rent}{last_offline_check} ||= time; |
146 | |
152 | |
147 | if ($pl->{rent}{last_online_check}) { |
153 | if ($pl->{rent}{last_online_check}) { |
148 | $pl->{rent}{last_online_check} = time |
154 | $pl->{rent}{last_online_check} = time |
149 | - List::Util::min 3600, |
155 | - List::Util::min 3600, |
150 | $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}; |
151 | } else { |
157 | } else { |
152 | $pl->{rent}{last_online_check} = time; |
158 | $pl->{rent}{last_online_check} = time; |
153 | } |
159 | } |
154 | |
160 | |
155 | update_balance $pl; |
161 | update_balance $pl; |
… | |
… | |
157 | ); |
163 | ); |
158 | |
164 | |
159 | cf::map::attachment rent => |
165 | cf::map::attachment rent => |
160 | on_enter => sub { |
166 | on_enter => sub { |
161 | my ($map, $pl, $x, $y) = @_; |
167 | my ($map, $pl, $x, $y) = @_; |
|
|
168 | |
|
|
169 | return if $pl->ob->flag (cf::FLAG_WIZ); |
162 | |
170 | |
163 | my $pfx = sprintf "~%s/", $pl->ob->name; |
171 | my $pfx = sprintf "~%s/", $pl->ob->name; |
164 | |
172 | |
165 | # only do something if entering ones own apartment |
173 | # only do something if entering ones own apartment |
166 | if ($pfx eq substr $map->path, 0, length $pfx) { |
174 | if ($pfx eq substr $map->path, 0, length $pfx) { |
… | |
… | |
177 | |
185 | |
178 | return; |
186 | return; |
179 | } |
187 | } |
180 | } |
188 | } |
181 | |
189 | |
182 | $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!"); |
183 | reject_entry $pl; |
191 | reject_entry $pl; |
184 | } |
192 | } |
185 | }, |
193 | }, |
186 | ; |
194 | ; |
187 | |
195 | |
188 | our $RENT_TIMER = Event->timer ( |
196 | our $RENT_TIMER = cf::periodic 3600, Coro::unblock_sub { |
189 | reentrant => 0, |
|
|
190 | after => 60, |
|
|
191 | interval => 3600, |
|
|
192 | data => cf::WF_AUTOCANCEL, |
|
|
193 | cb => Coro::unblock_sub { |
|
|
194 | pay_balance $_ for cf::player::list; |
197 | pay_balance $_ for cf::player::list; |
195 | }, |
198 | }; |
196 | ); |
|
|
197 | |
199 | |