Ejemplo n.º 1
0
def coconut_shy():
    log = open('coconut_shy.log', 'a')
    np = lib.NeoPage('/halloween/coconutshy.phtml')
    if np.contains('Come back tomorrow'):
        print('Coconut Shy: Already done today.')
        return
    swf_url = np.search(r"new SWFObject\('(.*?)',")[1]
    swf = lib.NeoPage()
    total_profit = 0
    while True:
        swf.set_referer(swf_url)
        swf.post(f'/halloween/process_cocoshy.phtml?coconut=1&r={random.randint(1, 99999)}')

        result = parse_qs(swf.content)
        log.write(f'{result}\n')
        points = int(result['points'][0])
        totalnp = int(result['totalnp'][0])
        success = int(result['success'][0])
        error = result['error'][0]

        if success == 0:
            print('Coconut Shy: Done enough.')
            break
        else:
            profit = points - 100
            print(f'Coconut Shy: Made {profit} NP. Code {success}. {error}')
            if points > 300:
                print(result)
            total_profit += profit
    print(f'Coconut Shy: Made {total_profit} NP in total.')
Ejemplo n.º 2
0
def coconut_shy():
    np = lib.NeoPage('/halloween/coconutshy.phtml')
    if np.contains('Come back tomorrow'):
        print('Coconut Shy: Already done today.')

    swf_url = np.search(r"new SWFObject\('(.*?)',")[1]
    swf = lib.NeoPage()
    while True:
        swf.set_referer(swf_url)
        swf.post(
            f'/halloween/process_cocoshy.phtml?coconut=1&r={random.randint(1, 99999)}'
        )

        result = parse_qs(swf.content)
        points = int(result['points'][0])
        totalnp = int(result['totalnp'][0])
        success = int(result['success'][0])
        error = result['error'][0]

        if success == 0:
            print('Coconut Shy: Done enough.')
            break
        else:
            print(
                f'Coconut Shy: Made {points - 100} NP. Success code {success}. Now have {totalnp} NP. {error}'
            )
Ejemplo n.º 3
0
def set_shop_prices():
    np = lib.NeoPage()
    np.get('/market_your.phtml')
    args = []
    args.append('type=update_prices')
    args.append('order_by=')
    args.append('view=')
    results = shop_item_re.findall(np.content)
    for (name, image, stock, category, obj_id_key, obj_id_val, old_cost_key,
         old_cost_val, cost_key, desc, back_to_inv_key) in results:
        args.append(f'{obj_id_key}={obj_id_val}')
        args.append(f'{old_cost_key}={old_cost_val}')
        try:
            true_price = item_db.get_price(name, image)
            if true_price < 1000000:
                my_price = true_price - 1
            else:
                my_price = 0
        except item_db.ShopWizardBannedException:
            my_price = 0
        if my_price != int(old_cost_val):
            print(f'Setting {name} to {my_price} NP')
        args.append(f'{cost_key}={my_price}')
        args.append(f'{back_to_inv_key}=0')
    args.append('obj_name=')
    np.post('/process_market.phtml', *args)
Ejemplo n.º 4
0
def deserted_tomb():
    np = lib.NeoPage('/worlds/geraptiku/tomb.phtml')
    if np.contains('enough excitement for one day'):
        print('Deserted tomb: Already done.')
        return
    np.post('/worlds/geraptiku/tomb.phtml', 'opened=1')
    np.post('/worlds/geraptiku/process_tomb.phtml')
    if np.contains('right on top of a Petpet.'):
        img = np.search(r'<div align="center"><img src="http://images.neopets.com/items/(.*?)" width="80" height="80" alt="" border="0"></div>')[1]
        if img:
            print(f'Deserted tomb: Got item with image {img}.')
        else:
            print('Deserted tomb: Got item, could not find image. TODO')
    elif np.contains('EUREKA!'):
        prize = np.search(r'You also stuff <strong>(.*?)</strong> <strong>Neopoints</strong> in your pockets')[1]
        prize = int(prize.replace(',', ''))
        print(f'Deserted tomb: Found treasure! Got items and {prize} NP.')
    elif np.contains('FIDDLESTICKS!'):
        print('Deserted tomb: Found empty treasure chamber.')
    elif np.contains('A giant monster leaps out from the darkness'):
        print('Deserted tomb: Monster.')
    elif np.contains('You watch as the arrows fly right at you'):
        print('Deserted tomb: Traps! TODO')
    elif np.contains('Deserted Tomb'):
        print('Deserted tomb: Different prize. TODO')
    else:
        print('Deserted tomb: Error.')
Ejemplo n.º 5
0
def pyramids(np_only=False):
    np = lib.NeoPage('/games/pyramids/index.phtml')
    np.post('/games/pyramids/pyramids.phtml')
    print('Pyramids: ', end='')

    while True:
        if np.contains('There are no more available moves!'):
            link = np.search(
                r"<b>There are no more available moves!<br><a href='(.*?)'><b>Collect Points</b>"
            )[1]
            np.get('/games/pyramids/' + link)
            verb = 'Won'
            noun = 'NP'
            reached_limit = False
            if np.contains(
                    'You have reached the <b>5000</b> Neopoint daily limit'):
                verb = 'Got'
                noun = 'pts'
                reached_limit = True
            status = np.search(
                r'Congratulations.*?<b>(\d+?)</b> (Neo)?points!.*total score has been updated to <b>(.*?)</b>.*?have played <b>(.*?)</b> game.*?cleared the pyramid <b>(.*?)</b>.*?current win streak is <b>(.*?)</b>'
            )
            print(
                f'\nPyramids: {verb} {status[1]} {noun}. Total: {status[3]}. Games: {status[4]}. Won: {status[5]}. Streak: {status[6]}.'
            )
            if reached_limit and np_only:
                break
            print('Pyramids: ', end='')
            np.post('/games/pyramids/pyramids.phtml')

        cur_card = np.search(r"&nbsp; <img src='.*?games/mcards/(.*?).gif'")[1]

        cards = []
        links = {}
        rows = np.findall(r"\n<td align='center'>(.*?)</td>")
        for row in rows:
            row_cards_raw = re.findall(r'images.neopets.com/(.*?).gif', row)
            row_cards = []
            for c in row_cards_raw:
                if 'backs' in c: row_cards.append('?')
                elif 'blank' in c: row_cards.append('')
                else: row_cards.append(c.split('/')[-1])
            row_playable_cards = [c for c in row_cards if c not in ['?', '']]
            row_links = re.findall(r"<a href='(.*?)'>", row)
            cards.append(row_cards)
            links.update(dict(zip(row_playable_cards, row_links)))

        best_card = best_move(cur_card, cards)
        cards_left = sum(1 if c else 0 for c in sum(cards, []))

        if cards_left < 10:
            print(cards_left, end='', flush=True)
        else:
            print('!' if best_card else '.', end='', flush=True)

        if best_card:
            np.get('/games/pyramids/' + links[best_card])
        else:
            np.get('/games/pyramids/pyramids.phtml?action=draw')
        time.sleep(min(random.expovariate(1 / 0.4), 5.0))
Ejemplo n.º 6
0
def faerie_caverns():
    np = lib.NeoPage(path)
    if np.contains('already visited today'):
        print('Already did faerie caverns.')
    else:
        inventory.ensure_np(400)
        while True:
            np.post(path, 'play=1')
            if np.contains('caverns/faerie_cave'):
                if np.contains('faerie_cave_dead_end.gif'):
                    print("Dead end!")
                    break
                elif np.contains("Click to see what you've found"):
                    print("Winning...")
                    continue
                elif np.contains('faerie_cave_success.gif'):
                    print("Won!")
                    np.save_to_file()
                    print(np.last_file_path)
                    break
                else:
                    print("In the Faerie Caverns...")
            else:
                print("Couldn't find faerie caverns.")
                break
Ejemplo n.º 7
0
def buy_scratchcard():
    inventory.ensure_np(1200)
    np = lib.NeoPage('/halloween/scratch.phtml')
    np.post('/halloween/process_scratch.phtml')
    if np.contains('Hey, give everybody else a chance'):
        print('Scratchcard: Already bought.')
    else:
        print('Bought a scratchcard???')
Ejemplo n.º 8
0
def rich_slorg():
    np = lib.NeoPage(path)
    if np.contains('slorg_payout=yes'):
        np.get(path, 'slorg_payout=yes')
        prize = np.search(r'You have received <strong>(.*?)</strong>')[1]
        print(f'Rich slorg: Got {prize}')
    else:
        print('Rich slorg: Could not find.')
Ejemplo n.º 9
0
def neoquest(once=False):
    np = lib.NeoPage(path)
    move_dirs = cycle(movedir_cycle)
    #?action=items
    #?action=items&useitemid=220000&do=use
    while True:
        hp_result = np.search(r'Health: <B>(\d+)</B>/(\d+)')
        hp = int(hp_result[1])
        hp_max = int(hp_result[2])
        print(f'Health: {hp}/{hp_max}')
        if np.contains('lupe_combat.gif'):
            moves = np.findall(
                r'''<A HREF="javascript:;" onClick="setdata\('(.*?)', (.*?)\); return false;">'''
            )
            if hp_max - hp > 60 and ('special', '200019') in moves:
                np.post(path, 'fact=special', 'type=200019')
            elif hp < 80 and ('item', '220004') in moves:
                np.post(path, 'fact=item', 'type=220004')
            elif hp < 80 and ('item', '220003') in moves:
                np.post(path, 'fact=item', 'type=220003')
            elif hp < 80 and ('item', '220002') in moves:
                np.post(path, 'fact=item', 'type=220002')
            elif hp < 80 and ('item', '220001') in moves:
                np.post(path, 'fact=item', 'type=220001')
            elif ('special', '4003') in moves:
                np.post(path, 'fact=special', 'type=4003')
            elif ('attack', '0') in moves:
                np.post(path, 'fact=attack', 'type=0')
            else:
                np.post(path, 'fact=noop', 'type=0')
        elif np.contains('Leader Board'):
            if once: break
            if hp_max - hp > 80:
                np.get(path, 'action=items')
                if np.contains('220003&do=use'):
                    np.get(path, 'action=items', 'useitemid=220003', 'do=use')
                elif np.contains('220002&do=use'):
                    np.get(path, 'action=items', 'useitemid=220002', 'do=use')
                elif np.contains('220001&do=use'):
                    np.get(path, 'action=items', 'useitemid=220001', 'do=use')
                np.post(path)
            else:
                movedir = next(move_dirs)
                np.get(path, 'action=move', f'movedir={movedir}')
        elif np.contains('You are attacked by'):
            monster = np.search(r'You are attacked .*? <B>(.*?)</B>')[1]
            print(f'Fighting {monster}')
            np.post(path)
        elif np.contains('You defeated'):
            rewards = np.search(
                r'<CENTER><IMG SRC="http://images.neopets.com/nq/n/lupe_win.gif">(.*?)</CENTER>'
            )[1]
            rewards = lib.strip_tags(rewards)
            print(rewards)
            np.post(path, 'end_fight=1')
        else:
            print("I don't know how to handle this.")
            break
Ejemplo n.º 10
0
def plushie_tycoon(details=False):
    np = lib.NeoPage(path)
    cash = amt(np.search(r'Cash on Hand: (.*?) NP')[1])
    print(f'Cash on Hand: {cash}')

    species_stats = check_store(np)
    check_warehouse(np)
    num_factory_jobs = check_factory(np, hire=True)
    material_prices, material_owned, accessories_owned, buy_links = check_materials(
        np)
    rois = calculate_rois(material_prices, species_stats)

    # Determine which kinds of plushies should be built, based on free space in
    # the factory and profitability of each species.
    # TODO: Also consider other materials used in plushies.
    if details:
        print(
            f'{"Species (cloths)": <21} {"n": <3} {"roi": <6} {"cost": <5} {"lst": <3} {"range": <7} {"avg": <6} {"med": <3} {"stdev": <6}'
        )
        for s, total_cost, roi in rois:
            stats = species_stats.get(s)
            roi_ = f'{roi:+.3f}' if roi else '??????'
            print(
                f'100x{s: <12} ({cloths[s]}): {stats["n"]: >3} {roi_} {total_cost: >5} {stats["last"]: >3} {stats["min"]: >3}-{stats["max"]: >3} {stats["avg"]: >6.2f} {stats["med"]: >3} {stats["stdev"]: >6.3f}'
            )

    num_jobs = 18 - num_factory_jobs
    jobs = pick_plushies(cash, rois, accessories_owned, num_jobs)
    jobs_chunked = []
    cur_chunk = []
    total_inv_slots = 0
    for s, qty in jobs:
        inv_slots = qty * (cloths[s] + 3)
        if inv_slots + total_inv_slots > 100:
            jobs_chunked.append(cur_chunk)
            cur_chunk = []
            total_inv_slots = 0
        cur_chunk.append((s, qty))
        total_inv_slots += inv_slots
    if cur_chunk: jobs_chunked.append(cur_chunk)
    print(f'Chunks: {jobs_chunked}')
    for job_chunk in jobs_chunked:
        print(f'Building job chunk {job_chunk}')
        accessory_species = defaultdict(int)
        for s, qty in job_chunk:
            accessory_species[s] += qty
        n_cloths = sum(qty * cloths[s] for s, qty in job_chunk)
        n_other = sum(qty for s, qty in job_chunk)
        print(f'Goods needed: {n_cloths} cloth, {n_other} other.')
        # TODO: Do something better than re-checking this.
        material_prices, material_owned, accessories_owned, buy_links = check_materials(
            np)
        buy_materials_up_to(np, [n_cloths, n_other, n_other, n_other],
                            buy_links, material_prices, material_owned,
                            accessories_owned, accessory_species)
        start_jobs(np, job_chunk)
    if jobs_chunked:
        check_factory(np, hire=True)
Ejemplo n.º 11
0
def restock(shop_id):
    inventory.ensure_np(99999)
    np = lib.NeoPage()
    np.get('/objects.phtml', f'obj_type={shop_id}', 'type=shop')
    items = re_shop_item.findall(np.content)
    shop_name = re_header.search(np.content)[1].strip()
    print(f'{len(items)} items found at {shop_name}.')

    # Look for profitable items
    best_score = ()
    best = None
    for obj_info_id, stock_id, g, brr, image, desc, name, stock, price in items:
        price = lib.amt(price)
        # TODO: Here we assume that items with the same name but drastically
        # different value won't restock in shops. For a more fine-grained
        # search, should search using image as well.
        true_price = item_db.get_price(name, update=False) or always_buy.get(name)
        if not true_price:
            continue
        print(f'Item: {stock} x {name} for {price} NP. (True price {true_price} NP)')

        profit = true_price - price
        score = (name in always_buy, profit, profit / price)
        if score > best_score:
            best_score = score
            best = (name, price, obj_info_id, stock_id, brr)

    if not best:
        return

    if best_score and (best_score[0] or best_score[1] >= MIN_PROFIT and best_score[2] >= MIN_PROFIT_MARGIN):
        name, price, obj_info_id, stock_id, brr = best
        np.get('/haggle.phtml', f'obj_info_id={obj_info_id}', f'stock_id={stock_id}', f'brr={brr}')
        referer = np.referer
        _x_pwned = re_captcha.search(np.content)[1]
        np.get('/captcha_show.phtml', f'_x_pwned={_x_pwned}')

        offer = haggle_price(price)
        print(f'Trying to buy {name} for {offer} !!')
        best_x, best_y = find_neopet(np.content, _x_pwned)
        np.set_referer(referer)
        print(f'Haggling @ {offer}')

        np.post('/haggle.phtml', f'current_offer={offer}', f'x={best_x}', f'y={best_y}')
        if 'I accept your offer' in np.content:
            print('Bought!')
        else:
            print('Not bought :( TODO: See what happened')
    else:
        print(f'No worthy items found. Best was {best[0]} (profit {best_score[2]*100:.1f}% = {best_score[1]})')

    # Learn about unknown items
    for obj_info_id, stock_id, g, brr, image, desc, name, stock, price in items:
        try:
            item_db.get_price(name)
        except item_db.ShopWizardBannedException:
            return neotime.now_nst() + datetime.timedelta(minutes=5)
Ejemplo n.º 12
0
def shrine():
    np = lib.NeoPage('/desert/shrine.phtml')
    np.post('/desert/shrine.phtml', 'type=approach')
    if np.contains('shrine_win.gif') or np.contains('shrine_scene.gif'):
        result = lib.strip_tags(np.search(r'\n<p>.*?<br clear="all">')[0])
        print(f"Coltzan's Shrine: {result}")
    elif np.contains('Maybe you should wait a while'):
        print("Coltzan's Shrine: Already visited.")
    else:
        print("Coltzan's Shrine: Error.")
Ejemplo n.º 13
0
def plushie():
    np = lib.NeoPage(path)
    np.post(path, 'talkto=1')
    if np.contains("<div align='center'>"):
        result = np.search(r"<div align='center'>(.*?)</div>")[1]
        print(f'Plushie: {result}')
    elif np.contains('already visited the plushie today'):
        print('Plushie: Already visited.')
    else:
        print('Plushie: Error.')
Ejemplo n.º 14
0
def bank_interest():
    path = '/bank.phtml'
    np = lib.NeoPage(path)
    if np.contains('You have already collected your interest today.'):
        print('Already collected interest today.')
    elif np.contains('Collect Interest ('):
        amount = np.search(r'Collect Interest \((.*?)\)')[1]
        print(f"Collecting {amount} interest.")
        np.post('/process_bank.phtml', 'type=interest')
    else:
        print("Error collecting bank interest.")
Ejemplo n.º 15
0
def jelly():
    path = '/jelly/jelly.phtml'
    np = lib.NeoPage(path)
    np.post(path, type='get_jelly')
    if np.contains('You take some'):
        prize = np.search(r'You take some <b>(.*?)</b>')[1]
        print(f"Giant Jelly: Got {prize}")
    elif np.contains('You cannot take more than one'):
        print("Already got jelly today.")
    else:
        print("Error getting giant jelly.")
Ejemplo n.º 16
0
def apple_bobbing():
    np = lib.NeoPage(path)
    if np.contains('Give it a shot!'):
        np.get(path, bobbing=1)
        message = np.search("<div id='bob_middle'>(.*?)</div>")[1].strip()
        message = lib.strip_tags(message)
        print(message)
    elif np.contains('blind underneath this hat'):
        print('Already apple bobbed today.')
    else:
        print("Couldn't find apple bobbing.")
Ejemplo n.º 17
0
def fruit_machine():
    np = lib.NeoPage(path)
    if np.contains('Spin, spin, spin!'):
        ck = np.search(r'<input type="hidden" name="ck" value="(.*?)">')[1]
        np.post(path, 'spin=1', f'ck={ck}')
        prize = np.search(r'<div id="fruitResult">(.*?)</div>')[1].strip()
        prize = lib.strip_tags(prize)
        print(f'Fruit machine: {prize}')
    elif np.contains('already had your free spin'):
        print('Fruit machine: Already played.')
    else:
        print('Fruit machine: Error!')
Ejemplo n.º 18
0
def magma_pool():
    log = open('magma_pool.log', 'a')
    np = lib.NeoPage(path)
    np.get(path)
    now = neotime.now_nst()
    if np.contains("I'm sorry, only those well-versed"):
        print('Magma Pool: Not your time.')
        log.write(f'{now} NO\n')
    else:
        print(f'Magma Pool: {now} may be your time!!!')
        log.write(f'{now} YES\n')
    log.close()
Ejemplo n.º 19
0
def ensure_login():
    np = lib.NeoPage()
    np.get('/')
    if 'templateLoginPopupIntercept' in np.content:
        user = os.environ.get('NP_USER')
        pswd = os.environ.get('NP_PASS')
        np.login(user, pswd)
        if 'templateLoginPopupIntercept' in np.content:
            print('Failed to log in!')
            sys.exit(1)
        else:
            print('Logged in.')
Ejemplo n.º 20
0
def lab_ray():
    log = open('lab_ray.log', 'a')
    np = lib.NeoPage('/lab.phtml')
    np.post('/lab2.phtml', 'donation=100')
    pet_name = np.active_pet_name()
    np.post('/process_lab2.phtml', f'chosen={pet_name}')
    if np.contains('You can only use the lab once a day'):
        print(f'Lab ray: Already fired.')
        return
    result = lib.strip_tags(
        np.search(r'''The ray is fired (.*?)<FORM action="/lab.phtml">''')[1])
    print(f'Lab ray: The ray is fired {result}')
    log.write(result + '\n')
Ejemplo n.º 21
0
def trudys_surprise():
    np = lib.NeoPage('/allevents.phtml')
    if not np.contains("Trudy's Surprise has reset"):
        print("Trudy's Surprise: Already done.")
        return
    else:
        np.get('/trudys_surprise.phtml')
        np.post('/trudydaily/ajax/claimprize.php', 'action=beginroll')
        result = json.loads(np.content)
        print(f"Trudy's Surprise: Won {result['prizes']}. Now have {result['adjustedNp']} NP.")
        time.sleep(0.7)
        np.post('/trudydaily/ajax/claimprize.php', 'action=prizeclaimed')
        np.get('/trudys_surprise.phtml')
Ejemplo n.º 22
0
def fishing():
    np = lib.NeoPage(path)
    np.post(path, go_fish=1)
    if np.contains('You reel in your line and get...'):
        prize = np.search('get...<P><CENTER>.*?<B>(.*?)</B>')[1]
        if np.contains('fishing skill increases'):
            lvl = np.search(
                r"Your pet's fishing skill increases to <B>(\d+)</B>!")[1]
            print(f'Underwater fishing: Got {prize}. Level increased to {lvl}')
        else:
            print(f'Underwater fishing: Got {prize}')
    else:
        print("Couldn't find underwater fishing.")
Ejemplo n.º 23
0
def kiko_pop():
    np = lib.NeoPage('/worlds/kiko/kpop/')
    # TODO: different difficulty?
    np.post('/worlds/kiko/kpop/ajax/difficulty.php', 'difficulty=2')
    print(np.content)
    result = json.loads(np.content)
    if not result['success']:
        print(f'Kiko Pop: Already done today.')
        return

    np.post('/worlds/kiko/kpop/ajax/prize.php', 'difficulty=2')
    print(f'Kiko Pop: {np.content}')
    result = json.loads(np.content)
Ejemplo n.º 24
0
def omelette():
    np = lib.NeoPage(path)
    if np.contains('The Omelette has Gone!!!'):
        print('Omelette: Gone!!!')
        return
    np.post(path, 'type=get_omelette')
    if np.contains('You cannot take more than'):
        print('Omelette: Already took today.')
    elif np.contains('You approach'):
        prize = np.search(r'You approach.*images.neopets.com/items/(.*?)\'')[1]
        print(f'Omelette: Got item with image {prize}')
    else:
        print('Omelette: Error.')
Ejemplo n.º 25
0
def tyranu_evavu():
    np = lib.NeoPage(path)

    while True:
        # Start a new game.
        ref_ck = np.search(
            r"<input type=hidden name='_ref_ck' value='(.*?)'>")[1]
        dealer = np.search(
            r"<input type=hidden name='dealer' value='(\d+)'>")[1]
        np.post(path, f'_ref_ck={ref_ck}', 'type=play', 'action=shuffle',
                r'dealer={dealer}')

        if np.contains('played enough for today'):
            print('Tyranu Evavu: Played enough for today.')
            return

        print('Tyranu Evavu: Starting game. (-30 NP)')

        counts = dict(zip(nums, [4] * 13))
        while True:
            card = np.findall(r'images.neopets.com/games/cards/(.*?)\.gif')[0]
            rank = int(card.split('_')[0])
            counts[rank] -= 1
            g = guess(rank, counts)

            if g == 'tyranu':
                print(f'{card} tyranu')
                np.post(path, 'type=play', 'action=higher')
            elif g == 'evavu':
                print(f'{card} evavu')
                np.post(path, 'type=play', 'action=lower')
            else:
                print(f'{card} idk')
                np.post(path, 'type=play',
                        'action=' + random.choice(['higher', 'lower']))

            if np.contains('Ugga!'):
                print(f'Good!')
                continue
            elif np.contains('Uhhg Uuuuu'):
                num_correct = np.search(
                    r'You managed <b>(\d+)</b> correct guesses...')[1]
                prize = np.search(r"That's worth <b>(\d+) np</b>!")[1]
                print(
                    f'Tyranu Evavu: Lost after {num_correct} rounds. Won {prize} NP.'
                )
                ref_ck = np.search(
                    r"<input type=hidden name='_ref_ck' value='(.*?)'>")[1]
                np.post(path, f'_ref_ck={ref_ck}', 'type=intro')
                break
Ejemplo n.º 26
0
def anchor_management():
    np = lib.NeoPage(path)
    if np.contains('form-fire-cannon'):
        action = np.search('<input name="action" type="hidden" value="(.*?)">')[1]
        np.post(path, action=action)
        if np.contains('prize-item-name'):
            prize = np.search('<span class="prize-item-name">(.*?)</span>')[1]
            print(f'Blasted krawken; got {prize}')
        else:
            print('Blasted krawken; got unknown prize')
    elif np.contains('safe from sea monsters for one day'):
        print('Already did anchor management.')
    else:
        print("Couldn't find anchor management.")
Ejemplo n.º 27
0
def forgotten_shore():
    np = lib.NeoPage(path)
    if np.contains('already searched the coast'):
        print('Forgotten shore: Already searched today.')
    elif np.contains('nothing of interest to be found'):
        print('Forgotten shore: Nothing today.')
    elif np.contains('A deserted shore stretches'):
        _ref_ck = np.search(r"<a href='\?confirm=1&_ref_ck=(.*?)'>")[1]
        np.get(path, 'confirm=1', f'_ref_ck={_ref_ck}')
        result = np.search(r"<br>A deserted shore.*?<br><br>\n")[0]
        result = lib.strip_tags(result)
        print(f'Forgotten shore: {result}')
    else:
        print('Forgotten shore not yet unlocked?')
Ejemplo n.º 28
0
def food_club():
    np = lib.NeoPage(path)
    np.get(path, 'type=bet')
    arenas = np.findall(r"<script language='javascript'>(.*?)</script>")
    for i,arena in enumerate(arenas[:5]):
        pirates = arena.strip().splitlines()
        pirate_odds = []
        for pirate in pirates:
            tokens = pirate.split()
            pirate_id = int(tokens[0].split('[')[1][:-1])
            odds = int(tokens[2][:-1])
            pirate_odds.append((pirate_id, odds))
        print(f'Arena {i}: {pirate_odds}')
        ar = sum(1/x for _,x in pirate_odds)
        print(ar)
Ejemplo n.º 29
0
def cheeseroller():
    log = open('cheeseroller.log', 'a')
    np = lib.NeoPage()
    while True:
        np.get(path)
        if np.contains('Sorry, you can only play 3'):
            print('Played too much.')
            return
        last_time = 0
        if np.contains('DISTANCE TO FINISH LINE'):
            last_time = int(np.search(r'TIME TAKEN</b> : (\d+?) seconds')[1])
        else:
            # Not in game; buy cheese and play
            print('Starting new game')
            np.post(path, 'cheese_name=Spicy+Juppie', 'thingy=1')
            np.post(path, 'cheese_name=Spicy+Juppie', 'type=buy')
        won = False
        while not won:
            action = random.randint(1, 5)
            print(f'Picking action {action}')
            np.post(path, 'cheese_action={action}')
            time_taken = -1
            if np.contains('DISTANCE TO FINISH LINE'):
                message = np.search(r'<hr noshade (.*?)>(.*?)<hr noshade')
                if message:
                    print(message[2])
                distance = np.search(
                    r'DISTANCE TO FINISH LINE</b> : (\d+?)m')[1]
                time_taken = np.search(r'TIME TAKEN</b> : (\d+?) seconds')[1]
                print(f"DIST: {distance}, TIME: {time_taken}")
            elif np.contains('finish_cheese_race.gif'):
                time_taken = np.search(r'You Finished in (\d+?) seconds')[1]
                score = np.search(r'Your Score</b> : (\d+?)<br>')[1]
                rating = np.search(r'Your Rating</b> : (.+?)</center>')[1]
                print(
                    f'Won! Time: {time_taken} sec - Score: {score} - Rating: {rating}'
                )
                won = True
            else:
                print('Error?')
                break

            time_taken = int(time_taken)
            time_elapsed = time_taken - last_time
            last_time = time_taken
            log.write(f'{action},{time_elapsed}\n')

            time.sleep(0.7 + random.random())
Ejemplo n.º 30
0
def wise_king():
    np = lib.NeoPage()
    for _ in range(1):
        np.get(path)
        parts = np.findall(r'<div id="(.)p(\d+)Div">(.*?)</div>')
        params = make_params(parts)
        params_hum = ' '.join(p.split('=')[1] for p in params)
        print(f'Wise King: Saying: {params_hum}')
        np.post(path2, *params)
        if np.contains('you have already regaled'):
            print(f'Wise King: Already done.')
        else:
            result = np.search(
                r'''<div align='center'>(.*?)<br clear="all">''')[1]
            result = lib.strip_tags(result)
            print(f'Wise King: {result}')