From 98b82a1de2f2d8cf3c3783b53f09228ecc31f7a1 Mon Sep 17 00:00:00 2001 From: partmedia Date: Sat, 3 Aug 2013 00:28:50 +0000 Subject: [PATCH] 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-b93c2d0d6712 --- python/IPO/banksay.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/python/IPO/banksay.py b/python/IPO/banksay.py index 4676ad2c3..b3c55fe0f 100644 --- a/python/IPO/banksay.py +++ b/python/IPO/banksay.py @@ -105,7 +105,12 @@ def strAmount(amount): for coinName in commonCoinNames[::-1]: value = CoinTypes[coinName] 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). return "%d %s" % (amount, "silver")