Explicit snack support
[zanchey/dispense2.git] / sql-edition / servers / VendServer.py
index c93fda0..a253f28 100755 (executable)
@@ -105,8 +105,19 @@ def scroll_options(username, mk, welcome = False):
                (slot_num, price, slot_name) = c.split(' ', 2)
                if slot_name == 'dead': continue
                choices += '%s8-%s (%sc) '%(slot_num, slot_name, price)
                (slot_num, price, slot_name) = c.split(' ', 2)
                if slot_name == 'dead': continue
                choices += '%s8-%s (%sc) '%(slot_num, slot_name, price)
+
+#      we don't want to print snacks for now since it'll be too large
+#      and there's physical bits of paper in the machine anyway - matt
+#      try:
+#              snacks = get_snacks()
+#      except:
+#              snacks = {}
+#
+#      for slot, ( name, price ) in snacks.items():
+#              choices += '%s8-%s (%sc) ' % ( slot, name, price )
+
        choices += '55-DOOR '
        choices += '55-DOOR '
-       choices += 'OR A SNACK. '
+       choices += 'OR ANOTHER SNACK. '
        choices += '99 TO READ AGAIN. '
        choices += 'CHOICE?   '
        msg.append((choices, False, None))
        choices += '99 TO READ AGAIN. '
        choices += 'CHOICE?   '
        msg.append((choices, False, None))
@@ -396,8 +407,14 @@ def make_selection(v, vstatus):
                else:
                        v.display('GOT COKE!')
        else:
                else:
                        v.display('GOT COKE!')
        else:
-               v.display(vstatus.cur_selection+' - $1.00')
-               if ((os.system('su - "%s" -c "dispense snack"'%(vstatus.username)) >> 8) == 0):
+               # first see if it's a named slot
+               try:
+                       price, shortname, name = get_snack( vstatus.cur_selection )
+               except:
+                       price, shortname, name = get_snack( '--' )
+               dollarprice = "$%.2f" % ( price / 100.0 )
+               v.display(vstatus.cur_selection+' - %s'%dollarprice)
+               if ((os.system('su - "%s" -c "dispense %s"'%(vstatus.username, shortname)) >> 8) == 0):
                        v.vend(vstatus.cur_selection)
                        v.display('THANK YOU')
                else:
                        v.vend(vstatus.cur_selection)
                        v.display('THANK YOU')
                else:

UCC git Repository :: git.ucc.asn.au