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,9 +202,10 @@ class Menu():
prompt += ("[%s] " % default) prompt += ("[%s] " % default)
while True: while True:
result = self.input_str(prompt) result = self.input_str(prompt)
if result = '':
if default is not None: if default is not None:
return default return default
elif null_allowed and result == '': elif null_allowed
return False return False
try: try:
value = int(result) value = int(result)
@ -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