예제 #1
0
async def unpossess_fishing_rod(cmd):
    user_data = EwUser(member=cmd.message.author)
    if user_data.life_state != ewcfg.life_state_corpse:
        response = "You have no idea what you're doing."
    elif not user_data.get_inhabitee():
        response = "You're not {}ing anyone right now.".format(
            ewcfg.cmd_inhabit)
    elif not user_data.get_possession('rod'):
        response = "You want to unpossess a fishing rod you aren't possessing?\n" \
                   "Huh, curious.\n" \
                   "ARE YOU RETARDED?"
    else:
        response = "You let go the fishing rod so your fishing partner doesn't need your help anymore, the tendrils near their hook begin to dissappear into a grey fog."
        user_data.cancel_possession()
    return await fe_utils.send_message(
        cmd.client, cmd.message.channel,
        fe_utils.formatMessage(cmd.message.author, response))
예제 #2
0
async def order(cmd):
    user_data = EwUser(member=cmd.message.author)
    mutations = user_data.get_mutations()
    if user_data.life_state == ewcfg.life_state_shambler and user_data.poi != ewcfg.poi_id_nuclear_beach_edge:
        response = "You lack the higher brain functions required to {}.".format(cmd.tokens[0])
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    market_data = EwMarket(id_server=cmd.guild.id)
    currency_used = 'slime'
    current_currency_amount = user_data.slimes
    # poi = ewmap.fetch_poi_if_coordless(cmd.message.channel.name)
    poi = poi_static.id_to_poi.get(user_data.poi)
    if poi is None or len(poi.vendors) == 0 or ewutils.channel_name_is_poi(cmd.message.channel.name) == False:
        # Only allowed in the food court.
        response = "There’s nothing to buy here. If you want to purchase some items, go to a sub-zone with a vendor in it, like the food court, the speakeasy, or the bazaar."
    else:
        poi = poi_static.id_to_poi.get(user_data.poi)
        district_data = EwDistrict(district=poi.id_poi, id_server=user_data.id_server)

        shambler_multiplier = 1  # for speakeasy during shambler times

        if district_data.is_degraded():
            if poi.id_poi == ewcfg.poi_id_speakeasy:
                shambler_multiplier = 4
            else:
                response = "{} has been degraded by shamblers. You can't {} here anymore.".format(poi.str_name, cmd.tokens[0])
                return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
        # value = ewutils.flattenTokenListToString(cmd.tokens[1:2])

        # if cmd.tokens_count > 1:
        #	value = cmd.tokens[1]
        #	value = value.lower()

        value = None

        togo = False
        if cmd.tokens_count > 1:
            for token in cmd.tokens[1:]:
                if token.startswith('<@') == False and token.lower() not in "togo":  # togo can be spelled together or separate
                    value = token
                    break

            for token in cmd.tokens[1:]:
                if token.lower() in "togo":  # lets people get away with just typing only to or only go (or only t etc.) but whatever
                    togo = True
                    break

        # Finds the item if it's an EwGeneralItem.

        if value == "mylittleponyfigurine":
            value = random.choice(static_items.furniture_pony)

        item = static_items.item_map.get(value)

        item_type = ewcfg.it_item
        if item != None:
            item_id = item.id_item
            name = item.str_name

        # Finds the item if it's an EwFood item.
        if item == None:
            item = static_food.food_map.get(value)
            item_type = ewcfg.it_food
            if item != None:
                item_id = item.id_food
                name = item.str_name

        # Finds the item if it's an EwCosmeticItem.
        if item == None:
            item = static_cosmetics.cosmetic_map.get(value)
            item_type = ewcfg.it_cosmetic
            if item != None:
                item_id = item.id_cosmetic
                name = item.str_name

        if item == None:
            item = static_items.furniture_map.get(value)
            item_type = ewcfg.it_furniture
            if item != None:
                item_id = item.id_furniture
                name = item.str_name
                if item_id in static_items.furniture_pony:
                    item.vendors = [ewcfg.vendor_bazaar]

        if item == None:
            item = static_weapons.weapon_map.get(value)
            item_type = ewcfg.it_weapon
            if item != None:
                item_id = item.id_weapon
                name = item.str_weapon

        if item == None:
            item = static_relic.relic_map.get(value)
            item_type = ewcfg.it_relic
            if item != None and relic_utils.canCreateRelic(item.id_relic, cmd.guild.id):
                item_id = item.id_relic
                name = item.str_name
            elif item != None:
                item = None


        if item != None:
            item_type = item.item_type
            # Gets a vendor that the item is available and the player currently located in
            try:
                current_vendor = (set(item.vendors).intersection(set(poi.vendors))).pop()
            except:
                current_vendor = None

            # Check if the item is available in the current bazaar item rotation
            if current_vendor == ewcfg.vendor_bazaar:
                if item_id not in market_data.bazaar_wares.values():
                    if item_id in static_items.furniture_pony and "mylittleponyfigurine" in market_data.bazaar_wares.values():
                        pass
                    else:
                        current_vendor = None


            if current_vendor is None or len(current_vendor) < 1:
                response = "Check the {} for a list of items you can {}.".format(ewcfg.cmd_menu, ewcfg.cmd_order)

            else:
                response = ""

                value = item.price

                premium_purchase = True if item_id in ewcfg.premium_items else False
                if premium_purchase:
                    togo = True  # Just in case they order a premium food item, don't make them eat it right then and there.

                    if ewcfg.cd_premium_purchase > (int(time.time()) - user_data.time_lastpremiumpurchase):
                        response = "That item is in very limited stock! The vendor asks that you refrain from purchasing it for a day or two."
                        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

                    elif ewcfg.cd_new_player > (int(time.time()) - user_data.time_joined):
                        response = "You've only been in the city for a few days. The vendor doesn't trust you with that item very much..."
                        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

                stock_data = None
                company_data = None
                # factor in the current stocks
                for vendor in item.vendors:
                    if vendor in ewcfg.vendor_stock_map:
                        stock = ewcfg.vendor_stock_map.get(vendor)
                        company_data = EwCompany(id_server=user_data.id_server, stock=stock)
                        stock_data = EwStock(id_server=user_data.id_server, stock=stock)

                if stock_data is not None:
                    value *= (stock_data.exchange_rate / ewcfg.default_stock_exchange_rate) ** 0.2

                controlling_faction = poi_utils.get_subzone_controlling_faction(user_data.poi, user_data.id_server)

                if controlling_faction != "":
                    # prices are halved for the controlling gang
                    if controlling_faction == user_data.faction:
                        value /= 2

                    # and 4 times as much for enemy gangsters
                    elif user_data.faction != "":
                        value *= 4

                # raise shambled speakeasy price 4 times
                value *= shambler_multiplier

                # Raise the price for togo ordering. This gets lowered back down later if someone does togo ordering on a non-food item by mistake.
                if togo:
                    value *= 1.5

                if current_vendor == ewcfg.vendor_breakroom and user_data.faction == ewcfg.faction_slimecorp:
                    value = 0

                value = int(value)

                food_ordered = False
                target_data = None

                # Kingpins eat free.
                if (user_data.life_state == ewcfg.life_state_kingpin or user_data.life_state == ewcfg.life_state_grandfoe) and item_type == ewcfg.it_food:
                    value = 0

                if value > current_currency_amount:
                    # Not enough money.
                    response = "A {} costs {:,} {}, and you only have {:,}.".format(name, value, currency_used, current_currency_amount)
                else:
                    mutations = user_data.get_mutations()
                    if random.randrange(5) == 0 and ewcfg.mutation_id_stickyfingers in mutations:
                        value = 0
                        user_data.change_crime(n=ewcfg.cr_larceny_points)

                    inv_response = bknd_item.check_inv_capacity(user_data=user_data, item_type=item_type, return_strings=True, pronoun="You")
                    if inv_response != "" and (item_type != ewcfg.it_food or togo):
                        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, inv_response))

                    if item_type == ewcfg.it_food:
                        food_ordered = True

                        target = None
                        target_data = None
                        if not togo:  # cant order togo for someone else, you can just give it to them in person
                            if cmd.mentions_count == 1:
                                target = cmd.mentions[0]
                                if target.id == cmd.message.author.id:
                                    target = None

                        if target != None:
                            target_data = EwUser(member=target)
                            if target_data.life_state == ewcfg.life_state_corpse and target_data.get_possession():
                                response = "How are you planning to feed them while they're possessing you?"
                                return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
                            elif target_data.poi != user_data.poi:
                                response = "You can't order anything for them because they aren't here!"
                                return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

                    elif item_type == ewcfg.it_weapon:

                        if user_data.life_state == ewcfg.life_state_corpse:
                            response = "Ghosts can't hold weapons."
                            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

                    item_props = itm_utils.gen_item_props(item)

                    # Only food should have the value multiplied. If someone togo orders a non-food item by mistake, lower it back down.
                    if not food_ordered and togo:
                        value = int(value / 1.5)

                    if currency_used == 'slime':
                        user_data.change_slimes(n=-value, source=ewcfg.source_spending)

                    if company_data is not None:
                        company_data.recent_profits += value
                        company_data.persist()

                    if item.str_name == "arcade cabinet":
                        item_props['furniture_desc'] = random.choice(ewcfg.cabinets_list)
                    elif item.item_type == ewcfg.it_furniture:
                        if "custom" in item_props.get('id_furniture'):
                            if cmd.tokens_count < 4 or cmd.tokens[2] == "" or cmd.tokens[3] == "":
                                response = "You need to specify the customization text before buying a custom item. Come on, isn't that self-evident? (!order [custom item] \"custom name\" \"custom description\")"
                                return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
                            else:
                                customname = cmd.tokens[2]

                                if len(customname) > 32:
                                    response = "That name is too long. ({:,}/32)".format(len(customname))
                                    return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

                                customdesc = cmd.tokens[3]

                                if len(customdesc) > 500:
                                    response = "That description is too long. ({:,}/500)".format(len(customdesc))
                                    return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

                                name = item_props['furniture_name'] = item_props['furniture_name'].format(custom=customname)
                                item_props['furniture_desc'] = customdesc
                                item_props['furniture_look_desc'] = item_props['furniture_look_desc'].format(custom=customname)
                                item_props['furniture_place_desc'] = item_props['furniture_place_desc'].format(custom=customname)

                    id_item = bknd_item.item_create(
                        item_type=item_type,
                        id_user=cmd.message.author.id,
                        id_server=cmd.guild.id,
                        stack_max=-1,
                        stack_size=0,
                        item_props=item_props
                    )

                    if value == 0:
                        response = "You swipe a {} from the counter at {}.".format(name, current_vendor)
                    else:
                        response = "You slam {:,} {} down on the counter at {} for {}.".format(value, currency_used, current_vendor, name)

                    if food_ordered and not togo:
                        item_data = EwItem(id_item=id_item)

                        # Eat food on the spot!
                        if target_data != None:

                            target_player_data = EwPlayer(id_user=target_data.id_user)

                            if value == 0:
                                response = "You swipe a {} from the counter at {} and give it to {}.".format(name, current_vendor, target_player_data.display_name)
                            else:
                                response = "You slam {:,} slime down on the counter at {} for {} and give it to {}.".format(value, current_vendor, name, target_player_data.display_name)

                            response += "\n\n*{}*: ".format(target_player_data.display_name) + target_data.eat(item_data)
                            target_data.persist()
                            
                        else:

                            if value == 0:
                                response = "You swipe a {} from the counter at {} and eat it right on the spot.".format(name, current_vendor)
                            else:
                                response = "You slam {:,} slime down on the counter at {} for {} and eat it right on the spot.".format(value, current_vendor, name)

                            user_player_data = EwPlayer(id_user=user_data.id_user)

                            response += "\n\n*{}*: ".format(user_player_data.display_name) + user_data.eat(item_data)
                            user_data.persist()

                    if premium_purchase:
                        user_data.time_lastpremiumpurchase = int(time.time())

                    user_data.persist()

        else:
            response = "Check the {} for a list of items you can {}.".format(ewcfg.cmd_menu, ewcfg.cmd_order)

    # Send the response to the player.
    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
예제 #3
0
async def possess_fishing_rod(cmd):
    user_data = EwUser(member=cmd.message.author)
    response = ""
    if user_data.life_state != ewcfg.life_state_corpse:
        response = "You have no idea what you're doing."
    elif not user_data.get_inhabitee():
        response = "You're not **{}**ing anyone right now.".format(
            ewcfg.cmd_inhabit)
    elif user_data.slimes >= ewcfg.slimes_to_possess_fishing_rod:
        response = "You'll have to become stronger before you can perform occult arts of this level."
    else:
        server = cmd.guild
        inhabitee_id = user_data.get_inhabitee()
        inhabitee_data = EwUser(id_user=inhabitee_id,
                                id_server=user_data.id_server)
        inhabitee_member = server.get_member(inhabitee_id)
        inhabitee_name = inhabitee_member.display_name
        if inhabitee_data.get_possession():
            response = "{} is already being possessed.".format(inhabitee_name)
        else:
            proposal_response = "You propose a trade to {}.\n" \
                                "You will possess their fishing rod to enhance it, making it more attractive to fish. In exchange, you will corrupt away all of the fish's slime, and absorb it as antislime.\n" \
                                "Both of you will need to reel the fish in together, and failing to do so will nullify this contract.\nWill they **{}** this exchange, or **{}** it?".format(inhabitee_name, ewcfg.cmd_accept, ewcfg.cmd_refuse)
            await fe_utils.send_message(
                cmd.client, cmd.message.channel,
                fe_utils.formatMessage(cmd.message.author, proposal_response))

            accepted = False
            try:
                msg = await cmd.client.wait_for(
                    'message',
                    timeout=30,
                    check=lambda message: message.author == inhabitee_member
                    and message.content.lower(
                    ) in [ewcfg.cmd_accept, ewcfg.cmd_refuse])
                if msg != None:
                    if msg.content.lower() == ewcfg.cmd_accept:
                        accepted = True
                    elif msg.content.lower() == ewcfg.cmd_refuse:
                        accepted = False
            except:
                accepted = False

            if accepted:
                bknd_core.execute_sql_query(
                    "UPDATE inhabitations SET {empowered} = %s WHERE {id_fleshling} = %s AND {id_ghost} = %s"
                    .format(
                        empowered=ewcfg.col_empowered,
                        id_fleshling=ewcfg.col_id_fleshling,
                        id_ghost=ewcfg.col_id_ghost,
                    ), (
                        'rod',
                        inhabitee_id,
                        user_data.id_user,
                    ))
                user_data.change_slimes(n=-ewcfg.slimes_to_possess_fishing_rod,
                                        source=ewcfg.source_ghost_contract)
                user_data.persist()
                accepted_response = "You feel a metallic taste in your mouth as you sign {}'s spectral contract. Their ghastly arms superpose yours, enhancing your grip and causing shadowy tendrils to appear near your rod's hook.".format(
                    cmd.message.author.display_name)
                await fe_utils.send_message(
                    cmd.client, cmd.message.channel,
                    fe_utils.formatMessage(inhabitee_member,
                                           accepted_response))
            else:
                response = "You should've known better, why would anyone ever trust you?"

    if response:
        return await fe_utils.send_message(
            cmd.client, cmd.message.channel,
            fe_utils.formatMessage(cmd.message.author, response))
예제 #4
0
async def possess_weapon(cmd):
    user_data = EwUser(member=cmd.message.author)
    response = ""
    if user_data.life_state != ewcfg.life_state_corpse:
        response = "You have no idea what you're doing."
    elif not user_data.get_inhabitee():
        response = "You're not **{}**ing anyone right now.".format(
            ewcfg.cmd_inhabit)
    elif user_data.slimes >= ewcfg.slimes_to_possess_weapon:
        response = "You'll have to become stronger before you can perform occult arts of this level."
    else:
        server = cmd.guild
        inhabitee_id = user_data.get_inhabitee()
        inhabitee_data = EwUser(id_user=inhabitee_id,
                                id_server=user_data.id_server)
        inhabitee_member = server.get_member(inhabitee_id)
        inhabitee_name = inhabitee_member.display_name
        if inhabitee_data.weapon < 0:
            response = "{} is not wielding a weapon right now.".format(
                inhabitee_name)
        elif inhabitee_data.get_possession():
            response = "{} is already being possessed.".format(inhabitee_name)
        else:
            proposal_response = "You propose a trade to {}.\n" \
                                "You will possess their weapon to empower it, and in return they'll sacrifice a fifth of their slime to your name upon their next kill.\n" \
                                "Will they **{}** this exchange, or **{}** it?".format(inhabitee_name, ewcfg.cmd_accept, ewcfg.cmd_refuse)
            await fe_utils.send_message(
                cmd.client, cmd.message.channel,
                fe_utils.formatMessage(cmd.message.author, proposal_response))

            accepted = False
            try:
                msg = await cmd.client.wait_for(
                    'message',
                    timeout=30,
                    check=lambda message: message.author == inhabitee_member
                    and message.content.lower(
                    ) in [ewcfg.cmd_accept, ewcfg.cmd_refuse])
                if msg != None:
                    if msg.content.lower() == ewcfg.cmd_accept:
                        accepted = True
                    elif msg.content.lower() == ewcfg.cmd_refuse:
                        accepted = False
            except:
                accepted = False

            if accepted:
                bknd_core.execute_sql_query(
                    "UPDATE inhabitations SET {empowered} = %s WHERE {id_fleshling} = %s AND {id_ghost} = %s"
                    .format(
                        empowered=ewcfg.col_empowered,
                        id_fleshling=ewcfg.col_id_fleshling,
                        id_ghost=ewcfg.col_id_ghost,
                    ), (
                        'weapon',
                        inhabitee_id,
                        user_data.id_user,
                    ))
                user_data.change_slimes(n=-ewcfg.slimes_to_possess_weapon,
                                        source=ewcfg.source_ghost_contract)
                user_data.persist()
                accepted_response = "You feel a metallic taste in your mouth as you sign {}'s spectral contract. You see them bind themselves to your weapon, which now bears their mark. It feels cold to the touch.".format(
                    cmd.message.author.display_name)
                await fe_utils.send_message(
                    cmd.client, cmd.message.channel,
                    fe_utils.formatMessage(inhabitee_member,
                                           accepted_response))
            else:
                response = "You should've known better, why would anyone ever trust you?"

    if response:
        return await fe_utils.send_message(
            cmd.client, cmd.message.channel,
            fe_utils.formatMessage(cmd.message.author, response))
예제 #5
0
async def cast(cmd):
    time_now = round(time.time())
    has_reeled = False
    user_data = EwUser(member=cmd.message.author)
    mutations = user_data.get_mutations()

    if ewutils.channel_name_is_poi(cmd.message.channel.name) == False:
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "You must {} in a zone's channel.".format(cmd.tokens[0])))

    market_data = EwMarket(id_server=cmd.message.author.guild.id)
    statuses = user_data.getStatusEffects()

    if cmd.message.author.id not in fishutils.fishers.keys():
        fishutils.fishers[cmd.message.author.id] = EwFisher()

    fisher = fishutils.fishers[cmd.message.author.id]

    # Ghosts cannot fish.
    if user_data.life_state == ewcfg.life_state_corpse:
        response = "You can't fish while you're dead. Try {}.".format(ewcfg.cmd_revive)

    # Players who are already cast a line cannot cast another one.
    elif fisher.fishing == True:
        response = "You've already cast a line."

    # Only fish at The Pier
    elif user_data.poi in poi_static.piers:
        poi = poi_static.id_to_poi.get(user_data.poi)
        district_data = EwDistrict(district=poi.id_poi, id_server=user_data.id_server)

        rod_possession = user_data.get_possession('rod')
        if rod_possession:
            fisher.inhabitant_id = rod_possession[0]

        elif user_data.hunger >= user_data.get_hunger_max():
            response = "You're too hungry to fish right now."
        elif (not fisher.inhabitant_id) and (poi.id_poi == ewcfg.poi_id_blackpond):
            response = "You cast your fishing line into the pond, but your hook bounces off its black waters like hard concrete."
        else:
            has_fishingrod = False

            if user_data.weapon >= 0:
                weapon_item = EwItem(id_item=user_data.weapon)
                weapon = static_weapons.weapon_map.get(weapon_item.item_props.get("weapon_type"))
                if weapon.id_weapon == "fishingrod":
                    has_fishingrod = True

            if ewcfg.status_high_id in statuses:
                fisher.high = True
            fisher.fishing = True
            fisher.bait = False
            fisher.bait_id = 0
            fisher.pier = poi
            fisher.current_fish = gen_fish(market_data, fisher, has_fishingrod)

            high_value_bait_used = False

            # global fishing_counter
            fishutils.fishing_counter += 1
            current_fishing_id = fisher.fishing_id = fishutils.fishing_counter

            item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])
            author = cmd.message.author
            server = cmd.guild

            item_sought = bknd_item.find_item(item_search=item_search, id_user=author.id, id_server=server.id)

            if item_sought:
                item = EwItem(id_item=item_sought.get('id_item'))

                if item.item_type == ewcfg.it_food:

                    str_name = item.item_props['food_name']
                    id_food = item.item_props.get('id_food')
                    fisher.bait = True

                    if id_food in static_food.plebe_bait:
                        fisher.current_fish = "plebefish"

                    elif id_food == "doublestuffedcrust":
                        if random.randrange(5) == 3:
                            fisher.current_fish = "doublestuffedflounder"

                    elif id_food in ["chickenbucket", "familymeal"]:
                        if random.randrange(5) == 3:
                            fisher.current_fish = "seacolonel"

                    elif id_food in ["steakvolcanoquesomachorito", "nachosupreme"]:
                        if random.randrange(5) == 3:
                            fisher.current_fish = "marlinsupreme"

                    elif id_food in "blacklimesour":
                        if random.randrange(2) == 1:
                            fisher.current_fish = "blacklimesalmon"

                    elif id_food in "pinkrowdatouille":
                        if random.randrange(2) == 1:
                            fisher.current_fish = "thrash"

                    elif id_food in "purplekilliflowercrustpizza":
                        if random.randrange(2) == 1:
                            fisher.current_fish = "dab"

                    elif id_food == "kingpincrab":
                        if random.randrange(5) == 1:
                            fisher.current_fish = "uncookedkingpincrab"

                    elif id_food == "masterbait":
                        high_value_bait_used = True

                    elif id_food == "ferroslimeoid":
                        fisher.current_fish = "seaitem"

                    elif float(item.time_expir if item.time_expir is not None else 0) < time.time():
                        if random.randrange(2) == 1:
                            fisher.current_fish = "plebefish"
                    fisher.bait_id = item_sought.get('id_item')

            if fisher.current_fish == "item":
                fisher.current_size = "item"

            else:
                mastery_bonus = 0
                # Git gud.
                if has_fishingrod:
                    mastery_bonus += user_data.weaponskill - 4 #
                else:
                    mastery_bonus += -4
                
                if rod_possession:
                    mastery_bonus += 1

                mastery_bonus = max(0, mastery_bonus)

                fisher.length = gen_fish_size(mastery_bonus)
                fisher.current_size = length_to_size(fisher.length)

            if fisher.bait == False:
                response = "You cast your fishing line into the "
            else:
                response = "You attach your {} to the hook as bait and then cast your fishing line into the ".format(str_name)

            if fisher.pier.pier_type == ewcfg.fish_slime_saltwater:
                response += "vast Slime Sea."
            elif fisher.pier.pier_type == ewcfg.fish_slime_freshwater:
                response += "glowing Slime Lake."
            elif fisher.pier.pier_type == ewcfg.fish_slime_void:
                response += "pond's black waters."

            user_data.hunger += ewcfg.hunger_perfish * ewutils.hunger_cost_mod(user_data.slimelevel)
            user_data.persist()

            await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

            bite_text = gen_bite_text(fisher.current_size)

            # User has a 1/10 chance to get a bite
            fun = 100

            if fisher.bait == True:
                # Bait attatched, chance to get a bite increases from 1/10 to 1/7
                fun -= 30
            if fisher.pier == ewcfg.poi_id_ferry:
                # Fisher is on the ferry, chance to get a bite increases from 1/10 to 1/9
                fun -= 10
            if ewcfg.mutation_id_lucky in mutations:
                fun -= 20
            if fisher.inhabitant_id:
                # Having your rod possessed increases your chance to get a bite by 50%
                fun = int(fun // 2)
            if high_value_bait_used:
                fun = 5

            bun = 0

            while not ewutils.TERMINATE:

                if fun <= 0:
                    fun = 1
                else:
                    damp = random.randrange(fun)

                if fisher.high:
                    await asyncio.sleep(30)
                elif high_value_bait_used:
                    await asyncio.sleep(5)
                else:
                    await asyncio.sleep(60)

                # Cancel if fishing was interrupted
                if current_fishing_id != fisher.fishing_id:
                    return
                if fisher.fishing == False:
                    return

                user_data = EwUser(member=cmd.message.author)

                if fisher.pier == "" or user_data.poi != fisher.pier.id_poi:
                    fisher.stop()
                    return
                if user_data.life_state == ewcfg.life_state_corpse:
                    fisher.stop()
                    return

                if damp > 10:
                    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, random.choice(comm_cfg.void_fishing_text if fisher.pier.pier_type == ewcfg.fish_slime_void else comm_cfg.normal_fishing_text)))
                    fun -= 2
                    bun += 1
                    if bun >= 5:
                        fun -= 1
                    if bun >= 15:
                        fun -= 1
                    continue
                else:
                    break

            fisher.bite = True
            await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, bite_text))

            await asyncio.sleep(8)

            if fisher.bite != False:
                response = "The fish got away..."
                response += cancel_rod_possession(fisher, user_data)
                fisher.stop()
                return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
            else:
                has_reeled = True

    else:
        response = "You can't fish here. Go to a pier."

    # Don't send out a response if the user actually reeled in a fish, since that gets sent by the reel command instead.
    if has_reeled == False:
        await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
예제 #6
0
async def reel(cmd):
    user_data = EwUser(member=cmd.message.author)

    if ewutils.channel_name_is_poi(cmd.message.channel.name) == False:
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "You must {} in a zone's channel.".format(cmd.tokens[0])))

    if cmd.message.author.id not in fishutils.fishers.keys():
        fishutils.fishers[cmd.message.author.id] = EwFisher()
    fisher = fishutils.fishers[cmd.message.author.id]
    poi = poi_static.id_to_poi.get(user_data.poi)

    if user_data.life_state == ewcfg.life_state_corpse:
        valid_possession = user_data.get_possession('rod')
        if valid_possession:
            inhabitee = user_data.get_inhabitee()
            fisher = fishutils.fishers[inhabitee] if inhabitee in fishutils.fishers.keys() else None
            if fisher:
                if fisher.bite == False:
                    fisher.fleshling_reeled = True
                    response = "You reeled in too early! You and your pal get nothing."
                    response += cancel_rod_possession(fisher, user_data)
                    fisher.fleshling_reeled = True
                    fisher.stop()
                else:
                    if fisher.fleshling_reeled:
                        response = await award_fish(fisher, cmd, user_data)
                        user_data = EwUser(member = cmd.message.author)
                    else:
                        fisher.ghost_reeled = True
                        response = "You reel in anticipation of your fleshy partner!"
            else:
                response = "You fleshy partner hasn't even cast their hook yet."
        else:
            response = "You can't fish while you're dead."

    elif user_data.poi in poi_static.piers:
        # Players who haven't cast a line cannot reel.
        if fisher.fishing == False:
            response = "You haven't cast your hook yet. Try !cast."

        # If a fish isn't biting, then a player reels in nothing.
        elif fisher.bite == False:
            response = ''
            if fisher.inhabitant_id:
                fisher.ghost_reeled = True
                response = "You reeled in too early! You and your pal get nothing."
                response += cancel_rod_possession(fisher, user_data)
            else:
                response = "You reeled in too early! Nothing was caught."
            fisher.stop()

        # On successful reel.
        else:
            if fisher.ghost_reeled or not fisher.inhabitant_id:
                response = await award_fish(fisher, cmd, user_data)
            else:
                fisher.fleshling_reeled = True
                response = "You reel in anticipation of your ghostly partner!"
    else:
        response = "You cast your fishing rod unto a sidewalk. That is to say, you've accomplished nothing. Go to a pier if you want to fish."

    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))