ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/maps/perl/bank.ext
(Generate patch)

Comparing deliantra/maps/perl/bank.ext (file contents):
Revision 1.19 by elmex, Tue Jul 11 16:56:27 2006 UTC vs.
Revision 1.23 by elmex, Mon Aug 14 21:38:59 2006 UTC

42 } else { 42 } else {
43 return $who->name." has no balance." 43 return $who->name." has no balance."
44 unless $balance >= 1; 44 unless $balance >= 1;
45 } 45 }
46 46
47 my $royalties = calc_exchange_rate $balance, "silver", "royalty"; 47 my $account_info = cf::cost_string_from_value ($balance);
48 my $platinum = calc_exchange_rate $royalties - (int $royalties), "royalty", "platina";
49 my $gold = calc_exchange_rate $platinum - (int $platinum), "platina", "gold";
50 my $silver = calc_exchange_rate $gold - (int $gold), "gold", "silver";
51
52 my $account_info =
53 (int $royalties) . " royalties, "
54 . (int $platinum) . " platinum, "
55 . (int $gold) . " gold and about "
56 . (int $silver) ." silver coins.";
57 48
58 return "You have $account_info" 49 return "You have $account_info"
59 unless $is_wiz; 50 unless $is_wiz;
60 51
61 return $who->name." has $account_info"; 52 return $who->name." has $account_info";
140 } 131 }
141 return $exchange_rates."This may change a bit with the stock markets but don't expect it to be much."; 132 return $exchange_rates."This may change a bit with the stock markets but don't expect it to be much.";
142 } 133 }
143} 134}
144 135
145sub on_say { 136cf::register_script_function "bank::command" => sub {
146 my ($event, $ob, $who, $msg) = @_; 137 my ($who, $msg, $npc) = @_;
138
147 my ($cmd, $arguments) = split /\s+/, $msg, 2; 139 my ($cmd, $arguments) = split /\s+/, $msg, 2;
148 my ($amount, $currency) = split /\s+/, $arguments, 2; 140 my ($amount, $currency) = split /\s+/, $arguments, 2;
149 my $name = $ob->name;
150 my $service_charge = 5; 141 my $service_charge = 5;
151 my @units = sort keys %unit; 142 my @units = sort keys %unit;
152 my $units = join ", ", @units; 143 my $units = join ", ", @units;
153 my $fees = - ($service_charge / 100) + 1; 144 my $fees = - ($service_charge / 100) + 1;
154 145
160 } 151 }
161 152
162 if ($cmd eq "balance") { 153 if ($cmd eq "balance") {
163 if ($who->flag (cf::FLAG_WIZ)) { 154 if ($who->flag (cf::FLAG_WIZ)) {
164 if (my $player = cf::player::find $arguments) { 155 if (my $player = cf::player::find $arguments) {
165 $who->message ("$name says: ".balance ($player->ob, 1), cf::NDI_WHITE); 156 $who->reply ($npc, balance $player->ob, 1);
166 } 157 }
167 } else { 158 } else {
168 $who->message ("$name says: ".balance ($who, 0), cf::NDI_WHITE); 159 $who->reply ($npc, balance $who, 0);
169 } 160 }
170 161
171 } elsif ($cmd eq "balance" and !$arguments) { 162 } elsif ($cmd eq "balance" and !$arguments) {
172 $who->message ("$name says: Balance of whom?", cf::NDI_WHITE); 163 $who->reply ($npc, "Balance of whom?");
173 164
174 } elsif ($cmd eq "deposit" and $currency) { 165 } elsif ($cmd eq "deposit" and $currency) {
175 $who->message ("$name says: " . (transaction $who, "deposit", $amount, $currency), cf::NDI_WHITE); 166 $who->reply ($npc, transaction $who, "deposit", $amount, $currency);
176 $who->message ("$name says: " . (balance $who), cf::NDI_WHITE); 167 $who->reply ($npc, balance $who);
177 168
178 } elsif ($cmd eq "deposit" and $amount and $currency eq "") { 169 } elsif ($cmd eq "deposit" and $amount and $currency eq "") {
179 $who->message ("$name says: Deposit $amount of what: $units", cf::NDI_WHITE); 170 $who->reply ($npc, "deposit $amount of what: $units");
180 171
181 } elsif ($cmd eq "deposit" and $amount eq "" and $currency eq "") { 172 } elsif ($cmd eq "deposit" and $amount eq "" and $currency eq "") {
182 $who->message ("$name says: How much do you want to deposit?", cf::NDI_WHITE); 173 $who->reply ($npc, "How much do you want to deposit?");
183 174
184 } elsif ($cmd eq "withdraw" and $currency) { 175 } elsif ($cmd eq "withdraw" and $currency) {
185 $who->message ("$name says: " . (transaction $who, "withdraw", $amount, $currency), cf::NDI_WHITE); 176 $who->reply ($npc, transaction $who, "withdraw", $amount, $currency);
186 $who->message ("$name says: " . (balance $who), cf::NDI_WHITE); 177 $who->reply ($npc, balance $who);
187 178
188 } elsif ($cmd eq "withdraw" and $amount and $currency eq "") { 179 } elsif ($cmd eq "withdraw" and $amount and $currency eq "") {
189 $who->message ("$name says: Withdraw $amount of what: $units", cf::NDI_WHITE); 180 $who->reply ($npc, "Withdraw $amount of what: $units");
190 181
191 } elsif ($cmd eq "withdraw" and $amount eq "" and $currency eq "") { 182 } elsif ($cmd eq "withdraw" and $amount eq "" and $currency eq "") {
192 $who->message ("$name says: How much do you want to withdraw?", cf::NDI_WHITE); 183 $who->reply ($npc, "How much do you want to withdraw?");
193 184
194 } elsif ($cmd eq "exchange") { 185 } elsif ($cmd eq "exchange") {
195 $who->message ("$name says: This function is not yet implemented. Ask me again later.", cf::NDI_WHITE); 186 $who->reply ($npc, "This function is not yet implemented. Ask me again later.");
196 187
197 } elsif ($cmd eq "help" or $cmd eq "yes" and $arguments eq "") { 188 } elsif ($cmd eq "help" or $cmd eq "yes" and $arguments eq "") {
198 $who->message ("$name says: " . (help $arguments), cf::NDI_WHITE); 189 $who->reply ($npc, help $arguments);
199 190
200 } elsif ($cmd eq "help" or $cmd eq "yes" and $arguments ne "") { 191 } elsif ($cmd eq "help" or $cmd eq "yes" and $arguments ne "") {
201 $who->message ("$name says: " . (help), cf::NDI_WHITE); 192 $who->reply ($npc, help);
202 193
203 } else { 194 } else {
204 $who->message ("$name says: Do you need help?", cf::NDI_WHITE); 195 $who->reply ($npc, "Do you need help?");
205 } 196 }
206} 197}
207 198

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines