Minor UI tweaks
[zanchey/dispense2.git] / sql-edition / servers / VendServer.py
index 861f7c9..7021622 100755 (executable)
@@ -183,7 +183,7 @@ class Idler:
 
 def cookie(v):
        seed(time())
-       messages = ['  WASSUP! ', 'PINK FISH ', ' SECRETS ']
+       messages = ['  WASSUP! ', 'PINK FISH ', ' SECRETS ', '  ESKIMO  ', ' FORTUNES ', 'MORE MONEY']
        choice = int(random()*len(messages))
        msg = messages[choice]
        left = range(len(msg))
@@ -200,7 +200,7 @@ def cookie(v):
                                else:
                                        s += chr(int(random()*26)+ord('A'))
                                reveal += 1
-                               reveal %= 53
+                               reveal %= 17
                        else:
                                s += msg[i]
                v.display(s)
@@ -295,7 +295,7 @@ if __name__ == '__main__':
 
                if time_to_autologout != None:
                        time_left = time_to_autologout - time()
-                       if time_left < 5 and (last_timeout_refresh is None or last_timeout_refresh > time_left):
+                       if time_left < 6 and (last_timeout_refresh is None or last_timeout_refresh > time_left):
                                mk.set_message('LOGOUT: '+str(int(time_left)))
                                last_timeout_refresh = int(time_left)
                                cur_selection = ''
@@ -324,6 +324,7 @@ if __name__ == '__main__':
                        e = v.next_event(0.1)
                        if e == None:
                                continue
+               time_to_idle = None
                (event, params) = e
                print e
                if event == DOOR:
@@ -348,10 +349,13 @@ if __name__ == '__main__':
                                if len(cur_user) == 5:
                                        uid = int(cur_user)
                                        if not has_good_pin(uid):
+                                               #mk.set_messages(
+                                                       #[(center('INVALID'), False, 0.7),
+                                                        #(center('PIN'), False, 0.7),
+                                                        #(center('SETUP'), False, 1.0),
+                                                        #(GREETING, False, None)])
                                                mk.set_messages(
-                                                       [(center('INVALID'), False, 0.7),
-                                                        (center('PIN'), False, 0.7),
-                                                        (center('SETUP'), False, 1.0),
+                                                       [(' '*10+'INVALID PIN SETUP'+' '*10, False, 3),
                                                         (GREETING, False, None)])
                                                cur_user = ''
                                                cur_pin = ''
@@ -391,9 +395,9 @@ if __name__ == '__main__':
                                        cur_pin = ''
                                        cur_user = ''
                                        cur_selection = ''
-                                       v.display('BYE!')
-                                       sleep(0.5)
-                                       mk.set_message(GREETING)
+                                       mk.set_messages(
+                                               [(center('BYE!'), False, 1.5),
+                                                (GREETING, False, None)])
                                        continue
                                cur_selection += chr(key + ord('0'))
                                mk.set_message('SELECT: '+cur_selection)
@@ -409,8 +413,13 @@ if __name__ == '__main__':
                                        #make_selection(cur_selection)
                                        # XXX this should move somewhere else:
                                        if cur_selection == '55':
-                                               v.display('GOT DOOR?')
-                                               os.system('su - "%s" -c "dispense door"'%username)
+                                               mk.set_message('OPENSESAME')
+                                               ret = os.system('su - "%s" -c "dispense door"'%username)
+                                               if ret == 0:
+                                                       mk.set_message(center('DOOR OPEN'))
+                                               else:
+                                                       mk.set_message(center('BAD DOOR'))
+                                               sleep(1)
                                        elif cur_selection == '91':
                                                cookie(v)
                                        elif cur_selection == '99':
@@ -427,4 +436,4 @@ if __name__ == '__main__':
                                        v.display('THANK YOU')
                                        sleep(0.5)
                                        cur_selection = ''
-                                       time_to_autologout = time() + 10
+                                       time_to_autologout = time() + 8

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