Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
difficulty Class Reference

Public Member Functions

def SetDiff
 
def __init__
 
def usingDifficulty
 
def getPlayerDifficulty
 
def Execute
 

Data Fields

 diff
 
 creds
 
 credsToMax
 
 i
 

Detailed Description

Definition at line 23 of file difficulty.py.

Constructor & Destructor Documentation

def __init__ (   self,
  credsMax 
)

Definition at line 28 of file difficulty.py.

28 
29  def __init__(self,credsMax):
30 # print "init diff"
31  global unbounddiff
32  self.diff=[]
33  unbounddiff=[]
34  self.creds=[]
35  self.credsToMax=credsMax
36 # print "unlogical start"
37  un=VS.getPlayerX(0)
38 # print "unlogical end"
39  self.i=0
40  while (not un.isNull()):
41  newunbounddiff=0
42  newdiff=0
43 # print "get save data length"
44 # (open ("/tmp/vswroteship","w")).close()
45  diffsavelen=Director.getSaveDataLength(self.i,_key)
46  if (diffsavelen):
47 # (open ("/tmp/vsgotdata","w")).close()
48 # print "get save dat"
49  newdiff=Director.getSaveData(self.i,_key,0)
50  if (diffsavelen>1):
51  newunbounddiff=Director.getSaveData(self.i,_key,1)
52  else:
53  newunbounddiff=newdiff
54  Director.pushSaveData(self.i,_key,newunbounddiff)
55 # print "get save end"
56  else:
57 # (open ("/tmp/vsmakedata","w")).close()
58 # print "get difficulty start"
59  newdiff=VS.GetDifficulty()
60 # print "get diff done"
61  Director.pushSaveData(self.i,_key,newdiff)
62  newunbounddiff=newdiff
63  Director.pushSaveData(self.i,_key,newunbounddiff)
64 # print "done director"
65 # (open ("/tmp/vsdonedir","w")).close()
66 # (open ("/tmp/vssetdifficulty","w")).close()
67  self.diff.append(newdiff)
68  unbounddiff.append(newunbounddiff)
69 # print "set diff start"
70  SetDiff(newdiff)
71 # print "set diff end"
72  self.creds+=[un.getCredits()]
73  self.i+=1
74 # print "save unit"
75  un=VS.getPlayerX(self.i)
76 # print "done init diff"
77 # (open ("/tmp/vsdoneinitdiff","w")).close()
# print "done init diff FINAL"

Member Function Documentation

def Execute (   self)

Definition at line 84 of file difficulty.py.

References difficulty.creds, HaveCredits.creds, AddCredits.creds, RemoveCredits.creds, SetCredits.creds, difficulty.credsToMax, difficulty.getPlayerDifficulty(), difficulty.i, _ThreadSafeCounter.i, and difficulty.SetDiff().

84 
85  def Execute(self):
86  global unbounddiff
87  if (self.i>=len(self.creds)):
88  self.i=0
89  else:
90  un=VS.getPlayerX(self.i)
91  if (un):
92  newcreds=un.getCredits()
93  if (self.creds[self.i]!=newcreds):
94  if (self.creds[self.i]<newcreds):
95  delta=((newcreds-self.creds[self.i])/self.credsToMax)
96  newdiff=self.getPlayerDifficulty(self.i)+delta
97  if (newdiff>.999):
98  newdiff=.999
99  #newdiff=1
100  Director.putSaveData(self.i,_key,0,newdiff)
101  SetDiff(newdiff)
102  unbounddiff[self.i]+=delta
103  Director.putSaveData(self.i,_key,1,unbounddiff[self.i])
104  self.creds[self.i]=newcreds
105  self.i+=1
def getPlayerDifficulty (   self,
  playa 
)

Definition at line 81 of file difficulty.py.

References difficulty.diff.

81 
82  def getPlayerDifficulty (self,playa):
83  return self.diff[playa]
def SetDiff (   self,
  diff 
)

Definition at line 24 of file difficulty.py.

24 
25  def SetDiff(self,diff):
26  if (diff>VS.GetDifficulty()):
27  VS.SetDifficulty(diff)
def usingDifficulty (   self)

Definition at line 78 of file difficulty.py.

78 
79  def usingDifficulty (self):
80  return (VS.GetDifficulty()!=1.0)

Field Documentation

creds

Definition at line 33 of file difficulty.py.

credsToMax

Definition at line 34 of file difficulty.py.

diff

Definition at line 31 of file difficulty.py.

i

Definition at line 38 of file difficulty.py.


The documentation for this class was generated from the following file: