This commit is contained in:
Vegard Aksland Sjonfjell 2013-02-11 19:22:44 +00:00
parent ffc9a647cc
commit 9d138f68b4
1 changed files with 7 additions and 6 deletions

View File

@ -202,10 +202,11 @@ class Menu():
prompt += ("[%s] " % default) prompt += ("[%s] " % default)
while True: while True:
result = self.input_str(prompt) result = self.input_str(prompt)
if default is not None: if result = '':
return default if default is not None:
elif null_allowed and result == '': return default
return False elif null_allowed
return False
try: try:
value = int(result) value = int(result)
if ((allowed_range[0] and value < allowed_range[0]) or if ((allowed_range[0] and value < allowed_range[0]) or
@ -1182,7 +1183,7 @@ class AddStockMenu(Menu):
Enter what you have bought for PVVVV here, along with your user name and how Enter what you have bought for PVVVV here, along with your user name and how
much money you're due in credits for the purchase when prompted. much money you're due in credits for the purchase when prompted.
''' '''
self.price = None self.price = 0
def _execute(self): def _execute(self):
questions = { questions = {
@ -1208,7 +1209,7 @@ much money you're due in credits for the purchase when prompted.
if isinstance(thing, Product): if isinstance(thing, Product):
self.printc("%d of %s registered" % (amount, thing.name)) self.printc("%d of %s registered" % (amount, thing.name))
self.price = self.input_int('Price a piece? ', (1,100000), default=thing.price) * amount self.price += self.input_int('Price a piece? ', (1,100000), default=thing.price) * amount
# once we get something in the # once we get something in the
# purchase, we want to protect the # purchase, we want to protect the