Exemple #1
0
async def clear_mutations(cmd):
    user_data = EwUser(member=cmd.message.author)
    market_data = EwMarket(id_server=user_data.id_server)
    response = ""
    if user_data.poi != ewcfg.poi_id_slimeoidlab:
        response = "You require the advanced equipment at the Slimeoid Lab to modify your mutations."
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    if user_data.life_state == ewcfg.life_state_corpse:
        response = "How do you expect to mutate without exposure to slime, dumbass?"
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    mutations = user_data.get_mutations()
    if len(mutations) == 0:
        response = "You have not developed any specialized mutations yet."
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    poudrin = ewitem.find_item(item_search="slimepoudrin",
                               id_user=cmd.message.author.id,
                               id_server=cmd.message.server.id
                               if cmd.message.server is not None else None)

    if poudrin == None:
        response = "You need a slime poudrin to replace a mutation."
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))
    else:
        ewitem.item_delete(id_item=poudrin.get('id_item'))  # Remove Poudrins
        market_data.donated_poudrins += 1
        market_data.persist()
        user_data.poudrin_donations += 1
        user_data.persist()

    user_data.clear_mutations()
    response = "After several minutes long elevator descents, in the depths of some basement level far below the laboratory's lobby, you lay down on a reclined medical chair. A SlimeCorp employee 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 getting slime. They oblige.\nThey grab a random used syringe with just a dash of black serum still left inside it. They carefully stab you with it, injecting the mystery formula into your bloodstream. Almost immediately, normalcy returns to your inherently abnormal life… your body returns to whatever might be considered normal for your species. You hand off one of your hard-earned poudrins to the SlimeCorp employee for their troubles."
    return await ewutils.send_message(
        cmd.client, cmd.message.channel,
        ewutils.formatMessage(cmd.message.author, response))
Exemple #2
0
    def eat(self, food_item=None):
        item_props = food_item.item_props
        mutations = self.get_mutations()

        if ewcfg.mutation_id_spoiledappetite not in mutations and float(
                food_item.time_expir if food_item.time_expir is not None else 0
        ) < time.time():
            response = "You realize that the food you were trying to eat is already spoiled. In disgust, you throw it away."
            ewitem.item_drop(food_item.id_item)
        else:
            hunger_restored = int(item_props['recover_hunger'])
            if self.id_user in ewutils.food_multiplier and ewutils.food_multiplier.get(
                    self.id_user) > 0:
                if ewcfg.mutation_id_bingeeater in mutations:
                    hunger_restored *= ewutils.food_multiplier.get(
                        self.id_user)
                ewutils.food_multiplier[self.id_user] += 1
            else:
                ewutils.food_multiplier[self.id_user] = 1

            self.hunger -= hunger_restored
            if self.hunger < 0:
                self.hunger = 0
            self.inebriation += int(item_props['inebriation'])
            if self.inebriation > 20:
                self.inebriation = 20

            try:
                if item_props['id_food'] in [
                        "coleslaw", "bloodcabbagecoleslaw"
                ]:
                    self.applyStatus(id_status=ewcfg.status_ghostbust_id)
                    #Bust player if they're a ghost
                    if self.life_state == ewcfg.life_state_corpse:
                        self.die(cause=ewcfg.cause_busted)
            except:
                # An exception will occur if there's no id_food prop in the database. We don't care.
                pass

            response = item_props['str_eat'] + ("\n\nYou're stuffed!"
                                                if self.hunger <= 0 else "")

            ewitem.item_delete(food_item.id_item)

        return response
async def smelt(cmd):
    poudrins = ewitem.inventory(id_user=cmd.message.author.id,
                                id_server=cmd.message.server.id,
                                item_type_filter=ewcfg.it_slimepoudrin)

    if len(poudrins) < 3:
        response = "You don't have enough poudrins to smelt."
    else:
        for i in range(3):
            ewitem.item_delete(id_item=poudrins[i].get('id_item'))

        patrician_rarity = 20
        patrician_smelted = random.randint(1, patrician_rarity)
        patrician = False

        if patrician_smelted == 1:
            patrician = True

        items = []

        for cosmetic in ewcfg.cosmetic_items_list:
            if patrician and cosmetic.rarity == ewcfg.rarity_patrician:
                items.append(cosmetic)
            elif not patrician and cosmetic.rarity == ewcfg.rarity_plebeian:
                items.append(cosmetic)

        item = items[random.randint(0, len(items) - 1)]

        ewitem.item_create(item_type=ewcfg.it_cosmetic,
                           id_user=cmd.message.author.id,
                           id_server=cmd.message.server.id,
                           item_props={
                               'cosmetic_name': item.name,
                               'cosmetic_desc': item.description,
                               'rarity': item.rarity,
                               'adorned': 'false'
                           })
        response = "You smelted a {item_name}!".format(item_name=item.name)
    await cmd.client.send_message(
        cmd.message.channel, ewutils.formatMessage(cmd.message.author,
                                                   response))
Exemple #4
0
async def smeltsoul(cmd):
    item = ewitem.find_item(item_search="reanimatedcorpse",
                            id_user=cmd.message.author.id,
                            id_server=cmd.guild.id)
    if not item:
        response = "You can't rip a soul out of a nonexistent object."
    else:
        item_obj = ewitem.EwItem(id_item=item.get('id_item'))
        if item_obj.item_props.get(
                'target') != None and item_obj.item_props.get('target') != "":
            targetid = item_obj.item_props.get('target')
            ewitem.give_item(id_user=cmd.message.author.id,
                             id_item=targetid,
                             id_server=cmd.guild.id)
            response = "You ripped the soul out of the reanimated corpse. It's in mangled bits now."
            ewitem.item_delete(id_item=item.get('id_item'))
        else:
            response = "That's not a reanimated corpse. It only looks like one. Get rid of the fake shit and we'll get started."
    await ewutils.send_message(
        cmd.client, cmd.message.channel,
        ewutils.formatMessage(cmd.message.author, response))
Exemple #5
0
    def eat(self, food_item=None):
        item_props = food_item.item_props

        if float(food_item.time_expir if not None else 0) < time.time():
            response = "You realize that the food you were trying to eat is already spoiled. In disgust, you throw it away."
        else:
            self.hunger -= int(item_props['recover_hunger'])
            if self.hunger < 0:
                self.hunger = 0
            self.inebriation += int(item_props['inebriation'])
            if self.inebriation > 20:
                self.inebriation = 20

            if food_item.id_item == "coleslaw":
                self.ghostbust = True

            response = item_props['str_eat'] + ("\n\nYou're stuffed!"
                                                if self.hunger <= 0 else "")

        ewitem.item_delete(food_item.id_item)

        return response
Exemple #6
0
def popcapsule(id_user=None, id_server=None, item=None):
    rarity_roll = random.randrange(10)
    ewitem.item_delete(item.id_item)

    if rarity_roll > 3:
        prank_item = random.choice(ewcfg.prank_items_heinous)
    elif rarity_roll > 0:
        prank_item = random.choice(ewcfg.prank_items_scandalous)
    else:
        prank_item = random.choice(ewcfg.prank_items_forbidden)

    item_props = ewitem.gen_item_props(prank_item)

    prank_item_id = ewitem.item_create(item_type=prank_item.item_type,
                                       id_user=id_user.id,
                                       id_server=id_server.id,
                                       item_props=item_props)

    response = "You pop open the Prank Capsule to reveal a {}! Whoa, sick!!".format(
        prank_item.str_name)

    return response
Exemple #7
0
async def sow(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 ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))

	# check if the user has a farming tool equipped
	weapon_item = EwItem(id_item=user_data.weapon)
	weapon = ewcfg.weapon_map.get(weapon_item.item_props.get("weapon_type"))
	has_tool = False
	if weapon is not None:
		if ewcfg.weapon_class_farming in weapon.classes:
			has_tool = True

	# Checking availability of sow action
	if user_data.life_state != ewcfg.life_state_juvenile and not has_tool:
		response = "Only Juveniles of pure heart and with nothing better to do can farm."

	elif cmd.message.channel.name not in [ewcfg.channel_jr_farms, ewcfg.channel_og_farms, ewcfg.channel_ab_farms]:
		response = "The cracked, filthy concrete streets around you would be a pretty terrible place for a farm. Try again on more arable land."

	else:
		poi = ewcfg.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 ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
		if user_data.poi == ewcfg.poi_id_jr_farms:
			farm_id = ewcfg.poi_id_jr_farms
		elif user_data.poi == ewcfg.poi_id_og_farms:
			farm_id = ewcfg.poi_id_og_farms
		else:  # if it's the farm in arsonbrook
			farm_id = ewcfg.poi_id_ab_farms

		farm = EwFarm(
			id_server = cmd.guild.id,
			id_user = cmd.message.author.id,
			farm = farm_id
		)

		if farm.time_lastsow > 0:
			response = "You’ve already sown something here. Try planting in another farming location. If you’ve planted in all three farming locations, you’re shit out of luck. Just wait, asshole."
		else:
			it_type_filter = None

			# gangsters can only plant poudrins
			if cmd.tokens_count > 1 and user_data.life_state == ewcfg.life_state_juvenile:
				item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])
				
				# if the item selected was a vegetable, use a food only filter in find_item
				for v in ewcfg.vegetable_list:
					if item_search in v.id_food or item_search in v.str_name:
						it_type_filter = ewcfg.it_food
						break
			else:
				item_search = "slimepoudrin"

			item_sought = ewitem.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 = it_type_filter)

			if item_sought == None:
				response = "You don't have anything to plant! Try collecting a poudrin."
			else:
				slimes_onreap = ewcfg.reap_gain
				item_data = EwItem(id_item = item_sought.get("id_item"))
				if item_data.item_type == ewcfg.it_item:
					if item_data.item_props.get("id_item") == ewcfg.item_id_slimepoudrin:
						vegetable = random.choice(ewcfg.vegetable_list)
						slimes_onreap *= 2
					elif item_data.item_props.get("context") == ewcfg.context_slimeoidheart:
						vegetable = random.choice(ewcfg.vegetable_list)
						slimes_onreap *= 2

						slimeoid_data = EwSlimeoid(id_slimeoid = item_data.item_props.get("subcontext"))
						slimeoid_data.delete()
						
					else:
						response = "The soil has enough toxins without you burying your trash here."
						return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
				elif item_data.item_type == ewcfg.it_food:
					food_id = item_data.item_props.get("id_food")
					vegetable = ewcfg.food_map.get(food_id)
					if ewcfg.vendor_farm not in vegetable.vendors:
						response = "It sure would be nice if {}s grew on trees, but alas they do not. Idiot.".format(item_sought.get("name"))
						return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
					elif user_data.life_state != ewcfg.life_state_juvenile:
						response = "You lack the knowledge required to grow {}.".format(item_sought.get("name"))
						return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))

				else:
					response = "The soil has enough toxins without you burying your trash here."
					return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))

				mutations = user_data.get_mutations()
				growth_time = ewcfg.crops_time_to_grow
				if user_data.life_state == ewcfg.life_state_juvenile:
					growth_time /= 2
				if ewcfg.mutation_id_greenfingers in mutations:
					growth_time /= 1.5
				
				hours = int(growth_time / 60)
				minutes = int(growth_time % 60)

				str_growth_time = "{} hour{}{}".format(hours, "s" if hours > 1 else "", " and {} minutes".format(minutes) if minutes > 0 else "")

				# Sowing
				response = "You sow a {} into the fertile soil beneath you. It will grow in about {}.".format(item_sought.get("name"), str_growth_time)

				farm.time_lastsow = int(time.time() / 60)  # Grow time is stored in minutes.
				farm.time_lastphase = int(time.time())
				farm.slimes_onreap = slimes_onreap
				farm.crop = vegetable.id_food
				farm.phase = ewcfg.farm_phase_sow
				farm.action_required = ewcfg.farm_action_none
				farm.sow_life_state = user_data.life_state
				ewitem.item_delete(id_item = item_sought.get('id_item'))  # Remove Poudrins

				farm.persist()

	await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
Exemple #8
0
async def on_message(message):
    time_now = int(time.time())
    """ do not interact with our own messages """
    if message.author.id == client.user.id or message.author.bot == True:
        return

    if message.server != None:
        # Note that the user posted a message.
        active_map = active_users_map.get(message.server.id)
        if active_map == None:
            active_map = {}
            active_users_map[message.server.id] = active_map
        active_map[message.author.id] = True

        # Update player information.
        ewplayer.player_update(member=message.author, server=message.server)

    content_tolower = message.content.lower()
    re_awoo = re.compile('.*![a]+[w]+o[o]+.*')

    if message.content.startswith(
            ewcfg.cmd_prefix) or message.server == None or len(
                message.author.roles) < 2:
        """
			Wake up if we need to respond to messages. Could be:
				message starts with !
				direct message (server == None)
				user is new/has no roles (len(roles) < 2)
		"""

        # tokenize the message. the command should be the first word.
        tokens = message.content.split(' ')
        tokens_count = len(tokens)
        cmd = tokens[0].lower()

        # remove mentions to us
        mentions = list(
            filter(lambda user: user.id != client.user.id, message.mentions))
        mentions_count = len(mentions)

        # Create command object
        cmd_obj = ewcmd.EwCmd(tokens=tokens,
                              message=message,
                              client=client,
                              mentions=mentions)
        """ reply to DMs with help document """
        if message.server == None:
            # Direct message the player their inventory.
            if ewitem.cmd_is_inventory(cmd):
                return await ewitem.inventory_print(cmd_obj)
            else:
                time_last = last_helped_times.get(message.author.id, 0)

                # Only send the help doc once every thirty seconds. There's no need to spam it.
                if (time_now - time_last) > 30:
                    last_helped_times[message.author.id] = time_now
                    await client.send_message(
                        message.channel,
                        'Check out the guide for help: https://ew.krakissi.net/guide/'
                    )

            # Nothing else to do in a DM.
            return

        # common data we'll need
        roles_map = cmd_obj.roles_map

        # assign the juveniles role to a user with only 1 or 0 roles.
        if len(message.author.roles) < 2:
            role_juvenile = roles_map[ewcfg.role_juvenile]
            await client.replace_roles(message.author, role_juvenile)
            return

        # Scold/ignore offline players.
        if message.author.status == discord.Status.offline:
            resp = await ewcmd.start(cmd=cmd_obj)
            response = "You cannot participate in the ENDLESS WAR while offline."

            if resp != None:
                await client.edit_message(
                    resp, ewutils.formatMessage(message.author, response))
            else:
                await client.send_message(
                    message.channel,
                    ewutils.formatMessage(message.author, response))

            return

        # process command words
        if cmd == ewcfg.cmd_kill or cmd == ewcfg.cmd_shoot:
            return await ewwep.attack(cmd_obj)

        # Choose your weapon
        elif cmd == ewcfg.cmd_equip:
            return await ewwep.equip(cmd_obj)

        # Kill yourself to return slime to your general.
        elif cmd == ewcfg.cmd_suicide:
            return await ewwep.suicide(cmd_obj)

        # Spar with an ally
        elif cmd == ewcfg.cmd_spar:
            return await ewwep.spar(cmd_obj)

        # Name your current weapon.
        elif cmd == ewcfg.cmd_annoint:
            return await ewwep.annoint(cmd_obj)

        # move from juvenile to one of the armies (rowdys or killers)
        elif cmd == ewcfg.cmd_enlist:
            return await ewjuviecmd.enlist(cmd_obj)

        # gives slime to the miner (message.author)
        elif cmd == ewcfg.cmd_mine:
            return await ewjuviecmd.mine(cmd_obj)

        # Show the current slime score of a player.
        elif cmd == ewcfg.cmd_score or cmd == ewcfg.cmd_score_alt1:
            return await ewcmd.score(cmd_obj)

        # Show a player's combat data.
        elif cmd == ewcfg.cmd_data:
            return await ewcmd.data(cmd_obj)

        #check what time it is, and the weather
        elif cmd == ewcfg.cmd_time or cmd == ewcfg.cmd_clock or cmd == ewcfg.cmd_weather:
            return await ewcmd.weather(cmd_obj)

        # Show the total of negative slime in the world.
        elif cmd == ewcfg.cmd_negaslime:
            return await ewspooky.negaslime(cmd_obj)

        # revive yourself as a juvenile after having been killed.
        elif cmd == ewcfg.cmd_revive:
            return await ewspooky.revive(cmd_obj)

        # Ghosts can haunt enlisted players to reduce their slime score.
        elif cmd == ewcfg.cmd_haunt:
            return await ewspooky.haunt(cmd_obj)

        # Play slime pachinko!
        elif cmd == ewcfg.cmd_slimepachinko:
            return await ewcasino.pachinko(cmd_obj)

        # Toss the dice at slime craps!
        elif cmd == ewcfg.cmd_slimecraps:
            return await ewcasino.craps(cmd_obj)

        # Pull the lever on a slot machine!
        elif cmd == ewcfg.cmd_slimeslots:
            return await ewcasino.slots(cmd_obj)

        # See what's for sale in the Food Court.
        elif cmd == ewcfg.cmd_menu:
            return await ewfood.menu(cmd_obj)

        # Order refreshing food and drinks!
        elif cmd == ewcfg.cmd_order:
            return await ewfood.order(cmd_obj)

        # Transfer slime between players. Shares a cooldown with investments.
        elif cmd == ewcfg.cmd_transfer or cmd == ewcfg.cmd_transfer_alt1:
            return await ewmarket.xfer(cmd_obj)

        # Invest in the slime market!
        elif cmd == ewcfg.cmd_invest:
            return await ewmarket.invest(cmd_obj)

        # Withdraw your investments!
        elif cmd == ewcfg.cmd_withdraw:
            return await ewmarket.withdraw(cmd_obj)

        # Show the current slime market exchange rate (slime per credit).
        elif cmd == ewcfg.cmd_exchangerate or cmd == ewcfg.cmd_exchangerate_alt1:
            return await ewmarket.rate(cmd_obj)

        # Show the player's slime credit.
        elif cmd == ewcfg.cmd_slimecredit or cmd == ewcfg.cmd_slimecredit_alt1:
            return await ewmarket.slimecoin(cmd_obj)

        # faction leader consumes the mentioned players of their own faction to absorb their slime count
        # kills the mentioned players
        elif cmd == ewcfg.cmd_devour:
            return await ewkingpin.devour(cmd_obj)

        # rowdy f****r and cop killer (leaders) can give slimes to anybody
        elif cmd == ewcfg.cmd_giveslime or cmd == ewcfg.cmd_giveslime_alt1:
            return await ewkingpin.giveslime(cmd_obj)

        # Remove a megaslime (1 mil slime) from a general.
        elif cmd == ewcfg.cmd_deadmega:
            return await ewkingpin.deadmega(cmd_obj)

        # FIXME debug
        # Test item creation
        elif cmd == '!create':
            item_id = ewitem.item_create(
                item_type='medal',
                id_user=message.author.id,
                id_server=message.server.id,
                item_props={
                    'medal_name':
                    'Test Award',
                    'medal_desc':
                    '**{medal_name}**: *Awarded to Krak by Krak for testing shit.*'
                })

            ewutils.logMsg('Created item: {}'.format(item_id))
            item = EwItem(id_item=item_id)
            item.item_props['test'] = 'meow'
            item.persist()

            item = EwItem(id_item=item_id)

            await client.send_message(
                message.channel,
                ewutils.formatMessage(message.author, ewitem.item_look(item)))

        # FIXME debug
        # Test item deletion
        elif cmd == '!delete':
            items = ewitem.inventory(id_user=message.author.id,
                                     id_server=message.server.id)

            for item in items:
                ewitem.item_delete(id_item=item.get('id_item'))

            await client.send_message(
                message.channel, ewutils.formatMessage(message.author, 'ok'))

        # Direct message the player their inventory.
        elif ewitem.cmd_is_inventory(cmd):
            return await ewitem.inventory_print(cmd_obj)

        # !harvest is not a command
        elif cmd == ewcfg.cmd_harvest:
            await client.send_message(
                message.channel,
                ewutils.formatMessage(
                    message.author,
                    '**HARVEST IS NOT A COMMAND YOU F*****G IDIOT**'))

        # AWOOOOO
        elif cmd == ewcfg.cmd_howl or cmd == ewcfg.cmd_howl_alt1 or re_awoo.match(
                cmd):
            return await ewcmd.cmd_howl(cmd_obj)

        # advertise patch notes
        elif cmd == ewcfg.cmd_patchnotes:
            await client.send_message(
                message.channel,
                ewutils.formatMessage(
                    message.author,
                    'Look for the latest patchnotes on the news page: https://ew.krakissi.net/news/'
                ))

        # advertise help services
        elif cmd == ewcfg.cmd_help or cmd == ewcfg.cmd_help_alt1 or cmd == ewcfg.cmd_help_alt2:
            await client.send_message(
                message.channel,
                ewutils.formatMessage(
                    message.author,
                    'Check out the guide for help: https://ew.krakissi.net/guide/'
                ))

        # Debug command to override the role of a user
        elif debug == True and cmd == (ewcfg.cmd_prefix + 'setrole'):
            resp = await ewcmd.start(cmd=cmd_obj)
            response = ""

            if mentions_count == 0:
                response = 'Set who\'s role?'
            else:
                role_target = tokens[1]
                role = roles_map.get(role_target)

                if role != None:
                    for user in mentions:
                        await client.replace_roles(user, role)

                    response = 'Done.'
                else:
                    response = 'Unrecognized role.'

            await client.edit_message(
                resp, ewutils.formatMessage(message.author, response))

        # didn't match any of the command words.
        else:
            resp = await ewcmd.start(cmd=cmd_obj)
            """ couldn't process the command. bail out!! """
            """ bot rule 0: be cute """
            randint = random.randint(1, 3)
            msg_mistake = "ENDLESS WAR is growing frustrated."
            if randint == 2:
                msg_mistake = "ENDLESS WAR denies you his favor."
            elif randint == 3:
                msg_mistake = "ENDLESS WAR pays you no mind."

            await asyncio.sleep(1)
            await client.edit_message(resp, msg_mistake)
            await asyncio.sleep(2)
            await client.delete_message(resp)

    elif content_tolower.find(ewcfg.cmd_howl) >= 0 or content_tolower.find(
            ewcfg.cmd_howl_alt1) >= 0 or re_awoo.match(content_tolower):
        """ Howl if !howl is in the message at all. """
        return await ewcmd.cmd_howl(ewcmd.EwCmd(message=message,
                                                client=client))
Exemple #9
0
async def dye(cmd):
    hat_id = ewutils.flattenTokenListToString(cmd.tokens[1:2])
    dye_id = ewutils.flattenTokenListToString(cmd.tokens[2:])

    try:
        hat_id_int = int(hat_id)
    except:
        hat_id_int = None

    try:
        dye_id_int = int(dye_id)
    except:
        dye_id_int = None

    if hat_id != None and len(hat_id) > 0 and dye_id != None and len(
            dye_id) > 0:
        response = "You don't have one."

        items = ewitem.inventory(
            id_user=cmd.message.author.id,
            id_server=cmd.guild.id,
        )

        cosmetic = None
        dye = None
        for item in items:

            if int(
                    item.get('id_item')
            ) == hat_id_int or hat_id in ewutils.flattenTokenListToString(
                    item.get('name')):
                if item.get(
                        'item_type') == ewcfg.it_cosmetic and cosmetic is None:
                    cosmetic = item

            if int(
                    item.get('id_item')
            ) == dye_id_int or dye_id in ewutils.flattenTokenListToString(
                    item.get('name')):
                if item.get('item_type') == ewcfg.it_item and item.get(
                        'name') in ewcfg.dye_map and dye is None:
                    dye = item

            if cosmetic != None and dye != None:
                break

        if cosmetic != None:
            if dye != None:
                cosmetic_item = EwItem(id_item=cosmetic.get("id_item"))
                dye_item = EwItem(id_item=dye.get("id_item"))

                hue = ewcfg.hue_map.get(dye_item.item_props.get('id_item'))

                response = "You dye your {} in {} paint!".format(
                    cosmetic_item.item_props.get('cosmetic_name'),
                    hue.str_name)
                cosmetic_item.item_props['hue'] = hue.id_hue

                cosmetic_item.persist()
                ewitem.item_delete(id_item=dye.get('id_item'))
            else:
                response = 'Use which dye? Check your **!inventory**.'
        else:
            response = 'Dye which cosmetic? Check your **!inventory**.'

        await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))
    else:
        await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(
                cmd.message.author,
                'You need to specify which cosmetic you want to paint and which dye you want to use! Check your **!inventory**.'
            ))
Exemple #10
0
async def cast(cmd):
	time_now = round(time.time())
	has_reeled = False
	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 ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))

	if ewutils.channel_name_is_poi(cmd.message.channel.name) == False:
		return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.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 fishers.keys():
		fishers[cmd.message.author.id] = EwFisher()

	fisher = 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 ewcfg.piers:
		poi = ewcfg.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 ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
		if user_data.hunger >= ewutils.hunger_max_bylevel(user_data.slimelevel):
			response = "You're too hungry to fish right now."

		else:
			has_fishingrod = False

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

			#if user_data.sidearm >= 0:
			#	sidearm_item = EwItem(id_item=user_data.sidearm)
			#	sidearm = ewcfg.weapon_map.get(sidearm_item.item_props.get("weapon_type"))
			#	if sidearm.id_weapon == "fishingrod":
			#		has_fishingrod = True

			if ewcfg.status_high_id in statuses:
				fisher.high = True
			fisher.fishing = True
			fisher.bait = False
			fisher.pier = ewcfg.id_to_poi.get(user_data.poi)
			fisher.current_fish = gen_fish(market_data, fisher, has_fishingrod)
			
			high_value_bait_used = False

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

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

			item_sought = ewitem.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 ewcfg.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 ["blacklimes", "blacklimesour"]:
						if random.randrange(2) == 1:
							fisher.current_fish = "blacklimesalmon"

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

					elif id_food in ["purplekilliflowercrustpizza", "purplekilliflower"]:
						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 float(item.time_expir if item.time_expir is not None else 0) < time.time():
						if random.randrange(2) == 1:
							fisher.current_fish = "plebefish"
					ewitem.item_delete(item_sought.get('id_item'))

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

			else:
				fisher.current_size = gen_fish_size(has_fishingrod)

			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."
			else:
				response += "glowing Slime Lake."

			user_data.hunger += ewcfg.hunger_perfish * ewutils.hunger_cost_mod(user_data.slimelevel)
			user_data.persist()
			
			await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.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/8
				fun -= 20
			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 ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, random.choice(ewcfg.nobite_text)))
					fun -= 2
					bun += 1
					if bun >= 5:
						fun -= 1
					if bun >= 15:
						fun -= 1
					continue
				else:
					break


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

			await asyncio.sleep(8)

			if fisher.bite != False:
				fisher.stop()
				return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, "The fish got away..."))
			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 ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
Exemple #11
0
async def appraise(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 = ewitem.find_item(item_search = item_search, id_user = cmd.message.author.id, id_server = cmd.message.server.id if cmd.message.server is not None else None)
	payment = ewitem.find_item(item_search = "manhattanproject", id_user = cmd.message.author.id, id_server = cmd.message.server.id if cmd.message.server 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 cmd.message.channel.name in [ewcfg.channel_tt_pier, ewcfg.channel_jp_pier, ewcfg.channel_cl_pier, ewcfg.channel_afb_pier, ewcfg.channel_vc_pier, ewcfg.channel_se_pier, ewcfg.channel_ferry]:
			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?'

	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!"'

				ewitem.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 ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
Exemple #12
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 = ewitem.find_item(item_search = item_search, id_user = cmd.message.author.id, id_server = cmd.message.server.id if cmd.message.server 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 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..."

		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

			poudrins_owned = ewitem.find_item_all(item_search = "slimepoudrin", id_user = user_data.id_user, id_server = user_data.id_server)
			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 size == ewcfg.fish_size_miniscule:
					fish.item_props['size'] = ewcfg.fish_size_small

				if size == ewcfg.fish_size_small:
					fish.item_props['size'] = ewcfg.fish_size_average

				if size == ewcfg.fish_size_average:
					fish.item_props['size'] = ewcfg.fish_size_big

				if size == ewcfg.fish_size_big:
					fish.item_props['size'] = ewcfg.fish_size_huge

				if size == ewcfg.fish_size_huge:
					fish.item_props['size'] = ewcfg.fish_size_colossal

				fish.persist()

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

				market_data.donated_poudrins += poudrin_cost
				market_data.persist()
				user_data.poudrin_donations += poudrin_cost
				user_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. A SlimeCorp employee 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 ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
Exemple #13
0
async def mill(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 = ewitem.find_item(item_search=item_search,
                                   id_user=cmd.message.author.id,
                                   id_server=cmd.message.server.id
                                   if cmd.message.server is not None else None)

    # 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 user_data.poi not in [
            ewcfg.poi_id_jr_farms, ewcfg.poi_id_og_farms, ewcfg.poi_id_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:
        items = []
        vegetable = EwItem(id_item=item_sought.get('id_item'))

        for result in ewcfg.mill_results:
            if result.ingredients != vegetable.item_props.get('id_food'):
                pass
            else:
                items.append(result)

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

            item_props = ewitem.gen_item_props(item)

            ewitem.item_create(item_type=item.item_type,
                               id_user=cmd.message.author.id,
                               id_server=cmd.message.server.id,
                               item_props=item_props)

            response = "You walk up to the official SlimeCorp Milling Station and shove your irradiated produce into the hand-crank. You painfully grip the needle-covered crank handle, dripping {} slime into a small compartment on the device’s side which supposedly fuels it. 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(
                ewcfg.slimes_permill, item.str_name)

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

            ewitem.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 ewutils.send_message(
        cmd.client, cmd.message.channel,
        ewutils.formatMessage(cmd.message.author, response))
async def smelt(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 ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))



	# Find sought recipe.
	if cmd.tokens_count > 1:
		sought_result = ewutils.flattenTokenListToString(cmd.tokens[1:])
		found_recipe = ewcfg.smelting_recipe_map.get(sought_result)

		if found_recipe != None:
			if 'soul' in found_recipe.products:
				return await smeltsoul(cmd=cmd)

			# Checks what ingredients are needed to smelt the recipe.
			necessary_ingredients = found_recipe.ingredients
			necessary_ingredients_list = []

			owned_ingredients = []

			# Seeks out the necessary ingredients in your inventory.
			missing_ingredients = []


			for matched_item in necessary_ingredients:
				necessary_items = necessary_ingredients.get(matched_item)
				necessary_str = "{} {}".format(necessary_items, matched_item)
				if necessary_items > 1:
					necessary_str += "s"
				necessary_ingredients_list.append(necessary_str)
				
				sought_items = ewitem.find_item_all(item_search = matched_item, id_user = user_data.id_user, id_server = user_data.id_server)
				missing_items = necessary_items - len(sought_items)
				if missing_items > 0:
					missing_str = "{} {}".format(missing_items, matched_item)
					if missing_items > 1:
						missing_str += "s"
					missing_ingredients.append(missing_str)
				else:
					for i in range(necessary_ingredients.get(matched_item)):
						sought_item = sought_items.pop()
						owned_ingredients.append(sought_item.get('id_item'))

			# If you don't have all the necessary ingredients.
			if len(missing_ingredients) > 0:
				response = "You’ve never done this before, have you? To smelt {}, you’ll need to combine *{}*.".format(found_recipe.str_name, ewutils.formatNiceList(names = necessary_ingredients_list, conjunction = "and"))

				response += " You are missing *{}*.".format(ewutils.formatNiceList(names = missing_ingredients, conjunction = "and"))

			else:
				# If you try to smelt a random cosmetic, use old smelting code to calculate what your result will be.
				if found_recipe.id_recipe == "cosmetic":
					patrician_rarity = 20
					patrician_smelted = random.randint(1, patrician_rarity)
					patrician = False

					if patrician_smelted == 1:
						patrician = True

					cosmetics_list = []

					for result in ewcfg.cosmetic_items_list:
						if result.acquisition == ewcfg.acquisition_smelting:
							cosmetics_list.append(result)
						else:
							pass

					items = []

					for cosmetic in cosmetics_list:
						if patrician and cosmetic.rarity == ewcfg.rarity_patrician:
							items.append(cosmetic)
						elif not patrician and cosmetic.rarity == ewcfg.rarity_plebeian:
							items.append(cosmetic)

					item = items[random.randint(0, len(items) - 1)]

					ewitem.item_create(
						item_type = ewcfg.it_cosmetic,
						id_user = cmd.message.author.id,
						id_server = cmd.message.server.id,
						item_props = {
							'id_cosmetic': item.id_cosmetic,
							'cosmetic_name': item.str_name,
							'cosmetic_desc': item.str_desc,
							'rarity': item.rarity,
							'adorned': 'false'
						}
					)

				# If you're trying to smelt a specific item.
				else:
					possible_results = []

					# Matches the recipe's listed products to actual items.
					for result in ewcfg.smelt_results:
						if hasattr(result, 'id_item'):
							if result.id_item not in found_recipe.products:
								pass
							else:
								possible_results.append(result)
						if hasattr(result, 'id_food'):
							if result.id_food not in found_recipe.products:
								pass
							else:
								possible_results.append(result)
						if hasattr(result, 'id_cosmetic'):
							if result.id_cosmetic not in found_recipe.products:
								pass
							else:
								possible_results.append(result)
						if hasattr(result, 'id_weapon'):
							if result.id_weapon not in found_recipe.products:
								pass
							else:
								possible_results.append(result)
						if hasattr(result, 'id_furniture'):
							if result.id_furniture not in found_recipe.products:
								pass
							else:
								possible_results.append(result)
					# If there are multiple possible products, randomly select one.
					item = random.choice(possible_results)

					item_props = ewitem.gen_item_props(item)

					newitem_id = ewitem.item_create(
						item_type = item.item_type,
						id_user = cmd.message.author.id,
						id_server = cmd.message.server.id,
						item_props = item_props
					)


				for id_item in owned_ingredients:
					item_check = ewitem.EwItem(id_item=id_item)
					if item_check.item_props.get('id_cosmetic') != 'soul':
						ewitem.item_delete(id_item = id_item)
					else:
						newitem = ewitem.EwItem(id_item=newitem_id)
						newitem.item_props['target'] = id_item
						newitem.persist()
						ewitem.give_item(id_item=id_item, id_user='******', id_server=cmd.message.server.id)

				name = ""
				if hasattr(item, 'str_name'):
					name = item.str_name
				elif hasattr(item, 'id_weapon'):
					name = item.id_weapon

				response = "You sacrifice your {} to smelt a {}!!".format(ewutils.formatNiceList(names = necessary_ingredients_list, conjunction = "and"), name)

				user_data.persist()

		else:
			response = "There is no recipe by the name."

	else:
		response = "Please specify a desired smelt result."

	# Send response
	await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def donate(cmd):
    user_data = EwUser(member=cmd.message.author)
    market_data = EwMarket(id_server=user_data.id_server)

    time_now = round(time.time())

    if user_data.poi == ewcfg.poi_id_slimecorphq:
        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.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)
                sewerchannel = ewutils.get_channel(cmd.message.server,
                                                   ewcfg.channel_sewers)
                await ewutils.send_message(
                    cmd.client, sewerchannel,
                    "{} ".format(ewcfg.emote_slimeskull) +
                    ewutils.formatMessage(
                        cmd.message.author,
                        "You have died in a medical mishap. {}".format(
                            ewcfg.emote_slimeskull)))
            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:
        poudrins = ewitem.find_item(item_search="slimepoudrin",
                                    id_user=cmd.message.author.id,
                                    id_server=cmd.message.server.id if
                                    cmd.message.server is not None else None)

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

        else:
            ewitem.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 SlimeCorp Lab in Brawlden."

    # Send the response to the player.
    await ewutils.send_message(
        cmd.client, cmd.message.channel,
        ewutils.formatMessage(cmd.message.author, response))
Exemple #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 ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))

	market_data = EwMarket(id_server = user_data.id_server)
	item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])
	item_sought = ewitem.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 = ewcfg.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 ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
		items = []
		vegetable = EwItem(id_item = item_sought.get('id_item'))

		for result in ewcfg.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 = ewitem.gen_item_props(item)
			
			ewitem.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()

			ewitem.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 ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
Exemple #17
0
async def sow(cmd):
    user_data = EwUser(member=cmd.message.author)

    # Checking availability of sow action
    if user_data.life_state != ewcfg.life_state_juvenile:
        response = "Only Juveniles of pure heart and with nothing better to do can farm."

    elif user_data.poi not in [
            ewcfg.poi_id_jr_farms, ewcfg.poi_id_og_farms, ewcfg.poi_id_ab_farms
    ]:
        response = "The cracked, filthy concrete streets around you would be a pretty terrible place for a farm. Try again on more arable land."

    else:
        if user_data.poi == ewcfg.poi_id_jr_farms:
            farm_id = ewcfg.poi_id_jr_farms
        elif user_data.poi == ewcfg.poi_id_og_farms:
            farm_id = ewcfg.poi_id_og_farms
        else:  # if it's the farm in arsonbrook
            farm_id = ewcfg.poi_id_ab_farms

        farm = EwFarm(id_server=cmd.message.server.id,
                      id_user=cmd.message.author.id,
                      farm=farm_id)

        if farm.time_lastsow > 0:
            response = "You’ve already sown something here. Try planting in another farming location. If you’ve planted in all three farming locations, you’re shit out of luck. Just wait, asshole."
        else:
            if cmd.tokens_count > 1:
                item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])
            else:
                item_search = "slimepoudrin"

            item_sought = ewitem.find_item(
                item_search=item_search,
                id_user=cmd.message.author.id,
                id_server=cmd.message.server.id
                if cmd.message.server is not None else None)

            if item_sought == None:
                response = "You don't have anything to plant! Try collecting a poudrin."
            else:
                slimes_onreap = ewcfg.reap_gain
                item_data = EwItem(id_item=item_sought.get("id_item"))
                if item_data.item_type == ewcfg.it_item:
                    if item_data.item_props.get(
                            "id_item") == ewcfg.item_id_slimepoudrin:
                        vegetable = random.choice(ewcfg.vegetable_list)
                        slimes_onreap *= 2
                    elif item_data.item_props.get(
                            "context") == ewcfg.context_slimeoidheart:
                        vegetable = random.choice(ewcfg.vegetable_list)
                        slimes_onreap *= 2

                        slimeoid_data = EwSlimeoid(
                            id_slimeoid=item_data.item_props.get("subcontext"))
                        slimeoid_data.delete()

                    else:
                        response = "The soil has enough toxins without you burying your trash here."
                        return await ewutils.send_message(
                            cmd.client, cmd.message.channel,
                            ewutils.formatMessage(cmd.message.author,
                                                  response))
                elif item_data.item_type == ewcfg.it_food:
                    food_id = item_data.item_props.get("id_food")
                    vegetable = ewcfg.food_map.get(food_id)
                    if ewcfg.vendor_farm not in vegetable.vendors:
                        response = "It sure would be nice if {}s grew on trees, but alas they do not. Idiot.".format(
                            item_sought.get("name"))
                        return await ewutils.send_message(
                            cmd.client, cmd.message.channel,
                            ewutils.formatMessage(cmd.message.author,
                                                  response))

                else:
                    response = "The soil has enough toxins without you burying your trash here."
                    return await ewutils.send_message(
                        cmd.client, cmd.message.channel,
                        ewutils.formatMessage(cmd.message.author, response))

                # Sowing
                response = "You sow a {} into the fertile soil beneath you. It will grow in about 3 hours.".format(
                    item_sought.get("name"))

                farm.time_lastsow = int(time.time() /
                                        60)  # Grow time is stored in minutes.
                farm.time_lastphase = int(time.time())
                farm.slimes_onreap = slimes_onreap
                farm.crop = vegetable.id_food
                farm.phase = ewcfg.farm_phase_sow
                farm.action_required = ewcfg.farm_action_none
                ewitem.item_delete(
                    id_item=item_sought.get('id_item'))  # Remove Poudrins

                farm.persist()

    await ewutils.send_message(
        cmd.client, cmd.message.channel,
        ewutils.formatMessage(cmd.message.author, response))
Exemple #18
0
async def reroll_last_mutation(cmd):
    last_mutation_counter = -1
    last_mutation = ""
    user_data = EwUser(member=cmd.message.author)
    market_data = EwMarket(id_server=user_data.id_server)
    response = ""

    if user_data.poi != ewcfg.poi_id_slimeoidlab:
        response = "You require the advanced equipment at the Slimeoid Lab to modify your mutations."
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    if user_data.life_state == ewcfg.life_state_corpse:
        response = "How do you expect to mutate without exposure to slime, dumbass?"
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    mutations = user_data.get_mutations()
    if len(mutations) == 0:
        response = "You have not developed any specialized mutations yet."
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    for id_mutation in mutations:
        mutation_data = EwMutation(id_server=user_data.id_server,
                                   id_user=user_data.id_user,
                                   id_mutation=id_mutation)
        if mutation_data.mutation_counter > last_mutation_counter:
            last_mutation_counter = mutation_data.mutation_counter
            last_mutation = id_mutation

    poudrin = ewitem.find_item(item_search="slimepoudrin",
                               id_user=cmd.message.author.id,
                               id_server=cmd.message.server.id
                               if cmd.message.server is not None else None)

    if poudrin == None:
        response = "You need a slime poudrin to replace a mutation."

        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))
    else:
        ewitem.item_delete(id_item=poudrin.get('id_item'))  # Remove Poudrins
        market_data.donated_poudrins += 1
        market_data.persist()
        user_data.poudrin_donations += 1
        user_data.persist()

    mutation_data = EwMutation(id_server=user_data.id_server,
                               id_user=user_data.id_user,
                               id_mutation=last_mutation)
    new_mutation = random.choice(list(ewcfg.mutation_ids))
    while new_mutation in mutations:
        new_mutation = random.choice(list(ewcfg.mutation_ids))

    mutation_data.id_mutation = new_mutation
    mutation_data.time_lastuse = int(time.time())
    mutation_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 on a reclined medical chair. A SlimeCorp employee 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 getting slime. They oblige.\nThey grab a butterfly needle and carefully stab you with it, draining some strangely colored slime from your bloodstream. Almost immediately, the effects of your last mutation fade away… but, this feeling of respite is fleeting. The SlimeCorp employee writes down a few notes, files away the freshly drawn sample, and soon enough you are stabbed with syringes. This time, it’s already filled with some bizarre, multi-colored serum you’ve never seen before. The effects are instantaneous. {}\nYou hand off one of your hard-earned poudrins to the SlimeCorp employee for their troubles.".format(
        ewcfg.mutations_map[new_mutation].str_acquire)
    return await ewutils.send_message(
        cmd.client, cmd.message.channel,
        ewutils.formatMessage(cmd.message.author, response))
Exemple #19
0
async def reroll_last_mutation(cmd):
    last_mutation_counter = -1
    last_mutation = ""
    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 ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    market_data = EwMarket(id_server=user_data.id_server)
    response = ""

    if cmd.message.channel.name != ewcfg.channel_slimeoidlab:
        response = "You require the advanced equipment at the Slimeoid Lab to modify your mutations."
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    poi = ewcfg.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 ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))
    if user_data.life_state == ewcfg.life_state_corpse:
        response = "How do you expect to mutate without exposure to slime, dumbass?"
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    mutations = user_data.get_mutations()
    if len(mutations) == 0:
        response = "You have not developed any specialized mutations yet."
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    for id_mutation in mutations:
        mutation_data = EwMutation(id_server=user_data.id_server,
                                   id_user=user_data.id_user,
                                   id_mutation=id_mutation)
        if mutation_data.mutation_counter > last_mutation_counter:
            last_mutation_counter = mutation_data.mutation_counter
            last_mutation = id_mutation

    reroll_fatigue = EwStatusEffect(id_status=ewcfg.status_rerollfatigue_id,
                                    user_data=user_data)

    poudrins_needed = int(1.5**int(reroll_fatigue.value))

    poudrins = ewitem.find_item_all(
        item_search=ewcfg.item_id_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)

    poudrins_have = len(poudrins)

    if poudrins_have < poudrins_needed:
        response = "You need {} slime poudrin{} to replace a mutation, but you only have {}.".format(
            poudrins_needed, "" if poudrins_needed == 1 else "s",
            poudrins_have)

        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))
    else:
        for delete in range(poudrins_needed):
            ewitem.item_delete(
                id_item=poudrins.pop(0).get('id_item'))  # Remove Poudrins
        market_data.donated_poudrins += poudrins_needed
        market_data.persist()
        user_data.poudrin_donations += poudrins_needed
        user_data.persist()
        reroll_fatigue.value = int(reroll_fatigue.value) + 1
        reroll_fatigue.persist()

    mutation_data = EwMutation(id_server=user_data.id_server,
                               id_user=user_data.id_user,
                               id_mutation=last_mutation)
    new_mutation = random.choice(list(ewcfg.mutation_ids))
    while new_mutation in mutations:
        new_mutation = random.choice(list(ewcfg.mutation_ids))

    mutation_data.id_mutation = new_mutation
    mutation_data.time_lastuse = int(time.time())
    mutation_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 on a reclined medical chair. A SlimeCorp employee 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 getting slime. They oblige.\nThey grab a butterfly needle and carefully stab you with it, draining some strangely colored slime from your bloodstream. Almost immediately, the effects of your last mutation fade away… but, this feeling of respite is fleeting. The SlimeCorp employee writes down a few notes, files away the freshly drawn sample, and soon enough you are stabbed with syringes. This time, it’s already filled with some bizarre, multi-colored serum you’ve never seen before. The effects are instantaneous. {}\nYou hand off {} of your hard-earned poudrins to the SlimeCorp employee for their troubles.".format(
        ewcfg.mutations_map[new_mutation].str_acquire, poudrins_needed)
    return await ewutils.send_message(
        cmd.client, cmd.message.channel,
        ewutils.formatMessage(cmd.message.author, response))
Exemple #20
0
async def on_message(message):
	time_now = int(time.time())
	ewcfg.set_client(client)

	""" do not interact with our own messages """
	if message.author.id == client.user.id or message.author.bot == True:
		return

	if message.server != None:
		# Note that the user posted a message.
		active_map = active_users_map.get(message.server.id)
		if active_map == None:
			active_map = {}
			active_users_map[message.server.id] = active_map
		active_map[message.author.id] = True

		# Update player information.
		ewplayer.player_update(
			member = message.author,
			server = message.server
		)

	content_tolower = message.content.lower()
	re_awoo = re.compile('.*![a]+[w]+o[o]+.*')

	# update the player's time_last_action which is used for kicking AFK players out of subzones
	if message.server != None:

		try:
			ewutils.execute_sql_query("UPDATE users SET {time_last_action} = %s WHERE id_user = %s AND id_server = %s".format(
				time_last_action = ewcfg.col_time_last_action
			), (
				int(time.time()),
				message.author.id,
				message.server.id
			))
		except:
			ewutils.logMsg('server {}: failed to update time_last_action for {}'.format(message.server.id, message.author.id))
		
		user_data = EwUser(member = message.author)
		
		statuses = user_data.getStatusEffects()

		if ewcfg.status_strangled_id in statuses:
			strangle_effect = EwStatusEffect(id_status=ewcfg.status_strangled_id, user_data=user_data)
			source = EwPlayer(id_user=strangle_effect.source, id_server=message.server.id)
			response = "You manage to break {}'s garrote wire!".format(source.display_name)
			user_data.clear_status(ewcfg.status_strangled_id)			
			return await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, response))

	if message.content.startswith(ewcfg.cmd_prefix) or message.server == None or len(message.author.roles) < 2:
		"""
			Wake up if we need to respond to messages. Could be:
				message starts with !
				direct message (server == None)
				user is new/has no roles (len(roles) < 2)
		"""

		#Ignore users with weird characters in their name
		try:
			message.author.display_name[:3].encode('utf-8').decode('ascii')
		except UnicodeError:
			return await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, "We don't take kindly to moon runes around here."))

		# tokenize the message. the command should be the first word.
		try:
			tokens = shlex.split(message.content)  # it's split with shlex now because shlex regards text within quotes as a single token
		except:
			tokens = message.content.split(' ')  # if splitting via shlex doesnt work (odd number of quotes), use the old splitting method so it doesnt give an exception

		tokens_count = len(tokens)
		cmd = tokens[0].lower() if tokens_count >= 1 else ""

		# remove mentions to us
		mentions = list(filter(lambda user : user.id != client.user.id, message.mentions))
		mentions_count = len(mentions)

		# Create command object
		cmd_obj = ewcmd.EwCmd(
			tokens = tokens,
			message = message,
			client = client,
			mentions = mentions
		)

		"""
			Handle direct messages.
		"""
		if message.server == None:
			playermodel = ewplayer.EwPlayer(id_user = message.author.id)
			usermodel = EwUser(id_user=message.author.id, id_server= playermodel.id_server)
			poi = ewcfg.id_to_poi.get(usermodel.poi)
			# Direct message the player their inventory.
			if ewitem.cmd_is_inventory(cmd):
				return await ewitem.inventory_print(cmd_obj)
			elif cmd == ewcfg.cmd_inspect:
				return await ewitem.item_look(cmd_obj)
			elif poi.is_apartment:
				return await ewapt.aptCommands(cmd=cmd_obj)
			else:
				time_last = last_helped_times.get(message.author.id, 0)

				# Only send the help doc once every thirty seconds. There's no need to spam it.
				if (time_now - time_last) > 30:
					last_helped_times[message.author.id] = time_now
					await ewutils.send_message(client, message.channel, ewcfg.generic_help_response)

			# Nothing else to do in a DM.
			return

		# assign the appropriate roles to a user with less than @everyone, faction, location
		if len(message.author.roles) < 3:
			await ewrolemgr.updateRoles(client = client, member = message.author)

		user_data = EwUser(member = message.author)
		if user_data.arrested:
			return

		mutations = user_data.get_mutations()
		# Scold/ignore offline players.
		if message.author.status == discord.Status.offline:

			if ewcfg.mutation_id_chameleonskin not in mutations or cmd not in ewcfg.offline_cmds:

				response = "You cannot participate in the ENDLESS WAR while offline."
    
				return await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, response))


		if user_data.time_lastoffline > time_now - ewcfg.time_offline:

			if ewcfg.mutation_id_chameleonskin not in mutations or cmd not in ewcfg.offline_cmds:
				response = "You are too paralyzed by ENDLESS WAR's judgemental stare to act."

				return await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, response))

		# Ignore stunned players
		if ewcfg.status_stunned_id in statuses:
			return

		# Check the main command map for the requested command.
		global cmd_map
		cmd_fn = cmd_map.get(cmd)

		if user_data.poi in ewcfg.tutorial_pois:	
			return await ewdungeons.tutorial_cmd(cmd_obj)

		elif cmd_fn != None:
			# Execute found command
			return await cmd_fn(cmd_obj)

		# FIXME debug
		# Test item creation
		elif debug == True and cmd == (ewcfg.cmd_prefix + 'createtestitem'):
			item_id = ewitem.item_create(
				item_type = 'medal',
				id_user = message.author.id,
				id_server = message.server.id,
				item_props = {
					'medal_name': 'Test Award',
					'medal_desc': '**{medal_name}**: *Awarded to Krak by Krak for testing shit.*'
				}
			)

			ewutils.logMsg('Created item: {}'.format(item_id))
			item = EwItem(id_item = item_id)
			item.item_props['test'] = 'meow'
			item.persist()

			item = EwItem(id_item = item_id)

			await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, ewitem.item_look(item)))

		# Creates a poudrin
		elif debug == True and cmd == (ewcfg.cmd_prefix + 'createpoudrin'):
			for item in ewcfg.item_list:
				if item.context == "poudrin":
					ewitem.item_create(
						item_type = ewcfg.it_item,
						id_user = message.author.id,
						id_server = message.server.id,
						item_props = {
							'id_item': item.id_item,
							'context': item.context,
							'item_name': item.str_name,
							'item_desc': item.str_desc,
						}
					),
					ewutils.logMsg('Created item: {}'.format(item.id_item))
					item = EwItem(id_item = item.id_item)
					item.persist()
			else:
				pass

			await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, "Poudrin created."))

		# Gives the user some slime
		elif debug == True and cmd == (ewcfg.cmd_prefix + 'getslime'):
			user_data = EwUser(member = message.author)
			user_initial_level = user_data.slimelevel

			response = "You get 100,000 slime!"

			levelup_response = user_data.change_slimes(n = 100000)

			was_levelup = True if user_initial_level < user_data.slimelevel else False

			if was_levelup:
				response += " {}".format(levelup_response)

			user_data.persist()
			await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, response))
		elif debug == True and cmd == (ewcfg.cmd_prefix + 'getcoin'):
			user_data = EwUser(member=message.author)
			user_data.change_slimecoin(n=1000000000, coinsource=ewcfg.coinsource_spending)

			response = "You get 1,000,000,000 slimecoin!"

			user_data.persist()
			await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, response))

		# Deletes all items in your inventory.
		elif debug == True and cmd == (ewcfg.cmd_prefix + 'clearinv'):
			user_data = EwUser(member = message.author)
			ewitem.item_destroyall(id_server = message.server.id, id_user = message.author.id)
			response = "You destroy every single item in your inventory."
			user_data.persist()
			await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, response))

		elif debug == True and cmd == (ewcfg.cmd_prefix + 'createapple'):
			item_id = ewitem.item_create(
				id_user = message.author.id,
				id_server = message.server.id,
				item_type = ewcfg.it_food,
				item_props = {
					'id_food': "direapples",
					'food_name': "Dire Apples",
					'food_desc': "This sure is a illegal Dire Apple!",
					'recover_hunger': 500,
					'str_eat': "You chomp into this illegal Dire Apple.",
					'time_expir': int(time.time() + ewcfg.farm_food_expir)
				}
			)

			ewutils.logMsg('Created item: {}'.format(item_id))
			item = EwItem(id_item = item_id)
			item.item_props['test'] = 'meow'
			item.persist()

			await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, "Apple created."))

		elif debug == True and cmd == (ewcfg.cmd_prefix + 'createhat'):
			patrician_rarity = 20
			patrician_smelted = random.randint(1, patrician_rarity)
			patrician = False

			if patrician_smelted == 1:
				patrician = True

			items = []

			for cosmetic in ewcfg.cosmetic_items_list:
				if patrician and cosmetic.rarity == ewcfg.rarity_patrician:
					items.append(cosmetic)
				elif not patrician and cosmetic.rarity == ewcfg.rarity_plebeian:
					items.append(cosmetic)

			item = items[random.randint(0, len(items) - 1)]

			item_id = ewitem.item_create(
				item_type = ewcfg.it_cosmetic,
				id_user = message.author.id,
				id_server = message.server.id,
				item_props = {
					'id_cosmetic': item.id_cosmetic,
					'cosmetic_name': item.str_name,
					'cosmetic_desc': item.str_desc,
					'rarity': item.rarity,
					'adorned': 'false'
				}
			)

			ewutils.logMsg('Created item: {}'.format(item_id))
			item = EwItem(id_item = item_id)
			item.item_props['test'] = 'meow'
			item.persist()

			await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, "Hat created."))

		elif debug == True and cmd == (ewcfg.cmd_prefix + 'createfood'):
			item = ewcfg.food_list[random.randint(0, len(ewcfg.food_list) - 1)]

			item_id = ewitem.item_create(
				item_type = ewcfg.it_food,
				id_user = message.author.id,
				id_server = message.server.id,
				item_props = {
					'id_food': item.id_food,
					'food_name': item.str_name,
					'food_desc': item.str_desc,
					'recover_hunger': item.recover_hunger,
					'str_eat': item.str_eat,
					'time_expir': item.time_expir
				}
			)

			ewutils.logMsg('Created item: {}'.format(item_id))
			item = EwItem(id_item = item_id)
			item.item_props['test'] = 'meow'
			item.persist()

			await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, "Food created."))

		# FIXME debug
		# Test item deletion
		elif debug == True and cmd == (ewcfg.cmd_prefix + 'delete'):
			items = ewitem.inventory(
				id_user = message.author.id,
				id_server = message.server.id
			)

			for item in items:
				ewitem.item_delete(
					id_item = item.get('id_item')
				)

			await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, 'ok'))

		# AWOOOOO
		elif re_awoo.match(cmd):
			return await ewcmd.cmd_howl(cmd_obj)

		# Debug command to override the role of a user
		elif debug == True and cmd == (ewcfg.cmd_prefix + 'setrole'):

			response = ""

			if mentions_count == 0:
				response = 'Set who\'s role?'
			else:
				roles_map = ewutils.getRoleMap(message.server.roles)
				role_target = tokens[1]
				role = roles_map.get(role_target)

				if role != None:
					for user in mentions:
						try:
							await client.replace_roles(user, role)
						except:
							ewutils.logMsg('Failed to replace_roles for user {} with {}.'.format(user.display_name, role.name))

					response = 'Done.'
				else:
					response = 'Unrecognized role.'

			await ewutils.send_message(client, cmd.message.channel, ewutils.formatMessage(message.author, response))
			
		elif debug == True and cmd == (ewcfg.cmd_prefix + 'getrowdy'):
			response = "You get rowdy. F**k. YES!"
			user_data = EwUser(member=message.author)
			user_data.life_state = ewcfg.life_state_enlisted
			user_data.faction = ewcfg.faction_rowdys
			user_data.time_lastenlist = time_now + ewcfg.cd_enlist
			user_data.persist()
			await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, response))
		
		elif debug == True and cmd == (ewcfg.cmd_prefix + 'getkiller'):
			response = "You uh... 'get' killer. Sure."
			user_data = EwUser(member=message.author)
			user_data.life_state = ewcfg.life_state_enlisted
			user_data.faction = ewcfg.faction_killers
			user_data.time_lastenlist = time_now + ewcfg.cd_enlist
			user_data.persist()
			await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, response))
			
		# Toggles rain on and off
		elif debug == True and cmd == (ewcfg.cmd_prefix + 'toggledownfall'):
			market_data = EwMarket(id_server=message.server.id)
			
			if market_data.weather == ewcfg.weather_bicarbonaterain:
				newweather = ewcfg.weather_sunny
				
				market_data.weather = newweather
				response = "Bicarbonate rain turned OFF. Weather was set to {}.".format(newweather)
			else:
				market_data.weather = ewcfg.weather_bicarbonaterain
				response = "Bicarbonate rain turned ON."
				
			market_data.persist()
			await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, response))

		elif debug == True and cmd == (ewcfg.cmd_prefix + 'dayforward'):
			market_data = EwMarket(id_server=message.server.id)

			market_data.day += 1
			market_data.persist()

			response = "Time has progressed 1 day forward manually."
			
			if ewutils.check_fursuit_active(market_data.id_server):
				response += "\nIt's a full moon!"
				
			await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, response))
			
		elif debug == True and cmd == (ewcfg.cmd_prefix + 'hourforward'):
			market_data = EwMarket(id_server=message.server.id)
			
			market_data.clock += 1
			response = "Time has progressed 1 hour forward manually."

			if market_data.clock >= 24 or market_data.clock < 0:
				market_data.clock = 0
				market_data.day += 1
				response += "\nMidnight has come. 1 day progressed forward."
				
			if ewutils.check_fursuit_active(market_data.id_server):
				response += "\nIt's a full moon!"
				
			market_data.persist()
			await ewutils.send_message(client, message.channel, ewutils.formatMessage(message.author, response))
			
			
		# didn't match any of the command words.
		else:
			""" couldn't process the command. bail out!! """
			""" bot rule 0: be cute """
			randint = random.randint(1,3)
			msg_mistake = "ENDLESS WAR is growing frustrated."
			if randint == 2:
				msg_mistake = "ENDLESS WAR denies you his favor."
			elif randint == 3:
				msg_mistake = "ENDLESS WAR pays you no mind."

			msg = await ewutils.send_message(client, cmd_obj.message.channel, msg_mistake)
			await asyncio.sleep(2)
			try:
				await client.delete_message(msg)
			except:
				pass

	elif content_tolower.find(ewcfg.cmd_howl) >= 0 or content_tolower.find(ewcfg.cmd_howl_alt1) >= 0 or re_awoo.match(content_tolower):
		""" Howl if !howl is in the message at all. """
		return await ewcmd.cmd_howl(ewcmd.EwCmd(
			message = message,
			client = client
		))
Exemple #21
0
async def cast(cmd):
	time_now = round(time.time())
	has_reeled = False
	user_data = EwUser(member = cmd.message.author)
	market_data = EwMarket(id_server = cmd.message.author.server.id)
	statuses = user_data.getStatusEffects()

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

	fisher = 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 cmd.message.channel.name in [ewcfg.channel_tt_pier, ewcfg.channel_jp_pier, ewcfg.channel_cl_pier, ewcfg.channel_afb_pier, ewcfg.channel_vc_pier, ewcfg.channel_se_pier, ewcfg.channel_ferry]:
		if user_data.hunger >= ewutils.hunger_max_bylevel(user_data.slimelevel):
			response = "You're too hungry to fish right now."

		else:
			has_fishingrod = False

			if user_data.weapon >= 0:
				weapon_item = EwItem(id_item = user_data.weapon)
				weapon = ewcfg.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.current_fish = gen_fish(market_data, cmd, has_fishingrod)
			fisher.fishing = True
			fisher.bait = False
			fisher.pier = user_data.poi
			item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])
			author = cmd.message.author
			server = cmd.message.server

			item_sought = ewitem.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 ewcfg.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 ["blacklimes", "blacklimesour"]:
						if random.randrange(2) == 1:
							fisher.current_fish = "blacklimesalmon"

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

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

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

					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"
					ewitem.item_delete(item_sought.get('id_item'))

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

			else:
				fisher.current_size = gen_fish_size(has_fishingrod)

			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 cmd.message.channel.name in [ewcfg.channel_afb_pier, ewcfg.channel_vc_pier, ewcfg.channel_se_pier, ewcfg.channel_ferry]:
				response += "vast Slime Sea."
			else:
				response += "glowing Slime Lake."

			user_data.hunger += ewcfg.hunger_perfish * ewutils.hunger_cost_mod(user_data.slimelevel)
			user_data.persist()
			
			await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.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, user has a 1/7 chance to get a bite
				fun = 70
			bun = 0

			while not ewutils.TERMINATE:
				
				if fun <= 0:
					fun = 1
				else:
					damp = random.randrange(fun)

				if not fisher.high:
					await asyncio.sleep(60)
				else:
					await asyncio.sleep(30)
				user_data = EwUser(member=cmd.message.author)

				if user_data.poi != fisher.pier:
					fisher.fishing = False
					return
				if user_data.life_state == ewcfg.life_state_corpse:
					fisher.fishing = False
					return
				if fisher.fishing == False:
					return

				if damp > 10:
					await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, random.choice(ewcfg.nobite_text)))
					fun -= 2
					bun += 1
					if bun >= 5:
						fun -= 1
					if bun >= 15:
						fun -= 1
					continue
				else:
					break


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

			await asyncio.sleep(8)

			if fisher.bite != False:
				fisher.fishing = False
				fisher.bite = False
				fisher.current_fish = ""
				fisher.current_size = ""
				fisher.bait = False
				return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, "The fish got away..."))
			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 ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
Exemple #22
0
async def on_message(message):
    time_now = int(time.time())
    """ do not interact with our own messages """
    if message.author.id == client.user.id or message.author.bot == True:
        return

    if message.server != None:
        # Note that the user posted a message.
        active_map = active_users_map.get(message.server.id)
        if active_map == None:
            active_map = {}
            active_users_map[message.server.id] = active_map
        active_map[message.author.id] = True

        # Update player information.
        ewplayer.player_update(member=message.author, server=message.server)

    content_tolower = message.content.lower()
    re_awoo = re.compile('.*![a]+[w]+o[o]+.*')

    if message.content.startswith(
            ewcfg.cmd_prefix) or message.server == None or len(
                message.author.roles) < 2:
        """
			Wake up if we need to respond to messages. Could be:
				message starts with !
				direct message (server == None)
				user is new/has no roles (len(roles) < 2)
		"""

        # tokenize the message. the command should be the first word.
        try:
            tokens = shlex.split(
                message.content
            )  # it's split with shlex now because shlex regards text within quotes as a single token
        except:
            tokens = message.content.split(
                ' '
            )  # if splitting via shlex doesnt work (odd number of quotes), use the old splitting method so it doesnt give an exception

        tokens_count = len(tokens)
        cmd = tokens[0].lower()

        # remove mentions to us
        mentions = list(
            filter(lambda user: user.id != client.user.id, message.mentions))
        mentions_count = len(mentions)

        # Create command object
        cmd_obj = ewcmd.EwCmd(tokens=tokens,
                              message=message,
                              client=client,
                              mentions=mentions)
        """
			Handle direct messages.
		"""
        if message.server == None:
            # Direct message the player their inventory.
            if ewitem.cmd_is_inventory(cmd):
                return await ewitem.inventory_print(cmd_obj)
            elif cmd == ewcfg.cmd_inspect:
                return await ewitem.item_look(cmd_obj)

            # FIXME add this back when the help doc is updated.
            """
			else:
				time_last = last_helped_times.get(message.author.id, 0)

				# Only send the help doc once every thirty seconds. There's no need to spam it.
				if (time_now - time_last) > 30:
					last_helped_times[message.author.id] = time_now
					await client.send_message(message.channel, 'Check out the guide for help: https://ew.krakissi.net/guide/')
			"""

            # Nothing else to do in a DM.
            return

        # assign the appropriate roles to a user with less than @everyone, faction, location
        if len(message.author.roles) < 3:
            return await ewrolemgr.updateRoles(client=client,
                                               member=message.author)

        # Scold/ignore offline players.
        if message.author.status == discord.Status.offline:

            response = "You cannot participate in the ENDLESS WAR while offline."

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

            return

        # Check the main command map for the requested command.
        global cmd_map
        cmd_fn = cmd_map.get(cmd)

        if cmd_fn != None:
            # Execute found command
            return await cmd_fn(cmd_obj)

        # FIXME debug
        # Test item creation
        elif debug == True and cmd == '!createtestitem':
            item_id = ewitem.item_create(
                item_type='medal',
                id_user=message.author.id,
                id_server=message.server.id,
                item_props={
                    'medal_name':
                    'Test Award',
                    'medal_desc':
                    '**{medal_name}**: *Awarded to Krak by Krak for testing shit.*'
                })

            ewutils.logMsg('Created item: {}'.format(item_id))
            item = EwItem(id_item=item_id)
            item.item_props['test'] = 'meow'
            item.persist()

            item = EwItem(id_item=item_id)

            await client.send_message(
                message.channel,
                ewutils.formatMessage(message.author, ewitem.item_look(item)))

        # Creates a poudrin
        elif debug == True and cmd == '!createpoudrin':
            item_id = ewitem.item_create(item_type=ewcfg.it_slimepoudrin,
                                         id_user=message.author.id,
                                         id_server=message.server.id)

            ewutils.logMsg('Created item: {}'.format(item_id))
            item = EwItem(id_item=item_id)
            item.persist()

            item = EwItem(id_item=item_id)

            await client.send_message(
                message.channel,
                ewutils.formatMessage(message.author, "Poudrin created."))

        # Gives the user some slime
        elif debug == True and cmd == '!getslime':
            user_data = EwUser(member=message.author)

            user_data.change_slimes(n=10000)
            user_data.persist()

            await client.send_message(
                message.channel,
                ewutils.formatMessage(message.author,
                                      "You receive 10,000 slime."))

        # FIXME debug
        # Test item deletion
        elif debug == True and cmd == '!delete':
            items = ewitem.inventory(id_user=message.author.id,
                                     id_server=message.server.id)

            for item in items:
                ewitem.item_delete(id_item=item.get('id_item'))

            await client.send_message(
                message.channel, ewutils.formatMessage(message.author, 'ok'))

        # AWOOOOO
        elif re_awoo.match(cmd):
            return await ewcmd.cmd_howl(cmd_obj)

        # Debug command to override the role of a user
        elif debug == True and cmd == (ewcfg.cmd_prefix + 'setrole'):

            response = ""

            if mentions_count == 0:
                response = 'Set who\'s role?'
            else:
                roles_map = ewutils.getRoleMap(message.server.roles)
                role_target = tokens[1]
                role = roles_map.get(role_target)

                if role != None:
                    for user in mentions:
                        await client.replace_roles(user, role)

                    response = 'Done.'
                else:
                    response = 'Unrecognized role.'

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

        # didn't match any of the command words.
        else:
            """ couldn't process the command. bail out!! """
            """ bot rule 0: be cute """
            randint = random.randint(1, 3)
            msg_mistake = "ENDLESS WAR is growing frustrated."
            if randint == 2:
                msg_mistake = "ENDLESS WAR denies you his favor."
            elif randint == 3:
                msg_mistake = "ENDLESS WAR pays you no mind."

            msg = await client.send_message(cmd_obj.message.channel,
                                            msg_mistake)
            await asyncio.sleep(2)
            await client.delete_message(msg)

    elif content_tolower.find(ewcfg.cmd_howl) >= 0 or content_tolower.find(
            ewcfg.cmd_howl_alt1) >= 0 or re_awoo.match(content_tolower):
        """ Howl if !howl is in the message at all. """
        return await ewcmd.cmd_howl(ewcmd.EwCmd(message=message,
                                                client=client))
Exemple #23
0
async def barter(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 = ewitem.find_item(item_search = item_search, id_user = cmd.message.author.id, id_server = cmd.message.server.id if cmd.message.server 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 cmd.message.channel.name in [ewcfg.channel_tt_pier, ewcfg.channel_jp_pier, ewcfg.channel_cl_pier, ewcfg.channel_afb_pier, ewcfg.channel_vc_pier, ewcfg.channel_se_pier, ewcfg.channel_ferry]:
			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?'

	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 ewcfg.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.message.server.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:
						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)

					else:
						for result in ewcfg.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 ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))

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

					if offer_decision != 2: # 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 ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))

				# Wait for an answer
				accepted = False

				try:
					message = await cmd.client.wait_for_message(timeout = 20, author = cmd.message.author, check = ewutils.check_accept_or_refuse)

					if message != None:
						if message.content.lower() == "!accept":
							accepted = True
						if message.content.lower() == "!refuse":
							accepted = False
				except:
					accepted = False

				offer = EwOffer(
					id_server = cmd.message.server.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 != user_data.id_user:
					accepted = False

				# cancel deal if the user has left the speakeasy
				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 = ewitem.gen_item_props(item)	

						ewitem.item_create(
							item_type = item.item_type,
							id_user = cmd.message.author.id,
							id_server = cmd.message.server.id,
							item_props = item_props
						)


					ewitem.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 ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
Exemple #24
0
async def embiggen(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 ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))

	market_data = EwMarket(id_server = user_data.id_server)
	item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])
	item_sought = ewitem.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:
		poi = ewcfg.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 ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
		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 = ewitem.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()
					ewitem.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..."

		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

			poudrins_owned = ewitem.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 size == ewcfg.fish_size_miniscule:
					fish.item_props['size'] = ewcfg.fish_size_small

				if size == ewcfg.fish_size_small:
					fish.item_props['size'] = ewcfg.fish_size_average

				if size == ewcfg.fish_size_average:
					fish.item_props['size'] = ewcfg.fish_size_big

				if size == ewcfg.fish_size_big:
					fish.item_props['size'] = ewcfg.fish_size_huge

				if size == ewcfg.fish_size_huge:
					fish.item_props['size'] = ewcfg.fish_size_colossal

				fish.persist()

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

				market_data.donated_poudrins += poudrin_cost
				market_data.persist()
				user_data.poudrin_donations += poudrin_cost
				user_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. A SlimeCorp employee 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 ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))