'''
Created on Oct 18, 2011
@author: Trevor Coleman
'''
import android
import urlparse
from HTMLTemplates import *
droid = android.Android()
#set application root path
urlPath = "file:///sdcard/sl4a/scripts/ExaltedCombatManager"
filePath = "/sdcard/sl4a/scripts/ExaltedCombatManager"
class Person():
def __init__(self):
#getNewPlayerInfo
#DISPLAY NEW PLAYER INFO PAGE
path = urlPath + "/html/newPlayerScreen.html"
droid.webViewShow(path)
#GET INFORMATION FROM FORM
result = droid.eventWaitFor('saveNewPlayer').result
data = urlparse.parse_qs(result['data'][1:])
x = data["playerName"]
playerName = x[0]
x = data['playerTicks']
playerTicks = int(x[0])
#ASSIGN INFO TO VARIABLES
self.name = playerName
self.ticks = playerTicks
self.dv_penalty = 0
toast = "Created player " + self.name
droid.makeToast(toast)
def turn(self):
path = filePath + "/html/playerName.html"
writeName = playerNameHTML % self.name
f = open(path, 'w')
f.write(writeName)
f.close()
path = urlPath + "/html/turnscreen.html"
droid.webViewShow(path)
result = droid.eventWaitFor('action').result
action = result['data']
if action == "aim":
self.aim()
print "AIM"
elif action == "guard":
self.guard()
print "GUARD"
elif action == "dash":
self.dash()
print "DASH"
elif action == "other":
self.ticks = int(droid.dialogGetInput("Speed of Action", "Please enter the speed of the action: ").result) - 1
dv_holder= int(droid.dialogGetInput("DV Penalty", "Please enter DV Penalty: ").result)
self.dv_penalty = -(int(dv_holder))
announce = self.name + " -- " + str(self.ticks) + " -- DV -" + str(self.dv_penalty)
droid.makeToast(announce)
def aim(self):
announce = self.name + " is aiming"
droid.makeToast(announce)
self.ticks = 3
self.dv_penalty = -1
def dash(self):
announce = self.name + " is dashing"
droid.makeToast(announce)
self.ticks = 3
self.dv_penalty = -2
def guard(self):
announce = self.name + " is guarding"
droid.makeToast(announce)
self.ticks = 3
self.dv_penalty = 0