… | |
… | |
17 | # we have to special case some special cases :) |
17 | # we have to special case some special cases :) |
18 | sub reject_entry { |
18 | sub reject_entry { |
19 | my ($pl) = @_; |
19 | my ($pl) = @_; |
20 | |
20 | |
21 | my $prev_pos = $pl->ob->{_prev_pos}; |
21 | my $prev_pos = $pl->ob->{_prev_pos}; |
22 | $pl->ob->goto ($prev_pos ? @$prev_pos : "/world/world_105_115", 2, 34); |
22 | $pl->ob->goto ($prev_pos ? @$prev_pos : ("/world/world_105_115", 2, 34)); |
23 | |
23 | |
24 | cf::override; |
24 | cf::override; |
25 | } |
25 | } |
26 | |
26 | |
27 | sub update_balance { |
27 | sub update_balance { |
… | |
… | |
58 | if ($deduct <= $pl->ob->{bank_balance}) { |
58 | if ($deduct <= $pl->ob->{bank_balance}) { |
59 | cf::db_put rent => balance => $deduct + cf::db_get rent => "balance"; |
59 | cf::db_put rent => balance => $deduct + cf::db_get rent => "balance"; |
60 | $pl->ob->{bank_balance} -= $deduct; |
60 | $pl->ob->{bank_balance} -= $deduct; |
61 | $pl->{rent}{balance} -= $deduct; |
61 | $pl->{rent}{balance} -= $deduct; |
62 | $pl->ob->reply (undef, "Something whispers into your ear:\n" |
62 | $pl->ob->reply (undef, "Something whispers into your ear:\n" |
63 | . "Sir, we deducted your apartment rent ($deduct_string) from your bank account."); |
63 | . "Your highness, we deducted your apartment rent ($deduct_string) from your bank account."); |
64 | } else { |
64 | } else { |
65 | $pl->ob->reply (undef, "Something whispers into your ear:\n" |
65 | $pl->ob->reply (undef, "Something whispers into your ear:\n" |
66 | . "Sir, we want to deduct the apartment rent ($deduct_string), but the bank informed us that they cannot perform the transaction. " |
66 | . "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."); |
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."); |
68 | } |
68 | } |
69 | } |
69 | } |
70 | |
70 | |
71 | sub check_balance { |
71 | sub check_balance { |
… | |
… | |
115 | |
115 | |
116 | update_balance $pl; |
116 | update_balance $pl; |
117 | |
117 | |
118 | $pl->{rent}{apartment}{$apartment} = undef; |
118 | $pl->{rent}{apartment}{$apartment} = undef; |
119 | |
119 | |
120 | $pl->ob->reply (undef, "Wonderful decision, sir! " |
120 | $pl->ob->reply (undef, "Wonderful decision, your highness! " |
121 | . "We told the proprietor in $apartment{$apartment}[1] to expect you and let you in. " |
121 | . "We told the proprietor in $apartment{$apartment}[1] to expect you and let you in. " |
122 | . "We are sure you will be satisfied!"); |
122 | . "We are sure you will be satisfied!"); |
123 | }; |
123 | }; |
124 | |
124 | |
125 | cf::register_script_function "rent::stop" => sub { |
125 | cf::register_script_function "rent::stop" => sub { |
… | |
… | |
165 | for my $path (keys %{ $pl->{rent}{apartment} }) { |
165 | for my $path (keys %{ $pl->{rent}{apartment} }) { |
166 | $path = sprintf "~%s%s", $pl->ob->name, $path; |
166 | $path = sprintf "~%s%s", $pl->ob->name, $path; |
167 | |
167 | |
168 | if ($map->path eq $path) { |
168 | if ($map->path eq $path) { |
169 | if (check_balance $pl) { |
169 | if (check_balance $pl) { |
170 | $pl->ob->reply (undef, "Welcome to your apartment, sir!"); |
170 | $pl->ob->reply (undef, "Welcome to your apartment, your highness!"); |
171 | } else { |
171 | } else { |
172 | $pl->ob->reply (undef, "We are sorry, sir, you have to pay your rent first."); |
172 | $pl->ob->reply (undef, "We are sorry, your highness, you have to pay your rent first."); |
173 | reject_entry $pl; |
173 | reject_entry $pl; |
174 | } |
174 | } |
175 | |
175 | |
176 | return; |
176 | return; |
177 | } |
177 | } |
178 | } |
178 | } |
179 | |
179 | |
180 | $pl->ob->reply (undef, "Sir, you have to rent this apartment in The Apartment Shop in Scorn first!"); |
180 | $pl->ob->reply (undef, "Your highness, you have to rent this apartment in The Apartment Shop in Scorn first!"); |
181 | reject_entry $pl; |
181 | reject_entry $pl; |
182 | } |
182 | } |
183 | }, |
183 | }, |
184 | ; |
184 | ; |
185 | |
185 | |