Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
computer.py
Go to the documentation of this file.
1 import custom
2 import dialog_box
3 import VS
4 
5 def runBountyMenu(cp=-1):
6  if cp==-1:
7  cp=VS.getCurrentPlayer()
8  un = VS.getPlayerX(cp)
9  id=None
10 
11  def callback(dialog,result):
12  print 'id is: ',id
13  action,inputs = dialog_box.fromValues(result)
14  if action=='Cancel':
15  dialog.undraw()
16  custom.respond(['close'],None,id)
17  return False
18  if action=='OK':
19  dialog.undraw()
20  custom.respond(['close'],None,id)
21 
22  callsign = inputs['logged_in_users']
23  if callsign=='' or callsign=='OR, Type in a user:':
24  callsign = inputs['callsign']
25 
26  print 'I would now place a bounty on '+str(callsign)+' for '+str(float(inputs['credits']))+' credits.'
27  print 'User value IS: '+str(inputs['logged_in_users'])
28  server_lib.placeBounty(callsign,float(inputs['credits']))
29  return False
30  return True
31 
32  items=['width', 1.5,
33  'text', "Place a bounty on someone's head",
34 ]
35  items+=['height',0.05,
36  'row',
37  'textwidth','Credits:',0.3,
38  'textinput','credits',('%g'%max(1000.,un.getCredits()/100.)),
39  'endrow',
40  'height',0.05]
41  if VS.isserver():
42  import server
43  logged_in_users=server.getDirector().getCallsignList()
44  logged_in_users.append('OR, Type in a user:')
45  items+=['text','Select a player in this system:',
46  'list','logged_in_users',len(logged_in_users)]+logged_in_users
47  items+=['row',
48  'textwidth','Other Player:',0.3,
49  'textinput','callsign','',
50  'endrow']
51  else:
52  items+=['list','logged_in_users',15,'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o']
53  items += dialog_box.button_row(1.5,'OK','Cancel')
54  id = dialog_box.dialog(items,callback)
55 
56 
57 def runComputer(local,cmd,args,id,cp=-1):
58  #def a():
59  # print "A() called"
60  # def b(result):
61  # print result
62  # if not result:
63  # result='NOT'
64  # def c(result):
65  # dialog_box.alert(result)
66  # dialog_box.confirm("Test message 2 "+str(result),c)
67  # dialog_box.confirm("Test message",b,buttons=('A','B','C','D','E',"F",'G','H','I','J'))
68  #dialog_box.alert("TEST\nALERT\nBox",callback=a)
69 
70  def callback(dialog,result):
71  print 'id is: ',id
72  action,inputs = dialog_box.fromValues(result)
73  if action=='Test':
74  print 'test clicked!!!!'
75  if action=='Bounty Hunt':
76  print 'hunting bounty'
77  runBountyMenu(cp)
78  if action=='OK' or action=="Exit Menu" or action=="Cancel":
79  dialog.undraw()
80  custom.respond(['close'],None,id)
81  return False
82  return True
83 
84  items=['width', 1.0,
85  'text', 'Public Computer Menu',
86  'space', 0., .1,
87  'button', 'Test',
88  'button', 'View Score',
89  'button', 'Bounty Hunt',
90  'button', 'Exit Menu']
91  id = dialog_box.dialog(items,callback)
92  print 'id is set to: ',id
93 
94 custom.add("computer",runComputer)
95