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 | "/celvear_port/tower2/tower2" => [ 100, "celvear port", "kevlar"], |
9 | "/gotischerbereich/steinwandstadt/sapartment1" => [ 100, "steinwandstadt", "konkret"], |
10 | "/navar_city/apartments/apartment" => [ 250, "navar", "navar"], |
10 | "/navar_city/apartments/apartment" => [ 250, "navar", "navar"], |
|
|
11 | "/celvear_port/tower2/tower2" => [ 300, "celvear port", "kevlar"], |
11 | "/azumauindo/ranbounagisatoshi/apartments/sapartment" => [ 100, "乱暴渚都市", "benjo"], |
12 | "/azumauindo/ranbounagisatoshi/apartments/sapartment" => [ 100, "乱暴渚都市", "benjo"], |
12 | "/azumauindo/suno-yamatoshi/apartments/lapartment1" => [ 1000, "スノー大和島根", "sama"], |
13 | "/azumauindo/suno-yamatoshi/apartments/lapartment1" => [ 1000, "スノー大和島根", "sama"], |
13 | "/elmex/jeweler/jeweler_inn_upper" => [ 500, "jeweler town", "jewelor"], |
14 | "/valleynoy/jewelertown/jeweler_inn_upper" => [ 500, "jeweler town", "jewelor"], |
14 | "/pup_land/nurnberg/apartment/main" => [ 300, "nürnberg", "sauerkraut"], |
15 | "/pup_land/nurnberg/apartment/main" => [ 300, "nürnberg", "sauerkraut"], |
15 | "/lostwages/petapartment" => [ 5000, "lostwages", "losvegas"], |
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"], |
16 | "/pup_land/lone_town/apartment/groundfloor" => [50000, "lone town", "looney"], |
20 | "/pup_land/lone_town/apartment/groundfloor" => [50000, "lone town", "looney"], |
17 | "/brest/apartments/brest_town_house" => [30000, "brest", "brecht"], |
|
|
18 | ); |
21 | ); |
19 | |
22 | |
20 | # we have to special case some special cases :) |
23 | # we have to special case some special cases :) |
21 | sub reject_entry { |
24 | sub reject_entry { |
22 | my ($pl) = @_; |
25 | my ($pl) = @_; |
… | |
… | |
94 | my ($pl, $types) = @_; |
97 | my ($pl, $types) = @_; |
95 | |
98 | |
96 | while (my ($k, $v) = each %apartment) { |
99 | while (my ($k, $v) = each %apartment) { |
97 | my $type = exists $pl->{rent}{apartment}{$k} ? 1 : 2; |
100 | my $type = exists $pl->{rent}{apartment}{$k} ? 1 : 2; |
98 | |
101 | |
99 | $pl->ob->reply (undef, "model \"$v->[2]\", situated in $v->[1] (" |
102 | $pl->ob->reply (undef, "model \"$v->[2]\", located in $v->[1] (" |
100 | . (cf::cost_string_from_value $v->[0]) . "/hr)\n") |
103 | . (cf::cost_string_from_value $v->[0]) . "/hr)\n") |
101 | if $type & $types; |
104 | if $type & $types; |
102 | } |
105 | } |
103 | }; |
106 | }; |
104 | |
107 | |
… | |
… | |
161 | |
164 | |
162 | cf::map::attachment rent => |
165 | cf::map::attachment rent => |
163 | on_enter => sub { |
166 | on_enter => sub { |
164 | my ($map, $pl, $x, $y) = @_; |
167 | my ($map, $pl, $x, $y) = @_; |
165 | |
168 | |
|
|
169 | return if $pl->ob->flag (cf::FLAG_WIZ); |
|
|
170 | |
166 | my $pfx = sprintf "~%s/", $pl->ob->name; |
171 | my $pfx = sprintf "~%s/", $pl->ob->name; |
167 | |
172 | |
168 | # only do something if entering ones own apartment |
173 | # only do something if entering ones own apartment |
169 | if ($pfx eq substr $map->path, 0, length $pfx) { |
174 | if ($pfx eq substr $map->path, 0, length $pfx) { |
170 | for my $path (keys %{ $pl->{rent}{apartment} }) { |
175 | for my $path (keys %{ $pl->{rent}{apartment} }) { |
… | |
… | |
172 | |
177 | |
173 | if ($map->path eq $path) { |
178 | if ($map->path eq $path) { |
174 | if (check_balance $pl) { |
179 | if (check_balance $pl) { |
175 | $pl->ob->reply (undef, "Welcome to your apartment, your highness!"); |
180 | $pl->ob->reply (undef, "Welcome to your apartment, your highness!"); |
176 | } else { |
181 | } else { |
177 | $pl->ob->reply (undef, "We are sorry, your highness, you have to pay your rent first."); |
182 | $pl->failmsg ("We are sorry, your highness, you have to pay your rent first."); |
178 | reject_entry $pl; |
183 | reject_entry $pl; |
179 | } |
184 | } |
180 | |
185 | |
181 | return; |
186 | return; |
182 | } |
187 | } |
183 | } |
188 | } |
184 | |
189 | |
185 | $pl->ob->reply (undef, "Your highness, you have to rent this apartment in The Apartment Shop in Scorn or other apartment shops first!"); |
190 | $pl->failmsg ("Your highness, you have to rent this apartment in The Apartment Shop in Scorn or other apartment shops first!"); |
186 | reject_entry $pl; |
191 | reject_entry $pl; |
187 | } |
192 | } |
188 | }, |
193 | }, |
189 | ; |
194 | ; |
190 | |
195 | |