예제 #1
0
async def eat_item(cmd):

    user_data = EwUser(member=cmd.message.author)
    mutations = user_data.get_mutations()
    item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])

    food_item = None

    # look for a food item if a name was given
    if item_search:
        item_sought = ewitem.find_item(item_search=item_search,
                                       id_user=user_data.id_user,
                                       id_server=user_data.id_server,
                                       item_type_filter=ewcfg.it_food)
        if item_sought:
            food_item = EwItem(id_item=item_sought.get('id_item'))
        else:
            item_sought = ewitem.find_item(item_search=item_search,
                                           id_user=user_data.id_user,
                                           id_server=user_data.id_server)
            if item_sought and ewcfg.mutation_id_trashmouth in mutations:
                return await devour(cmd=cmd)

    # otherwise find the first useable food
    else:
        food_inv = ewitem.inventory(id_user=user_data.id_user,
                                    id_server=user_data.id_server,
                                    item_type_filter=ewcfg.it_food)

        for food in food_inv:
            food_item = EwItem(id_item=food.get('id_item'))

            # check if the user can eat this item
            if float(getattr(food_item, "time_expir", 0)) > time.time() or \
             food_item.item_props.get('perishable') not in ['true', '1'] or \
             ewcfg.mutation_id_spoiledappetite in user_data.get_mutations():
                break

    if food_item != None:
        response = user_data.eat(food_item)
        user_data.persist()
    else:
        if item_search:
            response = "Are you sure you have that item?"
        else:
            response = "You don't have anything to eat."

    await ewutils.send_message(
        cmd.client, cmd.message.channel,
        ewutils.formatMessage(cmd.message.author, response))
예제 #2
0
async def dedorn(cmd):
	item_id = ewutils.flattenTokenListToString(cmd.tokens[1:])

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

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

		items = ewitem.inventory(
			id_user = cmd.message.author.id,
			id_server = cmd.message.server.id,
			item_type_filter = ewcfg.it_cosmetic
		)

		item_sought = None
		for item in items:
			if item.get('id_item') == item_id_int or item_id in ewutils.flattenTokenListToString(item.get('name')):
				i = EwItem(item.get('id_item'))
				if i.item_props.get("adorned") == 'true':
					item_sought = i
					break

		if item_sought != None:
			item_sought.item_props['adorned'] = 'false'

			response = "You successfully dedorn your " + item_sought.item_props['cosmetic_name'] + "."

			item_sought.persist()

		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, 'Dedorn which cosmetic? Check your **!inventory**.'))
예제 #3
0
async def dedorn(cmd):
	user_data = EwUser(member = cmd.message.author)

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

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

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

		cosmetic_items = ewitem.inventory(
			id_user = cmd.message.author.id,
			id_server = cmd.message.server.id,
			item_type_filter = ewcfg.it_cosmetic
		)

		item_sought = None
		already_adorned = False

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

			# Search for desired cosmetic
			if item.get('id_item') == item_id_int or item_id in ewutils.flattenTokenListToString(item.get('name')):
				if i.item_props.get("adorned") == 'true':
					already_adorned = True
					item_sought = i
					break

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

			# Unadorn the cosmetic
			if already_adorned:
				item_sought.item_props['adorned'] = 'false'

				unadorn_response = str(item_sought.item_props['str_unadorn'])

				response = unadorn_response.format(item_sought.item_props['cosmetic_name'])


				item_sought.persist()
				user_data.persist()

			# That garment has not be adorned..
			else:
				response = "You haven't adorned that garment in the first place! How can you dedorn something you haven't adorned? You disgust me."

		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, 'Adorn which cosmetic? Check your **!inventory**.'))
예제 #4
0
def dedorn_all_costumes():
    costumes = ewutils.execute_sql_query(
        "SELECT id_item FROM items_prop WHERE name = 'context' AND value = 'costume' AND id_item IN (SELECT id_item FROM items_prop WHERE (name = 'adorned' OR name = 'slimeoid') AND value = 'true')"
    )
    costume_count = 0

    for costume_id in costumes:
        costume_item = EwItem(id_item=costume_id)

        usermodel = EwUser(id_user=costume_item.id_owner,
                           id_server=costume_item.id_server)

        costume_item.item_props['adorned'] = 'false'

        if costume_item.item_props['slimeoid'] == 'false':

            usermodel.persist()

        costume_item.item_props['slimeoid'] = 'false'
        costume_item.persist()

        costume_count += 1

    ewutils.logMsg(
        "Dedorned {} costumes after full moon ended.".format(costume_count))
예제 #5
0
async def store(cmd):
	
	user_data = EwUser(member=cmd.message.author)
	response = ""

	poi = ewcfg.id_to_poi.get(user_data.poi)
	if poi.community_chest == None:
		response = "There is no community chest here."
		return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
	else:
		if len(poi.factions) > 0 and user_data.faction not in poi.factions:
			response = "Get real, asshole. You haven't even enlisted into this gang yet, so it's not like they'd trust you with a key to their valubles."
			return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))

	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 item_sought:
		item = EwItem(id_item = item_sought.get("id_item"))

		if not item.soulbound:
			if item.item_type == ewcfg.it_weapon:
				if user_data.weapon >= 0 and item.id_item == user_data.weapon:
					if user_data.weaponmarried:
						weapon = ewcfg.weapon_map.get(item.item_props.get("weapon_type"))
						response = "Your cuckoldry is appreciated, but your {} will always remain faithful to you.".format(item_sought.get('name'))
						return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
					else:
						user_data.weapon = -1
						user_data.persist()
				elif item.id_item == user_data.sidearm:
					user_data.sidearm = -1
					user_data.persist()

			if item.item_type == ewcfg.it_cosmetic:
				if "adorned" in item.item_props:
					item.item_props["adorned"] = "false"
				if "slimeoid" in item.item_props:
					item.item_props["slimeoid"] = "false"
			
			item.persist()
			ewitem.give_item(id_item = item.id_item, id_server = item.id_server, id_user = poi.community_chest)

			response = "You store your {} in the community chest.".format(item_sought.get("name"))

		else:
			response = "You can't {} soulbound items.".format(cmd.tokens[0])
	else:
		if item_search:
			response = "You don't have one"
		else:
			response = "{} which item? (check **!inventory**)".format(cmd.tokens[0])

	await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
예제 #6
0
async def dye(cmd):
	first_id = ewutils.flattenTokenListToString(cmd.tokens[1:2])
	second_id = ewutils.flattenTokenListToString(cmd.tokens[2:])

	try:
		first_id_int = int(first_id)
		second_id_int = int(second_id)
	except:
		first_id_int = None
		second_id_int = None

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

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

		cosmetic = None
		dye = None
		for item in items:
			if item.get('id_item') in [first_id_int, second_id_int] or first_id in ewutils.flattenTokenListToString(item.get('name')) or second_id in ewutils.flattenTokenListToString(item.get('name')):
				if item.get('item_type') == ewcfg.it_cosmetic and cosmetic is None:
					cosmetic = item

				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:
				user_data = EwUser(member = cmd.message.author)

				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**.'))
예제 #7
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))
예제 #8
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))
예제 #9
0
async def reel(cmd):
	user_data = EwUser(member = cmd.message.author)
	if cmd.message.author.id not in fishers.keys():
		fishers[cmd.message.author.id] = EwFisher()
	fisher = fishers[cmd.message.author.id]
	poi = ewcfg.id_to_poi.get(user_data.poi)

	# 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)

	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]:
		# Players who haven't cast a line cannot reel.
		if fisher.fishing == False:
			response = "You haven't cast your hook yet. Try !cast."

		# If a fish isn't biting, then a player reels in nothing.
		elif fisher.bite == False and fisher.fishing == True:
			fisher.current_fish = ""
			fisher.current_size = ""
			fisher.fishing = False
			fisher.pier = ""
			response = "You reeled in too early! Nothing was caught."

		# On successful reel.
		else:
			if fisher.current_fish == "item":
				
				slimesea_inventory = ewitem.inventory(id_server = cmd.message.server.id, id_user = ewcfg.poi_id_slimesea)
				
				pier_poi = ewcfg.id_to_poi.get(fisher.pier)				

				if pier_poi.pier_type != ewcfg.fish_slime_saltwater or len(slimesea_inventory) == 0 or random.random() < 0.5:

					item = random.choice(ewcfg.mine_results)
				
					unearthed_item_amount = (random.randrange(5) + 8) # anywhere from 8-12 drops

					item_props = ewitem.gen_item_props(item)

					for creation in range(unearthed_item_amount):
						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 reel in {} {}s! ".format(unearthed_item_amount, item.str_name)

				else:
					item = random.choice(slimesea_inventory)

					ewitem.give_item(id_item = item.get('id_item'), member = cmd.message.author)

					response = "You reel in a {}!".format(item.get('name'))

				fisher.fishing = False
				fisher.bite = False
				fisher.current_fish = ""
				fisher.current_size = ""
				fisher.pier = ""
				user_data.persist()

			else:
				user_initial_level = user_data.slimelevel

				gang_bonus = False

				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

				value = 0

				if fisher.current_size == ewcfg.fish_size_miniscule:
					slime_gain = ewcfg.fish_gain * 1
					value += 10

				elif fisher.current_size == ewcfg.fish_size_small:
					slime_gain = ewcfg.fish_gain * 2

					value += 20

				elif fisher.current_size == ewcfg.fish_size_average:
					slime_gain = ewcfg.fish_gain * 3
					value += 30

				elif fisher.current_size == ewcfg.fish_size_big:
					slime_gain = ewcfg.fish_gain * 4
					value += 40

				elif fisher.current_size == ewcfg.fish_size_huge:
					slime_gain = ewcfg.fish_gain * 5
					value += 50

				else:
					slime_gain = ewcfg.fish_gain * 6
					value += 60

				if ewcfg.fish_map[fisher.current_fish].rarity == ewcfg.fish_rarity_common:
					value += 10

				if ewcfg.fish_map[fisher.current_fish].rarity == ewcfg.fish_rarity_uncommon:
					value += 20

				if ewcfg.fish_map[fisher.current_fish].rarity == ewcfg.fish_rarity_rare:
					value += 30

				if ewcfg.fish_map[fisher.current_fish].rarity == ewcfg.fish_rarity_promo:
					value += 40

				if user_data.life_state == 2:
					if ewcfg.fish_map[fisher.current_fish].catch_time == ewcfg.fish_catchtime_day and user_data.faction == ewcfg.faction_rowdys:
						gang_bonus = True
						slime_gain = slime_gain * 1.5
						value += 20

					if ewcfg.fish_map[fisher.current_fish].catch_time == ewcfg.fish_catchtime_night and user_data.faction == ewcfg.faction_killers:
						gang_bonus = True
						slime_gain = slime_gain * 1.5
						value += 20

				if has_fishingrod == True:
					slime_gain = slime_gain * 2

				if fisher.current_fish == "plebefish":
					slime_gain = ewcfg.fish_gain * .5
					value = 10
				if poi.is_subzone:
					district_data = EwDistrict(district = poi.mother_district, id_server = cmd.message.server.id)
				else:
					district_data = EwDistrict(district = poi.id_poi, id_server = cmd.message.server.id)

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

				ewitem.item_create(
					id_user = cmd.message.author.id,
					id_server = cmd.message.server.id,
					item_type = ewcfg.it_food,
					item_props = {
						'id_food': ewcfg.fish_map[fisher.current_fish].id_fish,
						'food_name': ewcfg.fish_map[fisher.current_fish].str_name,
						'food_desc': ewcfg.fish_map[fisher.current_fish].str_desc,
						'recover_hunger': 20,
						'str_eat': ewcfg.str_eat_raw_material.format(ewcfg.fish_map[fisher.current_fish].str_name),
						'rarity': ewcfg.fish_map[fisher.current_fish].rarity,
						'size': fisher.current_size,
						'time_expir': time.time() + ewcfg.std_food_expir,
						'time_fridged': 0,
						'acquisition': ewcfg.acquisition_fishing,
						'value': value
					}
				)

				response = "You reel in a {fish}! {flavor} You grab hold and wring {slime} slime from it. "\
					.format(fish = ewcfg.fish_map[fisher.current_fish].str_name, flavor = ewcfg.fish_map[fisher.current_fish].str_desc, slime = str(slime_gain))

				if gang_bonus == True:
					if user_data.faction == ewcfg.faction_rowdys:
						response += "The Rowdy-pride this fish is showing gave you more slime than usual. "
					elif user_data.faction == ewcfg.faction_killers:
						response += "The Killer-pride this fish is showing gave you more slime than usual. "

				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

				market_data = EwMarket(id_server=user_data.id_server)
				if market_data.caught_fish == ewcfg.debugfish_goal and fisher.pier in ewcfg.debugpiers:
					
					item = ewcfg.debugitem
					
					ewitem.item_create(
						item_type=ewcfg.it_item,
						id_user=user_data.id_user,
						id_server=user_data.id_server,
						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()
					
					response += ewcfg.debugfish_response
					market_data.caught_fish += 1
					market_data.persist()
		
				elif market_data.caught_fish < ewcfg.debugfish_goal and fisher.pier in ewcfg.debugpiers:
					market_data.caught_fish += 1
					market_data.persist()

				fisher.fishing = False
				fisher.bite = False
				fisher.current_fish = ""
				fisher.current_size = ""
				fisher.pier = ""
				
				user_data.persist()
				
	else:
		response = "You cast your fishing rod unto a sidewalk. That is to say, you've accomplished nothing. Go to a pier if you want to fish."

	await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
예제 #10
0
async def order(cmd):
    user_data = EwUser(member=cmd.message.author)
    market_data = EwMarket(id_server=cmd.message.server.id)
    poi = ewmap.fetch_poi_if_coordless(cmd.message.channel.name)

    if poi is None or len(poi.vendors) == 0:
        # Only allowed in the food court.
        response = "There’s nothing to buy here. If you want to purchase some items, go to a sub-zone with a vendor in it, like the food court, the speakeasy, or the bazaar."
    else:
        value = ewutils.flattenTokenListToString(cmd.tokens[1:])
        #if cmd.tokens_count > 1:
        #	value = cmd.tokens[1]
        #	value = value.lower()

        # Finds the item if it's an EwGeneralItem.

        item = ewcfg.item_map.get(value)
        item_type = ewcfg.it_item
        if item != None:
            item_id = item.id_item
            name = item.str_name

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

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

        if item == None:
            item = ewcfg.furniture_map.get(value)
            item_type = ewcfg.it_furniture
            if item != None:
                item_id = item.id_furniture
                name = item.str_name

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

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

            # Check if the item is available in the current bazaar item rotation
            if current_vendor == ewcfg.vendor_bazaar:
                if item_id not in market_data.bazaar_wares.values():
                    current_vendor = None

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

            else:
                response = ""

                value = item.price

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

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

                if poi.is_subzone:
                    district_data = EwDistrict(district=poi.mother_district,
                                               id_server=cmd.message.server.id)
                else:
                    district_data = EwDistrict(district=poi.id_poi,
                                               id_server=cmd.message.server.id)

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

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

                value = int(value)

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

                # Yo, Slimernalia!
                if item_type == ewcfg.it_food:
                    value = 0

                if value > user_data.slimes:
                    # Not enough money.
                    response = "A {} costs {:,} slime, and you only have {:,}.".format(
                        name, value, user_data.slimes)
                else:
                    if item_type == ewcfg.it_food:
                        food_items = ewitem.inventory(
                            id_user=cmd.message.author.id,
                            id_server=cmd.message.server.id,
                            item_type_filter=ewcfg.it_food)

                        if len(food_items) >= user_data.get_food_capacity():
                            # user_data never got persisted so the player won't lose money unnecessarily
                            response = "You can't carry any more food than that."
                            return await ewutils.send_message(
                                cmd.client, cmd.message.channel,
                                ewutils.formatMessage(cmd.message.author,
                                                      response))

                    elif item_type == ewcfg.it_weapon:
                        weapons_held = ewitem.inventory(
                            id_user=user_data.id_user,
                            id_server=cmd.message.server.id,
                            item_type_filter=ewcfg.it_weapon)

                        has_weapon = False

                        # Thrown weapons are stackable
                        if ewcfg.weapon_class_thrown in item.classes:
                            # Check the player's inventory for the weapon and add amount to stack size. Create a new item the max stack size has been reached
                            for wep in weapons_held:
                                weapon = EwItem(id_item=wep.get("id_item"))
                                if weapon.item_props.get(
                                        "weapon_type"
                                ) == item.id_weapon and weapon.stack_size < weapon.stack_max:
                                    has_weapon = True
                                    weapon.stack_size += 1
                                    weapon.persist()
                                    response = "You slam {:,} slime down on the counter at {} for {}.".format(
                                        value, current_vendor, item.str_weapon)
                                    user_data.change_slimes(
                                        n=-value, source=ewcfg.source_spending)
                                    user_data.persist()
                                    return await ewutils.send_message(
                                        cmd.client, cmd.message.channel,
                                        ewutils.formatMessage(
                                            cmd.message.author, response))

                        if has_weapon == False:
                            if len(weapons_held
                                   ) >= user_data.get_weapon_capacity():
                                response = "You can't carry any more weapons."
                                return await ewutils.send_message(
                                    cmd.client, cmd.message.channel,
                                    ewutils.formatMessage(
                                        cmd.message.author, response))

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

                    user_data.change_slimes(n=-value,
                                            source=ewcfg.source_spending)

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

                    item_props = ewitem.gen_item_props(item)

                    if item.str_name == "arcade cabinet":
                        item_props['furniture_desc'] = random.choice(
                            ewcfg.cabinets_list)

                    ewitem.item_create(
                        item_type=item_type,
                        id_user=cmd.message.author.id,
                        id_server=cmd.message.server.id,
                        stack_max=20 if item_type == ewcfg.it_weapon
                        and ewcfg.weapon_class_thrown in item.classes else -1,
                        stack_size=1 if item_type == ewcfg.it_weapon
                        and ewcfg.weapon_class_thrown in item.classes else 0,
                        item_props=item_props)

                    response = "You slam {:,} slime down on the counter at {} for {}.".format(
                        value, current_vendor, item.str_name)
                    user_data.persist()

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

    # Send the response to the player.
    await ewutils.send_message(
        cmd.client, cmd.message.channel,
        ewutils.formatMessage(cmd.message.author, response))
예제 #11
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))
예제 #12
0
async def smoke(cmd):
    usermodel = EwUser(member=cmd.message.author)
    #item_sought = ewitem.find_item(item_search="cigarette", id_user=cmd.message.author.id, id_server=usermodel.id_server)
    item_sought = None
    space_adorned = 0
    item_stash = ewitem.inventory(id_user=cmd.message.author.id,
                                  id_server=usermodel.id_server)
    for item_piece in item_stash:
        item = EwItem(id_item=item_piece.get('id_item'))
        if item.item_props.get('adorned') == 'true':
            space_adorned += int(item.item_props.get('size'))

        if item_piece.get('item_type') == ewcfg.it_cosmetic and (
                item.item_props.get('id_cosmetic') == "cigarette"
                or item.item_props.get('id_cosmetic') == "cigar"
        ) and "lit" not in item.item_props.get('cosmetic_desc'):
            item_sought = item_piece

    if item_sought:
        item = EwItem(id_item=item_sought.get('id_item'))
        if item_sought.get(
                'item_type') == ewcfg.it_cosmetic and item.item_props.get(
                    'id_cosmetic') == "cigarette":
            if int(item.item_props.get('size')) > 0:
                space_adorned += int(item.item_props.get('size'))

            if space_adorned < ewutils.max_adornspace_bylevel(
                    usermodel.slimelevel):
                response = "You light a cig and bring it to your mouth. So relaxing. So *cool*. All those naysayers and PSAs in Health class can go f**k themselves."
                item.item_props[
                    'cosmetic_desc'] = "A single lit cigarette sticking out of your mouth. You huff these things down in seconds but you’re never seen without one. Everyone thinks you’re really, really cool."
                item.item_props['adorned'] = "true"
                item.persist()

                usermodel.persist()

                await ewutils.send_message(
                    cmd.client, cmd.message.channel,
                    ewutils.formatMessage(cmd.message.author, response))
                await asyncio.sleep(60)
                item = EwItem(id_item=item_sought.get('id_item'))

                response = "The cigarette fizzled out."

                item.item_props[
                    'cosmetic_desc'] = "It's a cigarette butt. What kind of hoarder holds on to these?"
                item.item_props['adorned'] = "false"
                item.item_props['id_cosmetic'] = "cigarettebutt"
                item.item_props['cosmetic_name'] = "cigarette butt"
                item.persist()

                usermodel.persist()

            else:
                response = "Sadly, you cannot smoke the cigarette. To smoke it, you'd have to have it inbetween your lips for approximately a minute, which technically counts as adorning something. " \
                     "And, seeing as you are out of adornable cosmetic space, you cannot do that. Sorry. Weird how this message doesn't show up when you suck all that dick though, huh?"

        elif item_sought.get(
                'item_type') == ewcfg.it_cosmetic and item.item_props.get(
                    'id_cosmetic') == "cigar":
            if int(item.item_props['size']) > 0:
                space_adorned += int(item.item_props['size'])

            if space_adorned < ewutils.max_adornspace_bylevel(
                    usermodel.slimelevel):
                response = "You light up your stogie and bring it to your mouth. So relaxing. So *cool*. All those naysayers and PSAs in Health class can go f**k themselves."
                item.item_props[
                    'cosmetic_desc'] = "A single lit cigar sticking out of your mouth. These thing take their time to kick in, but it's all worth it to look like a supreme gentleman."
                item.item_props['adorned'] = "true"

                item.persist()

                usermodel.persist()

                await ewutils.send_message(
                    cmd.client, cmd.message.channel,
                    ewutils.formatMessage(cmd.message.author, response))
                await asyncio.sleep(300)
                item = EwItem(id_item=item_sought.get('id_item'))

                response = "The cigar fizzled out."

                item.item_props[
                    'cosmetic_desc'] = "It's a cigar stump. It's seen better days."
                item.item_props['adorned'] = "false"
                item.item_props['id_cosmetic'] = "cigarstump"
                item.item_props['cosmetic_name'] = "cigar stump"
                item.persist()

                usermodel.persist()

            else:
                response = "Sadly, you cannot smoke the cigar. To smoke it, you'd have to have it inbetween your lips for approximately a minute, which technically counts as adorning something. " \
                     "And, seeing as you are out of adornable cosmetic space, you cannot do that. Sorry. Weird how this message doesn't show up when you suck all that dick though, huh?"
        else:
            response = "You can't smoke that."
    else:
        response = "There aren't any usable cigarettes or cigars in your inventory."
    return await ewutils.send_message(
        cmd.client, cmd.message.channel,
        ewutils.formatMessage(cmd.message.author, response))
예제 #13
0
async def adorn(cmd):
    user_data = EwUser(member=cmd.message.author)

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

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

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

        cosmetic_items = ewitem.inventory(id_user=cmd.message.author.id,
                                          id_server=cmd.guild.id,
                                          item_type_filter=ewcfg.it_cosmetic)

        item_sought = None
        item_from_slimeoid = None
        already_adorned = False
        space_adorned = 0

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

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

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

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

        if item_sought == None:
            item_sought = item_from_slimeoid

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

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

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

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

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

                item_sought.persist()
                user_data.persist()

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

        await 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,
                'Adorn which cosmetic? Check your **!inventory**.'))
예제 #14
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))
예제 #15
0
async def smoke(cmd):
	usermodel = EwUser(member=cmd.message.author)
	#item_sought = ewitem.find_item(item_search="cigarette", id_user=cmd.message.author.id, id_server=usermodel.id_server)
	item_sought = None
	item_stash = ewitem.inventory(id_user=cmd.message.author.id, id_server=usermodel.id_server)
	for item_piece in item_stash:
		item = EwItem(id_item=item_piece.get('id_item'))
		if item_piece.get('item_type') == ewcfg.it_cosmetic and item.item_props.get('id_cosmetic') == "cigarette" and "lit" not in item.item_props.get('cosmetic_desc'):
			item_sought = item_piece

	if item_sought:
		item = EwItem(id_item=item_sought.get('id_item'))
		if item_sought.get('item_type') == ewcfg.it_cosmetic and item.item_props.get('id_cosmetic') == "cigarette":
			response = "You light a cig and bring it to your mouth. So relaxing. So *cool*. All those naysayers and PSAs in Health class can go f**k themselves."
			item.item_props['cosmetic_desc'] = "A single lit cigarette sticking out of your mouth. You huff these things down in seconds but you’re never seen without one. Everyone thinks you’re really, really cool."
			item.item_props['adorned'] = "true"
			item.persist()
			await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
			await asyncio.sleep(60)
			item = EwItem(id_item=item_sought.get('id_item'))

			response = "The cigarette fizzled out."

			item.item_props['cosmetic_desc'] = "It's a cigarette butt. What kind of hoarder holds on to these?"
			item.item_props['adorned'] = "false"
			item.item_props['id_cosmetic'] = "cigarettebutt"
			item.item_props['cosmetic_name'] = "cigarette butt"
			item.persist()
		else:
			response = "There aren't any usable cigarettes in your inventory."
	else:
		response = "There aren't any usable cigarettes in your inventory."
	return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
예제 #16
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))
예제 #17
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))
예제 #18
0
async def reap(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))
	
	forcereap = False
	if cmd.tokens[0] == ewcfg.cmd_reap_alt:
		if cmd.message.author.guild_permissions.administrator:
			forcereap = True
		else:
			return
		

	response = ""
	levelup_response = ""
	mutations = user_data.get_mutations()
	cosmetic_abilites = ewutils.get_cosmetic_abilities(id_user = cmd.message.author.id, id_server = cmd.guild.id)
	poi = ewcfg.id_to_poi.get(user_data.poi)

	# 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 reap 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 = "Do you remember planting anything here in this barren wasteland? No, you don’t. Idiot."
	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 missed a step, you haven’t planted anything here yet."
		else:
			cur_time_min = time.time() / 60
			time_grown = cur_time_min - farm.time_lastsow

			if farm.phase != ewcfg.farm_phase_reap and not forcereap:
				response = "Patience is a virtue and you are morally bankrupt. Just wait, asshole."
			else: # Reaping
				if (time_grown > ewcfg.crops_time_to_grow * 16) and not forcereap:  # about 2 days
					response = "You eagerly cultivate your crop, but what’s this? It’s dead and wilted! It seems as though you’ve let it lay fallow for far too long. Pay better attention to your farm next time. You gain no slime."
					farm.time_lastsow = 0  # 0 means no seeds are currently planted
					farm.persist()
				else:
					user_initial_level = user_data.slimelevel

					slime_gain = farm.slimes_onreap

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

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

					if has_tool and weapon.id_weapon == ewcfg.weapon_id_hoe:
						slime_gain *= 1.5

					if ewcfg.mutation_id_greenfingers in mutations:
						slime_gain *= 1.2

					if user_data.poi == ewcfg.poi_id_jr_farms:
						slime_gain = int(slime_gain / 4)

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

					slime_gain = max(0, round(slime_gain))

					response = "You reap what you’ve sown. Your investment has yielded {:,} slime, ".format(slime_gain)

					# Determine if an item is found.
					unearthed_item = False
					unearthed_item_amount = 0

					unearthed_item_chance = 50 / ewcfg.unearthed_item_rarity  # 1 in 30 chance
					
					if ewcfg.mutation_id_lucky in mutations or ewcfg.cosmeticAbility_id_lucky in cosmetic_abilites:
						unearthed_item_chance *= 1.33

					if random.random() < unearthed_item_chance:
						unearthed_item = True
						unearthed_item_amount = 1 if random.randint(1, 3) != 1 else 2  # 33% chance of extra drop

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

						item_props = ewitem.gen_item_props(item)

						if item is not None:

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

						if unearthed_item_amount == 1:
							response += "a {}, ".format(item.str_name)
						elif unearthed_item_amount == 2:
							response += "two {}s, ".format(item.str_name)

					#  Determine what crop is grown.
					vegetable = ewcfg.food_map.get(farm.crop)
					if vegetable is None:
						vegetable = random.choice(ewcfg.vegetable_list)

					item_props = ewitem.gen_item_props(vegetable)

					#  Create and give a bushel of whatever crop was grown, unless it's a metal crop.
					if item_props.get('id_food') in [ewcfg.item_id_metallicaps, ewcfg.item_id_steelbeans, ewcfg.item_id_aushucks]:
						metallic_crop_ammount = 1
						if random.randrange(10) == 0:
							metallic_crop_ammount = 5 if random.randrange(2) == 0 else 6

						if has_tool and weapon.id_weapon == ewcfg.weapon_id_pitchfork:
							metallic_crop_ammount *= 2

						
						for vcreate in range(metallic_crop_ammount):
							ewitem.item_create(
								id_user=cmd.message.author.id,
								id_server=cmd.guild.id,
								item_type=vegetable.item_type,
								item_props=item_props
							)
							
						if metallic_crop_ammount == 1:
							response += "and a single {}!".format(vegetable.str_name)
						else:
							response += "and a bushel or two of {}!".format(vegetable.str_name)
						# if random.randrange(10) == 0:
						# 	for vcreate in range(6):
						# 		ewitem.item_create(
						# 			id_user=cmd.message.author.id,
						# 			id_server=cmd.guild.id,
						# 			item_type=vegetable.item_type,
						# 			item_props=item_props
						# 		)
						# 	
						# 	response += "and a bushel of {}!".format(vegetable.str_name)
						# else:
						# 	response += "and a bushel of... hey, what the hell! You didn't reap anything! Must've been some odd seeds..."
					else:
						unearthed_vegetable_amount = 3
						if has_tool and weapon.id_weapon == ewcfg.weapon_id_pitchfork:
							unearthed_vegetable_amount *= 2

						for vcreate in range(unearthed_vegetable_amount):
							ewitem.item_create(
								id_user = cmd.message.author.id,
								id_server = cmd.guild.id,
								item_type = vegetable.item_type,
								item_props = item_props
							)
	
						response += "and a bushel of {}!".format(vegetable.str_name)

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

					was_levelup = True if user_initial_level < user_data.slimelevel else False

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

					user_data.hunger += ewcfg.hunger_perfarm
					# Flag the user for PvP
					#enlisted = True if user_data.life_state == ewcfg.life_state_enlisted else False
					# user_data.time_expirpvp = ewutils.calculatePvpTimer(user_data.time_expirpvp, ewcfg.time_pvp_farm, enlisted)

					user_data.persist()

					farm.time_lastsow = 0  # 0 means no seeds are currently planted
					farm.persist()
					await ewrolemgr.updateRoles(client = cmd.client, member = cmd.message.author)


	await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
예제 #19
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))
예제 #20
0
async def weather_tick(id_server=None):
    if id_server != None:
        try:
            market_data = EwMarket(id_server=id_server)

            if market_data.weather == ewcfg.weather_sunny:
                exposed_pois = []
                exposed_pois.extend(ewcfg.capturable_districts)
                exposed_pois.extend(ewcfg.outskirts)
                exposed_pois = tuple(exposed_pois)

                users = ewutils.execute_sql_query(
                    "SELECT id_user FROM users WHERE id_server = %s AND {poi} IN %s AND {life_state} > 0"
                    .format(poi=ewcfg.col_poi,
                            life_state=ewcfg.col_life_state),
                    (id_server, exposed_pois))
                for user in users:
                    try:
                        user_data = EwUser(id_user=user[0],
                                           id_server=id_server)
                        if user_data.life_state == ewcfg.life_state_kingpin:
                            continue
                        else:
                            mutations = user_data.get_mutations()
                            if ewcfg.mutation_id_airlock in mutations:
                                user_data.hunger -= min(user_data.hunger, 5)
                    except:
                        ewutils.logMsg(
                            "Error occurred in weather tick for server {}".
                            format(id_server))

            if market_data.weather != ewcfg.weather_bicarbonaterain:
                return

            exposed_pois = []
            exposed_pois.extend(ewcfg.capturable_districts)
            exposed_pois.extend(ewcfg.outskirts)
            exposed_pois = tuple(exposed_pois)

            client = ewutils.get_client()
            server = client.get_guild(id_server)

            users = ewutils.execute_sql_query(
                "SELECT id_user FROM users WHERE id_server = %s AND {poi} IN %s AND {life_state} > 0"
                .format(poi=ewcfg.col_poi, life_state=ewcfg.col_life_state),
                (id_server, exposed_pois))

            deathreport = ""
            resp_cont = ewutils.EwResponseContainer(id_server=id_server)
            for user in users:
                user_data = EwUser(id_user=user[0], id_server=id_server)
                if user_data.life_state == ewcfg.life_state_kingpin:
                    continue
                user_poi = ewcfg.id_to_poi.get(user_data.poi)
                player_data = EwPlayer(id_server=user_data.id_server,
                                       id_user=user_data.id_user)

                protected = False
                slimeoid_protected = False

                if user_data.weapon >= 0:
                    weapon_item = EwItem(id_item=user_data.weapon)
                    if weapon_item.item_props.get(
                            'weapon_type') in ewcfg.rain_protection:
                        protected = True

                cosmetics = ewitem.inventory(
                    id_user=user_data.id_user,
                    id_server=id_server,
                    item_type_filter=ewcfg.it_cosmetic)

                for cosmetic in cosmetics:
                    cosmetic_data = EwItem(id_item=cosmetic.get('id_item'))
                    if cosmetic_data.item_props.get(
                            'id_cosmetic') in ewcfg.rain_protection:
                        if cosmetic_data.item_props.get('adorned') == 'true':
                            protected = True
                        elif cosmetic_data.item_props.get(
                                'slimeoid') == 'true':
                            slimeoid_protected = True

                if not protected:

                    if user_data.life_state == ewcfg.life_state_shambler:
                        slime_gain = (ewcfg.slimes_shambler -
                                      user_data.slimes) / 10
                        slime_gain = max(0, int(slime_gain))
                        user_data.change_slimes(n=slime_gain,
                                                source=ewcfg.source_weather)

                    else:
                        if random.random() < 0.01:
                            user_data.degradation += 1

                    user_data.persist()

                if not slimeoid_protected:
                    slimeoid_data = EwSlimeoid(id_user=user_data.id_user,
                                               id_server=id_server)

                    if slimeoid_data.life_state != ewcfg.slimeoid_state_active:
                        continue

                    slimeoid_response = ""
                    if random.randrange(10) < slimeoid_data.level:
                        slimeoid_response = "*{uname}*: {slname} cries out in pain, as it's hit by the bicarbonate rain.".format(
                            uname=player_data.display_name,
                            slname=slimeoid_data.name)

                    else:
                        item_props = {
                            'context':
                            ewcfg.context_slimeoidheart,
                            'subcontext':
                            slimeoid_data.id_slimeoid,
                            'item_name':
                            "Heart of {}".format(slimeoid_data.name),
                            'item_desc':
                            "A poudrin-like crystal. If you listen carefully you can hear something that sounds like a faint heartbeat."
                        }
                        ewitem.item_create(id_user=str(user_data.id_user),
                                           id_server=id_server,
                                           item_type=ewcfg.it_item,
                                           item_props=item_props)
                        slimeoid_data.die()
                        slimeoid_data.persist()
                        slimeoid_response = "*{uname}*: {slname} lets out a final whimper as it's dissolved by the bicarbonate rain. {skull} You quickly pocket its heart.".format(
                            uname=player_data.display_name,
                            slname=slimeoid_data.name,
                            skull=ewcfg.emote_slimeskull)

                    resp_cont.add_channel_response(user_poi.channel,
                                                   slimeoid_response)
            for poi in exposed_pois:
                district_data = EwDistrict(district=poi, id_server=id_server)
                slimes_to_erase = district_data.slimes * 0.01 * ewcfg.weather_tick_length
                slimes_to_erase = max(slimes_to_erase,
                                      ewcfg.weather_tick_length * 1000)
                slimes_to_erase = min(district_data.slimes, slimes_to_erase)

                #round up or down, randomly weighted
                remainder = slimes_to_erase - int(slimes_to_erase)
                if random.random() < remainder:
                    slimes_to_erase += 1
                slimes_to_erase = int(slimes_to_erase)

                district_data.change_slimes(n=-slimes_to_erase,
                                            source=ewcfg.source_weather)
                district_data.persist()

            enemies = ewutils.execute_sql_query(
                "SELECT id_enemy FROM enemies WHERE id_server = %s AND {poi} IN %s AND {life_state} = %s AND {weathertype} != %s"
                .format(poi=ewcfg.col_enemy_poi,
                        life_state=ewcfg.col_enemy_life_state,
                        weathertype=ewcfg.col_enemy_weathertype),
                (id_server, exposed_pois, ewcfg.enemy_lifestate_alive,
                 ewcfg.enemy_weathertype_rainresist))

            for enemy in enemies:
                enemy_data = EwEnemy(id_enemy=enemy[0])
                enemy_poi = ewcfg.id_to_poi.get(enemy_data.poi)

                slimes_to_erase = enemy_data.slimes * 0.01 * ewcfg.weather_tick_length
                slimes_to_erase = max(slimes_to_erase,
                                      ewcfg.weather_tick_length * 1000)
                slimes_to_erase = min(enemy_data.slimes, slimes_to_erase)

                #round up or down, randomly weighted
                remainder = slimes_to_erase - int(slimes_to_erase)
                if random.random() < remainder:
                    slimes_to_erase += 1
                slimes_to_erase = int(slimes_to_erase)

                enemy_data.change_slimes(n=-slimes_to_erase,
                                         source=ewcfg.source_weather)
                enemy_data.persist()

                response = "{name} takes {slimeloss:,} damage from the bicarbonate rain.".format(
                    name=enemy_data.display_name, slimeloss=slimes_to_erase)
                resp_cont.add_channel_response(enemy_poi.channel, response)
                if enemy_data.slimes <= 0:
                    ewhunting.delete_enemy(enemy_data)
                    deathreport = "{skull} {name} is dissolved by the bicarbonate rain. {skull}".format(
                        skull=ewcfg.emote_slimeskull,
                        name=enemy_data.display_name)
                    resp_cont.add_channel_response(enemy_poi.channel,
                                                   deathreport)

            await resp_cont.post()

        except:
            ewutils.logMsg(
                "Error occurred in weather tick for server {}".format(
                    id_server))
예제 #21
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))
예제 #22
0
async def sew(cmd):
    user_data = EwUser(member=cmd.message.author)

    # Player must be at the Bodega
    if user_data.poi == ewcfg.poi_id_bodega:
        item_id = ewutils.flattenTokenListToString(cmd.tokens[1:])

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

        # Check to see if you even have the item you want to repair
        if item_id != None and len(item_id) > 0:
            response = "You don't have one."

            cosmetic_items = ewitem.inventory(
                id_user=cmd.message.author.id,
                id_server=cmd.guild.id,
                item_type_filter=ewcfg.it_cosmetic)

            item_sought = None
            item_from_slimeoid = None

            for item in cosmetic_items:
                if item.get(
                        'id_item'
                ) == item_id_int or item_id in ewutils.flattenTokenListToString(
                        item.get('name')):
                    i = EwItem(item.get('id_item'))

                    if item_from_slimeoid == None and i.item_props.get(
                            "slimeoid") == 'true':
                        item_from_slimeoid = i
                        continue
                    else:
                        item_sought = i
                        break

            if item_sought == None:
                item_sought = item_from_slimeoid

            # If the cosmetic you want to have repaired is found
            if item_sought != None:
                # Can't repair items without durability limits, since they couldn't have been damaged in the first place
                if item_sought.item_props['durability'] is None:
                    response = "I'm sorry, but I can't repair that piece of clothing!"

                else:
                    if item_sought.item_props['id_cosmetic'] == 'soul':
                        original_durability = ewcfg.soul_durability

                    elif item_sought.item_props['id_cosmetic'] == 'scalp':
                        if 'original_durability' not in item_sought.item_props.keys(
                        ):  # If it's a scalp created before this update
                            original_durability = ewcfg.generic_scalp_durability
                        else:
                            original_durability = int(
                                float(item_sought.
                                      item_props['original_durability'])
                            )  # If it's a scalp created after

                    else:  # Find the mold of the item in ewcfg.cosmetic_items_list
                        if item_sought.item_props.get(
                                'rarity') == ewcfg.rarity_princeps:
                            original_durability = ewcfg.base_durability * 100
                            original_item = None  # Princeps do not have existing templates
                        else:
                            try:
                                original_item = ewcfg.cosmetic_map.get(
                                    item_sought.item_props['id_cosmetic'])
                                original_durability = original_item.durability
                            except:
                                original_durability = ewcfg.base_durability

                    current_durability = int(
                        float(item_sought.item_props['durability']))

                    # If the cosmetic is actually damaged at all
                    if current_durability < original_durability:
                        difference = abs(current_durability -
                                         original_durability)

                        # cost_ofrepair = difference * 4 # NO ONE SAID IT WOULD BE EASY
                        cost_ofrepair = 10000  # I did...

                        if cost_ofrepair > user_data.slimes:
                            response = 'The hipster behind the counter narrows his gaze, his thick-rimmed glasses magnify his hatred of your ignoble ancestry.\n"Sir… it would cost {:,} to sew this garment back together. That’s more slime than you or your clan could ever accrue. Good day, sir. I SAID GOOD DAY. Come back when you’re a little, mmmmhh, *richer*."'.format(
                                cost_ofrepair)
                        else:
                            response = '"Let’s see, all told… including tax… plus gratuity… and a hefty tip, of course… your total comes out to {}, sir."'.format(
                                cost_ofrepair)
                            response += "\n**!accept** or **!refuse** the 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,
                                    check=lambda message: message.author == cmd
                                    .message.author and message.content.lower(
                                    ) in [ewcfg.cmd_accept, ewcfg.cmd_refuse])

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

                            # Cancel deal if the hat is no longer in user's inventory
                            if item_sought.id_owner != str(user_data.id_user):
                                accepted = False

                            # Cancel deal if the user has left Krak Bay
                            if user_data.poi != ewcfg.poi_id_bodega:
                                accepted = False

                            # Candel deal if the user doesn't have enough slime anymore
                            if cost_ofrepair > user_data.slimes:
                                accepted = False

                            if accepted == True:
                                user_data.change_slimes(
                                    n=-cost_ofrepair,
                                    source=ewcfg.source_spending)
                                user_data.persist()

                                item_sought.item_props[
                                    'durability'] = original_durability
                                item_sought.persist()

                                response = '"Excellent. Just a moment… one more stitch and-- there, perfect! Your {}, sir. It’s good as new, no? Well, no refunds in any case."'.format(
                                    item_sought.item_props['cosmetic_name'])

                            else:
                                response = '"Oh, yes, of course. I understand, sir. No, really that’s okay. I get it. I totally get it. That’s your decision. Really, it’s okay. No problem here. Yep. Yup. Uh-huh, uh-huh. Yep. It’s fine, sir. That’s completely fine. For real. Seriously. I understand, sir. It’s okay. I totally get it. Yep. Uh-huh. Yes, sir. Really, it’s okay. Some people just don’t care how they look. I understand, sir."'
                    else:
                        response = 'The hipster behind the counter looks over your {} with the thoroughness that a true man would only spend making sure all the blood really was wrung from his most recent hunt’s neck or all the cum was ejactulated from his partner’s throbbing c**k…\n"Sir," he begins to say, turning back to you before almost vomiting at the sight. After he regains his composure, he continues, "I understand you are an, shall we say, uneducated peasant, to put it delicately, but even still you should be able to tell that your {} is in mint condition. Please, do not bother me with such wastes of my boss’ time again. I do enough of that on my own."'.format(
                            item_sought.item_props['cosmetic_name'],
                            item_sought.item_props['cosmetic_name'])
        else:
            response = "Sew which cosmetic? Check your **!inventory**."
    else:
        response = "Heh, yeah right. What kind of self-respecting juvenile delinquent knows how to sew? Sewing totally f*****g lame, everyone knows that! Even people who sew know that! You’re gonna have to find some nerd to do it for you."

    return await ewutils.send_message(
        cmd.client, cmd.message.channel,
        ewutils.formatMessage(cmd.message.author, response))
예제 #23
0
async def devour(cmd):
    user_data = EwUser(member=cmd.message.author)
    item_search = ewutils.flattenTokenListToString(cmd.tokens[1:])
    item_sought = ewitem.find_item(id_server=cmd.message.guild.id,
                                   id_user=cmd.message.author.id,
                                   item_search=item_search)
    mutations = user_data.get_mutations()

    if ewcfg.mutation_id_trashmouth not in mutations:
        response = "Wait, what? Quit trying to put everything in your mouth."
    elif item_sought:
        item_obj = EwItem(id_item=item_sought.get('id_item'))
        if (item_obj.item_type
                not in [ewcfg.it_cosmetic, ewcfg.it_furniture, ewcfg.it_food]
                and item_obj.item_props.get('id_item') != 'slimepoudrin'
            ) or item_obj.item_props.get('id_cosmetic') == 'soul':
            response = "You swallow the {} whole, but after realizing this might be a mistake, you cough it back up.".format(
                item_sought.get('name'))
        elif item_obj.soulbound == True:
            response = "You attempt to consume the {}, but you realize it's soulbound and that you were about to eat your own existnece. Your life flashes before your eyes, so you decide to stop.".format(
                item_sought.get('name'))
        else:

            str_eat = "You unhinge your gaping maw and shove the {} right down, no chewing or anything. It's about as nutritious as you'd expect.".format(
                item_sought.get('name'))

            if item_obj.item_type == ewcfg.it_cosmetic:
                recover_hunger = 100
            elif item_obj.item_type == ewcfg.it_furniture:
                furn = ewcfg.furniture_map.get(
                    item_obj.item_props.get('id_furniture'))
                if furn.acquisition != ewcfg.acquisition_bazaar:
                    recover_hunger = 100
                elif furn.price < 500:
                    recover_hunger = 0
                elif furn.price < 5000:
                    recover_hunger = 50
                elif furn.price < 1000000:
                    recover_hunger = 320
                else:
                    recover_hunger = 16000
            elif item_obj.item_type == ewcfg.it_food:
                if item_obj.item_props.get('perishable') != None:
                    perishable_status = item_obj.item_props.get('perishable')
                    if perishable_status == 'true' or perishable_status == '1':
                        item_is_non_perishable = False
                    else:
                        item_is_non_perishable = True
                else:
                    item_is_non_perishable = False

                user_has_spoiled_appetite = ewcfg.mutation_id_spoiledappetite in mutations
                item_has_expired = float(getattr(item_obj, "time_expir",
                                                 0)) < time.time()

                if item_has_expired and not (user_has_spoiled_appetite
                                             or item_is_non_perishable):
                    response = "You realize that the food you were trying to eat is already spoiled. Ugh, not eating that."
                    return await ewutils.send_message(
                        cmd.client, cmd.message.channel,
                        ewutils.formatMessage(cmd.message.author, response))
                    # ewitem.item_drop(food_item.id_item)

                recover_hunger = item_obj.item_props.get('recover_hunger')

            else:
                recover_hunger = 100

            item_obj.item_props = {
                'id_food': "convertedfood",
                'food_name': "",
                'food_desc': "",
                'recover_hunger': recover_hunger,
                'inebriation': 0,
                'str_eat': str_eat,
                'time_expir': time.time() + ewcfg.std_food_expir,
                'time_fridged': 0,
                'perishable': True,
            }

            response = user_data.eat(item_obj)
            user_data.persist()
    elif item_search == "":
        response = "Devour what?"
    else:
        response = "Are you sure you have that item?"
    return await ewutils.send_message(
        cmd.client, cmd.message.channel,
        ewutils.formatMessage(cmd.message.author, response))
예제 #24
0
def gen_data_text(id_user=None,
                  id_server=None,
                  display_name=None,
                  channel_name=None):
    resp_cont = ewutils.EwResponseContainer(id_server=id_server)
    response = ""
    user_data = EwUser(id_user=id_user, id_server=id_server)
    slimeoid = EwSlimeoid(id_user=id_user, id_server=id_server)

    mutations = user_data.get_mutations()

    cosmetics = ewitem.inventory(id_user=user_data.id_user,
                                 id_server=user_data.id_server,
                                 item_type_filter=ewcfg.it_cosmetic)
    adorned_cosmetics = []
    for cosmetic in cosmetics:
        cos = EwItem(id_item=cosmetic.get('id_item'))
        if cos.item_props['adorned'] == 'true':
            hue = ewcfg.hue_map.get(cos.item_props.get('hue'))
            adorned_cosmetics.append((hue.str_name +
                                      " " if hue != None else "") +
                                     cosmetic.get('name'))

    if user_data.life_state == ewcfg.life_state_grandfoe:
        poi = ewcfg.id_to_poi.get(user_data.poi)
        if poi != None:
            response = "{} is {} {}.".format(display_name, poi.str_in,
                                             poi.str_name)
        else:
            response = "You can't discern anything useful about {}.".format(
                display_name)

        resp_cont.add_channel_response(channel_name, response)
    else:

        # return somebody's score
        if user_data.life_state == ewcfg.life_state_corpse:
            response = "{} is a level {} deadboi.".format(
                display_name, user_data.slimelevel)
        else:
            response = "{} is a level {} slimeboi.".format(
                display_name, user_data.slimelevel)

        coinbounty = int(user_data.bounty / ewcfg.slimecoin_exchangerate)

        weapon_item = EwItem(id_item=user_data.weapon)
        weapon = ewcfg.weapon_map.get(
            weapon_item.item_props.get("weapon_type"))

        if weapon != None:
            response += " {} {}{}.".format(
                ewcfg.str_weapon_married if user_data.weaponmarried == True
                else ewcfg.str_weapon_wielding,
                ("" if len(weapon_item.item_props.get("weapon_name")) == 0 else
                 "{}, ".format(weapon_item.item_props.get("weapon_name"))),
                weapon.str_weapon)
            if user_data.weaponskill >= 5:
                response += " {}".format(
                    weapon.str_weaponmaster.format(
                        rank=(user_data.weaponskill - 4)))

        trauma = ewcfg.weapon_map.get(user_data.trauma)
        # if trauma is not gathered from weapon_map, get it from attack_type_map
        if trauma == None:
            trauma = ewcfg.attack_type_map.get(user_data.trauma)

        if trauma != None:
            response += " {}".format(trauma.str_trauma)

        response_block = ""
        for mutation in mutations:
            mutation_flavor = ewcfg.mutations_map[mutation]
            response_block += "{} ".format(mutation_flavor.str_describe_other)

        if len(response_block) > 0:
            response += "\n\n" + response_block

        resp_cont.add_channel_response(channel_name, response)

        response = ""
        response_block = ""

        user_kills = ewstats.get_stat(user=user_data, metric=ewcfg.stat_kills)

        enemy_kills = ewstats.get_stat(user=user_data,
                                       metric=ewcfg.stat_pve_kills)

        if user_kills > 0 and enemy_kills > 0:
            response_block += "They have {:,} confirmed kills, and {:,} confirmed hunts. ".format(
                user_kills, enemy_kills)
        elif user_kills > 0:
            response_block += "They have {:,} confirmed kills. ".format(
                user_kills)
        elif enemy_kills > 0:
            response_block += "They have {:,} confirmed hunts. ".format(
                enemy_kills)

        if coinbounty != 0:
            response_block += "SlimeCorp offers a bounty of {:,} SlimeCoin for their death. ".format(
                coinbounty)

        if len(adorned_cosmetics) > 0:
            response_block += "They have a {} adorned. ".format(
                ewutils.formatNiceList(adorned_cosmetics, 'and'))

        statuses = user_data.getStatusEffects()

        for status in statuses:
            status_effect = EwStatusEffect(id_status=status,
                                           user_data=user_data)
            if status_effect.time_expire > time.time(
            ) or status_effect.time_expire == -1:
                status_flavor = ewcfg.status_effects_def_map.get(status)
                if status_flavor is not None:
                    response_block += status_flavor.str_describe + " "

        if (slimeoid.life_state == ewcfg.slimeoid_state_active) and (
                user_data.life_state != ewcfg.life_state_corpse):
            response_block += "They are accompanied by {}, a {}-foot-tall Slimeoid.".format(
                slimeoid.name, str(slimeoid.level))
        if len(response_block) > 0:
            response += "\n" + response_block

        response += "\n\nhttps://ew.krakissi.net/stats/player.html?pl={}".format(
            id_user)

        resp_cont.add_channel_response(channel_name, response)

    return resp_cont
예제 #25
0
async def order(cmd):
    user_data = EwUser(member=cmd.message.author)
    if user_data.life_state == ewcfg.life_state_shambler and user_data.poi != ewcfg.poi_id_nuclear_beach_edge:
        response = "You lack the higher brain functions required to {}.".format(
            cmd.tokens[0])
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

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

        shambler_multiplier = 1  #for speakeasy during shambler times

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

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

        value = None

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

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

        # Finds the item if it's an EwGeneralItem.

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

        item = ewcfg.item_map.get(value)

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

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

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

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

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

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

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

            if current_vendor == ewcfg.vendor_downpourlaboratory:
                currency_used = 'brainz'
                current_currency_amount = user_data.gvs_currency

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

            else:
                response = ""

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

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

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

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

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

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

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

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

                # raise shambled speakeasy price 4 times
                value *= shambler_multiplier

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

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

                value = int(value)

                food_ordered = False
                target_data = None

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

                if value > current_currency_amount:
                    # Not enough money.
                    response = "A {} costs {:,} {}, and you only have {:,}.".format(
                        name, value, currency_used, current_currency_amount)
                else:
                    if item_type == ewcfg.it_food:
                        food_ordered = True

                        food_items = ewitem.inventory(
                            id_user=cmd.message.author.id,
                            id_server=cmd.guild.id,
                            item_type_filter=ewcfg.it_food)

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

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

                        if len(food_items) >= user_data.get_food_capacity(
                        ) and target_data == None and togo:
                            # user_data never got persisted so the player won't lose money unnecessarily
                            response = "You can't carry any more food than that."
                            return await ewutils.send_message(
                                cmd.client, cmd.message.channel,
                                ewutils.formatMessage(cmd.message.author,
                                                      response))

                    elif item_type == ewcfg.it_weapon:
                        weapons_held = ewitem.inventory(
                            id_user=user_data.id_user,
                            id_server=cmd.guild.id,
                            item_type_filter=ewcfg.it_weapon)

                        has_weapon = False

                        # Thrown weapons are stackable
                        if ewcfg.weapon_class_thrown in item.classes:
                            # Check the player's inventory for the weapon and add amount to stack size. Create a new item the max stack size has been reached
                            for wep in weapons_held:
                                weapon = EwItem(id_item=wep.get("id_item"))
                                if weapon.item_props.get(
                                        "weapon_type"
                                ) == item.id_weapon and weapon.stack_size < weapon.stack_max:
                                    has_weapon = True
                                    weapon.stack_size += 1
                                    weapon.persist()

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

                                    user_data.change_slimes(
                                        n=-value, source=ewcfg.source_spending)
                                    user_data.persist()
                                    return await ewutils.send_message(
                                        cmd.client, cmd.message.channel,
                                        ewutils.formatMessage(
                                            cmd.message.author, response))

                        if has_weapon == False:
                            if len(weapons_held
                                   ) >= user_data.get_weapon_capacity():
                                response = "You can't carry any more weapons."
                                return await ewutils.send_message(
                                    cmd.client, cmd.message.channel,
                                    ewutils.formatMessage(
                                        cmd.message.author, response))

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

                    item_props = ewitem.gen_item_props(item)

                    customtext = cmd.message.content[(len(cmd.tokens[0]) +
                                                      len(cmd.tokens[1]) + 2):]

                    if item.item_type == ewcfg.it_furniture and "custom" in item_props.get(
                            'id_furniture'):
                        if customtext == "":
                            response = "You need to specify the customization text before buying a custom item. Come on, isn't that self-evident?"
                            return await ewutils.send_message(
                                cmd.client, cmd.message.channel,
                                ewutils.formatMessage(cmd.message.author,
                                                      response))

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

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

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

                    if item.str_name == "arcade cabinet":
                        item_props['furniture_desc'] = random.choice(
                            ewcfg.cabinets_list)
                    elif item.item_type == ewcfg.it_furniture:
                        if "custom" in item_props.get('id_furniture'):
                            item_props['furniture_name'] = item_props[
                                'furniture_name'].format(custom=customtext)
                            item_props['furniture_desc'] = item_props[
                                'furniture_desc'].format(custom=customtext)
                            item_props['furniture_look_desc'] = item_props[
                                'furniture_look_desc'].format(
                                    custom=customtext)
                            item_props['furniture_place_desc'] = item_props[
                                'furniture_place_desc'].format(
                                    custom=customtext)
                            item.str_name = item.str_name.format(
                                custom=customtext)

                    id_item = ewitem.item_create(
                        item_type=item_type,
                        id_user=cmd.message.author.id,
                        id_server=cmd.guild.id,
                        stack_max=20 if item_type == ewcfg.it_weapon
                        and ewcfg.weapon_class_thrown in item.classes else -1,
                        stack_size=1 if item_type == ewcfg.it_weapon
                        and ewcfg.weapon_class_thrown in item.classes else 0,
                        item_props=item_props)

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

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

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

                            target_player_data = EwPlayer(
                                id_user=target_data.id_user)

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

                            response += "\n\n*{}*: ".format(
                                target_player_data.display_name
                            ) + target_data.eat(item_data)
                            target_data.persist()
                            asyncio.ensure_future(
                                ewutils.decrease_food_multiplier(
                                    user_data.id_user))
                        else:

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

                            user_player_data = EwPlayer(
                                id_user=user_data.id_user)

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

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

                    user_data.persist()

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

    # Send the response to the player.
    await ewutils.send_message(
        cmd.client, cmd.message.channel,
        ewutils.formatMessage(cmd.message.author, response))
예제 #26
0
async def data(cmd):
    response = ""
    user_data = None
    member = None
    resp_cont = ewutils.EwResponseContainer(id_server=cmd.message.server.id)

    if len(cmd.tokens) > 1 and cmd.mentions_count == 0:
        user_data = EwUser(member=cmd.message.author)

        soughtenemy = " ".join(cmd.tokens[1:]).lower()
        enemy = find_enemy(soughtenemy, user_data)
        if enemy != None:
            if enemy.attacktype != ewcfg.enemy_attacktype_unarmed:
                response = "{} is a level {} enemy. They have {} slime, and attack with their {}.".format(
                    enemy.display_name, enemy.level, enemy.slimes,
                    enemy.attacktype)
            else:
                response = "{} is a level {} enemy. They have {} slime.".format(
                    enemy.display_name, enemy.level, enemy.slimes)
        else:
            response = "ENDLESS WAR didn't understand that name."

        resp_cont.add_channel_response(cmd.message.channel.name, response)

    elif cmd.mentions_count == 0:

        user_data = EwUser(member=cmd.message.author)
        slimeoid = EwSlimeoid(member=cmd.message.author)
        mutations = user_data.get_mutations()

        cosmetics = ewitem.inventory(id_user=cmd.message.author.id,
                                     id_server=cmd.message.server.id,
                                     item_type_filter=ewcfg.it_cosmetic)
        adorned_cosmetics = []
        for cosmetic in cosmetics:
            cos = EwItem(id_item=cosmetic.get('id_item'))
            if cos.item_props['adorned'] == 'true':
                hue = ewcfg.hue_map.get(cos.item_props.get('hue'))
                adorned_cosmetics.append((hue.str_name +
                                          " " if hue != None else "") +
                                         cosmetic.get('name'))

        poi = ewcfg.id_to_poi.get(user_data.poi)
        if poi != None:
            response = "You find yourself {} {}. ".format(
                poi.str_in, poi.str_name)

        # return my data
        if user_data.life_state == ewcfg.life_state_corpse:
            response += "You are a level {} deadboi.".format(
                user_data.slimelevel)
        else:
            response += "You are a level {} slimeboi.".format(
                user_data.slimelevel)

        coinbounty = int(user_data.bounty / ewcfg.slimecoin_exchangerate)

        weapon_item = EwItem(id_item=user_data.weapon)
        weapon = ewcfg.weapon_map.get(
            weapon_item.item_props.get("weapon_type"))

        if weapon != None:
            response += " {} {}{}.".format(
                ewcfg.str_weapon_married_self if user_data.weaponmarried
                == True else ewcfg.str_weapon_wielding_self,
                ("" if len(weapon_item.item_props.get("weapon_name")) == 0 else
                 "{}, ".format(weapon_item.item_props.get("weapon_name"))),
                weapon.str_weapon)
            if user_data.weaponskill >= 5:
                response += " {}".format(
                    weapon.str_weaponmaster_self.format(
                        rank=(user_data.weaponskill - 4)))

        trauma = ewcfg.weapon_map.get(user_data.trauma)
        # if trauma is not gathered from weapon_map, get it from attack_type_map
        if trauma == None:
            trauma = ewcfg.attack_type_map.get(user_data.trauma)

        if trauma != None:
            response += " {}".format(trauma.str_trauma_self)

        response_block = ""
        for mutation in mutations:
            mutation_flavor = ewcfg.mutations_map[mutation]
            response_block += "{} ".format(mutation_flavor.str_describe_self)

        if len(response_block) > 0:
            response += "\n\n" + response_block

        resp_cont.add_channel_response(cmd.message.channel.name, response)

        response = ""
        response_block = ""

        user_kills = ewstats.get_stat(user=user_data, metric=ewcfg.stat_kills)
        enemy_kills = ewstats.get_stat(user=user_data,
                                       metric=ewcfg.stat_pve_kills)

        if user_kills > 0 and enemy_kills > 0:
            response_block += "You have {:,} confirmed kills, and {:,} confirmed hunts. ".format(
                user_kills, enemy_kills)
        elif user_kills > 0:
            response_block += "You have {:,} confirmed kills. ".format(
                user_kills)
        elif enemy_kills > 0:
            response_block += "You have {:,} confirmed hunts. ".format(
                enemy_kills)

        if coinbounty != 0:
            response_block += "SlimeCorp offers a bounty of {:,} SlimeCoin for your death. ".format(
                coinbounty)

        if len(adorned_cosmetics) > 0:
            response_block += "You have a {} adorned. ".format(
                ewutils.formatNiceList(adorned_cosmetics, 'and'))

        if user_data.hunger > 0:
            response_block += "You are {}% hungry. ".format(
                round(user_data.hunger * 100.0 / user_data.get_hunger_max(),
                      1))

        if user_data.busted and user_data.life_state == ewcfg.life_state_corpse:
            response_block += "You are busted and therefore cannot leave the sewers until your next !haunt. "

        statuses = user_data.getStatusEffects()

        for status in statuses:
            status_effect = EwStatusEffect(id_status=status,
                                           user_data=user_data)
            if status_effect.time_expire > time.time(
            ) or status_effect.time_expire == -1:
                status_flavor = ewcfg.status_effects_def_map.get(status)
                if status_flavor is not None:
                    response_block += status_flavor.str_describe_self + " "

        if (slimeoid.life_state == ewcfg.slimeoid_state_active) and (
                user_data.life_state != ewcfg.life_state_corpse):
            response_block += "You are accompanied by {}, a {}-foot-tall Slimeoid. ".format(
                slimeoid.name, str(slimeoid.level))

        if len(response_block) > 0:
            response += "\n" + response_block

        response += "\n\nhttps://ew.krakissi.net/stats/player.html?pl={}".format(
            user_data.id_user)

        resp_cont.add_channel_response(cmd.message.channel.name, response)
    else:
        member = cmd.mentions[0]
        resp_cont = gen_data_text(id_user=member.id,
                                  id_server=member.server.id,
                                  display_name=member.display_name,
                                  channel_name=cmd.message.channel.name)

    # Send the response to the player.
    resp_cont.format_channel_response(cmd.message.channel.name,
                                      cmd.message.author)
    await resp_cont.post()

    await ewrolemgr.updateRoles(client=cmd.client, member=cmd.message.author)
    if member != None:
        await ewrolemgr.updateRoles(client=cmd.client, member=member)
예제 #27
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))
예제 #28
0
async def retrofit(cmd):
    user_data = EwUser(member=cmd.message.author)

    # Player must be at the Bodega
    if user_data.poi == ewcfg.poi_id_bodega:
        item_id = ewutils.flattenTokenListToString(cmd.tokens[1:])

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

        # Check to see if you even have the item you want to retrofit
        if item_id != None and len(item_id) > 0:
            response = "You don't have one."

            cosmetic_items = ewitem.inventory(
                id_user=cmd.message.author.id,
                id_server=cmd.guild.id,
                item_type_filter=ewcfg.it_cosmetic)

            item_sought = None
            item_from_slimeoid = None

            for item in cosmetic_items:
                if item.get(
                        'id_item'
                ) == item_id_int or item_id in ewutils.flattenTokenListToString(
                        item.get('name')):
                    i = EwItem(item.get('id_item'))

                    if item_from_slimeoid == None and i.item_props.get(
                            "slimeoid") == 'true':
                        item_from_slimeoid = i
                        continue
                    else:
                        item_sought = i
                        break

            if item_sought == None:
                item_sought = item_from_slimeoid

            # If the cosmetic you want to have repaired is found
            if item_sought != None:
                if item_sought.item_props.get(
                        'id_cosmetic') == 'soul' or item_sought.item_props.get(
                            'id_cosmetic') == 'scalp':
                    response = 'The hipster behind the counter is taken aback by your total lack of self awareness. "By Doctor Who!" He exclaims. "This is a place where fine clothing is sold, sir. Not a common circus freak show for ill-bred worms to feed upon the suffering of others, where surely someone of your morally bankrupt description must surely have originated! That or the w***e house, oh my Rainbow Dash..." He begins to tear up. "Just… go. Take your {} and go. Do come back if you want it sewn back together, though."'.format(
                        item_sought.item_props['cosmetic_name'])
                else:
                    current_item_stats = {}
                    # Get the current stats of your cosmetic
                    for stat in ewcfg.playerstats_list:
                        if stat in item_sought.item_props.keys():
                            if abs(int(item_sought.item_props[stat])) > 0:
                                current_item_stats[stat] = int(
                                    item_sought.item_props[stat])

                    if 'ability' in item_sought.item_props.keys():
                        current_item_stats['ability'] = item_sought.item_props[
                            'ability']

                    # Get the stats retrofitting would give you from the item model in ewcfg.cosmetic_items_list
                    desired_item = ewcfg.cosmetic_map.get(
                        item_sought.item_props['id_cosmetic'])

                    if desired_item == None:
                        response = "The hipster behind the counter doesn't really know what to do with that cosmetic, it's simply too outdated and worn out. He thinks you should just take it home and stuff it inside a box as a souvenir."
                        return await ewutils.send_message(
                            cmd.client, cmd.message.channel,
                            ewutils.formatMessage(cmd.message.author,
                                                  response))

                    desired_item_stats = {}

                    for stat in ewcfg.playerstats_list:
                        if stat in desired_item.stats.keys():
                            if abs(int(desired_item.stats[stat])) > 0:
                                desired_item_stats[stat] = desired_item.stats[
                                    stat]

                    if desired_item.ability is not None:
                        desired_item_stats['ability'] = desired_item.ability

                    # Check to see if the cosmetic is actually outdated
                    if current_item_stats != desired_item_stats:
                        cost_ofretrofit = 100  # This is a completely random number that I arbitrarily pulled out of my ass

                        if cost_ofretrofit > user_data.slimes:
                            response = 'The hipster behind the counter narrows his gaze, his thick-rimmed glasses magnify his hatred of your ignoble ancestry.\n"Sir… it would cost {:,} to retrofit this garment with updated combat abilities. That’s more slime than you or your clan could ever accrue. Good day, sir. I SAID GOOD DAY. Come back when you’re a little, mmmmhh, *richer*."'.format(
                                cost_ofretrofit)
                        else:
                            response = '"Let’s see, all told… including tax… plus gratuity… and a hefty tip, of course… your total comes out to {}, sir."'.format(
                                cost_ofretrofit)
                            response += "\n**!accept** or **!refuse** the 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,
                                    check=lambda message: message.author == cmd
                                    .message.author and message.content.lower(
                                    ) in [ewcfg.cmd_accept, ewcfg.cmd_refuse])

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

                            # Cancel deal if the hat is no longer in user's inventory
                            if item_sought.id_owner != str(user_data.id_user):
                                accepted = False

                            # Cancel deal if the user has left Krak Bay
                            if user_data.poi != ewcfg.poi_id_bodega:
                                accepted = False

                            # Candel deal if the user doesn't have enough slime anymore
                            if cost_ofretrofit > user_data.slimes:
                                accepted = False

                            if accepted == True:
                                for stat in ewcfg.playerstats_list:
                                    if stat in desired_item_stats.keys():
                                        item_sought.item_props[
                                            stat] = desired_item_stats[stat]

                                item_sought.persist()

                                user_data.slimes -= cost_ofretrofit

                                user_data.persist()

                                response = '"Excellent. Just a moment… one more iron press and-- there, perfect! Your {}, sir. It’s like you just smelted it, no? Well, no refunds in any case."'.format(
                                    item_sought.item_props['cosmetic_name'])

                            else:
                                response = '"Oh, yes, of course. I understand, sir. No, really that’s okay. I get it. I totally get it. That’s your decision. Really, it’s okay. No problem here. Yep. Yup. Uh-huh, uh-huh. Yep. It’s fine, sir. That’s completely fine. For real. Seriously. I understand, sir. It’s okay. I totally get it. Yep. Uh-huh. Yes, sir. Really, it’s okay. Some people just don’t care how they look. I understand, sir."'
                    else:
                        response = 'The hipster behind the counter looks over your {} with the thoroughness that a true man would only spend making sure all the blood really was wrung from his most recent hunt’s neck or all the cum was ejactulated from his partner’s throbbing c**k…\n"Sir," he begins to say, turning back to you before almost vomiting at the sight. After he regains his composure, he continues, "I understand you are an, shall we say, uneducated peasant, to put it delicately, but even still you should be able to tell that your {} is already completely up-to-date. Please, do not bother me with such wastes of my boss’ time again. I do enough of that on my own."'.format(
                            item_sought.item_props['cosmetic_name'],
                            item_sought.item_props['cosmetic_name'])
        else:
            response = "Sew which cosmetic? Check your **!inventory**."
    else:
        response = "Heh, yeah right. What kind of self-respecting juvenile delinquent knows how to sew? Sewing totally lame, everyone knows that! Even people who sew know that! Looks like you’re gonna have to find some nerd to do it for you."

    return await ewutils.send_message(
        cmd.client, cmd.message.channel,
        ewutils.formatMessage(cmd.message.author, response))
예제 #29
0
async def adorn(cmd):
	item_id = ewutils.flattenTokenListToString(cmd.tokens[1:])

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

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

		items = ewitem.inventory(
			id_user = cmd.message.author.id,
			id_server = cmd.message.server.id,
			item_type_filter = ewcfg.it_cosmetic
		)

		item_sought = None
		item_from_slimeoid = None
		already_adorned = False
		for item in items:
			if item.get('id_item') == item_id_int or item_id in ewutils.flattenTokenListToString(item.get('name')):
				i = EwItem(item.get('id_item'))
				if item_from_slimeoid == None and i.item_props.get("slimeoid") == 'true':
					item_from_slimeoid = i
					continue

				if i.item_props.get("adorned") == 'true':
					already_adorned = True
				elif i.item_props.get("context") == 'costume':
					if not ewutils.check_fursuit_active(i.id_server):
						response = "You can't adorn your costume right now."
					else:
						item_sought = i
						break
				else:
					item_sought = i
					break

		if item_sought == None:
			item_sought = item_from_slimeoid

		if item_sought != None:
			adorned_items = 0
			for it in items:
				i = EwItem(it.get('id_item'))
				if i.item_props['adorned'] == 'true':
					adorned_items += 1

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

			if adorned_items >= ewutils.max_adorn_bylevel(user_data.slimelevel):
				response = "You can't adorn anymore cosmetics."
			else:
				item_sought.item_props['adorned'] = 'true'

				if item_sought.item_props.get('slimeoid') == 'true':
					item_sought.item_props['slimeoid'] = 'false'
					response = "You take your {} from your slimeoid and successfully adorn it.".format(
						item_sought.item_props.get('cosmetic_name'))

				else:
					response = "You successfully adorn your " + item_sought.item_props['cosmetic_name'] + "."

				item_sought.persist()

		elif already_adorned:
			response = "You already have it adorned."

		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, 'Adorn which cosmetic? Check your **!inventory**.'))
예제 #30
0
async def mine(cmd):
    market_data = EwMarket(id_server=cmd.message.author.server.id)
    user_data = EwUser(member=cmd.message.author)
    mutations = user_data.get_mutations()
    time_now = int(time.time())

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

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

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

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

    # Mine only in the mines.
    if cmd.message.channel.name in [
            ewcfg.channel_mines, ewcfg.channel_cv_mines, ewcfg.channel_tt_mines
    ]:

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

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

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

            #minesweeper = False
            if cmd.tokens_count < 2:
                response = "Please specify which vein to mine."
                await ewutils.send_message(
                    cmd.client, cmd.message.channel,
                    ewutils.formatMessage(cmd.message.author, response))
                return await print_grid(cmd)

            else:
                #minesweeper = True
                #grid_multiplier = grid_cont.cells_mined ** 0.4
                #flag = False
                row = -1
                col = -1
                for token in cmd.tokens[1:]:

                    if token.lower() == "reset":
                        user_data.hunger += ewcfg.hunger_perminereset * int(
                            hunger_cost_mod)
                        if random.random() < extra:
                            user_data.hunger += ewcfg.hunger_perminereset
                        user_data.persist()
                        init_grid(user_data.poi, user_data.id_server)
                        return await print_grid(cmd)

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

                        for char in coords:
                            if char in ewcfg.alphabet:
                                col = ewcfg.alphabet.index(char)
                                coords = coords.replace(char, "")

                        try:
                            row = int(coords)
                        except:
                            row = -1

                row -= 1

                if row not in range(len(grid)) or col not in range(
                        len(grid[row])):
                    response = "Invalid vein."
                    await ewutils.send_message(
                        cmd.client, cmd.message.channel,
                        ewutils.formatMessage(cmd.message.author, response))
                    return await print_grid(cmd)

                mining_yield = 0
                mining_accident = False

                slimes_pertile = ewcfg.slimes_pertile
                for current_row in range(max(0, row - 1),
                                         min(row + 2, len(grid))):
                    for current_col in range(
                            max(0, col - 1),
                            min(col + 2, len(grid[current_row]))):
                        symbol_prev = get_cell_symbol(
                            grid[current_row][current_col])
                        slimes_fromtile = slimes_pertile
                        if current_row == row and current_col == col:
                            slimes_fromtile *= 2
                        mining_yield += max(
                            0,
                            min(slimes_fromtile,
                                grid[current_row][current_col]))
                        grid[current_row][current_col] -= slimes_fromtile
                        if grid[current_row][
                                current_col] < -60 * ewcfg.slimes_pertile:
                            mining_accident = True
                        if get_cell_symbol(
                                grid[current_row][current_col]) != symbol_prev:
                            printgrid = True

                if mining_accident:
                    user_data.change_slimes(n=-(user_data.slimes * 0.5))
                    user_data.persist()

                    init_grid(user_data.poi, user_data.id_server)
                    response = "You have lost an arm and a leg in a mining accident. Tis but a scratch."

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

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

            has_pickaxe = False

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

            # Determine if an item is found.
            unearthed_item = False
            unearthed_item_amount = 0

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

            if random.random() < unearthed_item_chance:
                unearthed_item = True
                unearthed_item_amount = 1 if random.randint(
                    1, 3) != 1 else 2  # 33% chance of extra drop

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

                item_props = ewitem.gen_item_props(item)

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

                if unearthed_item_amount == 1:
                    response = "You unearthed a {}! ".format(item.str_name)
                elif unearthed_item_amount == 2:
                    response = "You unearthed two (2) {}! ".format(
                        item.str_name)

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

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

            user_initial_level = user_data.slimelevel

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

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

            #mining_yield = min(mining_yield, alternate_yield)

            if has_pickaxe == True:
                mining_yield *= 2

            # Fatigue the miner.

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

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

            was_levelup = True if user_initial_level < user_data.slimelevel else False

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

            user_data.persist()

            if printgrid:
                await print_grid(cmd)

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

    if len(response) > 0:
        await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))