示例#1
0
    def _handle_btn_events(self, cursor, event):

        if self.btn_dict.get("classic").is_clicked(cursor, event):
            Play()
        elif self.btn_dict.get("survival").is_clicked(cursor, event):
            Play()
        elif self.btn_dict.get("back").is_clicked(cursor, event):
            return 0
示例#2
0
def main(argv):
    maxInt = sys.maxsize
    decrement = True

    while decrement:
        # decrease the maxInt value by factor 10
        # as long as the OverflowError occurs.

        decrement = False
        try:
            csv.field_size_limit(maxInt)
        except OverflowError:
            maxInt = int(maxInt / 10)
            decrement = True
    names = []
    dir = './plays/'

    with open('hanochlevin.tsv', encoding="utf8") as fd:
        rd = csv.DictReader(fd, delimiter="\t", quotechar='"')
        for row in rd:
            name = row['play'].replace(' ', '_') + '.html'
            filename = dir + name
            if not os.path.exists(os.path.dirname(filename)):
                try:
                    os.makedirs(os.path.dirname(filename))
                except OSError as exc:  # Guard against race condition
                    if exc.errno != errno.EEXIST:
                        raise
            f = open(filename, "w", encoding='utf8')
            f.write(row['html'])
            f.close()
            names.append(name)

    labels = 'all_labels'
    edges = 'important'
    node_colors = 'one_color'
    metric = 'basic'

    for arg in argv:
        o, a = arg.split('=')
        if o == 'labels':
            labels = a
        elif o == 'edges':
            edges = a
        elif o == 'node_colors':
            node_colors = a
        elif o == 'metric':
            metric = a

    names_dealer = NamesDealer.NamesDealer()

    for name in names:
        htmp = MyHTMLParsers.MyHtmlParser()
        dirname = dir + name
        play = Play.Play(dirname, htmp, names_dealer, labels, edges,
                         node_colors, metric)
        play.graph()
        play.draw_graph()
示例#3
0
    def two_players_offline(self):
        play = Play(2, self.screen, self.clock, gameTerrain)
        play.two_players_offline('Player 1', 'Player 2')

        pygame.mouse.set_visible(True)
        #pygame.mixer.music.play(-1)

        self.start_menu()
        return
示例#4
0
    def one_player(self):
        active = False
        play = Play(1, self.screen, self.clock, gameTerrain)
        play.one_player()

        pygame.mouse.set_visible(True)
        #pygame.mixer.music.play(-1)

        active = True
示例#5
0
 def click(self, game, player):
     if player.used == []:  # Null play
         game.repeatTurn()
         return
     play = Play.Play(game, player)
     # Invalid plays
     if not play.isLegal(game) or (not game.challenge
                                   and not play.isValid(game)):
         game.display.clearMsg()
         game.display.printMsg("Illegal move")
         recall(game, player)
         game.repeatTurn()
     else:
         game.display.clearMsg()
         game.display.printMsg(player.name + " scored " + \
                 str(play.score) + " points!")
         game.plays.append(play)
         player.score += play.score
         player.newTurn = True
     player.used = []
示例#6
0
def Get_Team_Game_Stats(data):
    games = []
    game_num = 0

    # First seperate data into seperate games
    i = 1
    while i < len(data):
        game = []
        game.append(data[i])
        i += 1
        play_num = 0
        while data[i][CONST.CODE] == game[play_num][CONST.CODE]:
            game.append(data[i])
            i += 1
            play_num += 1
            if i >= len(data):
                break
        games.append(game)
        game_num += 1

    # Now compile data for each game
    team_game_stats = []
    team_game_stats_print = []
    team_game_stats_print.append(Team_Game_Stats_Header())
    for i in range(0, len(games)):
        game_stats_1 = Team_Game_Stat(games[i][0][CONST.CODE],
                                      games[i][0][CONST.OFF])
        game_stats_2 = Team_Game_Stat(games[i][0][CONST.CODE],
                                      games[i][0][CONST.DEF])

        for j in range(0, len(games[i])):
            play = Play(games[i][j])

            # Get next play
            if j + 1 < len(games[i]):
                next_play = Play(games[i][j + 1])
            else:
                next_play = Play([0] * len(games[i]))

            # Get rushing information
            play.Sack_Occurred()
            play.Fumble_Check(next_play)
            if "Rush" == play.data[CONST.TYPE] or (
                    "Pass" == play.data[CONST.TYPE] and play.Sack == 1):
                play.Rush_Att = 1
                try:
                    play.Rush_Yard = play.data[CONST.Y_DESC]
                except:
                    play.Rush_Yard = play.data[CONST.Y_DESC]
                play.Rushing_Touchdown_Occurred()

            # Get passing information
            if "Pass" == play.data[CONST.TYPE] and not (
                    "Pass" == play.data[CONST.TYPE] and play.Sack == 1):
                play.Pass_Att = 1
                play.Completion(next_play)
                play.Interception()
                play.Passing_Touchdown_Occurred()
                try:
                    play.Pass_Yard = play.data[CONST.Y_DESC]
                except:
                    play.Pass_Yard = play.data[CONST.Y_DESC]

            # Get kickoff information
            if "Kickoff" == play.data[CONST.TYPE]:
                play.Kickoff_Ret = 1
                play.Kickoff = 1
                if "Touchdown" == play.data[CONST.REST]:
                    play.Kickoff_Ret_TD = 1
                if None != re.search("touchback", play.data[CONST.P_REST],
                                     re.IGNORECASE):
                    play.Kickoff_Touchback = 1
                    play.Kickoff_Ret = 0

            # Points information
            play.Points = play.data[CONST.O_PT]

            # Get punt information
            if "Punt" == play.data[CONST.TYPE]:
                play.Punt = 1
                play.Punt_Ret = 1
                if "Touchdown" == play.data[CONST.REST]:
                    play.Punt_Ret_TD = 1
                    if None != re.search("block", play.data[CONST.P_REST],
                                         re.IGNORECASE):
                        play.Kick_Punt_Blocked = 1
                elif "Blocked" == play.data[CONST.REST]:
                    play.Kick_Punt_Blocked = 1

            # Get field goal information
            if "Field.Goal" == play.data[CONST.TYPE]:
                play.Field_Goal_Att = 1
                if "Made.FG" == play.data[CONST.REST]:
                    play.Field_Goal_Made = 1
                elif "Blocked" == play.data[CONST.REST]:
                    play.Kick_Punt_Blocked = 1
                if "Touchdown" == play.data[CONST.REST]:
                    if None != re.search("block", play.data[CONST.P_REST],
                                         re.IGNORECASE):
                        play.Kick_Punt_Blocked = 1

            # Get XP information
            if "Extra.Point" == play.data[CONST.TYPE]:
                play.Off_XP_Kick_Att = 1
                if None != re.search("made", play.data[CONST.P_REST],
                                     re.IGNORECASE):
                    play.Off_XP_Kick_Made = 1
                if "Blocked" == play.data[CONST.REST]:
                    play.Kick_Punt_Blocked = 1

            # Get two point conversion information
            if "Two.Point.Attempt" == play.data[CONST.TYPE]:
                play.Off_2XP_Att = 1
                play.Def_2XP_Att = 1
                play.Two_Pt_Conv_Successful(next_play)

            # Check for a safety
            play.Safety_Occurred(next_play)

            # Get tackles for loss data
            if "Rush" == play.data[CONST.TYPE] or "Pass" == play.data[
                    CONST.TYPE]:
                if None != re.search("loss", play.data[CONST.P_REST],
                                     re.IGNORECASE):
                    play.Tackle_For_Loss = 1
                    try:
                        play.Tackle_For_Loss_Yard = play.data[CONST.Y_SPOT]
                    except:
                        play.Tackle_For_Loss_Yard = play.data[CONST.Y_DESC]

            # Get penalty information
            if "Penalty" == play.data[CONST.TYPE]:
                play.Penalty = 1
                try:
                    play.Penalty_Yard = play.data[CONST.Y_SPOT]
                except:
                    play.Penalty_Yard = play.data[CONST.Y_DESC]

            # Get first down information
            play.First_Down(next_play)
            if 3 == play.data[CONST.DOWN] and (play.Rush_Att == 1
                                               or play.Pass_Att == 1):
                play.Third_Down_Att = 1
                if play.First_Down_Rush == 1 or play.First_Down_Pass == 1:
                    play.Third_Down_Conv = 1
            elif 4 == play.data[CONST.DOWN] and (play.Rush_Att == 1
                                                 or play.Pass_Att == 1):
                play.Fourth_Down_Att = 1
                if play.First_Down_Rush == 1 or play.First_Down_Pass == 1:
                    play.Fourth_Down_Conv = 1

            # Get time of possession information
            if play.data[CONST.CLK] < 900 and next_play.data[
                    CONST.CLK] < 900:  # normal
                play.Time_Of_Possession = play.data[
                    CONST.CLK] - next_play.data[CONST.CLK]
            elif next_play.data[CONST.CLK] == 900 and play.data[
                    CONST.CODE] == next_play.data[
                        CONST.CODE]:  # end of quarter
                play.Time_Of_Possession = play.data[CONST.CLK]
            elif play.data[CONST.CODE] != next_play.data[
                    CONST.CODE]:  # end of game
                play.Time_Of_Possession = play.data[CONST.CLK]

            # Get red zone information
            if (play.Pass_TD == 1
                    or play.Rush_TD == 1) and play.data[CONST.SPOT] <= 20:
                play.Red_Zone_TD = 1
            elif play.Field_Goal_Made == 1 and play.data[CONST.SPOT] <= 20:
                play.Red_Zone_Field_Goal = 1

            # Add play stats to team-game-stats
            if int(game_stats_1.Team_Code) == int(play.data[CONST.OFF]):
                game_stats_1.Add_Off_Stats(play)
                game_stats_2.Add_Def_Stats(play)
            elif int(game_stats_2.Team_Code) == int(play.data[CONST.OFF]):
                game_stats_2.Add_Off_Stats(play)
                game_stats_1.Add_Def_Stats(play)

        # Add this game to the array
        team_game_stats.append(game_stats_1)
        team_game_stats.append(game_stats_2)
        team_game_stats_print.append(game_stats_1.Compile_Stats())
        team_game_stats_print.append(game_stats_2.Compile_Stats())

    return (team_game_stats, team_game_stats_print)
示例#7
0
import Login_and_Logout_and_Add_and_Details
if __name__ == "__main__":
    while 1:
        print('\n=========WELCOME TO QUIZ ==========')
        print('-----------------------------------------')
        print('1. PLAY QUIZ')
        print("2. CREATE NEW ACCOUNT FOR PLAYER")
        print("3. CREATE NEW ACCOUNT FOR ADMIN")
        print("4. LOGIN")
        print("5. LOGOUT")
        print("6. ADD A QUESTION")
        print("7. VIEW ACCOUNT DETAILS")
        print("8. EXIT")
        choice = int(input('ENTER YOUR CHOICE: '))
        if choice == 1:
            Play.Play()
        elif choice == 2:
            name = input("Enter your name is : ")
            password = input("Enter your password is : ")
            Super_User.User(name, password)
        elif choice == 3:
            name = input("Enter your name is : ")
            password = input("Enter your password is : ")
            Super_User.Super_User(name, password)
        elif choice == 4:
            test_name = input("Enter your name is : ")
            test_password = input("Enter your password is : ")
            Login_and_Logout_and_Add_and_Details.Login(test_name,
                                                       test_password)
        elif choice == 5:
            Login_and_Logout_and_Add_and_Details.Logout()
示例#8
0
 def play_game(self):
     self.puzzle = Puzzle(self.instance)
     self.state = Play(self.puzzle)
     self.play = self.state.play()
示例#9
0
    def tournament(self):
        bg = pygame.image.load("img/white.png")
        self.screen.blit(bg, [0, 0])
        background_for_result = pygame.image.load(
            "img/Tournament_start_screen.jpg")
        self.screen.blit(background_for_result, [0, 0])

        font = pygame.font.Font('Base05.ttf', 20)
        black = (255, 204, 51)
        back_table = pygame.image.load("img/Left_sign.png")
        back_table = pygame.transform.scale(back_table, (200, 50))

        table_for_number_of_players = pygame.image.load("img/Right_sign.png")
        table_for_number_of_players = pygame.transform.scale(
            table_for_number_of_players, (200, 50))

        self.screen.blit(back_table, [0, 535])  # dole levo

        back_text = font.render('HOME', True, black)
        backRect = back_text.get_rect()
        backRect.center = (95, 560)
        self._display_surf.blit(back_text, backRect)

        self.screen.blit(table_for_number_of_players,
                         [300, 465])  # 8 igraca tabla
        self.screen.blit(table_for_number_of_players,
                         [300, 400])  # 7 igraca tabla
        self.screen.blit(table_for_number_of_players,
                         [300, 335])  # 6 igraca tabla
        self.screen.blit(table_for_number_of_players,
                         [300, 270])  # 5 igraca tabla
        self.screen.blit(table_for_number_of_players,
                         [300, 205])  # 4 igraca tabla

        four_players_text = font.render('4 PLAYERS', True, black)
        four_players_rect = four_players_text.get_rect()
        four_players_rect.center = (400, 230)

        five_players_text = font.render('5 PLAYERS', True, black)
        five_players_rect = five_players_text.get_rect()
        five_players_rect.center = (400, 295)

        six_players_text = font.render('6 PLAYERS', True, black)
        six_players_rect = six_players_text.get_rect()
        six_players_rect.center = (400, 360)

        seven_players_text = font.render('7 PLAYERS', True, black)
        seven_players_rect = seven_players_text.get_rect()
        seven_players_rect.center = (400, 425)

        eight_players_text = font.render('8 PLAYERS', True, black)
        eight_players_rect = eight_players_text.get_rect()
        eight_players_rect.center = (400, 490)

        self._display_surf.blit(four_players_text, four_players_rect)
        self._display_surf.blit(five_players_text, five_players_rect)
        self._display_surf.blit(six_players_text, six_players_rect)
        self._display_surf.blit(seven_players_text, seven_players_rect)
        self._display_surf.blit(eight_players_text, eight_players_rect)

        pygame.display.update()
        wait = True
        while wait:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.time.delay(500)
                    self.start_menu()
                    return

                if event.type == pygame.MOUSEBUTTONDOWN:
                    mouse_pos = event.pos
                    if 322 < mouse_pos[0] < 490 and 205 < mouse_pos[
                            1] < 255:  #za 4 igraca
                        print('4 igraca')
                        play = Play(4, self.screen, self.clock, gameTerrain)
                        process = mp.Process(
                            target=play.initialize_tournament())
                        process.start()
                        process.join()
                        pygame.mouse.set_visible(True)
                        pygame.mixer.music.play(-1)
                        self.start_menu()
                        return

                    if 322 < mouse_pos[0] < 490 and 270 < mouse_pos[
                            1] < 320:  #za 5 igraca
                        print('5 igraca')
                        play = Play(5, self.screen, self.clock, gameTerrain)
                        process = mp.Process(
                            target=play.initialize_tournament())
                        process.start()
                        process.join()
                        pygame.mouse.set_visible(True)
                        pygame.mixer.music.play(-1)
                        self.start_menu()
                        return

                    if 322 < mouse_pos[0] < 490 and 335 < mouse_pos[
                            1] < 385:  #za 6 igraca
                        print('6 igraca')
                        play = Play(6, self.screen, self.clock, gameTerrain)
                        process = mp.Process(
                            target=play.initialize_tournament())
                        process.start()
                        process.join()
                        pygame.mouse.set_visible(True)
                        pygame.mixer.music.play(-1)
                        self.start_menu()
                        return

                    if 322 < mouse_pos[0] < 490 and 400 < mouse_pos[
                            1] < 450:  #za 7 igraca
                        print('7 igraca')
                        play = Play(7, self.screen, self.clock, gameTerrain)
                        process = mp.Process(
                            target=play.initialize_tournament())
                        process.start()
                        process.join()
                        pygame.mouse.set_visible(True)
                        pygame.mixer.music.play(-1)
                        self.start_menu()
                        return

                    if 322 < mouse_pos[0] < 490 and 465 < mouse_pos[
                            1] < 515:  #za 8 igraca
                        print('8 igraca')
                        play = Play(8, self.screen, self.clock, gameTerrain)
                        process = mp.Process(
                            target=play.initialize_tournament())
                        process.start()
                        process.join()
                        pygame.mouse.set_visible(True)
                        pygame.mixer.music.play(-1)
                        self.start_menu()
                        return

                    if 30 < mouse_pos[0] < 180 and 535 < mouse_pos[
                            1] < 585:  # za HOME
                        pygame.mouse.set_visible(True)
                        pygame.mixer.music.play(-1)
                        pygame.time.delay(500)
                        self.start_menu()
                        return
示例#10
0
    def two_players_online(self):
        bg = pygame.image.load("img/white.png")
        self.screen.blit(bg, [0, 0])
        background_for_result = pygame.image.load(
            "img/Online_start_screen2.jpg")
        self.screen.blit(background_for_result, [0, 0])

        font = pygame.font.Font('Base05.ttf', 20)
        black = (255, 204, 51)
        back_table = pygame.image.load("img/Left_sign.png")
        back_table = pygame.transform.scale(back_table, (200, 50))

        table_for_connect = pygame.image.load("img/Right_sign.png")
        table_for_connect = pygame.transform.scale(table_for_connect,
                                                   (200, 50))

        self.screen.blit(back_table, [0, 535])  # dole levo

        back_text = font.render('HOME', True, black)
        backRect = back_text.get_rect()
        backRect.center = (95, 560)
        self._display_surf.blit(back_text, backRect)

        self.screen.blit(table_for_connect, [325, 335])  #bilo 300 i 335

        connect_text = font.render('CONNECT', True, black)
        connect_text_rect = connect_text.get_rect()
        connect_text_rect.center = (425, 360)  #bilo 400 i 360

        self._display_surf.blit(connect_text, connect_text_rect)

        pygame.display.update()
        wait = True
        while wait:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.time.delay(500)
                    self.start_menu()
                    return

                if event.type == pygame.MOUSEBUTTONDOWN:
                    mouse_pos = event.pos

                    #bilo 322 i 490
                    if 347 < mouse_pos[0] < 505 and 335 < mouse_pos[
                            1] < 385:  # za click na connect
                        #print('Connect')
                        play = Play(9, self.screen, self.clock, gameTerrain)
                        play.establish_a_connection()
                        #process = mp.Process(target=play.establish_a_connection())
                        #process.start()
                        #process.join()
                        pygame.mouse.set_visible(True)
                        pygame.mixer.music.play(-1)
                        self.start_menu()
                        return

                    if 30 < mouse_pos[0] < 180 and 535 < mouse_pos[
                            1] < 585:  # za HOME
                        pygame.mouse.set_visible(True)
                        pygame.mixer.music.play(-1)
                        pygame.time.delay(500)
                        self.start_menu()
                        return