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.16 by pippijn, Wed May 24 01:40:21 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";
87 return "$amount $currency received."; 78 return "$amount $currency received.";
88 } else { 79 } else {
89 return "You don't have enough money with you."; 80 return "You don't have enough money with you.";
90 } 81 }
91 } elsif ($action eq "withdraw") { 82 } elsif ($action eq "withdraw") {
92 if ($who->{bank_balance} - $pay > 0) { 83 if ($pay <= $who->{bank_balance}) {
84 my $paid = $who->pay_player_arch (
85 $currency eq 'royalty' ? 'royalty' : $currency . "coin",
86 $amount
87 );
88 if ($paid) {
93 $who->{bank_balance} -= $pay; 89 $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->insert_in_ob ($who);
98 } else { 90 } else {
99 my $money = cf::object::new $currency . "coin"; 91 $amount = 0;
100 $money->set_property (1, 24, $amount);
101 $money->insert_in_ob ($who);
102 } 92 }
103 return "Withdrew $amount $currency"; 93 return "Withdrew $amount $currency";
104 } else { 94 } else {
105 return "You don't have that much money on your bank account."; 95 return "You don't have that much money on your bank account.";
106 } 96 }
141 } 131 }
142 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.";
143 } 133 }
144} 134}
145 135
146sub on_say { 136cf::register_script_function "bank::command" => sub {
147 my ($event, $ob, $who, $msg) = @_; 137 my ($who, $msg, $npc) = @_;
138
148 my ($cmd, $arguments) = split /\s+/, $msg, 2; 139 my ($cmd, $arguments) = split /\s+/, $msg, 2;
149 my ($amount, $currency) = split /\s+/, $arguments, 2; 140 my ($amount, $currency) = split /\s+/, $arguments, 2;
150 my $name = $ob->name;
151 my $service_charge = 5; 141 my $service_charge = 5;
152 my @units = sort keys %unit; 142 my @units = sort keys %unit;
153 my $units = join ", ", @units; 143 my $units = join ", ", @units;
154 my $fees = - ($service_charge / 100) + 1; 144 my $fees = - ($service_charge / 100) + 1;
155 145
161 } 151 }
162 152
163 if ($cmd eq "balance") { 153 if ($cmd eq "balance") {
164 if ($who->flag (cf::FLAG_WIZ)) { 154 if ($who->flag (cf::FLAG_WIZ)) {
165 if (my $player = cf::player::find $arguments) { 155 if (my $player = cf::player::find $arguments) {
166 $who->message ("$name says: ".balance ($player->ob, 1), cf::NDI_WHITE); 156 $who->reply ($npc, balance $player->ob, 1);
167 } 157 }
168 } else { 158 } else {
169 $who->message ("$name says: ".balance ($who, 0), cf::NDI_WHITE); 159 $who->reply ($npc, balance $who, 0);
170 } 160 }
171 161
172 } elsif ($cmd eq "balance" and !$arguments) { 162 } elsif ($cmd eq "balance" and !$arguments) {
173 $who->message ("$name says: Balance of whom?", cf::NDI_WHITE); 163 $who->reply ($npc, "Balance of whom?");
174 164
175 } elsif ($cmd eq "deposit" and $currency) { 165 } elsif ($cmd eq "deposit" and $currency) {
176 $who->message ("$name says: " . (transaction $who, "deposit", $amount, $currency), cf::NDI_WHITE); 166 $who->reply ($npc, transaction $who, "deposit", $amount, $currency);
177 $who->message ("$name says: " . (balance $who), cf::NDI_WHITE); 167 $who->reply ($npc, balance $who);
178 168
179 } elsif ($cmd eq "deposit" and $amount and $currency eq "") { 169 } elsif ($cmd eq "deposit" and $amount and $currency eq "") {
180 $who->message ("$name says: Deposit $amount of what: $units", cf::NDI_WHITE); 170 $who->reply ($npc, "deposit $amount of what: $units");
181 171
182 } elsif ($cmd eq "deposit" and $amount eq "" and $currency eq "") { 172 } 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); 173 $who->reply ($npc, "How much do you want to deposit?");
184 174
185 } elsif ($cmd eq "withdraw" and $currency) { 175 } elsif ($cmd eq "withdraw" and $currency) {
186 $who->message ("$name says: " . (transaction $who, "withdraw", $amount, $currency), cf::NDI_WHITE); 176 $who->reply ($npc, transaction $who, "withdraw", $amount, $currency);
187 $who->message ("$name says: " . (balance $who), cf::NDI_WHITE); 177 $who->reply ($npc, balance $who);
188 178
189 } elsif ($cmd eq "withdraw" and $amount and $currency eq "") { 179 } elsif ($cmd eq "withdraw" and $amount and $currency eq "") {
190 $who->message ("$name says: Withdraw $amount of what: $units", cf::NDI_WHITE); 180 $who->reply ($npc, "Withdraw $amount of what: $units");
191 181
192 } elsif ($cmd eq "withdraw" and $amount eq "" and $currency eq "") { 182 } 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); 183 $who->reply ($npc, "How much do you want to withdraw?");
194 184
195 } elsif ($cmd eq "exchange") { 185 } elsif ($cmd eq "exchange") {
196 $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.");
197 187
198 } elsif ($cmd eq "help" or $cmd eq "yes" and $arguments eq "") { 188 } elsif ($cmd eq "help" or $cmd eq "yes" and $arguments eq "") {
199 $who->message ("$name says: " . (help $arguments), cf::NDI_WHITE); 189 $who->reply ($npc, help $arguments);
200 190
201 } elsif ($cmd eq "help" or $cmd eq "yes" and $arguments ne "") { 191 } elsif ($cmd eq "help" or $cmd eq "yes" and $arguments ne "") {
202 $who->message ("$name says: " . (help), cf::NDI_WHITE); 192 $who->reply ($npc, help);
203 193
204 } else { 194 } else {
205 $who->message ("$name says: Do you need help?", cf::NDI_WHITE); 195 $who->reply ($npc, "Do you need help?");
206 } 196 }
207} 197}
208 198

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines