def __init__(self, stateManager, window): super(MatchCreationState, self).__init__(stateManager) self.window = window self.text = utility.TextRenderer(window) #get the teams from the json file self.teams = jsonloader.data["teams"] #list which will loop through all of the players and find valid teams to display self.validTeams = [] self.teams = [] #checks to see the valid teams from the collection for x in range(len(jsonloader.data["players"])): for y in range(len(jsonloader.data["teams"])): if jsonloader.data["players"][x]["team"] == jsonloader.data[ "teams"][y]["teamName"]: if jsonloader.data["teams"][y][ "teamName"] in self.validTeams: pass else: self.validTeams.append( jsonloader.data["players"][x]["team"]) #text input for user to enter team self.teamInput = utility.TextInput(self.window, 0, 0, 24) self.teamOne = "" self.teamTwo = "" self.offset = 0 self.teamOneButton = utility.TextButton(self.window, 400, 450, 24) self.teamTwoButton = utility.TextButton(self.window, 800, 450, 24) self.canChangeState = False self.askOvers = False self.overs = 0
def __init__(self, stateManager, window): super(TeamCreationState, self).__init__(stateManager) self.window = window self.stateManager = stateManager self.text = utility.TextRenderer(window) self.teamInput = utility.TextInput(window, 0, 0, 24) self.menuButton = utility.Button( pygame.image.load("resources/MenuButton.png").convert(), 520, 630)
def __init__(self, stateManager, window, playerInfo): super(PlayerStatisticsState, self).__init__(stateManager) self.window = window self.playerInfo = playerInfo self.playerStats = utility.TextRenderer(self.window) self.playerStatisticsButton = utility.Button( pygame.image.load("resources/BrowsePlayers.png").convert(), 340, 630) self.menuButton = utility.Button( pygame.image.load("resources/MenuButton.png").convert(), 668, 630)
def __init__(self, stateManager, window, winningTeam, wicketTakers, runScorers): self.stateManager = stateManager self.window = window self.winningTeam = winningTeam self.text = utility.TextRenderer(window) self.runScorers = runScorers self.wicketTakersDict = self.parseWicketTakers(wicketTakers) self.save(self.wicketTakersDict, runScorers) self.menuButton = utility.Button( pygame.image.load("resources/MenuButton.png").convert(), 520, 630)
def __init__(self, stateManager, window): super(PlayerCreationState, self).__init__(stateManager) self.window = window self.text = utility.TextRenderer(window) self.inputBox = utility.TextInput(window, 510, 200, 24) self.addPlayerButton = utility.Button( pygame.image.load("resources/AddPlayerButton.png").convert(), 608, 630) self.playerData = '' self.playerName = '' self.playerAge = ''
def __init__(self, stateManager, window): super(PlayerBrowseState, self).__init__(stateManager) self.window = window self.text = utility.TextRenderer(window) self.menuButton = utility.Button( pygame.image.load("resources/MenuButton.png").convert(), 520, 630) self.createPlayerButton = utility.Button( pygame.image.load("resources/AddPlayerButton.png").convert(), 1200, 630) self.offset = 10 self.fontSize = 24 self.playerInput = utility.TextInput(self.window, 0, 0, 24) self.playerString = ""
def __init__(self, stateManager, window): super(MenuState, self).__init__(stateManager) self.window = window self.util = utility.TextRenderer(window) self.util.setFontSize(16) self.playerBrowseButton = utility.Button( pygame.image.load("resources/BrowsePlayers.png").convert(), 548, 230) self.createMatchButton = utility.Button( pygame.image.load("resources/CreateMatchButton.png").convert(), 548, 350) self.createTeamButton = utility.Button( pygame.image.load("resources/CreateTeamButton.png").convert(), 548, 470) self.titleText = utility.Button( pygame.image.load("resources/TitleText.png").convert_alpha(), 478, 50)
def __init__(self, stateManager, window, teamOne, teamTwo, battingFirst, overs): super(MatchState, self).__init__(stateManager) #constructor & utility stuff self.stateManager = stateManager self.window = window self.text = utility.TextRenderer(window) buttonFiles = [ "run1.png", "run2.png", "run3.png", "run4.png", "run5.png", "run6.png", "wicket1.png", "wicket2.png", "dot.png", "wide.png", "AddPlayerButton.png" ] self.buttons = [] offset = 50 spacing = 110 for i in range(len(buttonFiles)): self.buttons.append( utility.Button( pygame.image.load("resources/" + buttonFiles[i]).convert(), offset + (i * spacing), 640)) #important variables self.scoreThisBall = 0 self.score = 0 self.innings = 1 self.target = 0 self.wicketTaken = 0 self.totalWickets = 0 self.balls = 0 self.totalBalls = 0 self.ballsThisOver = 0 self.overs = 0 self.maxOvers = overs self.facingBatsman = 0 self.nonFacingBatsman = 1 self.askWicketTaker = False self.offset = 0 #data to save at the end of the match - gets passed on to next state to save the stats for the match self.wicketTakers = [] self.runScorers = [] #team stuff self.teamOne = teamOne self.teamTwo = teamTwo self.battingFirst = battingFirst #holds teams involved self.teams = [] self.battingPlayerNames = [] self.bowlingPlayerNames = [] #add order of teams batting first in list and add players to list if self.teamOne == self.battingFirst: self.teams.append(self.teamOne) self.teams.append(self.teamTwo) self.addPlayers(self.teamOne, self.battingPlayerNames) self.addPlayers(self.teamTwo, self.bowlingPlayerNames) else: self.teams.append(self.teamTwo) self.teams.append(self.teamOne) self.addPlayers(self.teamTwo, self.battingPlayerNames) self.addPlayers(self.teamOne, self.bowlingPlayerNames) #holds current batters and their scores self.currentBatting = [[self.battingPlayerNames[0], 0], [self.battingPlayerNames[1], 0]] #next batter variable self.nextBatter = 2 #------FOR TESTING-------# printList(self.currentBatting) printList(self.bowlingPlayerNames) self.found = False print(self.teams[0])