… | |
… | |
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 | |
31 | sub 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 | |
|
|
46 | # Calculates and returns how much money someone has starting with the |
31 | # Calculates and returns how much money someone has starting with the |
47 | # highest value currency going down. Think of it like having the date |
32 | # highest value currency going down. Think of it like having the date |
48 | # and time in the format of 2006-05-19 03:21:31 UTC instead of 1148001691 |
33 | # and time in the format of 2006-05-19 03:21:31 UTC instead of 1148001691 |
49 | # seconds since 1970-01-01 00:00:00 UTC. |
34 | # seconds since 1970-01-01 00:00:00 UTC. |
50 | sub balance { |
35 | sub balance { |
… | |
… | |
57 | } else { |
42 | } else { |
58 | return $who->name." has no balance." |
43 | return $who->name." has no balance." |
59 | unless $balance >= 1; |
44 | unless $balance >= 1; |
60 | } |
45 | } |
61 | |
46 | |
62 | my $account_info = amount_str ($balance); |
47 | my $account_info = cf::cost_string_from_value ($balance); |
63 | |
48 | |
64 | return "You have $account_info" |
49 | return "You have $account_info" |
65 | unless $is_wiz; |
50 | unless $is_wiz; |
66 | |
51 | |
67 | return $who->name." has $account_info"; |
52 | return $who->name." has $account_info"; |