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): 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, screenSize, screen, soundnames): self.screen = screen self.screenSize = screenSize self.buttons = [] for i in range(5): count = 0 count += i * 3 for j in range(3): count += 1 self.buttons.append( utility.Button( self.screen, (i * self.screenSize[0] / 5, j * screenSize[1] / 5, self.screenSize[0] / 5, self.screenSize[1] / 5), (random.randint(0, 255), random.randint( 0, 255), random.randint(0, 255)), (random.randint(0, 255), random.randint(0, 255), random.randint( 0, 255)), #(0+255/(i+2),20,20),(0+255/(j+2),135,0), utility.Text(self.screen, 0, 0, soundnames[count - 1], pygame.font.SysFont("comicsansms", 15), (255, 255, 255)))) self.sliders = [ utility.Slider(screen, screenSize, (screenSize[0] / 2, screenSize[1] * 4 / 6)), utility.Slider(screen, screenSize, (screenSize[0] / 2, screenSize[1] * 5 / 6)) ]
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): 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, 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, 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])