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.18 by elmex, Wed May 31 20:39:48 2006 UTC vs.
Revision 1.21 by root, Wed Jul 19 22:20:07 2006 UTC

88 } else { 88 } else {
89 return "You don't have enough money with you."; 89 return "You don't have enough money with you.";
90 } 90 }
91 } elsif ($action eq "withdraw") { 91 } elsif ($action eq "withdraw") {
92 if ($pay <= $who->{bank_balance}) { 92 if ($pay <= $who->{bank_balance}) {
93 my $paid = $who->pay_player_arch (
94 $currency eq 'royalty' ? 'royalty' : $currency . "coin",
95 $amount
96 );
97 if ($paid) {
93 $who->{bank_balance} -= $pay; 98 $who->{bank_balance} -= $pay;
94 if ($currency eq "royalty") {
95 my $money = cf::object::new "royalty";
96 $money->set_property (1, 24, $amount);
97 $money->take ($who);
98 } else { 99 } else {
99 my $money = cf::object::new $currency . "coin"; 100 $amount = 0;
100 $money->set_property (1, 24, $amount);
101 $money->take ($who);
102 } 101 }
103 return "Withdrew $amount $currency"; 102 return "Withdrew $amount $currency";
104 } else { 103 } else {
105 return "You don't have that much money on your bank account."; 104 return "You don't have that much money on your bank account.";
106 } 105 }
141 } 140 }
142 return $exchange_rates."This may change a bit with the stock markets but don't expect it to be much."; 141 return $exchange_rates."This may change a bit with the stock markets but don't expect it to be much.";
143 } 142 }
144} 143}
145 144
146sub on_say { 145cf::register_script_function "bank::command" => sub {
147 my ($event, $ob, $who, $msg) = @_; 146 my ($who, $msg, $npc) = @_;
147
148 my ($cmd, $arguments) = split /\s+/, $msg, 2; 148 my ($cmd, $arguments) = split /\s+/, $msg, 2;
149 my ($amount, $currency) = split /\s+/, $arguments, 2; 149 my ($amount, $currency) = split /\s+/, $arguments, 2;
150 my $name = $ob->name;
151 my $service_charge = 5; 150 my $service_charge = 5;
152 my @units = sort keys %unit; 151 my @units = sort keys %unit;
153 my $units = join ", ", @units; 152 my $units = join ", ", @units;
154 my $fees = - ($service_charge / 100) + 1; 153 my $fees = - ($service_charge / 100) + 1;
155 154
161 } 160 }
162 161
163 if ($cmd eq "balance") { 162 if ($cmd eq "balance") {
164 if ($who->flag (cf::FLAG_WIZ)) { 163 if ($who->flag (cf::FLAG_WIZ)) {
165 if (my $player = cf::player::find $arguments) { 164 if (my $player = cf::player::find $arguments) {
166 $who->message ("$name says: ".balance ($player->ob, 1), cf::NDI_WHITE); 165 $who->reply ($npc, balance $player->ob, 1);
167 } 166 }
168 } else { 167 } else {
169 $who->message ("$name says: ".balance ($who, 0), cf::NDI_WHITE); 168 $who->reply ($npc, balance $who, 0);
170 } 169 }
171 170
172 } elsif ($cmd eq "balance" and !$arguments) { 171 } elsif ($cmd eq "balance" and !$arguments) {
173 $who->message ("$name says: Balance of whom?", cf::NDI_WHITE); 172 $who->reply ($npc, "Balance of whom?");
174 173
175 } elsif ($cmd eq "deposit" and $currency) { 174 } elsif ($cmd eq "deposit" and $currency) {
176 $who->message ("$name says: " . (transaction $who, "deposit", $amount, $currency), cf::NDI_WHITE); 175 $who->reply ($npc, transaction $who, "deposit", $amount, $currency);
177 $who->message ("$name says: " . (balance $who), cf::NDI_WHITE); 176 $who->reply ($npc, balance $who);
178 177
179 } elsif ($cmd eq "deposit" and $amount and $currency eq "") { 178 } elsif ($cmd eq "deposit" and $amount and $currency eq "") {
180 $who->message ("$name says: Deposit $amount of what: $units", cf::NDI_WHITE); 179 $who->reply ($npc, "deposit $amount of what: $units");
181 180
182 } elsif ($cmd eq "deposit" and $amount eq "" and $currency eq "") { 181 } elsif ($cmd eq "deposit" and $amount eq "" and $currency eq "") {
183 $who->message ("$name says: How much do you want to deposit?", cf::NDI_WHITE); 182 $who->reply ($npc, "How much do you want to deposit?");
184 183
185 } elsif ($cmd eq "withdraw" and $currency) { 184 } elsif ($cmd eq "withdraw" and $currency) {
186 $who->message ("$name says: " . (transaction $who, "withdraw", $amount, $currency), cf::NDI_WHITE); 185 $who->reply ($npc, transaction $who, "withdraw", $amount, $currency);
187 $who->message ("$name says: " . (balance $who), cf::NDI_WHITE); 186 $who->reply ($npc, balance $who);
188 187
189 } elsif ($cmd eq "withdraw" and $amount and $currency eq "") { 188 } elsif ($cmd eq "withdraw" and $amount and $currency eq "") {
190 $who->message ("$name says: Withdraw $amount of what: $units", cf::NDI_WHITE); 189 $who->reply ($npc, "Withdraw $amount of what: $units");
191 190
192 } elsif ($cmd eq "withdraw" and $amount eq "" and $currency eq "") { 191 } elsif ($cmd eq "withdraw" and $amount eq "" and $currency eq "") {
193 $who->message ("$name says: How much do you want to withdraw?", cf::NDI_WHITE); 192 $who->reply ($npc, "How much do you want to withdraw?");
194 193
195 } elsif ($cmd eq "exchange") { 194 } elsif ($cmd eq "exchange") {
196 $who->message ("$name says: This function is not yet implemented. Ask me again later.", cf::NDI_WHITE); 195 $who->reply ($npc, "This function is not yet implemented. Ask me again later.");
197 196
198 } elsif ($cmd eq "help" or $cmd eq "yes" and $arguments eq "") { 197 } elsif ($cmd eq "help" or $cmd eq "yes" and $arguments eq "") {
199 $who->message ("$name says: " . (help $arguments), cf::NDI_WHITE); 198 $who->reply ($npc, help $arguments);
200 199
201 } elsif ($cmd eq "help" or $cmd eq "yes" and $arguments ne "") { 200 } elsif ($cmd eq "help" or $cmd eq "yes" and $arguments ne "") {
202 $who->message ("$name says: " . (help), cf::NDI_WHITE); 201 $who->reply ($npc, help);
203 202
204 } else { 203 } else {
205 $who->message ("$name says: Do you need help?", cf::NDI_WHITE); 204 $who->reply ($npc, "Do you need help?");
206 } 205 }
207} 206}
208 207

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines