#!/usr/bin/python silverval = 0.0 fpp = 0.0 fgp = 0.0 fsp = 0.0 fcp = 0.0 fdol = 0.0 def getInput(): return raw_input(">> ") print "AD&D Currency Converter - Converts between real and AD&D currency" print "Enter a monetary value followed by the currency (dollars, gp, sp, cp, pp)" print "Enter \"q\" by itself to quit." print "Enter \"s \"" print " to set the value of silver." while 1 : value = getInput() vlist = value.split(" ") if vlist[0].isdigit() : oldval = int(vlist[0]) if vlist[1].lower() == "gp": fgp = oldval fsp = fgp * 10 fcp = fsp * 10 fpp = fgp / 10 fdol = fsp * silverval elif vlist[1].lower() == "sp": fsp = oldval fgp = fsp / 10 fcp = fsp * 10 fpp = fgp / 10 fdol = fsp * silverval elif vlist[1].lower() == "cp": fcp = oldval fsp = fcp / 10 fgp = fsp / 10 fpp = fgp / 10 fdol = fsp * silverval elif vlist[1].lower() == "dollars": fsp = oldval / silverval fcp = fsp * 10 fgp = fsp / 10 fpp = fgp / 10 else: print "I didn't understand." continue print vlist[0], vlist[1], " converts to:" print "\t", fpp, " platinum (or)" print "\t", fgp, " gold pieces (or)" print "\t", fsp, " silver pieces (or)" print "\t", fcp, " copper pieces (or)" print "\t", fdol, " dollars" elif vlist[0].lower() == "q": break elif vlist[0].lower() == "s": if vlist[1].isdigit(): silverval = int(vlist[1]) print "silver value set to : ", silverval else : print "Please provide a numeric value as the second argument to the" print " \"s\" command." else: print "I didn't understand." continue