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

Comparing deliantra/server/ext/bank.ext (file contents):
Revision 1.5 by root, Thu Apr 10 15:35:16 2008 UTC vs.
Revision 1.8 by elmex, Thu Aug 20 18:12:13 2009 UTC

55 $currency = $amount > 1 ? $coin->name_pl : $coin->name; 55 $currency = $amount > 1 ? $coin->name_pl : $coin->name;
56 56
57 my $pay = $amount * $coin->value; 57 my $pay = $amount * $coin->value;
58 58
59 # First check for possible overflow and user stupidity 59 # First check for possible overflow and user stupidity
60 if ($amount > 2**30) { 60 if ($pay > 2**30) {
61 return "Sorry, we do not handle that kind of money for one $action."; 61 return "Sorry, we do not handle that kind of money for one $action.";
62 } elsif ($amount == 0) { 62 } elsif ($pay == 0) {
63 return "You can not $action nothing."; 63 return "You can not $action nothing.";
64 } elsif ($amount < 0) { 64 } elsif ($pay < 0) {
65 return "You can not $action negative values."; 65 return "You can not $action negative values.";
66 } 66 }
67 67
68 # Here we handle the transactions 68 # Here we handle the transactions
69 if ($action eq "deposit") { 69 if ($action eq "deposit") {
90sub help { 90sub 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
126cf::register_script_function "bank::command" => sub { 127cf::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 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines