… | |
… | |
90 | sub help { |
90 | sub help { |
91 | my ($command) = @_; |
91 | my ($command) = @_; |
92 | |
92 | |
93 | if ($command eq "") { |
93 | if ($command eq "") { |
94 | return "You can: |
94 | return "You can: |
|
|
95 | |
95 | deposit <amount> <currency> |
96 | deposit <amount> <currency> |
96 | withdraw <amount> <currency> |
97 | withdraw <amount> <currency> |
97 | balance |
98 | balance |
98 | help rates |
99 | help rates |
99 | help <deposit|withdraw|balance>"; |
100 | help <deposit|withdraw|balance>"; |
… | |
… | |
105 | withdraw <amount> <currency>"; |
106 | withdraw <amount> <currency>"; |
106 | } elsif ($command eq "balance") { |
107 | } elsif ($command eq "balance") { |
107 | return "I can tell you how much money you are saving in our bank, just ask me about your balance."; |
108 | return "I can tell you how much money you are saving in our bank, just ask me about your balance."; |
108 | } elsif ($command eq "rates") { |
109 | } elsif ($command eq "rates") { |
109 | my @coins = cf::coin_archetypes; |
110 | my @coins = cf::coin_archetypes; |
110 | my $exchange_rates = "Here is a list of exchange rates:\n\n\n"; |
111 | my $exchange_rates = "Here is a list of exchange rates:\n\n"; |
111 | |
112 | |
112 | for my $f (0 .. $#coins) { |
113 | for my $f (0 .. $#coins) { |
113 | for my $t ($f + 1 .. $#coins) { |
114 | for my $t ($f + 1 .. $#coins) { |
114 | $exchange_rates .= |
115 | $exchange_rates .= |
115 | sprintf "One %s is %d %s.\n\n", |
116 | sprintf " One %s is %d %s.\n", |
116 | $coins[$f]->name, |
117 | $coins[$f]->name, |
117 | (calc_exchange_rate 1, $coins[$f], $coins[$t]), |
118 | (calc_exchange_rate 1, $coins[$f], $coins[$t]), |
118 | $coins[$t]->name_pl; |
119 | $coins[$t]->name_pl; |
119 | } |
120 | } |
120 | } |
121 | } |
121 | |
122 | |
122 | return "$exchange_rates\n\nThis may change a bit with the stock markets but don't expect it to be much."; |
123 | return "$exchange_rates\nThis may change a bit with the stock markets but don't expect it to be much."; |
123 | } |
124 | } |
124 | } |
125 | } |
125 | |
126 | |
126 | cf::register_script_function "bank::command" => sub { |
127 | cf::register_script_function "bank::command" => sub { |
127 | my ($who, $msg, $npc) = @_; |
128 | my ($who, $msg, $npc) = @_; |
… | |
… | |
133 | |
134 | |
134 | if ($cmd eq "balance") { |
135 | if ($cmd eq "balance") { |
135 | if ($who->flag (cf::FLAG_WIZ) && $arguments =~ /\S/) { |
136 | if ($who->flag (cf::FLAG_WIZ) && $arguments =~ /\S/) { |
136 | cf::async { |
137 | cf::async { |
137 | if (my $player = cf::player::find $arguments) { |
138 | if (my $player = cf::player::find $arguments) { |
138 | $who->contr->send_msg ( |
139 | $who->reply ($npc, |
139 | $ext::chat::SAY_CHANNEL, "Nancy says: " . balance ($player->ob, 1), |
140 | "Nancy says: " . balance ($player->ob, 1), |
140 | cf::NDI_BROWN | cf::NDI_REPLY |
141 | cf::NDI_BROWN | cf::NDI_REPLY |
141 | ) if $who->contr; |
142 | ); |
142 | } |
143 | } |
143 | }; |
144 | }; |
144 | } else { |
145 | } else { |
145 | $who->reply ($npc, balance ($who, 0)); |
146 | $who->reply ($npc, balance ($who, 0)); |
146 | } |
147 | } |