1. '''
  2. Created on Oct 18, 2011
  3.  
  4. @author: Trevor Coleman
  5. '''
  6.  
  7. import android
  8. import urlparse
  9. from HTMLTemplates import *
  10.  
  11. droid = android.Android()
  12.  
  13. #set application root path
  14. urlPath = "file:///sdcard/sl4a/scripts/ExaltedCombatManager"
  15. filePath = "/sdcard/sl4a/scripts/ExaltedCombatManager"
  16.  
  17.  
  18. class Person():
  19.  
  20.  
  21.     def __init__(self):
  22.        
  23.        
  24.         #getNewPlayerInfo
  25.         #DISPLAY NEW PLAYER INFO PAGE
  26.        
  27.         path = urlPath + "/html/newPlayerScreen.html"
  28.        
  29.         droid.webViewShow(path)
  30.        
  31.         #GET INFORMATION FROM FORM
  32.         result = droid.eventWaitFor('saveNewPlayer').result
  33.         data = urlparse.parse_qs(result['data'][1:])
  34.         x = data["playerName"]
  35.         playerName =  x[0]
  36.    
  37.         x = data['playerTicks']
  38.         playerTicks = int(x[0])
  39.        
  40.         #ASSIGN INFO TO VARIABLES
  41.        
  42.         self.name = playerName
  43.         self.ticks = playerTicks
  44.         self.dv_penalty = 0
  45.        
  46.         toast = "Created player " + self.name
  47.        
  48.         droid.makeToast(toast)
  49.        
  50.     def turn(self):
  51.        
  52.         path = filePath + "/html/playerName.html"
  53.        
  54.         writeName = playerNameHTML % self.name
  55.        
  56.         f = open(path, 'w')
  57.         f.write(writeName)
  58.         f.close()
  59.        
  60.         path = urlPath + "/html/turnscreen.html"
  61.        
  62.         droid.webViewShow(path)
  63.        
  64.         result = droid.eventWaitFor('action').result
  65.        
  66.         action = result['data']
  67.                
  68.         if action == "aim":
  69.             self.aim()
  70.             print "AIM"
  71.            
  72.        
  73.         elif action == "guard":
  74.             self.guard()
  75.             print "GUARD"
  76.        
  77.         elif action == "dash":
  78.             self.dash()
  79.             print "DASH"
  80.            
  81.         elif action == "other":
  82.             self.ticks = int(droid.dialogGetInput("Speed of Action", "Please enter the speed of the action: ").result) - 1
  83.             dv_holder= int(droid.dialogGetInput("DV Penalty", "Please enter DV Penalty: ").result)
  84.             self.dv_penalty = -(int(dv_holder))
  85.             announce = self.name + " -- " + str(self.ticks) + " -- DV -" + str(self.dv_penalty)
  86.             droid.makeToast(announce)
  87.    
  88.     def aim(self):
  89.        
  90.         announce = self.name + " is aiming"
  91.        
  92.         droid.makeToast(announce)
  93.         self.ticks = 3
  94.         self.dv_penalty = -1
  95.    
  96.     def dash(self):
  97.         announce = self.name + " is dashing"
  98.         droid.makeToast(announce)
  99.         self.ticks = 3
  100.         self.dv_penalty = -2
  101.        
  102.     def guard(self):
  103.         announce = self.name + " is guarding"
  104.         droid.makeToast(announce)
  105.         self.ticks = 3
  106.         self.dv_penalty = 0
  107.        
  108.        
  109.    
  110.    
  111.  
  112.