Do not display the decimal point if it is not necessary.
git-svn-id: svn://svn.code.sf.net/p/crossfire/code/maps/trunk@18875 282e977c-c81d-0410-88c4-b93c2d0d6712master
parent
84764f325b
commit
98b82a1de2
|
@ -105,7 +105,12 @@ def strAmount(amount):
|
||||||
for coinName in commonCoinNames[::-1]:
|
for coinName in commonCoinNames[::-1]:
|
||||||
value = CoinTypes[coinName]
|
value = CoinTypes[coinName]
|
||||||
if amount >= value:
|
if amount >= value:
|
||||||
return "%.3f %s" % (float(amount) / value, coinName.lower())
|
# Do not display the decimal point if it is not necessary.
|
||||||
|
realValue = float(amount) / value
|
||||||
|
if realValue != int(realValue):
|
||||||
|
return "%.3f %s" % (realValue, coinName.lower())
|
||||||
|
else:
|
||||||
|
return "%d %s" % (int(realValue), coinName.lower())
|
||||||
|
|
||||||
# If no suitable coin was found, use the base value (silver).
|
# If no suitable coin was found, use the base value (silver).
|
||||||
return "%d %s" % (amount, "silver")
|
return "%d %s" % (amount, "silver")
|
||||||
|
|
Loading…
Reference in New Issue