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.21 by root, Wed Jul 19 22:20:07 2006 UTC vs.
Revision 1.22 by elmex, Mon Aug 14 07:11:10 2006 UTC

26 my ($value, $from_cur, $to_cur) = @_; 26 my ($value, $from_cur, $to_cur) = @_;
27 27
28 $value * $unit{$from_cur} / $unit{$to_cur} 28 $value * $unit{$from_cur} / $unit{$to_cur}
29} 29}
30 30
31sub amount_str {
32 my $amount = shift;
33
34 my $royalties = calc_exchange_rate $amount, "silver", "royalty";
35 my $platinum = calc_exchange_rate $royalties - (int $royalties), "royalty", "platina";
36 my $gold = calc_exchange_rate $platinum - (int $platinum), "platina", "gold";
37 my $silver = calc_exchange_rate $gold - (int $gold), "gold", "silver";
38
39 (int $royalties) . " royalties, "
40 . (int $platinum) . " platinum, "
41 . (int $gold) . " gold and about "
42 . (int $silver) ." silver coins.";
43
44}
45
31# Calculates and returns how much money someone has starting with the 46# Calculates and returns how much money someone has starting with the
32# highest value currency going down. Think of it like having the date 47# highest value currency going down. Think of it like having the date
33# and time in the format of 2006-05-19 03:21:31 UTC instead of 1148001691 48# and time in the format of 2006-05-19 03:21:31 UTC instead of 1148001691
34# seconds since 1970-01-01 00:00:00 UTC. 49# seconds since 1970-01-01 00:00:00 UTC.
35sub balance { 50sub balance {
42 } else { 57 } else {
43 return $who->name." has no balance." 58 return $who->name." has no balance."
44 unless $balance >= 1; 59 unless $balance >= 1;
45 } 60 }
46 61
47 my $royalties = calc_exchange_rate $balance, "silver", "royalty"; 62 my $account_info = amount_str ($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 63
58 return "You have $account_info" 64 return "You have $account_info"
59 unless $is_wiz; 65 unless $is_wiz;
60 66
61 return $who->name." has $account_info"; 67 return $who->name." has $account_info";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines