async def balance_cosmetics(cmd): author = cmd.message.author if not author.guild_permissions.administrator: return if cmd.tokens_count == 2: id_cosmetic = cmd.tokens[1] try: # Pull info from the cache if items are being cached item_cache = bknd_core.get_cache(obj_type="EwItem") if item_cache is not False: # find all cosmetics for the target server server_cosmetic_data = item_cache.find_entries( criteria={ "id_server": cmd.guild.id, "item_type": ewcfg.it_cosmetic }) # format the results the same way the sql query would data = list( map( lambda dat: [ dat.get("id_item"), dat.get("item_type"), dat.get("soulbound"), dat.get("stack_max"), dat.get("stack_size") ], server_cosmetic_data)) if len(data) == 0: data = None else: data = bknd_core.execute_sql_query( "SELECT {id_item}, {item_type}, {col_soulbound}, {col_stack_max}, {col_stack_size} FROM items WHERE {id_server} = {server_id} AND {item_type} = '{type_item}'" .format(id_item=ewcfg.col_id_item, item_type=ewcfg.col_item_type, col_soulbound=ewcfg.col_soulbound, col_stack_max=ewcfg.col_stack_max, col_stack_size=ewcfg.col_stack_size, id_server=ewcfg.col_id_server, server_id=cmd.guild.id, type_item=ewcfg.it_cosmetic)) if data != None: for row in data: id_item = row[0] item_data = EwItem(id_item=id_item) item_type = ewcfg.it_cosmetic item_data.item_type = item_type if id_cosmetic == "soul": if item_data.item_props['id_cosmetic'] == 'soul': item_data.item_props = { 'id_cosmetic': item_data.item_props['id_cosmetic'], 'cosmetic_name': item_data.item_props['cosmetic_name'], 'cosmetic_desc': item_data.item_props['cosmetic_desc'], 'str_onadorn': ewcfg.str_soul_onadorn, 'str_unadorn': ewcfg.str_soul_unadorn, 'str_onbreak': ewcfg.str_soul_onbreak, 'rarity': ewcfg.rarity_patrician, 'attack': 6, 'defense': 6, 'speed': 6, 'ability': None, 'durability': ewcfg.soul_durability, 'size': 1, 'fashion_style': ewcfg.style_cool, 'freshness': 10, 'adorned': 'false', 'user_id': item_data.item_props['user_id'] } elif id_cosmetic == "scalp": if item_data.item_props['id_cosmetic'] == 'scalp': item_data.item_props = { 'id_cosmetic': item_data.item_props['id_cosmetic'], 'cosmetic_name': item_data.item_props['cosmetic_name'], 'cosmetic_desc': item_data.item_props['cosmetic_desc'], 'str_onadorn': ewcfg.str_generic_onadorn, 'str_unadorn': ewcfg.str_generic_unadorn, 'str_onbreak': ewcfg.str_generic_onbreak, 'rarity': ewcfg.rarity_plebeian, 'attack': 0, 'defense': 0, 'speed': 0, 'ability': None, 'durability': ewcfg.generic_scalp_durability, 'size': 16, 'fashion_style': ewcfg.style_cool, 'freshness': 0, 'adorned': 'false', } elif id_cosmetic == "costume": if item_data.item_props.get('context') == 'costume': item_data.item_props = { 'id_cosmetic': 'dhcostume', 'cosmetic_name': item_data.item_props['cosmetic_name'], 'cosmetic_desc': item_data.item_props['cosmetic_desc'], 'str_onadorn': ewcfg.str_generic_onadorn, 'str_unadorn': ewcfg.str_generic_unadorn, 'str_onbreak': ewcfg.str_generic_onbreak, 'rarity': ewcfg.rarity_plebeian, 'attack': 1, 'defense': 1, 'speed': 1, 'ability': None, 'durability': ewcfg.base_durability * 100, 'size': 1, 'fashion_style': ewcfg.style_cute, 'freshness': 0, 'adorned': 'false', } elif id_cosmetic == 'cigarettebutt': if item_data.item_props.get( 'id_cosmetic') == 'cigarettebutt': item_data.item_props = { 'id_cosmetic': 'cigarettebutt', 'cosmetic_name': item_data.item_props['cosmetic_name'], 'cosmetic_desc': item_data.item_props['cosmetic_desc'], 'str_onadorn': ewcfg.str_generic_onadorn, 'str_unadorn': ewcfg.str_generic_unadorn, 'str_onbreak': ewcfg.str_generic_onbreak, 'rarity': ewcfg.rarity_plebeian, 'attack': 2, 'defense': 0, 'speed': 0, 'ability': None, 'durability': ewcfg.base_durability / 2, 'size': 1, 'fashion_style': ewcfg.style_cool, 'freshness': 5, 'adorned': 'false', } else: if item_data.item_props.get( 'id_cosmetic') == id_cosmetic: item = cosmetics.cosmetic_map.get( item_data.item_props['id_cosmetic']) item_data.item_props = { 'id_cosmetic': item.id_cosmetic, 'cosmetic_name': item.str_name, 'cosmetic_desc': item.str_desc, 'str_onadorn': item.str_onadorn if item.str_onadorn else ewcfg.str_generic_onadorn, 'str_unadorn': item.str_unadorn if item.str_unadorn else ewcfg.str_generic_unadorn, 'str_onbreak': item.str_onbreak if item.str_onbreak else ewcfg.str_generic_onbreak, 'rarity': item.rarity if item.rarity else ewcfg.rarity_plebeian, 'attack': item.stats[ewcfg.stat_attack] if ewcfg.stat_attack in item.stats.keys() else 0, 'defense': item.stats[ewcfg.stat_defense] if ewcfg.stat_defense in item.stats.keys() else 0, 'speed': item.stats[ewcfg.stat_speed] if ewcfg.stat_speed in item.stats.keys() else 0, 'ability': item.ability if item.ability else None, 'durability': item.durability if item.durability else ewcfg.base_durability, 'size': item.size if item.size else 1, 'fashion_style': item.style if item.style else ewcfg.style_cool, 'freshness': item.freshness if item.freshness else 0, 'adorned': 'false', } item_data.persist() ewutils.logMsg('Balanced cosmetic: {}'.format(id_item)) except KeyError as k: ewutils.logMsg("Key error: " + k) return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "Failure.")) except Exception as e: ewutils.logMsg(e) return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "Failure.")) return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, "Success!"))
async def devour(cmd): user_data = EwUser(member=cmd.message.author) item_search = ewutils.flattenTokenListToString(cmd.tokens[1:]) item_sought = bknd_item.find_item(id_server=cmd.message.guild.id, id_user=cmd.message.author.id, item_search=item_search) mutations = user_data.get_mutations() is_brick = 0 time_now = int(time.time()) mutation_data = EwMutation(id_user=user_data.id_user, id_server=user_data.id_server, id_mutation=ewcfg.mutation_id_trashmouth) if len(mutation_data.data) > 0: time_lastuse = int(mutation_data.data) else: time_lastuse = 0 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 time_lastuse + 60 > time_now: response = "You're still picking stuff out of your teeth from the last weird shit you ate. Try again in {} seconds.".format(time_lastuse + 60 - time_now) elif (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 = static_items.furniture_map.get(item_obj.item_props.get('id_furniture')) acquisition = None if furn is not None: acquisition = furn.acquisition if furn.id_furniture == 'brick': brickeat(item_obj=item_obj) is_brick = 1 recover_hunger = 50 response = str_eat elif 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 else: # This only happens in the case of propstanded items, so we just set it to the lowest possible recover_hunger = 50 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 {} you were trying to eat is already spoiled. Ugh, not eating that.".format(item_sought.get('name')) return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.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, } if item_obj.item_type != ewcfg.it_food: mutation_data.data = '{}'.format(time_now) if is_brick == 0: 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 fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))