async def shakeoff(cmd): user_data = EwUser(member=cmd.message.author) if cmd.mentions_count == 0: response = "God knows there are like a million third eyes floating around. You'll have to specify whose you're looking for." elif cmd.mentions_count > 1: response = "You're not that good at finding private eyes. Look for one at a time." else: target_data = EwUser(member=cmd.mentions[0]) try: bknd_core.execute_sql_query( "UPDATE mutations SET {data} = %s WHERE {id_server} = %s AND {mutation} = %s and {id_user} = %s;".format( data=ewcfg.col_mutation_data, id_server=ewcfg.col_id_server, id_user=ewcfg.col_id_user, mutation=ewcfg.col_id_mutation, ), ( "", user_data.id_server, ewcfg.mutation_id_oneeyeopen, target_data.id_user )) response = "You search high and low for {}'s third eye, shouting a bit to give it a good scare. If it was stalking you it certainly isn't now.".format(cmd.mentions[0].display_name) except: ewutils.logMsg("Failed to undo tracking for {}.".format(user_data.id_user)) response = "" return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def inhabit(cmd): user_data = EwUser(member=cmd.message.author) response = "" if user_data.life_state != ewcfg.life_state_corpse: # Only ghosts can inhabit other players response = "You have no idea what you're doing." else: if cmd.mentions_count > 1: response = "Are you trying to split yourself in half? You can only inhabit one body at a time." elif cmd.mentions_count == 1: member = cmd.mentions[0] target_data = EwUser(member=member) if ewutils.channel_name_is_poi(cmd.message.channel.name) == False: # Has to be done in a gameplay channel response = "You can't disturb the living from here." elif cmd.message.channel.name == ewcfg.channel_sewers: # Can't be done from the sewers response = "Try doing that in the overworld, it's difficult from down here." elif target_data.life_state == ewcfg.life_state_kingpin: # Can't target generals response = "He is far too strong for you to inhabit his body." elif user_data.poi != target_data.poi: # Player must be on the same location as their target response = "You'll have to find them first." elif target_data.life_state == ewcfg.life_state_corpse: # Can't target ghosts response = "You can't do that to your fellow ghost." elif move_utils.poi_is_pvp(target_data.poi) == False: response = "You can't torment the living here." else: # cancel the ghost's movement ewutils.moves_active[cmd.message.author.id] = 0 # drop any previous inhabitation by the ghost user_data.remove_inhabitation() # add the new inhabitation bknd_core.execute_sql_query( "REPLACE INTO inhabitations({id_ghost}, {id_fleshling}, {id_server}) VALUES (%s, %s, %s)" .format( id_ghost=ewcfg.col_id_ghost, id_fleshling=ewcfg.col_id_fleshling, id_server=ewcfg.col_id_server, ), ( user_data.id_user, target_data.id_user, user_data.id_server, )) response = "{}\'s body is inhabited by the ghost of {}!".format( member.display_name, cmd.message.author.display_name) else: response = "Your spookiness is appreciated, but ENDLESS WAR didn\'t understand that name." return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def clowncar(cmd): #shoves everyone not there into JR or the sewers if not cmd.message.author.guild_permissions.administrator: return id_server = cmd.guild.id server = ewcfg.server_list[cmd.guild.id] gellphones = itm_utils.find_item_all(item_search=ewcfg.item_id_gellphone, id_server=id_server, item_type_filter=ewcfg.it_item) for phone in gellphones: phone_data = EwItem(id_item=phone.get('id_item')) phone_data.item_props['gellphoneactive'] = 'false' phone_data.persist() if phone_data.id_owner.isnumeric() and int(phone_data.id_owner) > 0: print(phone_data.id_owner) member_object = server.get_member(int(phone_data.id_owner)) if member_object is None: continue user_data = EwUser(member=member_object) print('{}{}'.format('clowning:', user_data.id_user)) user_data.poi = 'juviesrow' user_data.persist() await ewrolemgr.updateRoles(client=cmd.client, member=member_object) if id_server != None: try: selection = bknd_core.execute_sql_query( "SELECT {id_user} FROM users WHERE id_server = %s AND {poi} NOT IN('juviesrow', 'thesewers', 'rowdyroughhouse', 'copkilltown')" .format(id_user=ewcfg.col_id_user, poi=ewcfg.col_poi), ([str(id_server)])) bknd_core.execute_sql_query( "UPDATE users SET {poi} = %s WHERE id_server = %s AND {poi} NOT IN('juviesrow', 'thesewers', 'rowdyroughhouse', 'copkilltown')" .format(poi=ewcfg.col_poi), ('juviesrow', [str(id_server)])) iterator = 0 for member in selection: iterator += 1 if iterator % 20 == 0: await asyncio.sleep(5) member_object = server.get_member(member[0]) await ewrolemgr.updateRoles(client=cmd.client, member=member_object) except: ewutils.logMsg('server {}: failed to clowncar.'.format( cmd.message.guild.id, cmd.message.author.id))
async def dedorn_all_costumes(): costume_count = 0 # Grab costumes from the cache if enabled item_cache = bknd_core.get_cache(obj_type="EwItem") if item_cache is not False: # separate search criteria for adorned or slimeoided p1 = {"context": "costume", "adorned": "true"} p2 = {"context": "costume", "slimeoid": "true"} # compile both results costumes_data = item_cache.find_entries(criteria={"item_props": p1}) costumes_data += item_cache.find_entries(criteria={"item_props": p2}) # Build a list that'll be handled in the same way costumes = list(map(lambda dat: dat.get("id_item"), costumes_data)) else: costumes = bknd_core.execute_sql_query( "SELECT id_item FROM items_prop WHERE name = 'context' AND value = 'costume' AND id_item IN (SELECT id_item FROM items_prop WHERE (name = 'adorned' OR name = 'slimeoid') AND value = 'true')" ) for costume_id in costumes: costume_item = EwItem(id_item=costume_id) costume_item.item_props['adorned'] = 'false' costume_item.item_props['slimeoid'] = 'false' costume_item.persist() costume_count += 1 ewutils.logMsg( "Dedorned {} costumes after full moon ended.".format(costume_count))
def getRecentTotalShares(id_server=None, stock=None, count=2): if id_server != None and stock != None: values = [] try: count = round(count) data = bknd_core.execute_sql_query( "SELECT {total_shares} FROM stocks WHERE {id_server} = %s AND {stock} = %s ORDER BY {timestamp} DESC LIMIT %s" .format( stock=ewcfg.col_stock, total_shares=ewcfg.col_total_shares, id_server=ewcfg.col_id_server, timestamp=ewcfg.col_timestamp, ), (id_server, stock, (count if (count > 0) else 2))) for row in data: values.append(row[0]) # Make sure we return at least one value. if len(values) == 0: values.append(0) # If we don't have enough data, pad out to count with the last value in the array. value_last = values[-1] while len(values) < count: values.append(value_last) except: pass finally: return values
async def one_eye_dm(id_user = None, id_server = None, poi = None): poi_obj = poi_static.id_to_poi.get(poi) client = ewutils.get_client() server = client.get_guild(id_server) server = client.get_guild(str(id_server)) server = client.get_guild(int(id_server)) id_player = EwPlayer(id_user=id_user, id_server=id_server) if poi_obj.pvp: try: recipients = bknd_core.execute_sql_query( "SELECT {id_user} FROM mutations WHERE {id_server} = %s AND {mutation} = %s and {data} = %s".format( data=ewcfg.col_mutation_data, id_server=ewcfg.col_id_server, id_user=ewcfg.col_id_user, mutation=ewcfg.col_id_mutation, ), ( id_server, ewcfg.mutation_id_oneeyeopen, str(id_user), )) for recipient in recipients: member = server.get_member(int(recipient[0])) mutation = EwMutation(id_server=id_server, id_user=recipient[0], id_mutation=ewcfg.mutation_id_oneeyeopen) mutation.data = "" mutation.persist() await fe_utils.send_message(client, member, fe_utils.formatMessage(member, "{} is stirring...".format(id_player.display_name))) except: ewutils.logMsg("Failed to do OEO notificaitons for {}.".format(id_user))
def getUserTotalShares(id_server=None, stock=None, id_user=None): if id_server != None and stock != None and id_user != None: values = 0 try: data = bknd_core.execute_sql_query( "SELECT {shares} FROM shares WHERE {id_server} = %s AND {id_user} = %s AND {stock} = %s" .format(stock=ewcfg.col_stock, shares=ewcfg.col_shares, id_server=ewcfg.col_id_server, id_user=ewcfg.col_id_user), ( id_server, id_user, stock, )) for row in data: values = row[0] except: pass finally: return values
def updateUserTotalShares(id_server=None, stock=None, id_user=None, shares=0): if id_server != None and stock != None and id_user != None: try: bknd_core.execute_sql_query( "REPLACE INTO shares({id_server}, {id_user}, {stock}, {shares}) VALUES(%s, %s, %s, %s)" .format(stock=ewcfg.col_stock, shares=ewcfg.col_shares, id_server=ewcfg.col_id_server, id_user=ewcfg.col_id_user), ( id_server, id_user, stock, shares, )) except: pass
async def kick(id_server): # Gets data for all living players from the database all_living_players = bknd_core.execute_sql_query("SELECT {poi}, {id_user} FROM users WHERE id_server = %s AND {life_state} > 0 AND {time_last_action} < %s".format( poi=ewcfg.col_poi, id_user=ewcfg.col_id_user, time_last_action=ewcfg.col_time_last_action, life_state=ewcfg.col_life_state ), ( id_server, (int(time.time()) - ewcfg.time_kickout) )) client = ewutils.get_client() for player in all_living_players: try: poi = poi_static.id_to_poi[player[0]] id_user = player[1] # checks if the player should be kicked from the subzone and kicks them if they should. if poi.is_subzone and poi.id_poi not in [ewcfg.poi_id_thesphere, ewcfg.poi_id_thebreakroom]: # Don't load the user until we know that we need to user_data = EwUser(id_user=id_user, id_server=id_server) # Some subzones could potentially have multiple mother districts. # Make sure to get one that's accessible before attempting a proper kickout. mother_district_chosen = random.choice(poi.mother_districts) if inaccessible(user_data=user_data, poi=poi_static.id_to_poi.get(mother_district_chosen)): # If the randomly chosen mother district is inaccessible, make one more attempt. mother_district_chosen = random.choice(poi.mother_districts) else: pass if not inaccessible(user_data=user_data, poi=poi_static.id_to_poi.get(mother_district_chosen)): if user_data.life_state not in [ewcfg.life_state_kingpin, ewcfg.life_state_lucky, ewcfg.life_state_executive] and user_data.id_user != 799933061080416266: server = ewcfg.server_list[id_server] member_object = server.get_member(id_user) user_data.poi = mother_district_chosen user_data.time_lastenter = int(time.time()) user_data.persist() await ewrolemgr.updateRoles(client=client, member=member_object) await user_data.move_inhabitants(id_poi=mother_district_chosen) mother_district_channel = fe_utils.get_channel(server, poi_static.id_to_poi[mother_district_chosen].channel) response = "You have been kicked out for loitering! You can only stay in a sub-zone and twiddle your thumbs for 1 hour at a time." await fe_utils.send_message(client, mother_district_channel, fe_utils.formatMessage(member_object, response)) except: ewutils.logMsg('failed to move inactive player out of subzone with poi {}: {}'.format(player[0], player[1]))
def get_transports_at_stop(id_server, stop): result = [] try: data = bknd_core.execute_sql_query( "SELECT {poi} FROM transports WHERE {id_server} = %s AND {current_stop} = %s" .format(poi=ewcfg.col_poi, id_server=ewcfg.col_id_server, current_stop=ewcfg.col_current_stop), (id_server, stop)) for row in data: result.append(row[0]) except: ewutils.logMsg( "Failed to retrieve transports at stop {}.".format(stop)) finally: return result
def dedorn_all_costumes(): costumes = bknd_core.execute_sql_query( "SELECT id_item FROM items_prop WHERE name = 'context' AND value = 'costume' AND id_item IN (SELECT id_item FROM items_prop WHERE (name = 'adorned' OR name = 'slimeoid') AND value = 'true')" ) costume_count = 0 for costume_id in costumes: costume_item = EwItem(id_item=costume_id) costume_item.item_props['adorned'] = 'false' costume_item.item_props['slimeoid'] = 'false' costume_item.persist() costume_count += 1 ewutils.logMsg( "Dedorned {} costumes after full moon ended.".format(costume_count))
async def negaslime(cmd): total = bknd_core.execute_sql_query( "SELECT SUM(slimes) FROM users WHERE slimes < 0 AND id_server = '{}'". format(cmd.guild.id)) total_negaslimes = total[0][0] if total_negaslimes: await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage( cmd.message.author, "The dead have amassed {:,} negative slime.".format( total_negaslimes))) else: await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage( cmd.message.author, "There is no negative slime in this world."))
def get_majority_shareholder(id_server=None, stock=None): result = None if id_server is not None and stock is not None: try: data = bknd_core.execute_sql_query( "SELECT {id_user}, {shares} FROM shares WHERE {id_server} = %s AND {stock} = %s ORDER BY {shares} DESC LIMIT 1" .format(stock=ewcfg.col_stock, shares=ewcfg.col_shares, id_server=ewcfg.col_id_server, id_user=ewcfg.col_id_user), ( id_server, stock, )) if len(data) > 0: if data[0][1] > 0: result = data[0][0] except: pass finally: return result
def get_random_prank_item(user_data, district_data): response = "" items_in_poi = bknd_core.execute_sql_query( "SELECT {id_item} FROM items WHERE {id_owner} = %s AND {id_server} = %s".format( id_item=ewcfg.col_id_item, id_owner=ewcfg.col_id_user, id_server=ewcfg.col_id_server ), ( user_data.poi, district_data.id_server )) prank_items = [] for item in items_in_poi: id_item = item[0] possible_prank_item = EwItem(id_item=id_item) context = possible_prank_item.item_props.get('context') food_item_id = possible_prank_item.item_props.get('id_food') if (context == ewcfg.context_prankitem or food_item_id == "defectivecreampie"): prank_items.append(id_item) if len(prank_items) > 0: id_item = random.choice(prank_items) prank_item = EwItem(id_item=id_item) item_name = prank_item.item_props.get('item_name') if item_name == None: item_name = prank_item.item_props.get('food_name') response = "\n\nYou think you can spot a {} lying on the ground somewhere...".format(item_name) return response
async def possess_fishing_rod(cmd): user_data = EwUser(member=cmd.message.author) response = "" if user_data.life_state != ewcfg.life_state_corpse: response = "You have no idea what you're doing." elif not user_data.get_inhabitee(): response = "You're not **{}**ing anyone right now.".format( ewcfg.cmd_inhabit) elif user_data.slimes >= ewcfg.slimes_to_possess_fishing_rod: response = "You'll have to become stronger before you can perform occult arts of this level." else: server = cmd.guild inhabitee_id = user_data.get_inhabitee() inhabitee_data = EwUser(id_user=inhabitee_id, id_server=user_data.id_server) inhabitee_member = server.get_member(inhabitee_id) inhabitee_name = inhabitee_member.display_name if inhabitee_data.get_possession(): response = "{} is already being possessed.".format(inhabitee_name) else: proposal_response = "You propose a trade to {}.\n" \ "You will possess their fishing rod to enhance it, making it more attractive to fish. In exchange, you will corrupt away all of the fish's slime, and absorb it as antislime.\n" \ "Both of you will need to reel the fish in together, and failing to do so will nullify this contract.\nWill they **{}** this exchange, or **{}** it?".format(inhabitee_name, ewcfg.cmd_accept, ewcfg.cmd_refuse) await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, proposal_response)) accepted = False try: msg = await cmd.client.wait_for( 'message', timeout=30, check=lambda message: message.author == inhabitee_member and message.content.lower( ) in [ewcfg.cmd_accept, ewcfg.cmd_refuse]) if msg != None: if msg.content.lower() == ewcfg.cmd_accept: accepted = True elif msg.content.lower() == ewcfg.cmd_refuse: accepted = False except: accepted = False if accepted: bknd_core.execute_sql_query( "UPDATE inhabitations SET {empowered} = %s WHERE {id_fleshling} = %s AND {id_ghost} = %s" .format( empowered=ewcfg.col_empowered, id_fleshling=ewcfg.col_id_fleshling, id_ghost=ewcfg.col_id_ghost, ), ( 'rod', inhabitee_id, user_data.id_user, )) user_data.change_slimes(n=-ewcfg.slimes_to_possess_fishing_rod, source=ewcfg.source_ghost_contract) user_data.persist() accepted_response = "You feel a metallic taste in your mouth as you sign {}'s spectral contract. Their ghastly arms superpose yours, enhancing your grip and causing shadowy tendrils to appear near your rod's hook.".format( cmd.message.author.display_name) await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(inhabitee_member, accepted_response)) else: response = "You should've known better, why would anyone ever trust you?" if response: return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def possess_weapon(cmd): user_data = EwUser(member=cmd.message.author) response = "" if user_data.life_state != ewcfg.life_state_corpse: response = "You have no idea what you're doing." elif not user_data.get_inhabitee(): response = "You're not **{}**ing anyone right now.".format( ewcfg.cmd_inhabit) elif user_data.slimes >= ewcfg.slimes_to_possess_weapon: response = "You'll have to become stronger before you can perform occult arts of this level." else: server = cmd.guild inhabitee_id = user_data.get_inhabitee() inhabitee_data = EwUser(id_user=inhabitee_id, id_server=user_data.id_server) inhabitee_member = server.get_member(inhabitee_id) inhabitee_name = inhabitee_member.display_name if inhabitee_data.weapon < 0: response = "{} is not wielding a weapon right now.".format( inhabitee_name) elif inhabitee_data.get_possession(): response = "{} is already being possessed.".format(inhabitee_name) else: proposal_response = "You propose a trade to {}.\n" \ "You will possess their weapon to empower it, and in return they'll sacrifice a fifth of their slime to your name upon their next kill.\n" \ "Will they **{}** this exchange, or **{}** it?".format(inhabitee_name, ewcfg.cmd_accept, ewcfg.cmd_refuse) await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, proposal_response)) accepted = False try: msg = await cmd.client.wait_for( 'message', timeout=30, check=lambda message: message.author == inhabitee_member and message.content.lower( ) in [ewcfg.cmd_accept, ewcfg.cmd_refuse]) if msg != None: if msg.content.lower() == ewcfg.cmd_accept: accepted = True elif msg.content.lower() == ewcfg.cmd_refuse: accepted = False except: accepted = False if accepted: bknd_core.execute_sql_query( "UPDATE inhabitations SET {empowered} = %s WHERE {id_fleshling} = %s AND {id_ghost} = %s" .format( empowered=ewcfg.col_empowered, id_fleshling=ewcfg.col_id_fleshling, id_ghost=ewcfg.col_id_ghost, ), ( 'weapon', inhabitee_id, user_data.id_user, )) user_data.change_slimes(n=-ewcfg.slimes_to_possess_weapon, source=ewcfg.source_ghost_contract) user_data.persist() accepted_response = "You feel a metallic taste in your mouth as you sign {}'s spectral contract. You see them bind themselves to your weapon, which now bears their mark. It feels cold to the touch.".format( cmd.message.author.display_name) await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(inhabitee_member, accepted_response)) else: response = "You should've known better, why would anyone ever trust you?" if response: return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
def update_hues(): for hue in hue_static.hue_list: hue_props = { ewcfg.col_hue_analogous_1: '', ewcfg.col_hue_analogous_2: '', ewcfg.col_hue_splitcomp_1: '', ewcfg.col_hue_splitcomp_2: '', ewcfg.col_hue_fullcomp_1: '', ewcfg.col_hue_fullcomp_2: '', } for h in hue.effectiveness: effect = hue.effectiveness.get(h) if effect == ewcfg.hue_analogous: if hue_props.get(ewcfg.col_hue_analogous_1) == '': hue_props[ewcfg.col_hue_analogous_1] = h elif hue_props.get(ewcfg.col_hue_analogous_2) == '': hue_props[ewcfg.col_hue_analogous_2] = h elif effect == ewcfg.hue_atk_complementary: if hue_props.get(ewcfg.col_hue_splitcomp_1) == '': hue_props[ewcfg.col_hue_splitcomp_1] = h elif effect == ewcfg.hue_special_complementary: if hue_props.get(ewcfg.col_hue_splitcomp_2) == '': hue_props[ewcfg.col_hue_splitcomp_2] = h elif effect == ewcfg.hue_full_complementary: if hue_props.get(ewcfg.col_hue_fullcomp_1) == '': hue_props[ewcfg.col_hue_fullcomp_1] = h elif hue_props.get(ewcfg.col_hue_fullcomp_2) == '': hue_props[ewcfg.col_hue_fullcomp_2] = h bknd_core.execute_sql_query( "REPLACE INTO hues ({}, {}, {}, {}, {}, {}, {}, {}) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)" .format( ewcfg.col_id_hue, ewcfg.col_is_neutral, ewcfg.col_hue_analogous_1, ewcfg.col_hue_analogous_2, ewcfg.col_hue_splitcomp_1, ewcfg.col_hue_splitcomp_2, ewcfg.col_hue_fullcomp_1, ewcfg.col_hue_fullcomp_2, ), ( hue.id_hue, 1 if hue.is_neutral else 0, hue_props.get(ewcfg.col_hue_analogous_1), hue_props.get(ewcfg.col_hue_analogous_2), hue_props.get(ewcfg.col_hue_splitcomp_1), hue_props.get(ewcfg.col_hue_splitcomp_2), hue_props.get(ewcfg.col_hue_fullcomp_1), hue_props.get(ewcfg.col_hue_fullcomp_2), ))
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 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 fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.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 fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.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 fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.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 fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) elif cmd.tokens[1] == "all": finalprice = 0 for mutation in mutations: finalprice += static_mutations.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 fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) else: response = "\"Sure you got the slime for that, whelp? It's {:,}.\"\n**Accept** or **refuse?**".format(finalprice) await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.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 = static_mutations.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: bknd_core.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 fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.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 fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.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 fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) elif static_mutations.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(static_mutations.mutations_map.get(target).tier * 5000) return await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.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 fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) else: price = static_mutations.mutations_map.get(target).tier * 5000 user_data.change_slimes(n=-price, source=ewcfg.source_spending) user_data.persist() try: bknd_core.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( static_mutations.mutations_map.get(target).str_name, user_data.get_mutation_level(), min(user_data.slimelevel, 50)) await fe_utils.send_message(cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))