示例#1
0
async def negapool(cmd):
    # Add persisted negative slime.
    market_data = EwMarket(id_server=cmd.guild.id)
    negaslime = market_data.negaslime

    await fe_utils.send_message(
        cmd.client, cmd.message.channel,
        fe_utils.formatMessage(
            cmd.message.author,
            "The dead have a total of {:,} negative slime at their disposal for summoning."
            .format(negaslime)))
示例#2
0
def brickeat(item_obj):
    id_item = item_obj.id_item
    market = EwMarket(id_server=item_obj.id_server)
    pushedclock = ((market.clock + random.randint(6, 12)) % 24) + 1
    item_obj.item_props['furniture_name'] = 'brick{:02d}'.format(pushedclock)
    digestion = '{}brickshit'.format(item_obj.id_owner)
    print(digestion)
    item_obj.persist()
    bknd_item.give_item(id_item=id_item,
                        id_user=digestion,
                        id_server=item_obj.id_server)
示例#3
0
async def flutter(cmd):
    user_data = EwUser(member=cmd.message.author)
    if user_data.race == ewcfg.race_avian:
        district_data = EwDistrict(district=user_data.poi, id_server=cmd.guild.id)
        market_data = EwMarket(id_server=cmd.guild.id)
        response = "You flap your wings in an attempt to fly, but "
        excuses = []

        if market_data.weather == ewcfg.weather_lightning:
            excuses.append("the current weather would make that a bit dangerous, so you decide not to.")
        if ewcfg.mutation_id_bigbones in user_data.get_mutations():
            excuses.append("your bones are too big for you to get off the ground.")
        if ewcfg.mutation_id_lightasafeather in user_data.get_mutations():
            excuses.append("your wings are too skinny to generate enough lift.")

        if 6 <= market_data.clock >= 20:
            excuses.append("it's not safe to fly at night, so you decide not to.")
        else:
            excuses.append("flying in plain daylight might get you shot off the sky, so you decide not to.")

        if user_data.slimes > 1000000:
            excuses.append("you have too much slime on you, so you don't even get off the ground.")
        else:
            excuses.append("you're too weak for this right now, gonna need to get more slime.")

        if user_data.life_state == ewcfg.life_state_corpse:
            excuses.append("your incorporeal wings generate no lift.")
        elif user_data.life_state == ewcfg.life_state_juvenile:
            excuses.append("you lack the moral fiber to do so.")
        else:
            if user_data.faction == ewcfg.faction_rowdys:
                excuses.append("you end up thrashing with your wings in an unorganized fashion.")
            if user_data.faction == ewcfg.faction_killers:
                excuses.append("you end up doing rapid dabs instead.")

        if len(district_data.get_players_in_district()) > 1:
            excuses.append("it's embarassing to do so with other people around.")
        else:
            excuses.append("you can't be bothered if there's no one here to see you do it.")

        if user_data.hunger / user_data.get_hunger_max() < 0.5:
            excuses.append("you're too hungry, and end up looking for worms instead.")
        else:
            excuses.append("you're too full from your last meal for such vigorous exercise.")

        response += random.choice(excuses)
    else:
        response = "You people are not allowed to do that."

    return await fe_utils.send_response(response, cmd)
async def fursuit(cmd):
    user_data = EwUser(member=cmd.message.author)
    mutations = user_data.get_mutations()
    market_data = EwMarket(id_server=cmd.guild.id)

    if ewcfg.mutation_id_organicfursuit in mutations:
        days_until = -market_data.day % 31

        if days_until == 0:
            response = "Hair is beginning to grow on the surface of your skin rapidly. Your canine instincts will take over soon!"
        else:
            response = "With a basic hairy palm reading, you determine that you'll be particularly powerful in {} day{}.".format(days_until, "s" if days_until != 1 else "")

        if ewutils.check_fursuit_active(market_data):
            response = "The full moon shines above! Now's your chance to strike!"

    else:
        response = "You're about as hairless as an egg, my friend."

    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
示例#5
0
async def stock_market_tick(stock_data, id_server):
    market_data = EwMarket(id_server=id_server)
    company_data = EwCompany(id_server=id_server, stock=stock_data.id_stock)
    crashstate = EwGamestate(id_server=id_server,
                             id_state='stockcrashdive').bit

    # Nudge the value back to stability.
    market_rate = stock_data.market_rate
    if market_rate >= 1030:
        market_rate -= 10
    elif market_rate <= 970:
        market_rate += 10

    # Invest/Withdraw effects
    coin_rate = 0
    #stock_at_last_tick = EwStock(id_server=id_server, stock=stock_data.id_stock, timestamp=market_data.time_lasttick)
    #latest_stock = EwStock(id_server=id_server, stock=stock_data.id_stock)
    if stock_data.previous_entry != 0:
        total_shares = [stock_data.total_shares, stock_data.previous_entry[4]]
    else:
        total_shares = [
            stock_data.total_shares,
            EwStock(id_server=id_server,
                    stock=stock_data.id_stock,
                    timestamp=market_data.time_lasttick).total_shares
        ]

    # Add profit bonus.
    profits = company_data.recent_profits
    profit_bonus = profits / 100  # - 1 * ((latest_stock.exchange_rate / ewcfg.default_stock_exchange_rate) ** 0.2)
    profit_bonus = min(50, max(profit_bonus, -50))
    market_rate += (profit_bonus / 2)

    if total_shares[0] != total_shares[1]:
        # Positive if net investment, negative if net withdrawal.
        coin_change = (total_shares[0] - total_shares[1])
        coin_rate = ((coin_change * 1.0) /
                     total_shares[1] if total_shares[1] != 0 else 1)

        if coin_rate > 1.0:
            coin_rate = 1.0
        elif coin_rate < -0.5:
            coin_rate = -0.5

        coin_rate = round((coin_rate *
                           ewcfg.max_iw_swing) if coin_rate > 0 else (
                               coin_rate * 2 * ewcfg.max_iw_swing))

    market_rate += coin_rate

    # Tick down the boombust cooldown.
    if stock_data.boombust < 0:
        stock_data.boombust += 1
    elif stock_data.boombust > 0:
        stock_data.boombust -= 1

    # Adjust the market rate.
    fluctuation = 0  # (random.randrange(5) - 2) * 100
    noise = (random.randrange(19) - 9) * 2
    subnoise = (random.randrange(13) - 6)

    # Some extra excitement!
    if noise == 0 and subnoise == 0:
        boombust = (random.randrange(3) - 1) * 200

        if crashstate == 1 and boombust > 0:
            boombust = -boombust

        # If a boombust occurs shortly after a previous boombust, make sure it's the opposite effect. (Boom follows bust, bust follows boom.)
        if (stock_data.boombust > 0
                and boombust > 0) or (stock_data.boombust < 0
                                      and boombust < 0):
            boombust *= -1

        if boombust != 0:
            stock_data.boombust = ewcfg.cd_boombust

            if boombust < 0:
                stock_data.boombust *= -1
    else:
        boombust = 0

    market_rate += fluctuation + noise + subnoise + boombust

    if market_rate > 500 and crashstate == 1:
        market_rate = round(market_rate / 1.25)

    if market_rate < 300:
        market_rate = (300 + noise + subnoise)

    # percentage = ((market_rate / 10) - 100)
    # percentage_abs = percentage * -1

    exchange_rate_increase = round(
        (market_rate - ewcfg.default_stock_market_rate) *
        min(stock_data.exchange_rate, ewcfg.default_stock_exchange_rate) /
        ewcfg.default_stock_market_rate)

    percentage = exchange_rate_increase / stock_data.exchange_rate
    percentage_abs = percentage * -1

    # negative exchange rate causes problems, duh
    # exchange_rate_increase = max(exchange_rate_increase, -stock_data.exchange_rate + 1000)

    points = abs(exchange_rate_increase / 1000.0)

    stock_data.exchange_rate += exchange_rate_increase
    stock_data.market_rate = market_rate

    # Give some indication of how the market is doing to the users.
    response = ewcfg.stock_emotes.get(
        stock_data.id_stock) + ' ' + ewcfg.stock_names.get(
            stock_data.id_stock) + ' '

    if stock_data.exchange_rate < 1000:
        response += 'has gone bankrupt!'
        if stock_data.total_shares > 0:
            majority_shareholder = get_majority_shareholder(
                stock=stock_data.id_stock, id_server=id_server)
            player_data = EwPlayer(id_user=majority_shareholder)
            shares = getUserTotalShares(stock=stock_data.id_stock,
                                        id_user=majority_shareholder,
                                        id_server=stock_data.id_server)
            shares_lost = round(shares * 0.9)
            stock_data.total_shares -= shares_lost
            updateUserTotalShares(stock=stock_data.id_stock,
                                  id_user=majority_shareholder,
                                  id_server=stock_data.id_server,
                                  shares=shares - shares_lost)
            response += ' The majority shareholder {} is held responsible. SlimeCorp seizes 90% of their shares in the company to pay for the damages.'.format(
                player_data.display_name)
            stock_data.exchange_rate = 10000
        else:
            response += ' SlimeCorp pumps several billion slimecoin into bailing the company out and a new image campaign.'
            stock_data.exchange_rate = ewcfg.default_stock_exchange_rate
            stock_data.market_rate = ewcfg.default_stock_market_rate
    else:
        # Market is up ...
        if market_rate > 1200:
            response += 'is skyrocketing!!! Slime stock is up {p:.3g} points!!!'.format(
                p=points)
        elif market_rate > 1100:
            response += 'is booming! Slime stock is up {p:.3g} points!'.format(
                p=points)
        elif market_rate > 1000:
            response += 'is doing well. Slime stock is up {p:.3g} points.'.format(
                p=points)
        # Market is down ...
        elif market_rate < 800:
            response += 'is plummeting!!! Slime stock is down {p:.3g} points!!!'.format(
                p=points)
        elif market_rate < 900:
            response += 'is stagnating! Slime stock is down {p:.3g} points!'.format(
                p=points)
        elif market_rate < 1000:
            response += 'is a bit sluggish. Slime stock is down {p:.3g} points.'.format(
                p=points)
        # Perfectly balanced
        else:
            response += 'is holding steady. No change in slime stock value.'

    response += ' ' + ewcfg.stock_emotes.get(stock_data.id_stock)

    stock_data.persist()

    company_data.total_profits += company_data.recent_profits
    company_data.recent_profits = 0
    company_data.persist()

    # Send the announcement.
    return response
示例#6
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))
示例#7
0
async def withdraw(cmd):
    user_data = EwUser(member=cmd.message.author)
    if user_data.life_state == ewcfg.life_state_shambler:
        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))

    time_now = round(time.time())
    market_data = EwMarket(id_server=cmd.message.author.guild.id)

    if market_data.clock < 6 or market_data.clock >= 20:
        response = ewcfg.str_exchange_closed
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    if cmd.message.channel.name != ewcfg.channel_stockexchange:  # or user_data.poi != ewcfg.poi_id_downtown:
        # Only allowed in the stock exchange.
        response = ewcfg.str_exchange_channelreq.format(currency="SlimeCoin", action="withdraw")
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    poi = poi_static.id_to_poi.get(user_data.poi)
    district_data = EwDistrict(district=poi.id_poi, id_server=user_data.id_server)

    if district_data.is_degraded():
        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))

    if user_data.life_state == ewcfg.life_state_corpse:
        # Disallow withdraws from ghosts.
        response = "Your slimebroker can't confirm your identity while you're dead."
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    else:
        value = None
        stock = None

        if cmd.tokens_count > 1:
            value = ewutils.getIntToken(cmd.tokens[1:], allow_all=True)

            for token in cmd.tokens[1:]:
                if token.lower() in ewcfg.stocks:
                    stock = token.lower()
                    break

        if stock != None:
            stock = EwStock(id_server=cmd.guild.id, stock=stock)

            total_shares = market_utils.getUserTotalShares(id_server=user_data.id_server, stock=stock.id_stock, id_user=user_data.id_user)

            if value != None:
                if value < 0:
                    value = total_shares
                if value <= 0:
                    value = None

            if value != None:

                if value <= total_shares:
                    exchange_rate = (stock.exchange_rate / 1000.0)

                    shares = value
                    slimecoin = round(value * exchange_rate)

                    if user_data.time_lastinvest + ewcfg.cd_invest > time_now:
                        # Limit frequency of withdrawals
                        response = ewcfg.str_exchange_busy.format(action="withdraw")
                    else:
                        user_data.change_slimecoin(n=slimecoin, coinsource=ewcfg.coinsource_withdraw)
                        total_shares -= shares
                        user_data.time_lastinvest = time_now
                        stock.total_shares -= shares

                        response = "You exchange {shares:,} shares in {stock} for {coins:,} SlimeCoin.".format(coins=slimecoin, shares=shares, stock=ewcfg.stock_names.get(stock.id_stock))
                        user_data.persist()
                        stock.timestamp = round(time.time())
                        stock.persist()
                        market_utils.updateUserTotalShares(id_server=user_data.id_server, stock=stock.id_stock, id_user=user_data.id_user, shares=total_shares)
                else:
                    response = "You don't have that many shares in {stock} to exchange.".format(stock=ewcfg.stock_names.get(stock.id_stock))
            else:
                response = ewcfg.str_exchange_specify.format(currency="SlimeCoin", action="withdraw")
        else:
            response = "That's not a valid stock name, please use a proper one, you c**t: {}".format(ewutils.formatNiceList(names=ewcfg.stocks))

    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
示例#8
0
async def xfer(cmd):
    time_now = round(time.time())
    user_data = EwUser(member=cmd.message.author)
    if user_data.life_state == ewcfg.life_state_shambler:
        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))

    if cmd.message.channel.name != ewcfg.channel_stockexchange:
        # Only allowed in the stock exchange.
        response = ewcfg.str_exchange_channelreq.format(currency="SlimeCoin", action="transfer")
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    poi = poi_static.id_to_poi.get(user_data.poi)
    district_data = EwDistrict(district=poi.id_poi, id_server=user_data.id_server)

    if district_data.is_degraded():
        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))

    if cmd.mentions_count != 1:
        # Must have exactly one target to send to.
        response = "Mention the player you want to send SlimeCoin to."
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    if user_data.time_lastinvest + ewcfg.cd_invest > time_now:
        # Limit frequency of transfers
        response = ewcfg.str_exchange_busy.format(action="transfer slimecoin")
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    if user_data.life_state == ewcfg.life_state_corpse:
        # Disallow transfers from ghosts.
        response = "Your slimebroker can't confirm your identity while you're dead."
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    member = cmd.mentions[0]
    target_data = EwUser(member=member)

    if target_data.life_state == ewcfg.life_state_kingpin:
        # Disallow transfers to RF and CK kingpins.
        response = "You can't transfer SlimeCoin to a known criminal warlord."
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

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

    if cmd.message.author.id == member.id:
        slimes_total = user_data.slimes
        slimes_drained = int(slimes_total * 0.1)
        slimes_todistrict = slimes_total - slimes_drained

        sewer_data = EwDistrict(district=ewcfg.poi_id_thesewers, id_server=user_data.id_server)
        sewer_data.change_slimes(n=slimes_drained)
        sewer_data.persist()

        district_data = EwDistrict(district=user_data.poi, id_server=cmd.guild.id)
        district_data.change_slimes(n=slimes_todistrict, source=ewcfg.source_killing)
        district_data.persist()

        # Set the id_killer to the player himself, remove his slime and slime poudrins.
        user_data.id_killer = cmd.message.author.id
        user_data.visiting = ewcfg.location_id_empty
        user_data.trauma = ewcfg.trauma_id_environment

        user_data.die(cause=ewcfg.cause_suicide)
        user_data.persist()

        await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "Gaming the slimeconomy is punishable by death. SlimeCorp soldiers execute you immediately."))
        await ewrolemgr.updateRoles(client=cmd.client, member=cmd.message.author)
        return

    # Parse the slime value to send.
    value = None
    if cmd.tokens_count > 1:
        value = ewutils.getIntToken(tokens=cmd.tokens)

    if value != None:
        if value < 0:
            value = user_data.slimes
        if value <= 0:
            value = None

    if value != None:
        # Cost including the transfer fee.
        cost_total = round(value * 1.1)

        if user_data.slimecoin < cost_total:
            response = "You don't have enough SlimeCoin. ({:,}/{:,})".format(user_data.slimecoin, cost_total)
        else:
            # Do the transfer if the player can afford it.
            target_data.change_slimecoin(n=value, coinsource=ewcfg.coinsource_transfer)
            user_data.change_slimecoin(n=-cost_total, coinsource=ewcfg.coinsource_transfer)
            user_data.time_lastinvest = time_now

            # Persist changes
            response = "You transfer {slime:,} SlimeCoin to {target_name}. Your slimebroker takes his nominal fee of {fee:,} SlimeCoin.".format(slime=value, target_name=member.display_name, fee=(cost_total - value))

            target_data.persist()
            user_data.persist()
    else:
        response = ewcfg.str_exchange_specify.format(currency="SlimeCoin", action="transfer")

    # Send the response to the player.
    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
示例#9
0
async def redeem(cmd):
    user_data = EwUser(member=cmd.message.author)
    if user_data.life_state == ewcfg.life_state_shambler:
        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))

    time_now = round(time.time())
    market_data = EwMarket(id_server=cmd.message.author.guild.id)

    if market_data.clock < 6 or market_data.clock >= 20:
        response = ewcfg.str_exchange_closed
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    if user_data.time_lastinvest + ewcfg.cd_invest > time_now:
        response = ewcfg.str_exchange_busy.format(action="redeem")

    if cmd.message.channel.name != ewcfg.channel_stockexchange:  # or user_data.poi != ewcfg.poi_id_downtown:
        # Only allowed in the stock exchange.
        response = ewcfg.str_exchange_channelreq.format(currency="SlimeCoin", action="redeem")
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    poi = poi_static.id_to_poi.get(user_data.poi)
    district_data = EwDistrict(district=poi.id_poi, id_server=user_data.id_server)

    if district_data.is_degraded():
        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))

    if user_data.life_state == ewcfg.life_state_corpse:
        # Disallow withdraws from ghosts.
        response = "Your slimebroker can't confirm your identity while you're dead."
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    else:
        slimecoin_exchange_rate = 25000000000000  # 25 trillion slime

        redeem_value = round(user_data.slimecoin / slimecoin_exchange_rate)

        if redeem_value <= 0:
            response = "Sadly, you haven't made enough Slimecoin to reedeem any slime!"

        else:
            response = ""

            if user_data.life_state == ewcfg.life_state_enlisted:
                response = "After you dot all the i’s and cross all the t’s, you immediately send your Kingpin half of your earnings."
                role_boss = (ewcfg.role_copkiller if user_data.faction == ewcfg.faction_killers else ewcfg.role_rowdyfucker)
                kingpin = fe_utils.find_kingpin(id_server=cmd.guild.id, kingpin_role=role_boss)
                kingpin = EwUser(id_server=cmd.guild.id, id_user=kingpin.id_user)
                if kingpin:
                    kingpin.change_slimes(n=int(redeem_value / 2))
                    kingpin.persist()

            else:
                response = "Your slimebroker pulls a fast one on you and gets you to sign a waiver that lets SlimeCorp keep half of your supposedly redeemed slime. Damn."

            response += "You walk out with {:,}.".format(int(redeem_value / 2))
            user_data.slimes += int(redeem_value / 2)
            user_data.slimecoin = round(user_data.slimecoin % slimecoin_exchange_rate)
            user_data.persist()

    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
示例#10
0
async def scavenge(cmd):
    market_data = EwMarket(id_server=cmd.message.author.guild.id)
    user_data = EwUser(member=cmd.message.author)
    mutations = user_data.get_mutations()

    time_now = int(time.time())
    response = ""

    time_since_last_scavenge = time_now - user_data.time_lastscavenge

    # Kingpins can't scavenge.
    if user_data.life_state == ewcfg.life_state_kingpin or user_data.life_state == ewcfg.life_state_grandfoe:
        return

    # ghosts cant scavenge
    if user_data.life_state == ewcfg.life_state_corpse:
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "What would you want to do that for? You're a ghost, you have no need for such lowly materialistic possessions like slime. You only engage in intellectual pursuits now. {} if you want to give into your base human desire to see numbers go up.".format(ewcfg.cmd_revive)))
    # currently not active - no cooldown
    if time_since_last_scavenge < ewcfg.cd_scavenge:
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "Slow down, you filthy hyena."))

    if user_data.poi == ewcfg.poi_id_slimesea:
        if user_data.life_state == ewcfg.life_state_shambler:
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "Are you trying to grab random trash instead of !searchingforbrainz? Pretty cringe bro..."))
        else:
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "You consider diving down to the bottom of the sea to grab some sick loot, but quickly change your mind when you {}.".format(random.choice(ewcfg.sea_scavenge_responses))))

    # Scavenge only in location channels
    if ewutils.channel_name_is_poi(cmd.message.channel.name) == True:
        if user_data.hunger >= user_data.get_hunger_max():
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "You are too exhausted to scrounge up scraps of slime off the street! Go get some grub!"))
        else:

            if juviecmdutils.scavenge_combos.get(user_data.id_user) == None:
                juviecmdutils.scavenge_combos[user_data.id_user] = 0

            combo = juviecmdutils.scavenge_combos.get(user_data.id_user)

            district_data = EwDistrict(district=user_data.poi, id_server=cmd.message.author.guild.id)

            user_initial_level = user_data.slimelevel
            # add scavenged slime to user
            if ewcfg.mutation_id_trashmouth in mutations:
                combo += 5

            time_since_last_scavenge = min(max(1, time_since_last_scavenge), ewcfg.soft_cd_scavenge)

            # scavenge_mod = 0.003 * (time_since_last_scavenge ** 0.9)
            scavenge_mod = 0.005 * combo

            if (ewcfg.mutation_id_whitenationalist in mutations or ewcfg.mutation_id_airlock in mutations) and market_data.weather == "snow":
                scavenge_mod *= 1.5

            if ewcfg.mutation_id_airlock in mutations and market_data.weather == "snow":
                scavenge_mod *= 1.5

            if ewcfg.mutation_id_webbedfeet in mutations:
                district_slimelevel = len(str(district_data.slimes))
                scavenge_mod *= max(1, min(district_slimelevel - 3, 4))

            scavenge_yield = math.floor(scavenge_mod * district_data.slimes)

            levelup_response = user_data.change_slimes(n=scavenge_yield, source=ewcfg.source_scavenging)
            district_data.change_slimes(n=-1 * scavenge_yield, source=ewcfg.source_scavenging)
            district_data.persist()

            if levelup_response != "":
                response += levelup_response + "\n\n"
            # response += "You scrape together {} slime from the streets.\n\n".format(scavenge_yield)
            if cmd.tokens_count > 1:

                item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])
                has_comboed = False

                if juviecmdutils.scavenge_combos.get(user_data.id_user) > 0 and (time_now - user_data.time_lastscavenge) < 60:
                    if juviecmdutils.scavenge_captchas.get(user_data.id_user).lower() == item_search.lower():
                        juviecmdutils.scavenge_combos[user_data.id_user] += 1
                        new_captcha = gen_scavenge_captcha(n=juviecmdutils.scavenge_combos.get(user_data.id_user), user_data=user_data)
                        response += "New captcha: **" + ewutils.text_to_regional_indicator(new_captcha) + "**"
                        if ewcfg.mutation_id_webbedfeet in mutations:
                            response += "\nYour flippers pick up {:,} slime.".format(scavenge_yield)
                        juviecmdutils.scavenge_captchas[user_data.id_user] = new_captcha
                        has_comboed = True

                        if ewcfg.mutation_id_dumpsterdiver in mutations:
                            has_comboed = False
                            item_search = item_search[random.randrange(len(item_search))]

                    else:
                        juviecmdutils.scavenge_combos[user_data.id_user] = 0

                if not has_comboed:
                    loot_resp = itm_utils.item_lootspecific(
                        user_data=user_data,
                        item_search=item_search
                    )

                    if loot_resp != "":
                        response = loot_resp + "\n\n" + response

            else:
                loot_multiplier = 1.0 + bknd_item.get_inventory_size(owner=user_data.poi, id_server=user_data.id_server)
                loot_chance = loot_multiplier / ewcfg.scavenge_item_rarity
                if ewcfg.mutation_id_dumpsterdiver in mutations:
                    loot_chance *= 10
                if random.random() < loot_chance:
                    loot_resp = itm_utils.item_lootrandom(
                        user_data
                    )

                    if loot_resp != "":
                        response += loot_resp + "\n\n"

                juviecmdutils.scavenge_combos[user_data.id_user] = 1
                new_captcha = gen_scavenge_captcha(n=1, user_data=user_data)
                response += "New captcha: **" + ewutils.text_to_regional_indicator(new_captcha) + "**"
                if ewcfg.mutation_id_webbedfeet in mutations:
                    response += "\nYour flippers pick up {:,} slime.".format(scavenge_yield)
                juviecmdutils.scavenge_captchas[user_data.id_user] = new_captcha

            # Fatigue the scavenger.
            hunger_cost_mod = ewutils.hunger_cost_mod(user_data.slimelevel)
            extra = hunger_cost_mod - int(hunger_cost_mod)  # extra is the fractional part of hunger_cost_mod

            user_data.hunger += ewcfg.hunger_perscavenge * int(hunger_cost_mod)
            if extra > 0:  # if hunger_cost_mod is not an integer
                # there's an x% chance that an extra stamina is deducted, where x is the fractional part of hunger_cost_mod in percent (times 100)
                if random.randint(1, 100) <= extra * 100:
                    user_data.hunger += ewcfg.hunger_perscavenge

            user_data.time_lastscavenge = time_now

            user_data.persist()

            # gangsters don't need their roles updated
            if user_data.life_state == ewcfg.life_state_juvenile:
                await ewrolemgr.updateRoles(client=cmd.client, member=cmd.message.author)

            if not response == "":
                return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    else:
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "You'll find no slime here, this place has been picked clean. Head into the city to try and scavenge some slime."))
示例#11
0
async def flag(cmd):
    market_data = EwMarket(id_server=cmd.message.author.guild.id)
    user_data = EwUser(member=cmd.message.author)
    mutations = user_data.get_mutations()
    if user_data.life_state == ewcfg.life_state_shambler:
        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))

    mutations = user_data.get_mutations()
    time_now = int(time.time())

    response = ""
    # Kingpins can't mine.
    if user_data.life_state == ewcfg.life_state_kingpin or user_data.life_state == ewcfg.life_state_grandfoe:
        return

    # ghosts cant mine (anymore)
    if user_data.life_state == ewcfg.life_state_corpse:
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "You can't mine while you're dead. Try {}.".format(ewcfg.cmd_revive)))

    # Enlisted players only mine at certain times.
    if user_data.life_state == ewcfg.life_state_enlisted:
        if user_data.faction == ewcfg.faction_rowdys and (market_data.clock < 8 or market_data.clock > 17) and ewcfg.mutation_id_lightminer not in mutations:
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "Rowdies only mine in the daytime. Wait for full daylight at 8am.".format(ewcfg.cmd_revive)))

        if user_data.faction == ewcfg.faction_killers and (market_data.clock < 20 and market_data.clock > 5) and ewcfg.mutation_id_lightminer not in mutations:
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "Killers only mine under cover of darkness. Wait for nightfall at 8pm.".format(ewcfg.cmd_revive)))

    # Mine only in the mines.
    if cmd.message.channel.name in ewcfg.mining_channels:
        poi = poi_static.id_to_poi.get(user_data.poi)
        district_data = EwDistrict(district=poi.id_poi, id_server=user_data.id_server)

        if district_data.is_degraded():
            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))

        if user_data.hunger >= user_data.get_hunger_max():
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "You've exhausted yourself from mining. You'll need some refreshment before getting back to work."))

        else:
            printgrid = True
            hunger_cost_mod = ewutils.hunger_cost_mod(user_data.slimelevel)
            extra = hunger_cost_mod - int(hunger_cost_mod)  # extra is the fractional part of hunger_cost_mod

            mining_type = ewcfg.mines_mining_type_map.get(user_data.poi)

            if mining_type != ewcfg.mining_type_minesweeper:
                response = "What do you think you can flag here?"
                return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

            if user_data.poi not in juviecmdutils.mines_map:
                response = "You can't mine here! Go to the mines in Juvie's Row, Toxington, or Cratersville!"
                return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
            elif user_data.id_server not in juviecmdutils.mines_map.get(user_data.poi):
                init_grid(user_data.poi, user_data.id_server)
                printgrid = True

            grid_cont = juviecmdutils.mines_map.get(user_data.poi).get(user_data.id_server)
            grid = grid_cont.grid

            grid_type = ewcfg.grid_type_by_mining_type.get(mining_type)
            if grid_type != grid_cont.grid_type:
                init_grid(user_data.poi, user_data.id_server)
                printgrid = True
                grid_cont = juviecmdutils.mines_map.get(user_data.poi).get(user_data.id_server)
                grid = grid_cont.grid

            row = -1
            col = -1
            if cmd.tokens_count < 2:
                response = "Please specify which Minesweeper vein to flag."
                return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

            for token in cmd.tokens[1:]:

                coords = token.lower()
                if col < 1:

                    for char in coords:
                        if char in ewcfg.alphabet:
                            col = ewcfg.alphabet.index(char)
                            coords = coords.replace(char, "")
                if row < 1:
                    try:
                        row = int(coords)
                    except:
                        row = -1

            row -= 1

            if row not in range(len(grid)) or col not in range(len(grid[row])):
                response = "Invalid Minesweeper vein."


            elif grid[row][col] == ewcfg.cell_empty_marked:
                grid[row][col] = ewcfg.cell_empty

            elif grid[row][col] == ewcfg.cell_mine_marked:
                grid[row][col] = ewcfg.cell_mine

            elif grid[row][col] == ewcfg.cell_empty_open:
                response = "This vein has already been mined dry."

            elif grid[row][col] == ewcfg.cell_mine:
                grid[row][col] = ewcfg.cell_mine_marked

            elif grid[row][col] == ewcfg.cell_empty:
                grid[row][col] = ewcfg.cell_empty_marked

            if printgrid:
                await print_grid(cmd)


    else:
        response = "You can't mine here! Go to the mines in Juvie's Row, Toxington, or Cratersville!"

    if len(response) > 0:
        await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
示例#12
0
async def mine(cmd):
    market_data = EwMarket(id_server=cmd.message.author.guild.id)
    user_data = EwUser(member=cmd.message.author)
    if user_data.life_state == ewcfg.life_state_shambler:
        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))

    mutations = user_data.get_mutations()
    cosmetic_abilites = itm_utils.get_cosmetic_abilities(id_user=cmd.message.author.id, id_server=cmd.guild.id)
    time_now = int(time.time())
    poi = poi_static.id_to_poi.get(user_data.poi)

    response = ""
    # Kingpins can't mine.
    if user_data.life_state == ewcfg.life_state_kingpin or user_data.life_state == ewcfg.life_state_grandfoe:
        return

    # ghosts cant mine (anymore)
    if user_data.life_state == ewcfg.life_state_corpse:
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "You can't mine while you're dead. Try {}.".format(ewcfg.cmd_revive)))

    # Enlisted players only mine at certain times.
    if user_data.life_state == ewcfg.life_state_enlisted:
        if user_data.faction == ewcfg.faction_rowdys and (market_data.clock < 8 or market_data.clock > 17):
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "Rowdies only mine in the daytime. Wait for full daylight at 8am.".format(ewcfg.cmd_revive)))

        if user_data.faction == ewcfg.faction_killers and (market_data.clock < 20 and market_data.clock > 5):
            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "Killers only mine under cover of darkness. Wait for nightfall at 8pm.".format(ewcfg.cmd_revive)))

    # Mine only in the mines.
    if cmd.message.channel.name in ewcfg.mining_channels:
        poi = poi_static.id_to_poi.get(user_data.poi)
        district_data = EwDistrict(district=poi.id_poi, id_server=user_data.id_server)

        if district_data.is_degraded():
            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))

        if user_data.hunger >= user_data.get_hunger_max():
            return await mismine(cmd, user_data, "exhaustion")
        # return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "You've exhausted yourself from mining. You'll need some refreshment before getting back to work."))

        else:
            printgrid = True
            hunger_cost_mod = ewutils.hunger_cost_mod(user_data.slimelevel)
            extra = hunger_cost_mod - int(hunger_cost_mod)  # extra is the fractional part of hunger_cost_mod

            world_events = bknd_worldevent.get_world_events(id_server=cmd.guild.id)
            mining_type = ewcfg.mines_mining_type_map.get(user_data.poi)
            for id_event in world_events:

                if world_events.get(id_event) == ewcfg.event_type_minecollapse:
                    event_data = EwWorldEvent(id_event=id_event)
                    if int(event_data.event_props.get('id_user')) == user_data.id_user and event_data.event_props.get('poi') == user_data.poi:
                        captcha = event_data.event_props.get('captcha').lower()
                        tokens_lower = []
                        for token in cmd.tokens[1:]:
                            tokens_lower.append(token.lower())

                        if captcha in tokens_lower:
                            bknd_worldevent.delete_world_event(id_event=id_event)
                            response = "You escape from the collapsing mineshaft."
                            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
                        elif ewcfg.mutation_id_lightminer in mutations:
                            bknd_worldevent.delete_world_event(id_event=id_event)
                            response = "You nimbly step outside the collapse without even thinking about it."
                            return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
                        else:
                            return await mismine(cmd, user_data, ewcfg.event_type_minecollapse)

            if user_data.poi not in juviecmdutils.mines_map:
                response = "You can't mine here! Go to the mines in Juvie's Row, Toxington, or Cratersville!"
                return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
            elif user_data.id_server not in juviecmdutils.mines_map.get(user_data.poi):
                init_grid(user_data.poi, user_data.id_server)
                printgrid = True

            grid_cont = juviecmdutils.mines_map.get(user_data.poi).get(user_data.id_server)
            grid = grid_cont.grid

            grid_type = ewcfg.grid_type_by_mining_type.get(mining_type)
            if grid_type != grid_cont.grid_type:
                init_grid(user_data.poi, user_data.id_server)
                printgrid = True
                grid_cont = juviecmdutils.mines_map.get(user_data.poi).get(user_data.id_server)
                grid = grid_cont.grid

            # minesweeper = True
            # grid_multiplier = grid_cont.cells_mined ** 0.4
            # flag = False
            mining_yield = get_mining_yield_by_grid_type(cmd, grid_cont)

            if type(mining_yield) == type(""):
                response = mining_yield
                if len(response) > 0:
                    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
                if time_now > grid_cont.time_last_posted + 10:
                    await print_grid(cmd)
                return

            if mining_yield == 0:
                user_data.hunger += ewcfg.hunger_permine * int(hunger_cost_mod)
                user_data.persist()
                # response = "This vein has already been mined dry."
                # await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
                if printgrid:
                    return await print_grid(cmd)
                else:
                    return

            has_pickaxe = 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 == ewcfg.weapon_id_pickaxe or weapon.id_weapon == ewcfg.weapon_id_diamondpickaxe)  and user_data.life_state != ewcfg.life_state_juvenile:
                    has_pickaxe = True
            # if user_data.sidearm >= 0:
            #	sidearm_item = EwItem(id_item=user_data.sidearm)
            #	sidearm = static_weapons.weapon_map.get(sidearm_item.item_props.get("weapon_type"))
            #	if sidearm.id_weapon == ewcfg.weapon_id_pickaxe:
            #		has_pickaxe = True

            # Determine if an item is found.
            unearthed_item = False
            unearthed_item_amount = (random.randrange(3) + 5)  # anywhere from 5-7 drops

            # juvies get items 4 times as often as enlisted players
            unearthed_item_chance = 1 / ewcfg.unearthed_item_rarity
            if user_data.life_state == ewcfg.life_state_juvenile:
                unearthed_item_chance *= 2
            if has_pickaxe == True:
                unearthed_item_chance *= 1.5
            if ewcfg.mutation_id_lucky in mutations:
                unearthed_item_chance *= 1.33
            if ewcfg.cosmeticAbility_id_lucky in cosmetic_abilites:
                unearthed_item_chance *= 1.33

            # event bonus
            for id_event in world_events:

                if world_events.get(id_event) == ewcfg.event_type_slimefrenzy:
                    event_data = EwWorldEvent(id_event=id_event)
                    if event_data.event_props.get('poi') == user_data.poi and int(event_data.event_props.get('id_user')) == user_data.id_user:
                        mining_yield *= 2

                if world_events.get(id_event) == ewcfg.event_type_poudrinfrenzy:
                    event_data = EwWorldEvent(id_event=id_event)
                    if event_data.event_props.get('poi') == user_data.poi and int(event_data.event_props.get('id_user')) == user_data.id_user:
                        unearthed_item_chance = 1
                        unearthed_item_amount = 1

            if random.random() < 0.05:
                id_event = create_mining_event(cmd)
                event_data = EwWorldEvent(id_event=id_event)

                if event_data.id_event == -1:
                    return ewutils.logMsg("Error couldn't find world event with id {}".format(id_event))

                if event_data.event_type == ewcfg.event_type_slimeglob:
                    mining_yield *= 4
                    bknd_worldevent.delete_world_event(id_event=id_event)

                if event_data.time_activate <= time.time():

                    event_def = poi_static.event_type_to_def.get(event_data.event_type)
                    if event_def == None:
                        return ewutils.logMsg("Error, couldn't find event def for event type {}".format(event_data.event_type))
                    str_event_start = event_def.str_event_start

                    if event_data.event_type == ewcfg.event_type_minecollapse:
                        str_event_start = str_event_start.format(cmd=ewcfg.cmd_mine, captcha=ewutils.text_to_regional_indicator(event_data.event_props.get('captcha')))
                        await fe_utils.send_response(str_event_start, cmd)
                        event_data.time_expir = time_now + 60
                        event_data.persist()
                        str_event_start = ""

                    if str_event_start != "":
                        response += str_event_start + "\n"

            if random.random() < unearthed_item_chance:
                unearthed_item = True

            if unearthed_item == True:
                # If there are multiple possible products, randomly select one.
                item = random.choice(vendors.mine_results)

                if bknd_item.check_inv_capacity(user_data=user_data, item_type=item.item_type):

                    item_props = itm_utils.gen_item_props(item)

                    for creation in range(unearthed_item_amount):
                        bknd_item.item_create(
                            item_type=item.item_type,
                            id_user=cmd.message.author.id,
                            id_server=cmd.guild.id,
                            item_props=item_props
                        )

                    if unearthed_item_amount == 1:
                        response += "You unearthed a {}! ".format(item.str_name)
                    else:
                        response += "You unearthed {} {}s! ".format(unearthed_item_amount, item.str_name)

                    ewstats.change_stat(user=user_data, metric=ewcfg.stat_lifetime_poudrins, n=unearthed_item_amount)

            # ewutils.logMsg('{} has found {} {}(s)!'.format(cmd.message.author.display_name, item.str_name, unearthed_item_amount))

            user_initial_level = user_data.slimelevel

            # Add mined slime to the user.
            slime_bylevel = ewutils.slime_bylevel(user_data.slimelevel)

            # mining_yield = math.floor((slime_bylevel / 10) + 1)
            # alternate_yield = math.floor(200 + slime_bylevel ** (1 / math.e))

            # mining_yield = min(mining_yield, alternate_yield)

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

            if controlling_faction != "" and controlling_faction == user_data.faction:
                mining_yield *= 2

            if has_pickaxe == True:
                mining_yield *= 2
            if user_data.life_state == ewcfg.life_state_juvenile:
                mining_yield *= 2

            # trauma = se_static.trauma_map.get(user_data.trauma)
            # if trauma != None and trauma.trauma_class == ewcfg.trauma_class_slimegain:
            #	mining_yield *= (1 - 0.5 * user_data.degradation / 100)

            mining_yield = max(0, round(mining_yield))

            # Fatigue the miner.

            user_data.hunger += ewcfg.hunger_permine * int(hunger_cost_mod)
            if extra > 0:  # if hunger_cost_mod is not an integer
                # there's an x% chance that an extra stamina is deducted, where x is the fractional part of hunger_cost_mod in percent (times 100)
                if random.randint(1, 100) <= extra * 100:
                    user_data.hunger += ewcfg.hunger_permine

            levelup_response = user_data.change_slimes(n=mining_yield, source=ewcfg.source_mining)

            was_levelup = True if user_initial_level < user_data.slimelevel else False

            # Tell the player their slime level increased and/or they unearthed an item.
            if was_levelup:
                response += levelup_response

            user_data.persist()

            if printgrid:
                await print_grid(cmd)

            # gangsters don't need their roles updated
            if user_data.life_state == ewcfg.life_state_juvenile:
                await ewrolemgr.updateRoles(client=cmd.client, member=cmd.message.author)

    else:
        return await mismine(cmd, user_data, "channel")
    # response = "You can't mine here! Go to the mines in Juvie's Row, Toxington, or Cratersville!"

    if len(response) > 0:
        await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
示例#13
0
async def handle_hourly_events(id_server=None):
    if id_server != None:
        client = ewutils.get_client()
        server = client.get_guild(id_server)
        time_current = EwMarket(id_server=id_server).clock

        events = bknd_event.get_world_events(id_server, True)
        for we_id, we_type in events.items():
            if we_type in ewcfg.hourly_events:
                we = EwWorldEvent(id_event=we_id)
                if we.event_props.get("time") == str(time_current):
                    # Handle brickshitting code
                    if we_type == ewcfg.event_type_brickshit:

                        brick_obj = EwItem(
                            id_item=we.event_props.get("brick_id"))
                        id_user = brick_obj.id_owner.replace("stomach", "")
                        brick_user = EwUser(id_server=id_server,
                                            id_user=id_user)
                        brick_member = server.get_member(user_id=int(id_user))
                        poi = poi_static.id_to_poi.get(brick_user.poi)
                        channel_brick = fe_utils.get_channel(
                            server, poi.channel)
                        if brick_member:
                            try:
                                await fe_utils.send_message(
                                    client, channel_brick,
                                    fe_utils.formatMessage(
                                        brick_member,
                                        "UUUUUUUUUUGGGGGGGGGGGGHHHHHHHHHHH... OOOOOOOOOOOOOOOOOAAAAAAAAAAAAAAAHHHHH th-tunk. You just shit a brick. Congratulations?"
                                    ))
                                brick_obj.id_owner = poi.id_poi
                                brick_obj.item_props[
                                    'furniture_name'] = 'brick'
                                brick_obj.persist()
                            except:
                                ewutils.logMsg(
                                    "failed to shit brick on user {}".format(
                                        brick_member.id))
                            else:
                                bknd_event.delete_world_event(we_id)

                    # Handle alarm clock code
                    elif we_type == ewcfg.event_type_alarmclock:
                        clock_obj = EwItem(
                            id_item=we.event_props.get("clock_id"))
                        if "decorate" in clock_obj.id_owner:
                            isFurnished = True
                        clock_user = clock_obj.id_owner.replace("decorate", "")
                        clock_member = server.get_member(user_id=clock_user)
                        if clock_member != None:
                            clock_player = EwUser(member=clock_member)
                            if (isFurnished == False or
                                ("apt" in clock_player.poi
                                 and clock_player.visiting
                                 == "empty")) and clock_member:
                                try:
                                    await fe_utils.send_message(
                                        client, clock_member,
                                        fe_utils.formatMessage(
                                            clock_member,
                                            "BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP"
                                        ))
                                except:
                                    ewutils.logMsg(
                                        "failed to send alarm to user {}".
                                        format(clock_member.id))
示例#14
0
async def setOffAlarms(id_server=None):
    ewutils.logMsg('Setting off alarms...')

    if id_server != None:
        client = ewutils.get_client()
        server = client.get_guild(id_server)
        time_current = EwMarket(id_server=id_server).clock
        if time_current <= 12:
            displaytime = str(time_current)
            ampm = 'am'
        if time_current > 12:
            displaytime = str(time_current - 12)
            ampm = 'pm'

        if time_current == 24:
            ampm = "am"
        elif time_current == 12:
            ampm = "pm"

        item_search = "alarm clock set to {}{}".format(displaytime, ampm)
        item_search_brick = "brick{:02d}".format(time_current)
        clockinv = item_utils.find_item_all(
            item_search="alarmclock",
            id_server=id_server,
            item_type_filter=ewcfg.it_furniture)
        brickinv = item_utils.find_item_all(
            item_search=item_search_brick,
            id_server=id_server,
            item_type_filter=ewcfg.it_furniture,
            search_names=True)

        for clock in clockinv:
            isFurnished = False
            clock_obj = EwItem(id_item=clock.get('id_item'))

            if clock_obj.item_props.get('furniture_name') == item_search:
                if "decorate" in clock_obj.id_owner:
                    isFurnished = True
                clock_user = clock_obj.id_owner.replace("decorate", "")
                clock_member = server.get_member(user_id=clock_user)
                if clock_member != None:
                    clock_player = EwUser(member=clock_member)
                    if (isFurnished == False or
                        ("apt" in clock_player.poi and clock_player.visiting
                         == "empty")) and clock_member:
                        try:
                            await fe_utils.send_message(
                                client, clock_member,
                                fe_utils.formatMessage(
                                    clock_member,
                                    "BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP BLAAAP"
                                ))
                        except:
                            ewutils.logMsg(
                                "failed to send alarm to user {}".format(
                                    clock_member.id))

        for brick in brickinv:
            brick_obj = EwItem(id_item=brick.get('id_item'))
            id_user = brick_obj.id_owner.replace("brickshit", "")
            print(id_user)
            brick_user = EwUser(id_server=id_server, id_user=id_user)
            brick_member = server.get_member(user_id=int(id_user))
            poi = poi_static.id_to_poi.get(brick_user.poi)
            channel_brick = fe_utils.get_channel(server, poi.channel)
            print('pass1')
            if brick_member != None:
                print('pass2')
                if brick_member:
                    print('pass3')
                    try:
                        await fe_utils.send_message(
                            client, channel_brick,
                            fe_utils.formatMessage(
                                brick_member,
                                "UUUUUUUUUUGGGGGGGGGGGGHHHHHHHHHHH... OOOOOOOOOOOOOOOOOAAAAAAAAAAAAAAAHHHHH th-tunk. You just shit a brick. Congratulations?"
                            ))
                        brick_obj.id_owner = poi.id_poi
                        brick_obj.item_props['furniture_name'] = 'brick'
                        brick_obj.persist()
                    except:
                        ewutils.logMsg(
                            "failed to shit brick on user {}".format(
                                brick_member.id))
示例#15
0
async def adorn(cmd):
    user_data = EwUser(member=cmd.message.author)
    market_data = EwMarket(id_server=user_data.id_server)

    # Check to see if you even have the item you want to repair
    item_id = ewutils.flattenTokenListToString(cmd.tokens[1:])

    try:
        item_id_int = int(item_id)
    except:
        item_id_int = None

    if item_id is not None and len(item_id) > 0:
        response = "You don't have one."

        cosmetic_items = bknd_item.inventory(
            id_user=cmd.message.author.id,
            id_server=cmd.guild.id,
            item_type_filter=ewcfg.it_cosmetic)
        item_sought = None
        item_from_slimeoid = None
        already_adorned = False
        space_adorned = 0

        for item in cosmetic_items:
            i = EwItem(item.get('id_item'))
            # Get space used adorned cosmetics
            if i.item_props['adorned'] == 'true':
                space_adorned += int(i.item_props['size'])

        # Check all cosmetics found
        for item in cosmetic_items:
            i = EwItem(item.get('id_item'))

            # Search for desired cosmetic
            if item.get(
                    'id_item'
            ) == item_id_int or item_id in ewutils.flattenTokenListToString(
                    item.get('name')):

                if item_from_slimeoid == None and i.item_props.get(
                        "slimeoid") == 'true':
                    item_from_slimeoid = i
                    continue
                if i.item_props.get("adorned") == 'true':
                    already_adorned = True
                elif i.item_props.get(
                        "context") == 'costume' and not ewcfg.dh_active:
                    if not ewcfg.dh_active and not ewutils.check_fursuit_active(
                            market_data):
                        response = "You can't adorn your costume right now."
                else:
                    item_sought = i
                    break

        if item_sought == None:
            item_sought = item_from_slimeoid

        # If the cosmetic you want to adorn is found
        if item_sought != None:

            # Calculate how much space you'll have after adorning...
            if int(item_sought.item_props['size']) > 0:
                space_adorned += int(item_sought.item_props['size'])

            # If you don't have enough space, abort
            if space_adorned > ewutils.max_adornspace_bylevel(
                    user_data.slimelevel):
                response = "Oh yeah? And, pray tell, just how do you expect to do that? You’re out of space, you can’t adorn any more garments!"

            # If you have enough space, adorn
            else:
                item_sought.item_props['adorned'] = 'true'

                # Take the hat from your slimeoid if necessary
                if item_sought.item_props.get('slimeoid') == 'true':
                    item_sought.item_props['slimeoid'] = 'false'
                    response = "You take your {} from your slimeoid and successfully adorn it.".format(
                        item_sought.item_props.get('cosmetic_name'))
                else:
                    onadorn_response = item_sought.item_props['str_onadorn']
                    response = onadorn_response.format(
                        item_sought.item_props['cosmetic_name'])

                item_sought.persist()
                user_data.persist()

        elif already_adorned:
            response = "You already have that garment adorned!"

        await fe_utils.send_message(
            cmd.client, cmd.message.channel,
            fe_utils.formatMessage(cmd.message.author, response))
    else:
        await fe_utils.send_message(
            cmd.client, cmd.message.channel,
            fe_utils.formatMessage(
                cmd.message.author,
                'Adorn which cosmetic? Check your **!inventory**.'))
示例#16
0
async def mill(cmd):
    user_data = EwUser(member=cmd.message.author)
    if user_data.life_state == ewcfg.life_state_shambler:
        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=user_data.id_server)
    item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])
    item_sought = bknd_item.find_item(
        item_search=item_search,
        id_user=cmd.message.author.id,
        id_server=cmd.guild.id if cmd.guild is not None else None,
        item_type_filter=ewcfg.it_food)

    # Checking availability of milling
    if user_data.life_state != ewcfg.life_state_juvenile:
        response = "Only Juveniles of pure heart and with nothing better to do can mill their vegetables."
    elif cmd.message.channel.name not in [
            ewcfg.channel_jr_farms, ewcfg.channel_og_farms,
            ewcfg.channel_ab_farms
    ]:
        response = "Alas, there doesn’t seem to be an official SlimeCorp milling station anywhere around here. Probably because you’re in the middle of the f*****g city. Try looking where you reaped your vegetable in the first place, dumbass."

    # elif user_data.slimes < ewcfg.slimes_permill:
    # 	response = "It costs {} to !mill, and you only have {}.".format(ewcfg.slimes_permill, user_data.slimes)

    elif item_sought:
        poi = poi_static.id_to_poi.get(user_data.poi)
        district_data = EwDistrict(district=poi.id_poi,
                                   id_server=user_data.id_server)

        if district_data.is_degraded():
            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))
        items = []
        vegetable = EwItem(id_item=item_sought.get('id_item'))

        for result in vendors.mill_results:
            if type(result.ingredients) == str:
                if vegetable.item_props.get('id_food') != result.ingredients:
                    pass
                else:
                    items.append(result)
            elif type(result.ingredients) == list:
                if vegetable.item_props.get(
                        'id_food') not in result.ingredients:
                    pass
                else:
                    items.append(result)

        if len(items) > 0:
            item = random.choice(items)

            item_props = itm_utils.gen_item_props(item)

            bknd_item.item_create(item_type=item.item_type,
                                  id_user=cmd.message.author.id,
                                  id_server=cmd.guild.id,
                                  item_props=item_props)

            response = "You walk up to the official ~~SlimeCorp~~ Garden Gankers Milling Station and shove your irradiated produce into the hand-crank. You begin slowly churning them into a glorious, pastry goo. As the goo tosses and turns inside the machine, it solidifies, and after a few moments a {} pops out!".format(
                item.str_name)

            # market_data.donated_slimes += ewcfg.slimes_permill
            market_data.persist()

            bknd_item.item_delete(id_item=item_sought.get('id_item'))
            # user_data.change_slimes(n = -ewcfg.slimes_permill, source = ewcfg.source_spending)
            # user_data.slime_donations += ewcfg.slimes_permill
            user_data.persist()
        else:
            response = "You can only mill fresh vegetables! SlimeCorp obviously wants you to support local farmers."

    else:
        if item_search:  # if they didn't forget to specify an item and it just wasn't found
            response = "You don't have one."
        else:
            response = "Mill which item? (check **!inventory**)"

    await fe_utils.send_message(
        cmd.client, cmd.message.channel,
        fe_utils.formatMessage(cmd.message.author, response))
示例#17
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))
示例#18
0
async def donate(cmd):
    user_data = EwUser(member=cmd.message.author)
    if user_data.life_state == ewcfg.life_state_shambler:
        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=user_data.id_server)

    time_now = round(time.time())

    if user_data.poi == ewcfg.poi_id_slimecorphq:
        poi = poi_static.id_to_poi.get(user_data.poi)
        district_data = EwDistrict(district=poi.id_poi, id_server=user_data.id_server)

        if district_data.is_degraded():
            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 = None
        if cmd.tokens_count > 1:
            value = ewutils.getIntToken(tokens=cmd.tokens, allow_all=True)

        if value != None:
            if value < 0:
                value = user_data.slimes
            if value <= 0:
                value = None

        if value != None and value < ewcfg.slimecoin_exchangerate:
            response = "You must volunteer to donate at least %d slime to receive compensation." % ewcfg.slimecoin_exchangerate

        elif value != None:
            # Amount of slime invested.
            cost_total = round(value)
            coin_total = round(value / ewcfg.slimecoin_exchangerate)

            if user_data.slimes < cost_total:
                response = "Acid-green flashes of light and bloodcurdling screams emanate from small window of SlimeCorp HQ. Unfortunately, you did not survive the procedure. Your body is dumped down a disposal chute to the sewers."
                market_data.donated_slimes += user_data.slimes
                market_data.persist()
                user_data.trauma = ewcfg.trauma_id_environment
                die_resp = user_data.die(cause=ewcfg.cause_donation)
                user_data.persist()
                # Assign the corpse role to the player. He dead.
                await ewrolemgr.updateRoles(client=cmd.client, member=cmd.message.author)
                await die_resp.post()
            else:
                # Do the transfer if the player can afford it.
                market_data.donated_slimes += cost_total
                market_data.persist()
                user_data.change_slimes(n=-cost_total, source=ewcfg.source_spending)
                user_data.change_slimecoin(n=coin_total, coinsource=ewcfg.coinsource_donation)
                user_data.slime_donations += cost_total

                # Persist changes
                user_data.persist()

                response = "You stumble out of a Slimecorp HQ vault room in a stupor. You don't remember what happened in there, but your body hurts and you've got {slimecoin:,} shiny new SlimeCoin in your pocket.".format(slimecoin=coin_total)

        else:
            response = ewcfg.str_exchange_specify.format(currency="slime", action="donate")

    elif user_data.poi == ewcfg.poi_id_slimeoidlab:
        poi = poi_static.id_to_poi.get(user_data.poi)
        district_data = EwDistrict(district=poi.id_poi, id_server=user_data.id_server)

        if district_data.is_degraded():
            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))

        poudrins = bknd_item.find_item(item_search="slimepoudrin", id_user=cmd.message.author.id, id_server=cmd.guild.id if cmd.guild is not None else None, item_type_filter=ewcfg.it_item)

        if poudrins == None:
            response = "You have to own a poudrin in order to donate a poudrin. Duh."

        else:
            bknd_item.item_delete(id_item=poudrins.get('id_item'))  # Remove Poudrins
            market_data.donated_poudrins += 1
            market_data.persist()
            user_data.poudrin_donations += 1
            user_data.persist()

            response = "You hand off one of your hard-earned poudrins to the front desk receptionist, who is all too happy to collect it. Pretty uneventful, but at the very least you’re glad donating isn’t physically painful anymore."

    else:
        response = "To donate slime, go to the SlimeCorp HQ in Downtown. To donate poudrins, go to the N.L.A.C.U. Lab in Brawlden."

    # Send the response to the player.
    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
示例#19
0
async def appraise(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])))

    market_data = EwMarket(id_server=user_data.id_server)
    item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])
    item_sought = bknd_item.find_item(item_search=item_search, id_user=cmd.message.author.id, id_server=cmd.guild.id if cmd.guild is not None else None)
    payment = bknd_item.find_item(item_search="manhattanproject", id_user=cmd.message.author.id, id_server=cmd.guild.id if cmd.guild is not None else None, item_type_filter=ewcfg.it_food)

    # Checking availability of appraisal
    # if market_data.clock < 8 or market_data.clock > 17:
    #	response = "You ask the bartender if he knows someone who would want to trade you something for your recently caught fish. Apparently, at night, an old commodore by the name of Captain Albert Alexander comes to drown his sorrows at this very tavern. You guess you’ll just have to sit here and wait for him, then."

    if cmd.message.channel.name != ewcfg.channel_speakeasy:
        if user_data.poi in poi_static.piers:
            response = 'You ask a nearby fisherman if he could appraise this fish you just caught. He tells you to f**k off, but also helpfully informs you that there’s an old sea captain that frequents the Speakeasy that might be able to help you. What an inexplicably helpful/grouchy fisherman!'
        else:
            response = 'What random passerby is going to give two shits about your fish? You’ll have to consult a fellow fisherman… perhaps you’ll find some on a pier?'
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
    elif item_sought:
        name = item_sought.get('name')
        fish = EwItem(id_item=item_sought.get('id_item'))
        item_props = fish.item_props
        # str_fish = fish.item_props.get('str_name')
        # id_fish = item_props['id_food']
        acquisition = item_props.get('acquisition')

        response = "You approach a man of particularly swashbuckling appearance, adorned in an old sea captain's uniform and bicorne cap, and surrounded by empty glass steins. You ask him if he is Captain Albert Alexander and he replies that he hasn’t heard that name in a long time. You submit your {} for appraisal".format(name)

        if acquisition != ewcfg.acquisition_fishing:
            response += '. \n"Have you lost yer mind, laddy? That’s not a fish!! Just what’re you trying to pull??"'.format(name)

        else:

            if payment == None:
                response += ", but he says he won’t provide his services for free... but, if you bring him a Manhattan Project, you might be able to get an appraisal."

            else:
                item_props = fish.item_props
                rarity = item_props['rarity']
                size = item_props['size']
                value = int(item_props['value'])

                response += ' and offer him a Manhattan Project as payment. \n"Hm, alright, let’s see here...'

                if rarity == ewcfg.fish_rarity_common:
                    response += "Ah, a {}, that’s a pretty common fish... ".format(name)

                if rarity == ewcfg.fish_rarity_uncommon:
                    response += "Interesting, a {}, that’s a pretty uncommon fish you’ve got there... ".format(name)

                if rarity == ewcfg.fish_rarity_rare:
                    response += "Amazing, it’s a {}! Consider yourself lucky, that’s a pretty rare fish! ".format(name)

                if rarity == ewcfg.fish_rarity_promo:
                    response += "Shiver me timbers, is that a {}?? Unbelievable, that’s an extremely rare fish!! It was only ever released as a promotional item in Japan during the late ‘90s. ".format(name)

                if size == ewcfg.fish_size_miniscule:
                    response += "Or, is it just a speck of dust? Seriously, that {} is downright miniscule! ".format(name)

                if size == ewcfg.fish_size_small:
                    response += "Hmmm, it’s a little small, don’t you think? "

                if size == ewcfg.fish_size_average:
                    response += "It’s an average size for the species. "

                if size == ewcfg.fish_size_big:
                    response += "Whoa, that’s a big one, too! "

                if size == ewcfg.fish_size_huge:
                    response += "Look at the size of that thing, it’s huge! "

                if size == ewcfg.fish_size_colossal:
                    response += "By Neptune’s beard, what a sight to behold, this {name} is absolutely colossal!! In all my years in the Navy, I don’t think I’ve ever seen a {name} as big as yours!! ".format(name=name)

                response += "So, I’d say this fish "

                if value <= 20:
                    response += 'is absolutely worthless."'

                if value <= 40 and value >= 21:
                    response += 'isn’t worth very much."'

                if value <= 60 and value >= 41:
                    response += 'is somewhat valuable."'

                if value <= 80 and value >= 61:
                    response += 'is highly valuable!"'

                if value <= 99 and value >= 81:
                    response += 'is worth a fortune!!"'

                if value >= 100:
                    response += 'is the most magnificent specimen I’ve ever seen!"'

                bknd_item.item_delete(id_item=payment.get('id_item'))

                user_data.persist()
    else:
        if item_search:  # If they didn't forget to specify an item and it just wasn't found.
            response = "You don't have one."

        else:
            response = "Ask Captain Albert Alexander to appraise which fish? (check **!inventory**)"

    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
示例#20
0
async def invest(cmd):
    user_data = EwUser(member=cmd.message.author)
    if user_data.life_state == ewcfg.life_state_shambler:
        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))

    time_now = round(time.time())
    market_data = EwMarket(id_server=cmd.message.author.guild.id)

    if cmd.message.channel.name != ewcfg.channel_stockexchange:  # or user_data.poi != ewcfg.poi_id_downtown:
        # Only allowed in the stock exchange.
        response = ewcfg.str_exchange_channelreq.format(currency="SlimeCoin", action="invest")
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    poi = poi_static.id_to_poi.get(user_data.poi)
    district_data = EwDistrict(district=poi.id_poi, id_server=user_data.id_server)

    if district_data.is_degraded():
        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))

    if market_data.clock < 6 or market_data.clock >= 20:
        response = ewcfg.str_exchange_closed
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    if user_data.time_lastinvest + ewcfg.cd_invest > time_now:
        # Limit frequency of investments.
        response = ewcfg.str_exchange_busy.format(action="invest")
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    if user_data.life_state == ewcfg.life_state_corpse:
        # Disallow invests from ghosts.
        response = "Your slimebroker can't confirm your identity while you're dead."
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    if user_data.life_state == ewcfg.life_state_kingpin:
        # Disallow investments by RF and CK kingpins.
        response = "You need that money to buy more videogames."
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    else:
        value = None
        stock = None

        if cmd.tokens_count > 1:
            value = ewutils.getIntToken(cmd.tokens, allow_all=True)

            for token in cmd.tokens[1:]:
                if token.lower() in ewcfg.stocks:
                    stock = token.lower()
                    break

        if value != None:
            if value < 0:
                value = user_data.slimecoin
            if value <= 0:
                value = None

        if value != None:
            if stock != None:

                stock = EwStock(id_server=cmd.guild.id, stock=stock)
                # basic exchange rate / 1000 = 1 share
                exchange_rate = (stock.exchange_rate / 1000.0)

                cost_total = round(value * 1.05)

                # gets the highest value possible where the player can still pay the fee
                if value == user_data.slimecoin:
                    while cost_total > user_data.slimecoin:
                        value -= cost_total - value
                        cost_total = round(value * 1.05)

                # The user can only buy a whole number of shares, so adjust their cost based on the actual number of shares purchased.
                net_shares = round(value / exchange_rate)

                if user_data.slimecoin < cost_total:
                    response = "You don't have enough SlimeCoin. ({:,}/{:,})".format(user_data.slimecoin, cost_total)

                elif value > user_data.slimecoin:
                    response = "You don't have that much SlimeCoin to invest."

                elif net_shares == 0:
                    response = "You don't have enough SlimeCoin to buy a share in {stock}".format(stock=ewcfg.stock_names.get(stock.id_stock))

                else:
                    user_data.change_slimecoin(n=-cost_total, coinsource=ewcfg.coinsource_invest)
                    shares = market_utils.getUserTotalShares(id_server=user_data.id_server, stock=stock.id_stock, id_user=user_data.id_user)
                    shares += net_shares
                    market_utils.updateUserTotalShares(id_server=user_data.id_server, stock=stock.id_stock, id_user=user_data.id_user, shares=shares)
                    user_data.time_lastinvest = time_now

                    stock.total_shares += net_shares
                    response = "You invest {coin:,} SlimeCoin and receive {shares:,} shares in {stock}. Your slimebroker takes his nominal fee of {fee:,} SlimeCoin.".format(coin=value, shares=net_shares, stock=ewcfg.stock_names.get(stock.id_stock), fee=(cost_total - value))

                    user_data.persist()
                    stock.timestamp = round(time.time())
                    stock.persist()

            else:
                response = "That's not a valid stock name, please use a proper one, you c**t: {}".format(ewutils.formatNiceList(names=ewcfg.stocks))

        else:
            response = ewcfg.str_exchange_specify.format(currency="SlimeCoin", action="invest")

    # Send the response to the player.
    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
示例#21
0
async def barter(cmd):
    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=user_data.id_server)
    item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])
    item_sought = bknd_item.find_item(item_search=item_search, id_user=cmd.message.author.id, id_server=cmd.guild.id if cmd.guild is not None else None)

    # Checking availability of appraisal
    # if market_data.clock < 8 or market_data.clock > 17:
    #	response = "You ask the bartender if he knows someone who would want to trade you something for your recently caught fish. Apparently, at night, an old commodore by the name of Captain Albert Alexander comes to drown his sorrows at this very tavern. You guess you’ll just have to sit here and wait for him, then."

    if cmd.message.channel.name != ewcfg.channel_speakeasy:
        if user_data.poi in poi_static.piers:
            response = 'You ask a nearby fisherman if he wants to trade you anything for this fish you just caught. He tells you to f**k off, but also helpfully informs you that there’s an old sea captain that frequents the Speakeasy that might be able to help you. What an inexplicably helpful/grouchy fisherman!'
        else:
            response = 'What random passerby is going to give two shits about your fish? You’ll have to consult a fellow fisherman… perhaps you’ll find some on a pier?'
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    if user_data.life_state == ewcfg.life_state_corpse:
        response = 'Captain Albert Alexander hits the table with his glass and shouts "Nay laddy, you can fool me once but not twice! I dont do deals with spirits, get out of my sight!"'
        return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))

    elif item_sought:

        name = item_sought.get('name')
        fish = EwItem(id_item=item_sought.get('id_item'))
        id_fish = fish.id_item
        # str_fish = fish.item_props.get('str_name')
        item_props = fish.item_props
        acquisition = item_props.get('acquisition')
        response = "You approach a man of particularly swashbuckling appearance, adorned in an old sea captain's uniform and bicorne cap, and surrounded by empty glass steins. You ask him if he is Captain Albert Alexander and he replies that he hasn’t heard that name in a long time. You submit your {} for bartering".format(name)

        if acquisition != ewcfg.acquisition_fishing:
            response += '. \n"Have you lost yer mind, laddy? That’s not a fish!! Just what’re you trying to pull??"'

        else:
            value = int(item_props['value'])

            items = []

            # Filters out all non-generic items without the current fish as an ingredient.
            for result in vendors.appraise_results:
                if result.ingredients == fish.item_props.get('id_item') or result.ingredients == "generic" and result.acquisition == ewcfg.acquisition_bartering:  # Generic means that it can be made with any fish.
                    items.append(result)
                else:
                    pass

            # Filters out items of greater value than your fish.
            for value_filter in items:
                if value < value_filter.context:
                    items.remove(value_filter)
                else:
                    pass

            else:
                offer = EwOffer(
                    id_server=cmd.guild.id,
                    id_user=cmd.message.author.id,
                    offer_give=id_fish
                )

                cur_time_min = time.time() / 60
                time_offered = cur_time_min - offer.time_sinceoffer

                if offer.time_sinceoffer > 0 and time_offered < ewcfg.fish_offer_timeout:
                    offer_receive = str(offer.offer_receive)

                    if offer_receive.isdigit() == True and ewcfg.mutation_id_onemansjunk in mutations:
                        item = random.choice(items)

                        if hasattr(item, 'id_item'):
                            offer.offer_receive = item.id_item

                        if hasattr(item, 'id_food'):
                            offer.offer_receive = item.id_food

                        if hasattr(item, 'id_cosmetic'):
                            offer.offer_receive = item.id_cosmetic

                        response = '\n"Well, back again I see! That fish certainly looked better the last time I saw it. Best I’ll do is trade ya a {} for your {}."'.format(item.str_name, name)
                    elif offer_receive.isdigit() == True:
                        slime_gain = int(offer.offer_receive)

                        response = '\n"Well, back again I see! My offer still stands, I’ll trade ya {} slime for your {}"'.format(slime_gain, name)

                    elif ewcfg.mutation_id_davyjoneskeister in mutations and item_props.get('noslime') != "true":
                        max_value = value * 6000  # 600,000 slime for a colossal promo fish, 120,000 for a miniscule common fish.
                        min_value = max_value / 10  # 60,000 slime for a colossal promo fish, 12,000 for a miniscule common fish.

                        slime_gain = round(random.triangular(min_value, max_value, min_value * 2))

                        offer.offer_receive = slime_gain
                        offer.persist()
                        response = '\n"You know what, laddy? I like the cut of your jib. I\'ll change my offer. How about {} slime for your {}?"'.format(slime_gain, name)

                    else:
                        for result in vendors.appraise_results:
                            if hasattr(result, 'id_item'):
                                if result.id_item != offer.offer_receive:
                                    pass
                                else:
                                    item = result

                            if hasattr(result, 'id_food'):
                                if result.id_food != offer.offer_receive:
                                    pass
                                else:
                                    item = result

                            if hasattr(result, 'id_cosmetic'):
                                if result.id_cosmetic != offer.offer_receive:
                                    pass
                                else:
                                    item = result

                        response = '\n"Well, back again I see! My offer still stands, I’ll trade ya a {} for your {}"'.format(item.str_name, name)

                    response += "\n**!accept** or **!refuse** Captain Albert Alexander's deal."

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

                else:
                    # Random choice between 0, 1, and 2
                    offer_decision = random.randint(0, 2)

                    if (offer_decision != 2 or ewcfg.mutation_id_davyjoneskeister in mutations) and item_props.get('noslime') != "true" and ewcfg.mutation_id_onemansjunk not in mutations:  # If Captain Albert Alexander wants to offer you slime for your fish. 66% chance.
                        max_value = value * 6000  # 600,000 slime for a colossal promo fish, 120,000 for a miniscule common fish.
                        min_value = max_value / 10  # 60,000 slime for a colossal promo fish, 12,000 for a miniscule common fish.

                        slime_gain = round(random.triangular(min_value, max_value, min_value * 2))

                        offer.offer_receive = slime_gain

                        response = '"Hm, alright… for this {}... I’ll offer you {} slime! Trust me, you’re not going to get a better deal anywhere else, laddy."'.format(name, slime_gain)

                    else:  # If Captain Albert Alexander wants to offer you an item for your fish. 33% chance. Once there are more unique items, we'll make this 50%.
                        item = random.choice(items)

                        if hasattr(item, 'id_item'):
                            offer.offer_receive = item.id_item

                        if hasattr(item, 'id_food'):
                            offer.offer_receive = item.id_food

                        if hasattr(item, 'id_cosmetic'):
                            offer.offer_receive = item.id_cosmetic

                        response = '"Hm, alright… for this {}... I’ll offer you a {}! Trust me, you’re not going to get a better deal anywhere else, laddy."'.format(name, item.str_name)

                    offer.time_sinceoffer = int(time.time() / 60)
                    offer.persist()

                    response += "\n**!accept** or **!refuse** Captain Albert Alexander's deal."

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

                # Wait for an answer
                accepted = False

                try:
                    message = await cmd.client.wait_for('message', timeout=20, check=lambda message: message.author == cmd.message.author and
                                                                                                     message.content.lower() in [ewcfg.cmd_accept, ewcfg.cmd_refuse])

                    if message != None:
                        if message.content.lower() == ewcfg.cmd_accept:
                            accepted = True
                        if message.content.lower() == ewcfg.cmd_refuse:
                            accepted = False
                except:
                    accepted = False

                offer = EwOffer(
                    id_server=cmd.guild.id,
                    id_user=cmd.message.author.id,
                    offer_give=id_fish
                )

                user_data = EwUser(member=cmd.message.author)
                fish = EwItem(id_item=id_fish)

                # cancel deal if fish is no longer in user's inventory
                if fish.id_owner != str(user_data.id_user):
                    accepted = False

                # cancel deal if the user has left Vagrant's Corner
                if user_data.poi != ewcfg.poi_id_speakeasy:
                    accepted = False

                # cancel deal if the offer has been deleted
                if offer.time_sinceoffer == 0:
                    accepted = False

                if accepted == True:
                    offer_receive = str(offer.offer_receive)

                    response = ""

                    if offer_receive.isdigit() == True:
                        slime_gain = int(offer_receive)

                        user_initial_level = user_data.slimelevel

                        levelup_response = user_data.change_slimes(n=slime_gain, source=ewcfg.source_fishing)

                        was_levelup = True if user_initial_level < user_data.slimelevel else False

                        # Tell the player their slime level increased.
                        if was_levelup:
                            response += levelup_response
                            response += "\n\n"

                    else:
                        item_props = itm_utils.gen_item_props(item)

                        bknd_item.item_create(
                            item_type=item.item_type,
                            id_user=cmd.message.author.id,
                            id_server=cmd.guild.id,
                            item_props=item_props
                        )

                    bknd_item.item_delete(id_item=item_sought.get('id_item'))

                    user_data.persist()

                    offer.deal()

                    response += '"Pleasure doing business with you, laddy!"'

                else:
                    response = '"Ah, what a shame. Maybe you’ll change your mind in the future…?"'

    else:
        if item_search:  # If they didn't forget to specify an item and it just wasn't found.
            response = "You don't have one."
        else:
            response = "Offer Captain Albert Alexander which fish? (check **!inventory**)"

    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
示例#22
0
async def haunt(cmd):
    time_now = int(time.time())
    response = ""
    resp_cont = EwResponseContainer(id_server=cmd.guild.id)

    if cmd.mentions_count > 1:
        response = "You can only spook one person at a time. Who do you think you are, the Lord of Ghosts?"
    else:
        haunted_data = None
        member = None
        if cmd.mentions_count == 0 and cmd.tokens_count > 1:
            server = cmd.guild
            member = server.get_member(ewutils.getIntToken(cmd.tokens))
            haunted_data = EwUser(member=member)
        elif cmd.mentions_count == 1:
            member = cmd.mentions[0]
            haunted_data = EwUser(member=member)

        if member:
            # Get the user and target data from the database.
            user_data = EwUser(member=cmd.message.author)
            market_data = EwMarket(id_server=cmd.guild.id)
            target_mutations = haunted_data.get_mutations()
            target_poi = poi_static.id_to_poi.get(haunted_data.poi)
            target_is_shambler = haunted_data.life_state == ewcfg.life_state_shambler
            target_is_inhabitted = haunted_data.id_user == user_data.get_inhabitee(
            )

            if user_data.life_state != ewcfg.life_state_corpse:
                # Only dead players can haunt.
                response = "You can't haunt now. Try {}.".format(
                    ewcfg.cmd_suicide)
            elif haunted_data.life_state == ewcfg.life_state_kingpin:
                # Disallow haunting of generals.
                response = "He is too far from the sewers in his ivory tower, and thus cannot be haunted."
            elif (time_now - user_data.time_lasthaunt) < ewcfg.cd_haunt:
                # Disallow haunting if the user has haunted too recently.
                response = "You're being a little TOO spooky lately, don't you think? Try again in {} seconds.".format(
                    int(ewcfg.cd_haunt -
                        (time_now - user_data.time_lasthaunt)))
            elif ewutils.channel_name_is_poi(
                    cmd.message.channel.name) == False:
                response = "You can't commit violence from here."
            elif target_poi.pvp == False:
                # Require the target to be in a PvP area, and flagged if it's a remote haunt
                response = "{} is not mired in the ENDLESS WAR right now.".format(
                    member.display_name)
            elif haunted_data.life_state == ewcfg.life_state_corpse:
                # Dead players can't be haunted.
                response = "{} is already dead.".format(member.display_name)
            elif haunted_data.life_state == ewcfg.life_state_grandfoe:
                # Grand foes can't be haunted.
                response = "{} is invulnerable to ghosts.".format(
                    member.display_name)
            elif haunted_data.life_state == ewcfg.life_state_enlisted or haunted_data.life_state == ewcfg.life_state_juvenile or haunted_data.life_state == ewcfg.life_state_shambler:
                haunt_power_multiplier = 1

                # power to the ancients
                ghost_age = time_now - user_data.time_lastdeath
                if ghost_age > 60 * 60 * 24 * 7:  # dead for longer than
                    if ghost_age > 60 * 60 * 24 * 365:  # one friggin year
                        haunt_power_multiplier *= 2.5
                    if ghost_age > 60 * 60 * 24 * 90:  # three months
                        haunt_power_multiplier *= 2
                    elif ghost_age > 60 * 60 * 24 * 30:  # one month
                        haunt_power_multiplier *= 1.5
                    else:  # one week
                        haunt_power_multiplier *= 1.25

                # vitriol as virtue
                list_ids = []
                for quadrant in ewcfg.quadrant_ids:
                    quadrant_data = EwQuadrant(id_server=cmd.guild.id,
                                               id_user=cmd.message.author.id,
                                               quadrant=quadrant)
                    if quadrant_data.id_target != -1 and quadrant_data.check_if_onesided(
                    ) is False:
                        list_ids.append(quadrant_data.id_target)
                    if quadrant_data.id_target2 != -1 and quadrant_data.check_if_onesided(
                    ) is False:
                        list_ids.append(quadrant_data.id_target2)
                if haunted_data.id_user in list_ids:  # any mutual quadrants
                    haunt_power_multiplier *= 1.2
                if haunted_data.faction and (
                    (not user_data.faction) or
                    (user_data.faction != haunted_data.faction)
                ):  # opposite faction (or no faction at all)
                    haunt_power_multiplier *= 1.2
                if user_data.id_killer == haunted_data.id_user:  # haunting your murderer/buster
                    haunt_power_multiplier *= 1.2

                # places of power.
                if haunted_data.poi in [
                        ewcfg.poi_id_thevoid, ewcfg.poi_id_wafflehouse,
                        ewcfg.poi_id_blackpond
                ]:
                    haunt_power_multiplier *= 2
                elif haunted_data.poi in get_void_connection_pois(
                        cmd.guild.id):
                    haunt_power_multiplier *= 1.25

                # glory to the vanquished
                target_kills = ewstats.get_stat(user=haunted_data,
                                                metric=ewcfg.stat_kills)
                if target_kills > 5:
                    haunt_power_multiplier *= 1.25 + (
                        (target_kills - 5) / 100)  # 1% per kill after 5
                else:
                    haunt_power_multiplier *= 1 + (target_kills * 5 / 100
                                                   )  # 5% per kill

                if time_now - haunted_data.time_lastkill < (60 * 15):
                    haunt_power_multiplier *= 1.5  #  wet hands

                # misc
                if weather_static.weather_map.get(
                        market_data.weather) == ewcfg.weather_foggy:
                    haunt_power_multiplier *= 1.1
                if not haunted_data.has_soul:
                    haunt_power_multiplier *= 1.2
                # uncomment this after moon mechanics update
                # if (market_data.day % 31 == 15 and market_data.clock >= 20) or (market_data.day % 31 == 16 and market_data.clock <= 6):
                # 	haunt_power_multiplier *= 2

                # divide haunt power by 2 if not in same area
                if user_data.poi != haunted_data.poi:
                    haunt_power_multiplier /= 2

                # Double Halloween
                if ewcfg.dh_active:
                    haunt_power_multiplier *= 4

                haunted_slimes = int(
                    (haunted_data.slimes / ewcfg.slimes_hauntratio) *
                    haunt_power_multiplier)
                slimes_lost = int(
                    haunted_slimes / 5
                )  # hauntee only loses 1/5th of what the ghost gets as antislime

                if ewcfg.mutation_id_coleblooded in target_mutations:
                    haunted_slimes = -10000
                    if user_data.slimes > haunted_slimes:
                        haunted_slimes = user_data.slimes

                haunted_data.change_slimes(n=-slimes_lost,
                                           source=ewcfg.source_haunted)
                user_data.change_slimes(n=-haunted_slimes,
                                        source=ewcfg.source_haunter)
                market_data.negaslime -= haunted_slimes

                user_data.time_lasthaunt = time_now
                user_data.clear_status(id_status=ewcfg.status_busted_id)

                resp_cont.add_member_to_update(cmd.message.author)
                # Persist changes to the database.
                user_data.persist()
                haunted_data.persist()
                market_data.persist()

                response = "{} has been haunted by the ghost of {}! Slime has been lost! {} antislime congeals within you.".format(
                    member.display_name, cmd.message.author.display_name,
                    haunted_slimes)
                if ewcfg.mutation_id_coleblooded in target_mutations:
                    response = "{} has been haunted by the ghost of {}! Their exorcising coleslaw blood purges {} antislime from your being! Better not do that again.".format(
                        member.display_name, cmd.message.author.display_name,
                        -haunted_slimes)

                haunted_channel = poi_static.id_to_poi.get(
                    haunted_data.poi).channel
                haunt_message = "You feel a cold shiver run down your spine"
                if cmd.tokens_count > 2:
                    haunt_message_content = re.sub(
                        "<.+>" if cmd.mentions_count == 1 else "\d{17,}", "",
                        cmd.message.content[(len(cmd.tokens[0])):]).strip()
                    # Cut down really big messages so discord doesn't crash
                    if len(haunt_message_content) > 500:
                        haunt_message_content = haunt_message_content[:-500]
                    haunt_message += " and faintly hear the words \"{}\"".format(
                        haunt_message_content)
                haunt_message += ". {} slime evaporates from your body.".format(
                    slimes_lost)
                if ewcfg.mutation_id_coleblooded in target_mutations:
                    haunt_message += " The ghost that did it wails in agony as their ectoplasm boils in your coleslaw blood!"

                haunt_message = fe_utils.formatMessage(member, haunt_message)
                resp_cont.add_channel_response(haunted_channel, haunt_message)
        else:
            # No mentions, or mentions we didn't understand.
            response = "Your spookiness is appreciated, but ENDLESS WAR didn\'t understand that name."

    # Send the response to the player.
    resp_cont.add_channel_response(cmd.message.channel.name, response)
    await resp_cont.post()
示例#23
0
async def embiggen(cmd):
    user_data = EwUser(member=cmd.message.author)

    market_data = EwMarket(id_server=user_data.id_server)
    item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])
    item_sought = bknd_item.find_item(item_search=item_search, id_user=cmd.message.author.id, id_server=cmd.guild.id if cmd.guild is not None else None)

    if cmd.message.channel.name != ewcfg.channel_slimeoidlab:
        response = "How are you going to embiggen your fish on the side of the street? You’ve got to see a professional for this, man. Head to the SlimeCorp Laboratory, they’ve got dozens of modern day magic potions ‘n shit over there."

    elif item_sought:
        name = item_sought.get('name')
        fish = EwItem(id_item=item_sought.get('id_item'))
        acquisition = fish.item_props.get('acquisition')

        if fish.item_props.get('id_furniture') == "singingfishplaque":

            poudrins_owned = itm_utils.find_item_all(item_search="slimepoudrin", id_user=user_data.id_user, id_server=user_data.id_server, item_type_filter=ewcfg.it_item)
            poudrin_amount = len(poudrins_owned)

            if poudrin_amount < 2:
                response = "You don't have the poudrins for it."
            else:
                for delete in range(2):
                    poudrin = poudrins_owned.pop()
                    bknd_item.item_delete(id_item=poudrin.get("id_item"))
                fish.item_props['id_furniture'] = "colossalsingingfishplaque"
                fish.item_props['furniture_look_desc'] = "There's a fake fish mounted on the wall. Hoo boy, it's a whopper."
                fish.item_props['furniture_place_desc'] = "You take a nail gun to the wall to force it to hold this fish. Christ,  this thing is your f*****g Ishmael. Er, Moby Dick. Whatever."
                fish.item_props['furniture_name'] = "colossal singing fish plaque"
                fish.item_props['furniture_desc'] = "You press the button on your gigantic plaque.\n***" + fish.item_props.get('furniture_desc')[38:-87].upper().replace(":NOTES:", ":notes:") + "***\nYou abruptly turn the fish off before you rupture an eardrum."
                fish.persist()
                response = "The elevator ride down to the embiggening ward feels like an eterninty. Are they going to find out the fish you're embiggening is fake? God, you hope not. But eventually, you make it down, and place the plaque in the usual reclined surgeon's chair. A stray spark from one of the defibrilators nearly gives you a heart attack. But even so, the embiggening process begins like usual. You sign the contract, and they take a butterfly needle to your beloved wall prop. And sure enough, it begins to grow. You hear the sounds of cracked plastic and grinding electronics, and catch a whiff of burnt wires. It's growing. It's 6 feet, no, 10 feet long. Good god. You were hoping for growth, but science has gone too far. Eventually, it stops. Although you raise a few eyebrows with ths anomaly, you still get back the colossal fish plaque without a hitch."
        elif acquisition != ewcfg.acquisition_fishing:
            response = "You can only embiggen fishes, dummy. Otherwise everyone would be walking around with colossal nunchucks and huge chicken buckets. Actually, that gives me an idea..."

        elif fish.item_props.get('embiggened') is not None:
            response = "After several minutes long elevator descents, in the depths of some basement level far below the laboratory's lobby, you lay down your {} on a reclined medical chair. An NLACU med student finishes the novel length terms of service they were reciting and asks you if you have any questions. You weren’t listening so you just tell them to get on with it so you can go back to haggling prices with Captain Albert Alexander. They oblige.\nThey grab a butterfly needle and carefully stab your fish with it, avoiding the rumbling tumors it's grown from its previous embiggening. All of a sudden, before the surgeon can inject, the {}'s heart rate monitor starts going f*****g nuts. The nurses begin to panic and duck behind equipment as the syringe flies out of the fish and sprays caustic rainbow goop over all the expensive machinery. Some of it lands on your pinky, and it expands into a second thumb. You are escorted out of the basement with a combination of fury and embarrassment.\n\nWelp, guess you can't embiggen the same fish twice. Too many...surgical complications.".format(
                name, name)
        else:
            size = fish.item_props.get('size')

            poudrin_cost = 0

            if size == ewcfg.fish_size_miniscule:
                poudrin_cost = 2

            if size == ewcfg.fish_size_small:
                poudrin_cost = 4

            if size == ewcfg.fish_size_average:
                poudrin_cost = 8

            if size == ewcfg.fish_size_big:
                poudrin_cost = 16

            if size == ewcfg.fish_size_huge:
                poudrin_cost = 32

            if size == ewcfg.fish_size_colossal:
                poudrin_cost = 32

            poudrins_owned = itm_utils.find_item_all(item_search="slimepoudrin", id_user=user_data.id_user, id_server=user_data.id_server, item_type_filter=ewcfg.it_item)
            poudrin_amount = len(poudrins_owned)

            if poudrin_cost == 0:
                response = "Your {} is already as colossal as a fish can get!".format(name)

            elif poudrin_amount < poudrin_cost:
                response = "You need {} poudrins to embiggen your {}, but you only have {}!!".format(poudrin_cost, name, poudrin_amount)

            else:
                if fish.item_props.get('length') is None:
                    fish.item_props['length'] = float((ewcfg.fish_size_range.get(fish.item_props.get('size'))[0] + ewcfg.fish_size_range.get(fish.item_props.get('size'))[1])/2)

                fish.item_props['length'] =  float(fish.item_props['length']) + random.randint(5 + poudrin_cost, 15 + poudrin_cost)

                fish.item_props['size'] = fishutils.length_to_size(size_number=float(fish.item_props['length']))
                fish.item_props['embiggened'] = 'illegal'

                fish.persist()

                for delete in range(poudrin_cost):
                    poudrin = poudrins_owned.pop()
                    bknd_item.item_delete(id_item=poudrin.get("id_item"))

                market_data.donated_poudrins += poudrin_cost
                market_data.persist()

                response = "After several minutes long elevator descents, in the depths of some basement level far below the laboratory's lobby, you lay down your {} on a reclined medical chair. An NLACU med student finishes the novel length terms of service they were reciting and asks you if you have any questions. You weren’t listening so you just tell them to get on with it so you can go back to haggling prices with Captain Albert Alexander. They oblige.\nThey grab a butterfly needle and carefully stab your fish with it, injecting filled with some bizarre, multi-colored serum you’ve never seen before. Sick, it’s bigger now!!".format(
                    name)

    else:
        if item_search:  # If they didn't forget to specify an item and it just wasn't found.
            response = "You don't have one."
        else:
            response = "Embiggen which fish? (check **!inventory**)"

    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
示例#24
0
async def revive(cmd, player_auto=None):
    time_now = int(time.time())
    response = ""

    if cmd.message.channel.name != ewcfg.channel_endlesswar and cmd.message.channel.name != ewcfg.channel_sewers and player_auto is None:
        response = "Come to me. I hunger. #{}.".format(ewcfg.channel_sewers)
    else:
        if player_auto:
            player_data = EwUser(id_server=cmd.guild.id, id_user=player_auto)
        else:
            player_data = EwUser(member=cmd.message.author)

        # time_until_revive = (player_data.time_lastdeath + 600) - time_now
        time_until_revive = (player_data.time_lastdeath) - time_now

        if time_until_revive > 0 and player_auto is None:
            response = "ENDLESS WAR is not ready to {} you yet ({}s).".format(
                cmd.tokens[0], time_until_revive)
            return await fe_utils.send_message(
                cmd.client, cmd.message.channel,
                fe_utils.formatMessage(cmd.message.author, response))

        slimeoid = EwSlimeoid(member=cmd.message.author)

        if player_data.life_state == ewcfg.life_state_corpse:
            market_data = EwMarket(id_server=cmd.guild.id)

            # Endless War collects his fee.
            # fee = (player_data.slimecoin / 10)
            # player_data.change_slimecoin(n = -fee, coinsource = ewcfg.coinsource_revival)
            # market_data.slimes_revivefee += fee
            # player_data.busted = False

            # Preserve negaslime
            if player_data.slimes < 0:
                # market_data.negaslime += player_data.slimes
                player_data.change_slimes(n=-player_data.slimes)  # set to 0

            # reset slimelevel to zero
            player_data.slimelevel = 0

            # Set time of last revive. This used to provied spawn protection, but currently isn't used.
            player_data.time_lastrevive = time_now

            if False:  #player_data.degradation >= 100:
                player_data.life_state = ewcfg.life_state_shambler
                player_data.change_slimes(n=0.5 * ewcfg.slimes_shambler)
                player_data.trauma = ""
                poi_death = poi_static.id_to_poi.get(player_data.poi_death)
                if move_utils.inaccessible(poi=poi_death,
                                           user_data=player_data):
                    player_data.poi = ewcfg.poi_id_endlesswar
                else:
                    player_data.poi = poi_death.id_poi
            else:
                # Set life state. This is what determines whether the player is actually alive.
                player_data.life_state = ewcfg.life_state_juvenile
                # Give player some initial slimes.
                player_data.change_slimes(n=ewcfg.slimes_onrevive)
                # Get the player out of the sewers.
                player_data.poi = ewcfg.poi_id_endlesswar

            # Give newly spawned juvies a foul odour
            player_data.applyStatus(ewcfg.status_repelled_id)

            player_data.persist()
            market_data.persist()

            # Shower every district in the city with slime from the sewers.
            sewer_data = EwDistrict(district=ewcfg.poi_id_thesewers,
                                    id_server=cmd.guild.id)
            # the amount of slime showered is divided equally amongst the districts
            districts_amount = len(poi_static.capturable_districts)
            geyser_amount = int(0.5 * sewer_data.slimes / districts_amount)
            # Get a list of all the districts
            for poi in poi_static.capturable_districts:
                district_data = EwDistrict(district=poi,
                                           id_server=cmd.guild.id)

                district_data.change_slimes(n=geyser_amount)
                sewer_data.change_slimes(n=-1 * geyser_amount)

                district_data.persist()
                sewer_data.persist()

            sewer_inv = bknd_item.inventory(id_user=sewer_data.name,
                                            id_server=sewer_data.id_server)
            for item in sewer_inv:
                district = ewcfg.poi_id_slimesea
                if random.random() < 0.5:
                    district = random.choice(poi_static.capturable_districts)
                bknd_item.give_item(id_item=item.get("id_item"),
                                    id_user=district,
                                    id_server=sewer_data.id_server)

            await ewrolemgr.updateRoles(client=cmd.client,
                                        member=cmd.message.author)

            response = '{slime4} Geysers of fresh slime erupt from every manhole in the city, showering their surrounding districts. {slime4} {name} has been reborn in slime. {slime4}'.format(
                slime4=ewcfg.emote_slime4,
                name=cmd.message.author.display_name)
        else:
            response = 'You\'re not dead just yet.'

        #	deathreport = "You were {} by {}. {}".format(kill_descriptor, cmd.message.author.display_name, ewcfg.emote_slimeskull)
        #	deathreport = "{} ".format(ewcfg.emote_slimeskull) + fe_utils.formatMessage(member, deathreport)

        if slimeoid.life_state == ewcfg.slimeoid_state_active:
            reunite = ""
            brain = sl_static.brain_map.get(slimeoid.ai)
            reunite += brain.str_revive.format(slimeoid_name=slimeoid.name)
            new_poi = poi_static.id_to_poi.get(player_data.poi)
            revivechannel = fe_utils.get_channel(cmd.guild, new_poi.channel)
            reunite = fe_utils.formatMessage(cmd.message.author, reunite)
            await fe_utils.send_message(cmd.client, revivechannel, reunite)

    # Send the response to the player.
    await fe_utils.send_message(
        cmd.client, cmd.message.channel,
        fe_utils.formatMessage(cmd.message.author, response))
示例#25
0
async def refresh_bazaar(id_server=None):
    if id_server:
        # Update the list of available bazaar items by clearing the current list and adding the new items
        market_data = EwMarket(id_server)
        market_data.bazaar_wares.clear()

        bazaar_foods = []
        bazaar_cosmetics = []
        bazaar_general_items = []
        bazaar_furniture = []
        bazaar_relics = []

        for item in vendors.vendor_inv.get(ewcfg.vendor_bazaar):
            if item in static_items.item_names:
                bazaar_general_items.append(item)

            elif item in static_food.food_names:
                bazaar_foods.append(item)

            elif item in cosmetics.cosmetic_names:
                bazaar_cosmetics.append(item)

            elif item in static_items.furniture_names:
                bazaar_furniture.append(item)

            elif item in static_relic.relic_names and relic_utils.canCreateRelic(
                    item=item, id_server=id_server) is not None:
                bazaar_relics.append(item)

        if (ewdebug.bazaarTurnout() == 1) and (len(bazaar_relics) > 0):
            market_data.bazaar_wares['relic1'] = random.choice(bazaar_relics)

        market_data.bazaar_wares['slimecorp1'] = ewcfg.weapon_id_umbrella
        market_data.bazaar_wares['slimecorp2'] = ewcfg.cosmetic_id_raincoat

        market_data.bazaar_wares['generalitem'] = random.choice(
            bazaar_general_items)

        market_data.bazaar_wares['food1'] = random.choice(bazaar_foods)
        # Don't add repeated foods
        bw_food2 = None
        while bw_food2 is None or bw_food2 in market_data.bazaar_wares.values(
        ):
            bw_food2 = random.choice(bazaar_foods)

        market_data.bazaar_wares['food2'] = bw_food2

        market_data.bazaar_wares['cosmetic1'] = random.choice(bazaar_cosmetics)
        # Don't add repeated cosmetics
        bw_cosmetic2 = None
        while bw_cosmetic2 is None or bw_cosmetic2 in market_data.bazaar_wares.values(
        ):
            bw_cosmetic2 = random.choice(bazaar_cosmetics)

        market_data.bazaar_wares['cosmetic2'] = bw_cosmetic2

        bw_cosmetic3 = None
        while bw_cosmetic3 is None or bw_cosmetic3 in market_data.bazaar_wares.values(
        ):
            bw_cosmetic3 = random.choice(bazaar_cosmetics)

        market_data.bazaar_wares['cosmetic3'] = bw_cosmetic3

        market_data.bazaar_wares['furniture1'] = random.choice(
            bazaar_furniture)

        bw_furniture2 = None
        while bw_furniture2 is None or bw_furniture2 in market_data.bazaar_wares.values(
        ):
            bw_furniture2 = random.choice(bazaar_furniture)

        market_data.bazaar_wares['furniture2'] = bw_furniture2

        bw_furniture3 = None
        while bw_furniture3 is None or bw_furniture3 in market_data.bazaar_wares.values(
        ):
            bw_furniture3 = random.choice(bazaar_furniture)

        market_data.bazaar_wares['furniture3'] = bw_furniture3

        if random.random() < 0.05:  # 1 / 20
            market_data.bazaar_wares['minigun'] = ewcfg.weapon_id_minigun

        if random.random() < 0.05:  # 1 / 20
            market_data.bazaar_wares['bustedrifle'] = ewcfg.item_id_bustedrifle

        market_data.persist()
示例#26
0
async def menu(cmd):
    user_data = EwUser(member=cmd.message.author, data_level=2)
    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)
    # poi = ewmap.fetch_poi_if_coordless(cmd.message.channel.name)
    poi = poi_static.id_to_poi.get(user_data.poi)

    if user_data.poi == ewcfg.poi_id_clinicofslimoplasty:
        response = "Try {}browse. The menu is in the zines.".format(ewcfg.cmd_prefix)
    elif 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)

        mother_district_data = None
        for mother_poi in poi.mother_districts:

            mother_poi_data = poi_static.id_to_poi.get(mother_poi)

            if mother_poi_data.is_district:
                # One of the mother pois was a district, get its controlling faction
                mother_district_data = EwDistrict(district=mother_poi, id_server=user_data.id_server)
                break
            else:
                # One of the mother pois was a street, get the father district of that street and its controlling faction
                father_poi = mother_poi_data.father_district
                mother_district_data = EwDistrict(district=father_poi, id_server=user_data.id_server)
                break

        district_data = EwDistrict(district=poi.id_poi, id_server=user_data.id_server)
        # mother_district_data = EwDistrict(district = destination_poi.id_poi, id_server = user_data.id_server)

        shambler_multiplier = 1  # for speakeasy during shambler times

        if district_data.is_degraded() and poi.id_poi != ewcfg.poi_id_nuclear_beach_edge:
            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))

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

        response = "{} Menu:\n\n".format(poi.str_name)

        vendors_list = poi.vendors

        for vendor in vendors_list:
            if vendor == ewcfg.vendor_secretbodega:
                if user_data.freshness < ewcfg.freshnesslevel_4:
                    continue
                else:
                    response += '\nThe hipster behind the counter nearly falls out of his chair after laying eyes on the sheer, unadulterated freshness before him.\n"S-Sir! Your outfit... i-it is positively ***on fleek!!*** As I see you are a fashion enthusiast like myself, let me show you the good stuff…"\n'

            items = []
            # If the vendor is the bazaar get the current rotation of items from the market_data
            vendor_inv = vendors.vendor_inv[vendor] if vendor != ewcfg.vendor_bazaar else market_data.bazaar_wares.values()
            for item_name in vendor_inv:
                item_item = static_items.item_map.get(item_name)
                food_item = static_food.food_map.get(item_name)
                cosmetic_item = static_cosmetics.cosmetic_map.get(item_name)
                furniture_item = static_items.furniture_map.get(item_name)
                weapon_item = static_weapons.weapon_map.get(item_name)
                relic_item = static_relic.relic_map.get(item_name)

                if relic_item is not None:
                    if relic_utils.canCreateRelic(item_name, cmd.guild.id) == None:
                        continue

                # increase profits for the stock market
                stock_data = None
                if vendor in ewcfg.vendor_stock_map:
                    stock = ewcfg.vendor_stock_map.get(vendor)
                    stock_data = EwStock(id_server=user_data.id_server, stock=stock)

                value = 0

                if item_item:
                    value = item_item.price

                if food_item:
                    value = food_item.price

                if cosmetic_item:
                    value = cosmetic_item.price

                if furniture_item:
                    value = furniture_item.price

                if weapon_item:
                    value = weapon_item.price

                if relic_item:
                    value = relic_item.price

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

                # multiply by 4 is speakeasy is shambled
                value *= shambler_multiplier

                if mother_district_data != None:
                    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

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

                value = int(value)

                if value != 0:
                    items.append('{} ({:,})'.format(item_name, value))
                else:
                    items.append(item_name)

            response += "**{}**: *{}*\n".format(vendor, ewutils.formatNiceList(names=items))

            if vendor == ewcfg.vendor_bodega:
                if user_data.freshness < ewcfg.freshnesslevel_1:
                    response += "\nThe hipster behind the counter is utterly repulsed by the fashion disaster in front of him. Looks like you just aren’t fresh enough for him."
            if user_data.has_soul == 0:
                if vendor == ewcfg.vendor_dojo:
                    response += "\n\nThe Dojo master looks at your soulless form with pity."
                elif vendor == ewcfg.vendor_bar:
                    response += "\n\nThe bartender, sensing your misery, asks if you're okay."
                elif vendor == ewcfg.vendor_diner:
                    response += "\n\nThe cook gives you a concerned look as he throws down another helping of flapjacks."
                elif vendor == ewcfg.vendor_seafood:
                    response += "\n\nThe waiter sneers at how soulless and unkempt you look. You try to ignore him."
                elif vendor == ewcfg.vendor_bazaar:
                    response += "\n\nAll the shops seem so lively. You wish you had a soul so you could be like them."
                elif vendor == ewcfg.vendor_beachresort or vendor == ewcfg.vendor_countryclub:
                    response += "\n\nEverything looks so fancy here, but it doesn't really appeal to you since you don't have a soul."
                elif vendor == ewcfg.vendor_bodega:
                    if user_data.freshness < ewcfg.freshnesslevel_1:
                        response += ".. and you probably never will be."
                elif vendor == ewcfg.vendor_glocksburycomics:
                    response += "\n\nThe cashier here tries to start up a conversation about life being worth living. You're having none of it."
                elif vendor == ewcfg.vendor_basedhardware:
                    response += "\n\nSo many industrial metals here... You contemplate which you could use to kill yourself..."
                elif vendor == ewcfg.vendor_wafflehouse:
                    response += "\n\nNot even waffles could hope to make your emptiness go away."
                elif vendor == ewcfg.vendor_greencakecafe:
                    response += "\n\nThe barista behind the counter pauses to look at your soulless misery for a second, but decides you're not worth it and gets back to work."
                elif vendor == ewcfg.vendor_slimypersuits:
                    response += "\n\nYour mere presence in here ruins the cheery atmosphere."

    # Send the response to the player.
    await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
示例#27
0
async def publish_manuscript(cmd):
    user_data = EwUser(member=cmd.message.author)
    if user_data.life_state == ewcfg.life_state_shambler:
        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=user_data.id_server)

    poi = poi_static.id_to_poi.get(user_data.poi)

    if not poi.write_manuscript:
        response = "You'd love to work on your zine, however your current location doesn't strike you as a particularly good place to write. Try heading over the the Cafe, the Comic Shop, or one of the colleges (NLACU/NMS)."

    elif user_data.manuscript == -1:
        response = "You have yet to create a manuscript. Try !createmanuscript"

    else:
        book = EwBook(member=cmd.message.author, book_state=0)
        # check if zine is unreasonably short
        length = 0
        for page in book.book_pages.keys():
            length += len(book.book_pages[page])

        if book.genre == -1:
            response = "Before you publish your zine, you must first set a genre with !setgenre. The genre choices are {}.".format(ewutils.formatNiceList(ewcfg.book_genres))

        elif len(book.book_pages.keys()) < 3 or length < 10:
            response = "Who are you trying to fool? This zine is obviously too short!"

        else:
            accepted = False

            response = "Are you sure you want to publish your manuscript? This cannot be undone. **!accept** or **!refuse**"

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

            try:
                message = await cmd.client.wait_for('message', timeout=20, check=lambda message: message.author == cmd.message.author and
                                                                                                 message.content.lower() in [ewcfg.cmd_accept, ewcfg.cmd_refuse])

                if message != None:
                    if message.content.lower() == ewcfg.cmd_accept:
                        accepted = True
                    if message.content.lower() == ewcfg.cmd_refuse:
                        accepted = False
            except:
                accepted = False

            if not accepted:
                response = "The manuscript was not published."

            else:
                book.book_state = 1
                book.date_published = market_data.day
                length = 0

                for page in range(1, book.pages + 1):
                    length += len(book.book_pages.get(page, ""))

                book.length = length
                user_data.manuscript = -1

                user_data.persist()
                book.persist()

                bknd_item.item_create(
                    item_type=ewcfg.it_book,
                    id_user=user_data.id_user,
                    id_server=book.id_server,
                    item_props={
                        "title": book.title,
                        "author": book.author,
                        "date_published": book.date_published,
                        "id_book": book.id_book,
                        "book_desc": "A zine by {}, published on {}. It's the author's copy.".format(book.author, book.date_published)
                    })

                book_sale = EwBookSale(id_book=book.id_book, member=cmd.message.author)
                book_sale.bought = 1

                book_sale.persist()

                response = "You've published your manuscript! Anybody can now buy your creation and you'll get royalties!"

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