def handle_game(screen,Rects,rect_index,Players,Cards,cur_player,Cards_Rects,Option_Rects,Info_Cards_Rects,isRunning):
    
    
    # a board card was clicked

    if len(Rects) == 40:
        if rect_index != 40:
            if Rects[0] == None:
                print("Info card : " + str(rect_index))
            else:
                print("Board card : " + str(rect_index))

    # a game action was clicked

    if len(Rects) == 9 and rect_index != 9:
        

        if rect_index == 0:
            
            cur_player = handle_dice_roll(screen,Players,Cards,cur_player,Cards_Rects,Option_Rects,Info_Cards_Rects)


        elif rect_index == 1:

            cur_player = handle_build(screen,Players,Cards,cur_player,Cards_Rects,Option_Rects,Info_Cards_Rects)

        elif rect_index == 2:

            cur_player = handle_trade(screen,Players,Cards,cur_player,Cards_Rects,Option_Rects,Info_Cards_Rects)
            
        elif rect_index == 3:

            cur_player = handle_sell(screen,Players,Cards,cur_player,Cards_Rects,Option_Rects,Info_Cards_Rects)

        elif rect_index == 4:

            cur_player = handle_mortgage(screen,Players,Cards,cur_player,Cards_Rects,Option_Rects,Info_Cards_Rects)

        elif rect_index == 5:

            cur_player = handle_unmortgage(screen,Players,Cards,cur_player,Cards_Rects,Option_Rects,Info_Cards_Rects)

        elif rect_index == 6:

            cur_player = handle_decide_winner(screen,Players,Cards,cur_player)

        elif rect_index == 7:

            cur_player = handle_rules(screen,Players,Cards,cur_player)

        elif rect_index == 8:

            cur_player = handle_quit(screen,Players,Cards,cur_player)



        # unlocking the game loop
        isRunning = False

        return cur_player,isRunning
def handle_quit_player(screen,Players,Cards,cur_player):

    player = Players[cur_player]

    # updating the card status and other related fields

    for prop in player.property_owned:

        Cards[prop].status = 0
        Cards[prop].houses_built = 0
        Cards[prop].hotel_built = 0

    for player in player.property_mortgaged:

        Cards[prop].status = 0
        Cards[prop].houses_built = 0
        Cards[prop].hotel_built = 0
   
    # remove player from the list

    Players.remove(player)

    if len(Players) == 1:
        handle_decide_winner(screen,Players,Cards,0)
def handle_quit_player(screen, Players, Cards, cur_player):

    player = Players[cur_player]

    # updating the card status and other related fields

    for prop in player.property_owned:

        Cards[prop].status = 0
        Cards[prop].houses_built = 0
        Cards[prop].hotel_built = 0

    for player in player.property_mortgaged:

        Cards[prop].status = 0
        Cards[prop].houses_built = 0
        Cards[prop].hotel_built = 0

    # remove player from the list

    Players.remove(player)

    if len(Players) == 1:
        handle_decide_winner(screen, Players, Cards, 0)
Example #4
0
def handle_game(screen, Rects, rect_index, Players, Cards, cur_player,
                Cards_Rects, Option_Rects, Info_Cards_Rects, isRunning):

    # a board card was clicked

    if len(Rects) == 40:
        if rect_index != 40:
            if Rects[0] == None:
                print("Info card : " + str(rect_index))
            else:
                print("Board card : " + str(rect_index))

    # a game action was clicked

    if len(Rects) == 9 and rect_index != 9:

        if rect_index == 0:

            cur_player = handle_dice_roll(screen, Players, Cards, cur_player,
                                          Cards_Rects, Option_Rects,
                                          Info_Cards_Rects)

        elif rect_index == 1:

            cur_player = handle_build(screen, Players, Cards, cur_player,
                                      Cards_Rects, Option_Rects,
                                      Info_Cards_Rects)

        elif rect_index == 2:

            cur_player = handle_trade(screen, Players, Cards, cur_player,
                                      Cards_Rects, Option_Rects,
                                      Info_Cards_Rects)

        elif rect_index == 3:

            cur_player = handle_sell(screen, Players, Cards, cur_player,
                                     Cards_Rects, Option_Rects,
                                     Info_Cards_Rects)

        elif rect_index == 4:

            cur_player = handle_mortgage(screen, Players, Cards, cur_player,
                                         Cards_Rects, Option_Rects,
                                         Info_Cards_Rects)

        elif rect_index == 5:

            cur_player = handle_unmortgage(screen, Players, Cards, cur_player,
                                           Cards_Rects, Option_Rects,
                                           Info_Cards_Rects)

        elif rect_index == 6:

            cur_player = handle_decide_winner(screen, Players, Cards,
                                              cur_player)

        elif rect_index == 7:

            cur_player = handle_rules(screen, Players, Cards, cur_player)

        elif rect_index == 8:

            cur_player = handle_quit(screen, Players, Cards, cur_player)

        # unlocking the game loop
        isRunning = False

        return cur_player, isRunning