This repository has been archived on 2026-05-18. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
dnd-utils/addcurrconv

70 lines
2.0 KiB
Plaintext
Raw Normal View History

2026-05-18 12:28:52 -04:00
#!/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 <new value of a silver piece in modern dollars>\""
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