コード例 #1
0
ファイル: ewsmelting.py プロジェクト: huckleton/endless-war
async def find_recipes_by_item(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))

    used_recipe = None

    # if the player specifies an item name
    if cmd.tokens_count > 1:
        sought_item = ewutils.flattenTokenListToString(cmd.tokens[1:])

        # Allow for the use of recipe aliases
        found_recipe = ewcfg.smelting_recipe_map.get(sought_item)
        if found_recipe != None:
            used_recipe = found_recipe.id_recipe

        # item_sought_in_inventory = ewitem.find_item(item_search=sought_item, id_user=cmd.message.author.id, id_server=cmd.guild.id if cmd.guild is not None else None)
        makes_sought_item = []
        uses_sought_item = []

        # if the item name is an item in the player's inventory, we're assuming that the player is looking up information about this item specifically.
        # if item_sought_in_inventory is not None:
        # sought_item = item_sought_in_inventory.id_item
        # print(item_sought_in_inventory['item_def'])
        # man i could NOT get this to work . maybe another day

        # finds the recipes in questions that applys
        for name in ewcfg.recipe_names:
            # find recipes that this item is used as an ingredient in
            if ewcfg.smelting_recipe_map[name].ingredients.get(
                    sought_item) is not None:
                uses_sought_item.append(name)

            # find recipes used to create this item
            elif sought_item in ewcfg.smelting_recipe_map[name].products:
                makes_sought_item.append(ewcfg.smelting_recipe_map[name])

            # finds recipes based on possible recipe aliases
            elif used_recipe in ewcfg.smelting_recipe_map[name].products:
                makes_sought_item.append(ewcfg.smelting_recipe_map[name])

        # zero matches in either of the above:
        if len(makes_sought_item) < 1 and len(uses_sought_item) < 1:
            response = "No recipes found for *{}*.".format(sought_item)

        #adds the recipe list to a response
        else:
            response = "\n"
            number_recipe = 1
            list_length = len(makes_sought_item)
            for item in makes_sought_item:
                if (item.id_recipe == "toughcosmetic"
                        and ewcfg.cosmetic_map[sought_item].style
                        is not ewcfg.style_tough
                        or item.id_recipe == "smartcosmetic"
                        and ewcfg.cosmetic_map[sought_item].style
                        is not ewcfg.style_smart
                        or item.id_recipe == "beautifulcosmetic"
                        and ewcfg.cosmetic_map[sought_item].style
                        is not ewcfg.style_beautiful
                        or item.id_recipe == "cutecosmetic"
                        and ewcfg.cosmetic_map[sought_item].style
                        is not ewcfg.style_cute
                        or item.id_recipe == "coolcosmetic"
                        and ewcfg.cosmetic_map[sought_item].style
                        is not ewcfg.style_cool):
                    list_length -= 1
                    continue
                else:
                    # formats items in form "# item" (like "1 poudrin" or whatever)
                    ingredients_list = []
                    ingredient_strings = []
                    for ingredient in item.ingredients:
                        ingredient_strings.append("{} {}".format(
                            item.ingredients.get(ingredient), ingredient))

                    if number_recipe == 1:
                        response += "To smelt this item, you'll need *{}*. ({})\n".format(
                            ewutils.formatNiceList(names=ingredient_strings,
                                                   conjunction="and"),
                            item.id_recipe)
                    else:
                        response += "Alternatively, to smelt this item, you'll need *{}*. ({})\n".format(
                            ewutils.formatNiceList(names=ingredient_strings,
                                                   conjunction="and"),
                            item.id_recipe)
                    number_recipe += 1

            if len(uses_sought_item) > 0:
                response += "This item can be used to smelt *{}*.".format(
                    ewutils.formatNiceList(names=uses_sought_item,
                                           conjunction="and"))

    # if the player doesnt specify a 2nd argument
    else:
        response = "Please specify an item you would like to look up usage for."

    # send response to player
    await ewutils.send_message(
        cmd.client, cmd.message.channel,
        ewutils.formatMessage(cmd.message.author, response))
コード例 #2
0
ファイル: ewfish.py プロジェクト: DoopedyShmoople/endless-war
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)

	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

			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)
					
				await asyncio.sleep(60)
				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))
コード例 #3
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.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 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.chname_to_poi.get(cmd.message.channel.name)
		district_data = EwDistrict(district = poi.id_poi, id_server = cmd.message.server.id)

		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 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))
コード例 #4
0
async def graft(cmd):
    user_data = EwUser(member=cmd.message.author)

    if cmd.message.channel.name != ewcfg.channel_clinicofslimoplasty:
        response = "Chemotherapy doesn't just grow on trees. You'll need to go to the clinic in Crookline to get some."
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))
    elif user_data.life_state == ewcfg.life_state_shambler:
        response = '"Oh goodness me, it seems like another one of these decaying subhumans has wandered into my office. Go on, shoo!"\n\nTough luck, seems shamblers aren\'t welcome here.'.format(
            cmd.tokens[0])
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

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

    if district_data.is_degraded():
        response = "{} has been degraded by shamblers. You can't {} here anymore.".format(
            poi.str_name, cmd.tokens[0])
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))
    elif user_data.life_state == ewcfg.life_state_corpse:
        response = '"You get out of here, dirty nega. We don\'t serve your kind." \n\n Auntie Dusttrap threatingly flails a jar of cole slaw at you. Looks like you need a body to mutate a body.'
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))
    elif len(cmd.tokens) <= 1:
        response = '"What, just anything? I love a good improv surgery! I had to leave town the last one I did though, so you\'ll have to pick an actual surgical procedure. Sorry, sonny."'
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    target_name = ewutils.flattenTokenListToString(cmd.tokens[1:])
    target = ewutils.get_mutation_alias(target_name)

    mutations = user_data.get_mutations()

    if target == 0:
        response = '"What? My ears aren\'t what they used to be. I thought you suggested I give you {}. Only braindead squicks would say that."'.format(
            ' '.join(cmd.tokens[1:]))
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))
    elif target in mutations:
        response = '"Nope, you already have that mutation. Hey, I thought I was supposed to be the senile one here!"'
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))
    elif user_data.get_mutation_level(
    ) + ewcfg.mutations_map[target].tier > min([user_data.slimelevel, 50]):
        response = '"Your body\'s already full of mutations. Your sentient tumors will probably start bitin\' once I take out my scalpel."\n\nLevel:{}/50\nMutation Levels Added:{}/{}'.format(
            user_data.slimelevel, user_data.get_mutation_level(),
            min(user_data.slimelevel, 50))
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))
    elif ewcfg.mutations_map.get(target).tier * 10000 > user_data.slimes:
        response = '"We\'re not selling gumballs here. It\'s cosmetic surgery. It\'ll cost at least {} slime, ya idjit!"'.format(
            ewcfg.mutations_map.get(target).tier * 10000)
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))
    else:
        price = ewcfg.mutations_map.get(target).tier * 10000
        user_data.change_slimes(n=-price, source=ewcfg.source_spending)
        user_data.persist()

        user_data.add_mutation(id_mutation=target, is_artificial=1)
        response = ewcfg.mutations_map[
            target].str_transplant + "\n\nMutation Levels Added:{}/{}".format(
                user_data.get_mutation_level(), min(user_data.slimelevel, 50))
        await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))
コード例 #5
0
async def take(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))

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

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

    if item_sought:
        if item_sought.get('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():
                response = "You can't carry any more food items."
                return await ewutils.send_message(
                    cmd.client, cmd.message.channel,
                    ewutils.formatMessage(cmd.message.author, response))

        if item_sought.get('item_type') == ewcfg.it_weapon:
            weapons_held = ewitem.inventory(id_user=cmd.message.author.id,
                                            id_server=cmd.message.server.id,
                                            item_type_filter=ewcfg.it_weapon)

            if 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))
            elif 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))

        ewitem.give_item(id_item=item_sought.get('id_item'),
                         id_server=user_data.id_server,
                         id_user=user_data.id_user)

        response = "You retrieve a {} from the community chest.".format(
            item_sought.get("name"))

    else:
        if item_search:
            response = "There isn't one here."
        else:
            response = "{} which item? (check **{}**)".format(
                cmd.tokens[0], ewcfg.cmd_communitychest)

    await ewutils.send_message(
        cmd.client, cmd.message.channel,
        ewutils.formatMessage(cmd.message.author, response))
コード例 #6
0
async def shambleball(cmd):

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

    if user_data.life_state != ewcfg.life_state_shambler:
        response = "You have too many higher brain functions left to play Shambleball."
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    if not ewutils.channel_name_is_poi(cmd.message.channel.name):
        response = "You have to go into the city to play Shambleball."
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    poi_data = ewcfg.chname_to_poi.get(cmd.message.channel.name)

    if poi_data.is_subzone or poi_data.is_transport:
        response = "This place is too cramped for playing Shambleball. Go outside!"
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    district_data = EwDistrict(district=poi_data.id_poi,
                               id_server=cmd.message.server.id)

    if not district_data.is_degraded:
        response = "This place is too functional and full of people to play Shambleball. You'll have to {} it first.".format(
            ewcfg.cmd_shamble)
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    global sb_userid_to_player
    shamble_player = sb_userid_to_player.get(cmd.message.author.id)

    game_data = None

    if shamble_player != None:
        global sb_games
        game_data = sb_games.get(shamble_player.id_game)

        if game_data != None and game_data.poi != poi_data.id_poi:
            game_data.players.remove(shamble_player)
            game_data = None

    if game_data == None:
        global sb_idserver_to_gamemap

        gamemap = sb_idserver_to_gamemap.get(cmd.message.server.id)
        if gamemap != None:
            game_data = gamemap.get(poi_data.id_poi)

        team = ewutils.flattenTokenListToString(cmd.tokens[1:])
        if team not in ["purple", "pink"]:
            response = "Please choose if you want to play on the pink team or the purple team."
            return await ewutils.send_message(
                cmd.client, cmd.message.channel,
                ewutils.formatMessage(cmd.message.author, response))

        if game_data == None:
            game_data = EwShambleBallGame(poi_data.id_poi,
                                          cmd.message.server.id)
            response = "You put your severed head on the floor and start a new game of Shambleball as a {team} team player."
        else:
            response = "You join the Shambleball game on the {team} team."

        shamble_player = EwShambleBallPlayer(cmd.message.author.id,
                                             cmd.message.server.id,
                                             game_data.id_game, team)
    else:
        response = "You are playing Shambleball on the {team} team. You are currently at {player_coords} going in direction {player_vel}. The ball is currently at {ball_coords} going in direction {ball_vel}. The score is purple {score_purple} : {score_pink} pink."

    response = response.format(team=shamble_player.team,
                               player_coords=shamble_player.coords,
                               ball_coords=game_data.ball_coords,
                               player_vel=shamble_player.velocity,
                               ball_vel=game_data.ball_velocity,
                               score_purple=game_data.score_purple,
                               score_pink=game_data.score_pink)
    return await ewutils.send_message(
        cmd.client, cmd.message.channel,
        ewutils.formatMessage(cmd.message.author, response))
コード例 #7
0
ファイル: ewfood.py プロジェクト: seanialt/endless-war
async def order(cmd):
    user_data = EwUser(member=cmd.message.author)
    poi = ewcfg.id_to_poi.get(user_data.poi)
    market_data = EwMarket(id_server=cmd.message.server.id)

    if poi == 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:
                    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))
コード例 #8
0
ファイル: ewfarm.py プロジェクト: Mordnilap/endless-war
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
                if ewcfg.mutation_id_greenfingers in mutations:
                    if user_data.life_state == ewcfg.life_state_juvenile:
                        farm.sow_life_state = ewcfg.farm_life_state_juviethumb
                    else:
                        farm.sow_life_state = ewcfg.farm_life_state_thumb

                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))
コード例 #9
0
async def barter(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))

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

	market_data = EwMarket(id_server = 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)

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

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

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

		if district_data.is_degraded():
			response = "{} has been degraded by shamblers. You can't {} here anymore.".format(poi.str_name, cmd.tokens[0])
			return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
		name = item_sought.get('name')
		fish = EwItem(id_item = item_sought.get('id_item'))
		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.guild.id,
					id_user = cmd.message.author.id,
					offer_give = id_fish
				)

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

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

					if offer_receive.isdigit() == True:
						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, check=lambda message: message.author == cmd.message.author and 
															message.content.lower() in [ewcfg.cmd_accept, ewcfg.cmd_refuse])

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

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

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

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

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

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


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

					response = ""

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

						user_initial_level = user_data.slimelevel

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

						was_levelup = True if user_initial_level < user_data.slimelevel else False

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

					else:
						item_props = 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
						)


					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))
コード例 #10
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
        for item in items:
            if item.get(
                    'id_item'
            ) == item_id_int or item_id in ewutils.flattenTokenListToString(
                    item.get('name')):
                item_sought = item
                break

        if item_sought != None:
            id_item = item_sought.get('id_item')
            item_def = item_sought.get('item_def')
            name = item_sought.get('id_cosmetic')
            item_type = item_sought.get('item_type')

            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)
            item = EwItem(id_item=id_item)

            if item.item_props['adorned'] == 'true':
                item.item_props['adorned'] = 'false'
                response = "You successfully dedorn your " + item.item_props[
                    'cosmetic_name'] + "."
            else:
                if adorned_items >= ewutils.max_adorn_bylevel(
                        user_data.slimelevel):
                    response = "You can't adorn anymore cosmetics."
                else:
                    item.item_props['adorned'] = 'true'

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

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

            item.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,
                'Adorn which cosmetic? Check your **!inventory**.'))
コード例 #11
0
async def appraise(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))

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

	market_data = EwMarket(id_server = 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)
	payment = ewitem.find_item(item_search = "manhattanproject", id_user = cmd.message.author.id, id_server = cmd.guild.id if cmd.guild is not None else None, item_type_filter = ewcfg.it_food)

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

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

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

		if district_data.is_degraded():
			response = "{} has been degraded by shamblers. You can't {} here anymore.".format(poi.str_name, cmd.tokens[0])
			return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
		name = item_sought.get('name')
		fish = EwItem(id_item = item_sought.get('id_item'))
		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))
コード例 #12
0
async def cast(cmd):
	time_now = round(time.time())
	has_reeled = False
	user_data = EwUser(member = cmd.message.author)
	if user_data.life_state == ewcfg.life_state_shambler:
		response = "You lack the higher brain functions required to {}.".format(cmd.tokens[0])
		return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))

	if ewutils.channel_name_is_poi(cmd.message.channel.name) == False:
		return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, "You must {} in a zone's channel.".format(cmd.tokens[0])))
	
	market_data = EwMarket(id_server = cmd.message.author.guild.id)
	statuses = user_data.getStatusEffects()

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

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

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

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

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

		if district_data.is_degraded():
			response = "{} has been degraded by shamblers. You can't {} here anymore.".format(poi.str_name, cmd.tokens[0])
			return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
		if user_data.hunger >= ewutils.hunger_max_bylevel(user_data.slimelevel):
			response = "You're too hungry to fish right now."

		else:
			has_fishingrod = False

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

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

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

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

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

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

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

				if item.item_type == ewcfg.it_food:

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

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

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

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

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

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

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

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

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

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

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

			else:
				fisher.current_size = gen_fish_size(has_fishingrod)

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


			if fisher.pier.pier_type == ewcfg.fish_slime_saltwater:
				response += "vast Slime Sea."
			else:
				response += "glowing Slime Lake."

			user_data.hunger += ewcfg.hunger_perfish * ewutils.hunger_cost_mod(user_data.slimelevel)
			user_data.persist()
			
			await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
	
			bite_text = gen_bite_text(fisher.current_size)
			
			# User has a 1/10 chance to get a bite
			fun = 100

			if fisher.bait == True:
				# Bait attatched, chance to get a bite increases from 1/10 to 1/7
				fun -= 30
			if fisher.pier == ewcfg.poi_id_ferry:
				# Fisher is on the ferry, chance to get a bite increases from 1/10 to 1/8
				fun -= 20
			if high_value_bait_used:
				fun = 5
				
			bun = 0

			while not ewutils.TERMINATE:
				
				if fun <= 0:
					fun = 1
				else:
					damp = random.randrange(fun)
				
				if fisher.high:
					await asyncio.sleep(30)
				elif high_value_bait_used:
					await asyncio.sleep(5)
				else:
					await asyncio.sleep(60)

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

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

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

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


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

			await asyncio.sleep(8)

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

	else:
		response = "You can't fish here. Go to a pier."
	
	# Don't send out a response if the user actually reeled in a fish, since that gets sent by the reel command instead.
	if has_reeled == False:
		await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
コード例 #13
0
async def embiggen(cmd):
	user_data = EwUser(member = cmd.message.author)
	if user_data.life_state == ewcfg.life_state_shambler:
		response = "You lack the higher brain functions required to {}.".format(cmd.tokens[0])
		return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))

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

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

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

		if district_data.is_degraded():
			response = "{} has been degraded by shamblers. You can't {} here anymore.".format(poi.str_name, cmd.tokens[0])
			return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
		name = item_sought.get('name')
		fish = EwItem(id_item = item_sought.get('id_item'))
		acquisition = fish.item_props.get('acquisition')

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

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

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

		else:
			size = fish.item_props.get('size')

			poudrin_cost = 0

			if size == ewcfg.fish_size_miniscule:
				poudrin_cost = 2

			if size == ewcfg.fish_size_small:
				poudrin_cost = 4

			if size == ewcfg.fish_size_average:
				poudrin_cost = 8

			if size == ewcfg.fish_size_big:
				poudrin_cost = 16

			if size == ewcfg.fish_size_huge:
				poudrin_cost = 32

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

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

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

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

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

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

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

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

				fish.persist()

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

				market_data.donated_poudrins += poudrin_cost
				market_data.persist()
				user_data.poudrin_donations += poudrin_cost
				user_data.persist()

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

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

	await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
コード例 #14
0
async def sew(cmd):
	user_data = EwUser(member = cmd.message.author)

	# Player must be at the Bodega
	if cmd.message.channel.name == ewcfg.channel_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.message.server.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
						original_item = ewcfg.cosmetic_map.get(item_sought.item_props['id_cosmetic'])
						original_durability = original_item.durability

					current_durability = int(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

						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, 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

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

							# Cancel deal if the user has left Krak Bay
							if user_data.poi != ewcfg.poi_id_krakbay:
								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.slimes -= cost_ofrepair
								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))
コード例 #15
0
ファイル: ewcosmeticitem.py プロジェクト: teorec/endless-war
async def dedorn(cmd):
    user_data = EwUser(member=cmd.message.author)
    # ewutils.moves_active[cmd.message.author.id] = 0

    # 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
        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**.'))
コード例 #16
0
async def retrofit(cmd):
	user_data = EwUser(member = cmd.message.author)

	# Player must be at the Bodega
	if cmd.message.channel.name == ewcfg.channel_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.message.server.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'])
					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:
						if desired_item.price:
							cost_ofretrofit = desired_item.price * 4

						else:
							cost_ofretrofit = 1000000 # 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, 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

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

							# Cancel deal if the user has left Krak Bay
							if user_data.poi != ewcfg.poi_id_krakbay:
								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))
コード例 #17
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**.'
            ))
コード例 #18
0
async def embark(cmd):
    # can only use movement commands in location channels
    if ewmap.channel_name_is_poi(cmd.message.channel.name) == False:
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(
                cmd.message.author,
                "You must {} in a zone's channel.".format(cmd.tokens[0])))

    poi = ewcfg.chname_to_poi.get(cmd.message.channel.name)
    district_data = EwDistrict(district=poi.id_poi,
                               id_server=cmd.message.server.id)

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

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

    if ewutils.active_restrictions.get(
            user_data.id_user) != None and ewutils.active_restrictions.get(
                user_data.id_user) > 0:
        response = "You can't do that right now."
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    poi = ewmap.fetch_poi_if_coordless(cmd.message.channel.name)

    # must be at a transport stop to enter a transport
    if poi != None and poi.id_poi in ewcfg.transport_stops:
        transport_ids = get_transports_at_stop(id_server=user_data.id_server,
                                               stop=poi.id_poi)

        # can't embark, when there's no vehicles to embark on
        if len(transport_ids) == 0:
            response = "There are currently no transport vehicles to embark on here."
            return await ewutils.send_message(
                cmd.client, cmd.message.channel,
                ewutils.formatMessage(cmd.message.author, response))

        # automatically embark on the only transport at the station, if no arguments were provided
        elif len(transport_ids) == 1 and cmd.tokens_count < 2:
            transport_data = EwTransport(id_server=user_data.id_server,
                                         poi=transport_ids[0])
            target_name = transport_data.current_line

        # get target name from command arguments
        else:
            target_name = ewutils.flattenTokenListToString(cmd.tokens[1:])

        # report failure, if the vehicle to be boarded couldn't be ascertained
        if target_name == None or len(target_name) == 0:
            return await ewutils.send_message(
                cmd.client, cmd.message.channel,
                ewutils.formatMessage(cmd.message.author,
                                      "Which transport line?"))

        transport_line = ewcfg.id_to_transport_line.get(target_name)

        # report failure, if an invalid argument was given
        if transport_line == None:
            return await ewutils.send_message(
                cmd.client, cmd.message.channel,
                ewutils.formatMessage(cmd.message.author,
                                      "Never heard of it."))

        for transport_id in transport_ids:
            transport_data = EwTransport(id_server=user_data.id_server,
                                         poi=transport_id)

            # check if one of the vehicles at the stop matches up with the line, the user wants to board
            if transport_data.current_line == transport_line.id_line:
                last_stop_poi = ewcfg.id_to_poi.get(transport_line.last_stop)
                response = "Embarking on {}.".format(transport_line.str_name)
                # schedule tasks for concurrent execution
                message_task = asyncio.ensure_future(
                    ewutils.send_message(
                        cmd.client, cmd.message.channel,
                        ewutils.formatMessage(cmd.message.author, response)))
                wait_task = asyncio.ensure_future(asyncio.sleep(5))

                # Take control of the move for this player.
                ewmap.move_counter += 1
                move_current = ewutils.moves_active[
                    cmd.message.author.id] = ewmap.move_counter
                await message_task
                await wait_task

                # check if the user entered another movement command while waiting for the current one to be completed
                if move_current == ewutils.moves_active[cmd.message.author.id]:
                    user_data = EwUser(member=cmd.message.author)

                    transport_data = EwTransport(id_server=user_data.id_server,
                                                 poi=transport_id)

                    # check if the transport is still at the same stop
                    if transport_data.current_stop == poi.id_poi:
                        user_data.poi = transport_data.poi
                        user_data.persist()

                        transport_poi = ewcfg.id_to_poi.get(transport_data.poi)

                        response = "You enter the {}.".format(
                            transport_data.transport_type)
                        await ewrolemgr.updateRoles(client=cmd.client,
                                                    member=cmd.message.author)
                        return await ewutils.send_message(
                            cmd.client,
                            ewutils.get_channel(cmd.message.server,
                                                transport_poi.channel),
                            ewutils.formatMessage(cmd.message.author,
                                                  response))
                    else:
                        response = "The {} starts moving just as you try to get on.".format(
                            transport_data.transport_type)
                        return await ewutils.send_message(
                            cmd.client, cmd.message.channel,
                            ewutils.formatMessage(cmd.message.author,
                                                  response))

        response = "There is currently no vehicle following that line here."
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    else:
        response = "No transport vehicles stop here. Try going to a subway station or a ferry port."
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))
コード例 #19
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**.'))
コード例 #20
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))

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

        if not item.soulbound:
            if item.item_type == ewcfg.it_weapon and 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()

            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))
コード例 #21
0
async def rate_zine(cmd):
	if len(cmd.tokens) < 2:
		response = "What zine do you want to rate?"

	else:
		if len(cmd.tokens) >= 3:
			rating = ewutils.getIntToken(cmd.tokens)
			book_title = ewutils.flattenTokenListToString(cmd.tokens[1:len(cmd.tokens) - 1])

			if rating == None:
				response = "How many f***s do you want to give the zine? (1-5)"

			elif rating not in range(1, 6):
				response = "Easy now, keep your f***s between 1 and 5."

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

				if book_sought:
					book_item = EwItem(id_item=book_sought.get('id_item'))
					id_book = book_item.item_props.get("id_book")
					book = EwBook(id_book = id_book)
					sale = EwBookSale(id_book = id_book, member = cmd.message.author)

					if sale.bought == 1:
						if sale.rating == 0:
							book.rates += 1
						sale.rating = rating
						sale.persist()
						try:
							conn_info = ewutils.databaseConnect()
							conn = conn_info.get('conn')
							cursor = conn.cursor()

							cursor.execute((
									"SELECT {} FROM book_sales WHERE {} = %s AND {} = %s AND {} != 0".format(
										ewcfg.col_rating,
										ewcfg.col_id_server,
										ewcfg.col_id_user,
										ewcfg.col_rating,
									)
							), (
								cmd.message.server.id,
								cmd.message.author.id,
							))

							data = cursor.fetchall()
							ratings = []
							total_rating = 0

							if data != None:
								for row in data:
									ratings.append(row)
									total_rating += row[0]

						finally:
							# Clean up the database handles.
							cursor.close()
							ewutils.databaseClose(conn_info)

						book.rating = str(total_rating / len(ratings))[:4]

						# zine is excluded from normal browsing
						if book.book_state == 1:
							if book.rates >= 10 and float(book.rating) <= 2.0:
								book.book_state = 2
							elif book.rates >= 4 and float(book.rating) <= 1.5:
								book.book_state = 2

						# zine is included back into normal browsing
						elif book.book_state == 2:
							if float(book.rating) > 2.0 and book.rates > 10:
								book.book_state = 1
							elif float(book.rating) > 1.5 and book.rates > 5:
								book.book_state = 1

						book.persist()

						response = "{}, you carve a {} into the back of the zine in order to indicate how many f***s you give about it.".format(ewcfg.rating_flavor[rating], rating)

					else:
						response = "You've never bought this book."

				else:
					response = "You don't have that zine on you."
		else:
			response = "How many f***s do you want to give the zine? (1-5)"

	await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
コード例 #22
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))


	# 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 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.chname_to_poi.get(cmd.message.channel.name)
		district_data = EwDistrict(district = poi.id_poi, id_server = cmd.message.server.id)

		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 cmd.message.channel.name == ewcfg.channel_jr_farms:
			farm_id = ewcfg.poi_id_jr_farms
		elif cmd.message.channel.name == ewcfg.channel_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))
コード例 #23
0
async def read_book(cmd = None, dm = False):
	user_data = EwUser(member=cmd.message.author)

	if not dm:
		response = "ENDLESS WAR politely asks that you !read in his DMs."

	elif len(cmd.tokens) < 2:
		response = "What zine do you want to read?"

	else:
		if len(cmd.tokens) < 3:
			book_title = ewutils.flattenTokenListToString(cmd.tokens)
			page_number = 0
		else:
			book_title = ewutils.flattenTokenListToString(cmd.tokens[1:len(cmd.tokens) - 1])
			page_number = ewutils.getIntToken(cmd.tokens)

		book_sought = ewitem.find_item(item_search=book_title, id_user=cmd.message.author.id, id_server=cmd.message.server.id if cmd.message.server is not None else None, item_type_filter = ewcfg.it_book)

		if book_sought:
			book = EwItem(id_item = book_sought.get('id_item'))
			id_book = book.item_props.get("id_book")
			book = EwBook(id_book=id_book)

			if page_number not in range(0, book.pages+1):
				page_number = 0

			accepted = True
			if book.genre == 3:

				accepted = False
				response = "ENDLESS WAR sees you about to open up a p**n zine and wants to make sure you're 18 years or older. Use **!accept** to open or **!refuse** to abstain."

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

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

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

			if book.book_state < 0:
				response = "You simply can't make out the letters on the page. Maybe it's better this way."

			elif accepted:
				page_contents = get_page(id_book, page_number)

				if page_number == 0 and page_contents == "":
					page_contents = get_page(id_book, 1)

				page_text = "turn to page {}".format(page_number)

				if page_number == 0:
					page_text = "look at the cover"

				response = "You {} and begin to read.\n\n\"{} \"".format(page_text, page_contents)
				readers[user_data.id_user] = (id_book, page_number)

				if page_contents == "":
					response = "You open up to page {} only to find that it's blank!".format(page_number)

				if page_number != 0:
					response += "\n\nUse **!previouspage** to go back one page."

				if page_number != book.pages:
					response += "\n\nUse **!nextpage** to go forward one page."

			else:
				response = "You decide not to indulge yourself."

		else:
			response = "You don't have that zine. Make sure you use **!read [zine title] [page]**"

	await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
コード例 #24
0
async def chemo(cmd):
    user_data = EwUser(member=cmd.message.author)

    if cmd.message.channel.name != ewcfg.channel_clinicofslimoplasty:
        response = "Chemotherapy doesn't just grow on trees. You'll need to go to the clinic in Crookline to get some."
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))
    elif user_data.life_state == ewcfg.life_state_shambler:
        response = '"Oh goodness me, it seems like another one of these decaying subhumans has wandered into my office. Go on, shoo!"\n\nTough luck, seems shamblers aren\'t welcome here.'.format(
            cmd.tokens[0])
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

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

    if district_data.is_degraded():
        response = "{} has been degraded by shamblers. You can't {} here anymore.".format(
            poi.str_name, cmd.tokens[0])
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))
    elif user_data.life_state == ewcfg.life_state_corpse:
        response = '"You get out of here. We don\'t serve your kind." \n\n Auntie Dusttrap threatingly flails a jar of cole slaw at you. Looks like you need a body to operate on one.'
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    mutations = user_data.get_mutations()
    if len(mutations) == 0:
        response = '"I can chemo you all day long, sonny. You\'re not getting any cleaner than you are."'
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))
    elif len(cmd.tokens) <= 1:
        response = '"Are you into chemo for the thrill, boy? You have to tell me what you want taken out."'
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))
    elif cmd.tokens[1] == "all":
        finalprice = 0

        for mutation in mutations:
            finalprice += ewcfg.mutations_map.get(mutation).tier * 5000

        if finalprice > user_data.slimes:
            response = '"We\'re not selling gumballs here. It\'s chemotherapy. It\'ll cost at least {:,} slime, ya idjit!"'.format(
                finalprice)
            return await ewutils.send_message(
                cmd.client, cmd.message.channel,
                ewutils.formatMessage(cmd.message.author, response))
        else:
            response = "\"Sure you got the slime for that, whelp? It's {:,}.\"\n**Accept** or **refuse?**".format(
                finalprice)
            await ewutils.send_message(
                cmd.client, cmd.message.channel,
                ewutils.formatMessage(cmd.message.author, response))
            try:
                accepted = False
                message = await cmd.client.wait_for(
                    'message',
                    timeout=30,
                    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 Exception as e:
                print(e)
                accepted = False

            if not accepted:
                response = "\"Tch. Knew you weren't good for it.\""
            else:

                for mutation in mutations:

                    price = ewcfg.mutations_map.get(mutation).tier * 5000
                    user_data.change_slimes(n=-price,
                                            source=ewcfg.source_spending)

                    mutation_obj = EwMutation(id_mutation=mutation,
                                              id_user=user_data.id_user,
                                              id_server=cmd.message.guild.id)
                    if mutation_obj.artificial == 0:
                        try:
                            ewutils.execute_sql_query(
                                "DELETE FROM mutations WHERE {id_server} = %s AND {id_user} = %s AND {mutation} = %s"
                                .format(id_server=ewcfg.col_id_server,
                                        id_user=ewcfg.col_id_user,
                                        mutation=ewcfg.col_id_mutation), (
                                            user_data.id_server,
                                            user_data.id_user,
                                            mutation,
                                        ))
                        except:
                            ewutils.logMsg(
                                "Failed to clear mutations for user {}.".
                                format(user_data.id_user))
                user_data.persist()
                response = '"Everything, eh? All right then. This might hurt a lottle!" Auntie Dusttrap takes a specialized shop vac and sucks the slime out of you. While you\'re reeling in slimeless existential dread, she runs it through a filtration process that gets rid of the carcinogens that cause mutation. She grabs the now purified canister and haphazardly dumps it back into you. You feel pure, energized, and ready to dirty up your slime some more!'
            return await ewutils.send_message(
                cmd.client, cmd.message.channel,
                ewutils.formatMessage(cmd.message.author, response))
    else:
        target_name = ewutils.flattenTokenListToString(cmd.tokens[1:])
        target = ewutils.get_mutation_alias(target_name)
        mutation_obj = EwMutation(id_mutation=target,
                                  id_user=user_data.id_user,
                                  id_server=cmd.message.guild.id)

        if target == 0:
            response = '"I don\'t know what kind of gold-rush era disease that is, but I have no idea how to take it out of you."'
            return await ewutils.send_message(
                cmd.client, cmd.message.channel,
                ewutils.formatMessage(cmd.message.author, response))
        elif target not in mutations:
            response = '"Oy vey, another hypochondriac. You don\'t have that mutation, so I can\'t remove it."'
            return await ewutils.send_message(
                cmd.client, cmd.message.channel,
                ewutils.formatMessage(cmd.message.author, response))
        elif ewcfg.mutations_map.get(target).tier * 5000 > user_data.slimes:
            response = '"We\'re not selling gumballs here. It\'s chemotherapy. It\'ll cost at least {} slime, ya idjit!"'.format(
                ewcfg.mutations_map.get(target).tier * 5000)
            return await ewutils.send_message(
                cmd.client, cmd.message.channel,
                ewutils.formatMessage(cmd.message.author, response))
        elif mutation_obj.artificial == 1:
            response = '"Hey, didn\'t I do that to ya? Well no refunds!"\n\nGuess you can\'t get rid of artificial mutations with chemo.'
            return await ewutils.send_message(
                cmd.client, cmd.message.channel,
                ewutils.formatMessage(cmd.message.author, response))
        else:
            price = ewcfg.mutations_map.get(target).tier * 5000
            user_data.change_slimes(n=-price, source=ewcfg.source_spending)
            user_data.persist()

            try:
                ewutils.execute_sql_query(
                    "DELETE FROM mutations WHERE {id_server} = %s AND {id_user} = %s AND {mutation} = %s"
                    .format(id_server=ewcfg.col_id_server,
                            id_user=ewcfg.col_id_user,
                            mutation=ewcfg.col_id_mutation), (
                                user_data.id_server,
                                user_data.id_user,
                                target,
                            ))
            except:
                ewutils.logMsg("Failed to clear mutations for user {}.".format(
                    user_data.id_user))
            response = '"Alright, dearie, let\'s get you purged." You enter a dingy looking operating room, with slime strewn all over the floor. Dr. Dusttrap pulls out a needle the size of your bicep and injects into odd places on your body. After a few minutes of this, you get fatigued and go under.\n\n You wake up and {} is gone. Nice! \nMutation Levels Added:{}/{}'.format(
                ewcfg.mutations_map.get(target).str_name,
                user_data.get_mutation_level(), min(user_data.slimelevel, 50))
            await ewutils.send_message(
                cmd.client, cmd.message.channel,
                ewutils.formatMessage(cmd.message.author, response))
コード例 #25
0
ファイル: ewfood.py プロジェクト: EbolaSpreadn247/endless-war
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'))
				acquisition = None
				if furn is not None:
					acquisition = furn.acquisition
				if 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))
コード例 #26
0
async def preserve(cmd):
    user_data = EwUser(member=cmd.message.author)
    mutations = user_data.get_mutations()
    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_obj = ewitem.EwItem(id_item=item_sought.get('id_item'))

        if item_obj.item_props.get('preserved') == None:
            preserve_id = 0
        else:
            preserve_id = int(item_obj.item_props.get('preserved'))

        if ewcfg.mutation_id_rigormortis not in mutations:
            response = "You can't just preserve something by saying you're going to. Everything ends eventually."
            return await ewutils.send_message(
                cmd.client, cmd.message.channel,
                ewutils.formatMessage(cmd.message.author, response))
        elif item_obj.soulbound == True:
            response = "This thing's bound to your soul. There's no need to preserve it twice."
            return await ewutils.send_message(
                cmd.client, cmd.message.channel,
                ewutils.formatMessage(cmd.message.author, response))
        elif preserve_id == int(user_data.id_user):
            response = "Didn't you already preserve this? You're so paranoid."
            return await ewutils.send_message(
                cmd.client, cmd.message.channel,
                ewutils.formatMessage(cmd.message.author, response))
        elif item_obj.item_props.get('preserved') == "nopreserve":
            response = "You shove it into your body but it just won't fit for some reason. That phrasing was completely intentional, by the way."
            return await ewutils.send_message(
                cmd.client, cmd.message.channel,
                ewutils.formatMessage(cmd.message.author, response))
        else:

            rigor = EwMutation(id_user=cmd.message.author.id,
                               id_server=cmd.message.guild.id,
                               id_mutation=ewcfg.mutation_id_rigormortis)

            if rigor.data.isdigit() == False:
                num = 0
            else:
                num = int(rigor.data)

            if num >= 5:
                response = "Your body's dried up, it's lost its ability to preserve objects."
            else:
                response = "You take the {} and embrace it with all your might. As you squeeze, it slowly but surely begins to phase inside your body. That won't get stolen anytime soon!".format(
                    item_sought.get('name'))
                num += 1
                rigor.data = str(num)
                item_obj.item_props['preserved'] = user_data.id_user
                rigor.persist()
                item_obj.persist()
            return await ewutils.send_message(
                cmd.client, cmd.message.channel,
                ewutils.formatMessage(cmd.message.author, response))
    else:
        response = "Preserve what?"
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))
コード例 #27
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.message.server.id,
			item_type_filter = ewcfg.it_cosmetic
		)

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

		# 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

			# Get space used adorned cosmetics
			if i.item_props['adorned'] == 'true':
				space_adorned += int(i.item_props['size'])

		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**.'))
コード例 #28
0
ファイル: ewsmelting.py プロジェクト: huckleton/endless-war
async def smelt(cmd):
    user_data = EwUser(member=cmd.message.author)
    if user_data.life_state == ewcfg.life_state_shambler:
        response = "You lack the higher brain functions required to {}.".format(
            cmd.tokens[0])
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

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

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

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

            owned_ingredients = []

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

            for matched_item in necessary_ingredients:
                necessary_items = necessary_ingredients.get(matched_item)
                necessary_str = "{} {}".format(necessary_items, matched_item)
                if necessary_items > 1:
                    necessary_str += "s"
                necessary_ingredients_list.append(necessary_str)

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

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

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

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

                    if patrician_smelted <= 5:
                        patrician = True

                    cosmetics_list = []

                    if found_recipe.id_recipe == "toughcosmetic":
                        style = ewcfg.style_tough
                    elif found_recipe.id_recipe == "smartcosmetic":
                        style = ewcfg.style_smart
                    elif found_recipe.id_recipe == "beautifulcosmetic":
                        style = ewcfg.style_beautiful
                    elif found_recipe.id_recipe == "cutecosmetic":
                        style = ewcfg.style_cute
                    else:
                        style = ewcfg.style_cool

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

                    items = []

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

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

                    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)

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

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

                    item_props = ewitem.gen_item_props(item)

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

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

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

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

                user_data.persist()

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

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

    # Send response
    await ewutils.send_message(
        cmd.client, cmd.message.channel,
        ewutils.formatMessage(cmd.message.author, response))
コード例 #29
0
ファイル: ewfish.py プロジェクト: DoopedyShmoople/endless-war
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))