MCPcopy Create free account
hub / github.com/ActiveState/code / usedbefore

Method usedbefore

recipes/Python/334728_Cricket_GUI/recipe-334728.py:85–114  ·  view source on GitHub ↗
(self, w,y,x,numofovers, win,used_before, battingfirst)

Source from the content-addressed store, hash-verified

83
84
85 def usedbefore(self, w,y,x,numofovers, win,used_before, battingfirst):
86 #this function a) is the function called by the GUI and b) is the function that decides if information from last time
87 #this program was called should be used to get a more accurate picture
88 x = int(x)
89 dlruns = x
90 dlovers = int(y)
91 dlwicks = w
92 wold = 0
93 yold = 0
94 originalscore = 0
95 orignoovers = 0
96 if used_before == 'N':
97 #it has not been used before so just use the info entered
98 results = self.runfuns(w,y,x,numofovers, win, originalscore, orignoovers, wold, yold, dlruns, dlovers, dlwicks, battingfirst )
99 else:
100 #x score, y number of overs, w number of wickets
101 originalscore, yold, wold = self.openlasttime()
102 #if it is more than 5 overs and the score has increased or stayed the same use the values from last time
103 if int(y) - int(yold) > 5 and int(wold) >= int(w) and x >= int(originalscore) :
104 #code to get the results from last time
105 results = self.runfuns(w,y,x,numofovers, win, originalscore, orignoovers, wold, yold, dlruns, dlovers, dlwicks, battingfirst)
106 #it goes wrong on the line above
107 else:
108 originalscore = 0
109 yold = 0
110 wold = 0
111 results = self.runfuns(w,y,x,numofovers, win, originalscore, orignoovers, wold, yold, dlruns, dlovers, dlwicks, battingfirst)
112 #we want to save the current state
113 self.savecurrentstate(x,y,w)
114 return results
115
116
117

Callers 1

getresultsMethod · 0.95

Calls 3

runfunsMethod · 0.95
openlasttimeMethod · 0.95
savecurrentstateMethod · 0.95

Tested by

no test coverage detected