… | |
… | |
70 | |
70 | |
71 | return "You can not $action fractions." |
71 | return "You can not $action fractions." |
72 | unless $amount =~ /^\d+$/; |
72 | unless $amount =~ /^\d+$/; |
73 | |
73 | |
74 | # First check for possible overflow and user stupidity |
74 | # First check for possible overflow and user stupidity |
75 | if ($amount > 100000) { |
75 | if ($amount > 10**12) { |
76 | return "Sorry, we do not handle more than 100000 units for one ".$action."."; |
76 | return "Sorry, we do not handle more than 1,000,000,000,000 units for one ".$action."."; |
77 | } elsif ($amount == 0) { |
77 | } elsif ($amount == 0) { |
78 | return "You can not ".$action." nothing."; |
78 | return "You can not ".$action." nothing."; |
79 | } elsif ($amount < 0) { |
79 | } elsif ($amount < 0) { |
80 | return "You can not ".$action." negative values."; |
80 | return "You can not ".$action." negative values."; |
81 | } |
81 | } |
… | |
… | |
122 | return "To get the money you stored in our system back, just say: |
122 | return "To get the money you stored in our system back, just say: |
123 | withdraw <amount> <currency>"; |
123 | withdraw <amount> <currency>"; |
124 | } elsif ($command eq "balance") { |
124 | } elsif ($command eq "balance") { |
125 | return "I can tell you how much money you are saving in our bank, just ask me about your balance."; |
125 | return "I can tell you how much money you are saving in our bank, just ask me about your balance."; |
126 | } elsif ($command eq "exchange") { |
126 | } elsif ($command eq "exchange") { |
127 | return "We exchange between imperial notes and platinum coins at a very low price. To change from platinum to imperials, say: |
127 | return "We exchange between imperial notes and platina coins at a very low price. To change from platina to imperials, say: |
128 | exchange <amount> platina\nTo change from imperials to platinum, say: |
128 | exchange <amount> platina\nTo change from imperials to platina, say: |
129 | exchange <amount> imperial\nWe currently only exchange between these two currencies. If you want to know more about exchange rates, ask me: |
129 | exchange <amount> imperial\nWe currently only exchange between these two currencies. If you want to know more about exchange rates, ask me: |
130 | help exchange rates\nThanks for using our bank."; |
130 | help exchange rates\nThanks for using our bank."; |
131 | } elsif ($command eq "exchange rates") { |
131 | } elsif ($command eq "exchange rates") { |
132 | my @units = sort { $unit{$b} <=> $unit{$a} } keys %unit; |
132 | my @units = sort { $unit{$b} <=> $unit{$a} } keys %unit; |
133 | my $exchange_rates = "Here is a list of exchange rates:\n"; |
133 | my $exchange_rates = "Here is a list of exchange rates:\n"; |
… | |
… | |
148 | my $name = $ob->name; |
148 | my $name = $ob->name; |
149 | my $service_charge = 5; |
149 | my $service_charge = 5; |
150 | my @units = sort keys %unit; |
150 | my @units = sort keys %unit; |
151 | my $units = join ", ", @units; |
151 | my $units = join ", ", @units; |
152 | my $fees = - ($service_charge / 100) + 1; |
152 | my $fees = - ($service_charge / 100) + 1; |
|
|
153 | if ($currency eq "platinum") { |
|
|
154 | $currency = "platina"; |
|
|
155 | } |
|
|
156 | |
153 | |
157 | |
154 | if ($cmd eq "balance") { |
158 | if ($cmd eq "balance") { |
155 | if ($who->flag (cf::FLAG_WIZ)) { |
159 | if ($who->flag (cf::FLAG_WIZ)) { |
156 | if (my $player = cf::player::find $arguments) { |
160 | if (my $player = cf::player::find $arguments) { |
157 | $who->message ("$name says: ".balance ($player->ob, 1), cf::NDI_WHITE); |
161 | $who->message ("$name says: ".balance ($player->ob, 1), cf::NDI_WHITE); |
… | |
… | |
181 | $who->message ("$name says: Withdraw $amount of what: $units", cf::NDI_WHITE); |
185 | $who->message ("$name says: Withdraw $amount of what: $units", cf::NDI_WHITE); |
182 | |
186 | |
183 | } elsif ($cmd eq "withdraw" and $amount eq "" and $currency eq "") { |
187 | } elsif ($cmd eq "withdraw" and $amount eq "" and $currency eq "") { |
184 | $who->message ("$name says: How much do you want to withdraw?", cf::NDI_WHITE); |
188 | $who->message ("$name says: How much do you want to withdraw?", cf::NDI_WHITE); |
185 | |
189 | |
|
|
190 | } elsif ($cmd eq "exchange") { |
|
|
191 | $who->message ("$name says: This function is not yet implemented. Ask me again later.", cf::NDI_WHITE); |
|
|
192 | |
186 | } elsif ($cmd eq "help" or $cmd eq "yes" and $arguments eq "") { |
193 | } elsif ($cmd eq "help" or $cmd eq "yes" and $arguments eq "") { |
187 | $who->message ("$name says: " . (help $arguments), cf::NDI_WHITE); |
194 | $who->message ("$name says: " . (help $arguments), cf::NDI_WHITE); |
188 | |
195 | |
189 | } elsif ($cmd eq "help" or $cmd eq "yes" and $arguments ne "") { |
196 | } elsif ($cmd eq "help" or $cmd eq "yes" and $arguments ne "") { |
190 | $who->message ("$name says: " . (help), cf::NDI_WHITE); |
197 | $who->message ("$name says: " . (help), cf::NDI_WHITE); |