def fake(base_url, username, password, tourney_id):
    url_opener = _utils.login_and_enter_arcade(base_url, username, password)

    # calculate some more URLs
    tourneys_url = urljoin(base_url, "arcade.php?&do=viewtournaments")
    join_tourney_url = urljoin(base_url, "arcade.php?&do=registertourney&tid={0}".format(
        tourney_id
    ))
    #view_tourney_url = urljoin(base_url, "arcade.php?&do=viewtourney&tid={0}".format(
    #    tourney_id
    #))

    # go to tourneys
    print("entering tourneys page")
    tourneys_response = url_opener.open(tourneys_url)
    tourneys_response.read()

    # go to tourney creation form
    print("joining tourney")
    join_tourney_response = url_opener.open(join_tourney_url)
    join_tourney_response.read()

    # look at tourney to make sure it sticks
    #print("looking at tourney")
    #view_tourney_response = url_opener.open(view_tourney_url)
    #view_tourney_response.read()

    print("done")
Example #2
0
def fake(base_url, username, password, game_id, player_count, attempt_count):
    url_opener = _utils.login_and_enter_arcade(base_url, username, password)

    # calculate some more URLs
    tourneys_url = urljoin(base_url, "arcade.php?&do=viewtournaments")
    create_tourney_url = urljoin(base_url, "arcade.php?&act=Arcade&do=createtourney")
    submit_tourney_url = urljoin(base_url, "arcade.php")

    # go to tourneys
    print("entering tourneys page")
    tourneys_response = url_opener.open(tourneys_url)
    tourneys_response.read()

    # go to tourney creation form
    print("opening tourney creation page")
    create_tourney_response = url_opener.open(create_tourney_url)
    create_tourney_response.read()

    # fill it out and submit it
    post_values = {
        "act": "Arcade",
        "do": "docreatetourney",
        "the_game": game_id,
        "nbjoueurs": player_count,
        "nbtries": attempt_count,
    }
    post_data = _utils.encode_post_data(post_values)
    print("creating tourney")
    submit_tourney_response = url_opener.open(submit_tourney_url, data=post_data)
    submit_tourney_response.read()

    print("done")
Example #3
0
def fake(base_url, username, password, game_id, time, score, game_name=None):
    url_opener = _utils.login_and_enter_arcade(base_url, username, password)

    # calculate some more URLs
    play_game_url = urljoin(base_url, "arcade.php?do=play&gameid={0}".format(game_id))
    score_url = urljoin(base_url, "index.php?act=Arcade&do=newscore")

    # pretend to play the game
    print("playing the game")
    play_game_response = url_opener.open(play_game_url)
    play_game = HTML(play_game_response.read())

    if game_name is None:
        # (meanwhile, find the game's name)
        game_flash = play_game.find(".//embed[@type='application/x-shockwave-flash']")
        if game_flash is None:
            print("didn't find the flash plugin on the game page :'-(")
            return

        flash_vars = game_flash.attrib['flashvars'].split("&")
        for var in flash_vars:
            if var.startswith("gamename="):
                game_name = var[len("gamename="):]

    if game_name is None:
        print("game name not found :'-(")
        return

    # wait the given time
    print("waiting")
    sleep(time)

    post_values = {
        "gscore": score,
        "gname": game_name
    }
    post_data = _utils.encode_post_data(post_values)
    print("submitting fake score")
    score_response = url_opener.open(score_url, data=post_data)
    score_response.read()

    print("done")
Example #4
0
def fake(base_url, username, password, game_id, time, score, tourney_id, game_name=None, rung=None,
         face_off=None):
    url_opener = _utils.login_and_enter_arcade(base_url, username, password)

    # calculate some more URLs
    tourneys_url = urljoin(base_url, "arcade.php?&do=viewtournaments")
    view_tourney_url = urljoin(base_url, "arcade.php?&act=Arcade&do=viewtourney&tid={0}".format(
        tourney_id
    ))
    play_tourney_game_url = urljoin(
        base_url,
        "arcade.php?&do=playtourney&gameid={0}&tid={1}{2}{3}".format(
            game_id, tourney_id,
            "&rung={0}".format(rung) if rung is not None else "",
            "&faceoff={0}".format(face_off) if face_off is not None else ""
        )
    )
    score_url = urljoin(base_url, "index.php?act=Arcade&do=newscore")

    # go to tourneys
    print("entering tourneys page")
    tourneys_response = url_opener.open(tourneys_url)
    tourneys_response.read()

    # view the tourney
    print("looking at the tourney")
    view_tourney_response = url_opener.open(view_tourney_url)
    view_tourney_response.read()

    # pretend to play the game
    print("playing the game")
    play_tourney_game_response = url_opener.open(play_tourney_game_url)
    play_tourney_game = HTML(play_tourney_game_response.read())

    if game_name is None:
        # (meanwhile, find the game's name)
        game_flash = play_tourney_game.find(".//embed[@type='application/x-shockwave-flash']")
        if game_flash is None:
            print("didn't find the flash plugin on the game page :'-(")
            return

        flash_vars = game_flash.attrib['flashvars'].split("&")
        for var in flash_vars:
            if var.startswith("gamename="):
                game_name = var[len("gamename="):]

    if game_name is None:
        print("game name not found :'-(")
        return

    # wait the given time
    print("waiting")
    sleep(time)

    post_values = {
        "gscore": score,
        "gname": game_name
    }
    post_data = _utils.encode_post_data(post_values)
    print("submitting fake score")
    score_response = url_opener.open(score_url, data=post_data)
    score_response.read()

    print("done")