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

Method runfuns

recipes/Python/334728_Cricket_GUI/recipe-334728.py:144–182  ·  view source on GitHub ↗

This is to get all functions to run

(self, w,y,x,numofovers, win, originalscore, orignoovers, wold, yold, dlruns, dlovers, dlwicks, battingfirst)

Source from the content-addressed store, hash-verified

142
143 #create a function to run all functions
144 def runfuns(self, w,y,x,numofovers, win, originalscore, orignoovers, wold, yold, dlruns, dlovers, dlwicks, battingfirst):
145 """This is to get all functions to run"""
146 numberofovers = orignoovers
147 #numberofovers = numofovers
148 #Cricket = Cricket()
149 numberofoversplayed = float(y)
150 y = self.numberofballs(y)
151 #y = numberofballs(y)
152 runsperball = self.scoreperball(x,y)
153 #see if they will survive numofovers overs
154 alloutearly = self.willsurvive(w,y,numofovers, wold, yold)
155 x = int(x)
156 numofovers = float(numofovers) -numberofoversplayed
157 if alloutearly == 0:
158 #take off the number of overs they have already had
159 a = self.ifnotout(runsperball,numofovers)
160 a = a + x
161 #a = a + originalscore
162 #a = str(a)
163 #resulttext = "Predicted score is", a + originalscore
164 resulttext = "Predicted score is "
165 resulttext = self.formatresults(resulttext, a, originalscore)
166 else:
167 b = self.ifallout(runsperball,alloutearly)
168 b = b + x
169 resulttext = "Predicted score is all out for "
170 resulttext = self.formatresults(resulttext, b, originalscore)
171 a = self.ifnotout(runsperball, numofovers)
172 resulttext2 = "\n" + " However if they do not get out, they will get "
173 #resulttext2 = self.formatresults(resulttext2, a, originalscore)
174 resulttext2 = self.formatresults(resulttext2, a, originalscore)
175 #resulttext2 = self.formatresults(resulttext2, b, originalscore)
176 resulttext = resulttext + resulttext2
177 if dlovers >20 and battingfirst != 'Not entered':
178 dresults = self.duckworthlewis(dlruns, dlovers, dlwicks, numofovers, battingfirst)
179 dtest = 'The duckworth lewis score in case of rain would be '
180 dtest = self.formatresults(dtest, dresults, 0)
181 resulttext = resulttext + "\n" + dtest
182 return resulttext
183
184 def savecurrentstate(self, x,y,w):
185 listcurrentstate = [x,y,w]

Callers 1

usedbeforeMethod · 0.95

Calls 7

numberofballsMethod · 0.95
scoreperballMethod · 0.95
willsurviveMethod · 0.95
ifnotoutMethod · 0.95
formatresultsMethod · 0.95
ifalloutMethod · 0.95
duckworthlewisMethod · 0.95

Tested by

no test coverage detected