async def eat_item(cmd): user_data = EwUser(member=cmd.message.author) mutations = user_data.get_mutations() item_search = ewutils.flattenTokenListToString(cmd.tokens[1:]) food_item = None # look for a food item if a name was given if item_search: item_sought = ewitem.find_item(item_search=item_search, id_user=user_data.id_user, id_server=user_data.id_server, item_type_filter=ewcfg.it_food) if item_sought: food_item = EwItem(id_item=item_sought.get('id_item')) else: item_sought = ewitem.find_item(item_search=item_search, id_user=user_data.id_user, id_server=user_data.id_server) if item_sought and ewcfg.mutation_id_trashmouth in mutations: return await devour(cmd=cmd) # otherwise find the first useable food else: food_inv = ewitem.inventory(id_user=user_data.id_user, id_server=user_data.id_server, item_type_filter=ewcfg.it_food) for food in food_inv: food_item = EwItem(id_item=food.get('id_item')) # check if the user can eat this item if float(getattr(food_item, "time_expir", 0)) > time.time() or \ food_item.item_props.get('perishable') not in ['true', '1'] or \ ewcfg.mutation_id_spoiledappetite in user_data.get_mutations(): break if food_item != None: response = user_data.eat(food_item) user_data.persist() else: if item_search: response = "Are you sure you have that item?" else: response = "You don't have anything to eat." await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def flutter(cmd): user_data = EwUser(member = cmd.message.author) if user_data.race == ewcfg.races["avian"]: district_data = EwDistrict(district = user_data.poi, id_server = cmd.guild.id) market_data = EwMarket(id_server=cmd.guild.id) response = "You flap your wings in an attempt to fly, but " excuses = [] if market_data.weather == ewcfg.weather_lightning: excuses.append("the current weather would make that a bit dangerous, so you decide not to.") if ewcfg.mutation_id_bigbones in user_data.get_mutations(): excuses.append("your bones are too big for you to get off the ground.") if ewcfg.mutation_id_lightasafeather in user_data.get_mutations(): excuses.append("your wings are too skinny to generate enough lift.") if 6 <= market_data.clock >= 20: excuses.append("it's not safe to fly at night, so you decide not to.") else: excuses.append("flying in plain daylight might get you shot off the sky, so you decide not to.") if user_data.slimes > 1000000: excuses.append("you have too much slime on you, so you don't even get off the ground.") else: excuses.append("you're too weak for this right now, gonna need to get more slime.") if user_data.life_state == ewcfg.life_state_corpse: excuses.append("your incorporeal wings generate no lift.") elif user_data.life_state == ewcfg.life_state_juvenile: excuses.append("you lack the moral fiber to do so.") else: if user_data.faction == ewcfg.faction_boober: excuses.append("you end up thrashing with your wings in an unorganized fashion.") if user_data.faction == ewcfg.faction_milkers: excuses.append("you end up doing rapid dabs instead.") if len(district_data.get_players_in_district()) > 1: excuses.append("it's embarassing to do so with other people around.") else: excuses.append("you can't be bothered if there's no one here to see you do it.") if user_data.hunger / user_data.get_hunger_max() < 0.5: excuses.append("you're too hungry, and end up looking for worms instead.") else: excuses.append("you're too full from your last meal for such vigorous exercise.") response += random.choice(excuses) else: response = "You people are not allowed to do that." return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def clear_mutations(cmd): user_data = EwUser(member = cmd.message.author) market_data = EwMarket(id_server = user_data.id_server) response = "" if cmd.message.channel.name != ewcfg.channel_slimeoidlab: response = "You require the advanced equipment at the Slimeoid Lab to modify your mutations." return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) if user_data.life_state == ewcfg.life_state_corpse: response = "How do you expect to mutate without exposure to slime, dumbass?" return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) mutations = user_data.get_mutations() if len(mutations) == 0: response = "You have not developed any specialized mutations yet." return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) poudrin = ewitem.find_item(item_search = "slimepoudrin", id_user = cmd.message.author.id, id_server = cmd.message.server.id if cmd.message.server is not None else None, item_type_filter = ewcfg.it_item) if poudrin == None: response = "You need a slime poudrin to replace a mutation." return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) else: ewitem.item_delete(id_item = poudrin.get('id_item')) # Remove Poudrins market_data.donated_poudrins += 1 market_data.persist() user_data.poudrin_donations += 1 user_data.persist() user_data.clear_mutations() response = "After several minutes long elevator descents, in the depths of some basement level far below the laboratory's lobby, you lay down on a reclined medical chair. A SlimeCorp employee finishes the novel length terms of service they were reciting and asks you if you have any questions. You weren’t listening so you just tell them to get on with it so you can go back to getting slime. They oblige.\nThey grab a random used syringe with just a dash of black serum still left inside it. They carefully stab you with it, injecting the mystery formula into your bloodstream. Almost immediately, normalcy returns to your inherently abnormal life… your body returns to whatever might be considered normal for your species. You hand off one of your hard-earned poudrins to the SlimeCorp employee for their troubles." return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def track_oneeyeopen(cmd): user_data = EwUser(id_user=cmd.message.author.id, id_server=cmd.message.guild.id) if cmd.mentions_count > 0: target_data = EwUser(member=cmd.mentions[0]) mutations = user_data.get_mutations() if ewcfg.mutation_id_oneeyeopen not in mutations: response = "No can do. Your third eye is feeling pretty flaccid today." elif cmd.mentions_count == 0: response = "Who are you tracking?" elif cmd.mentions_count > 1: response = "Nice try, but you're not the NSA. Limit your espionage to one poor sap." elif cmd.mentions[0] == cmd.message.author: response = "You set your third eye to track yourself. However, you are too uncomfortable with your body to keep it there. Better try something else." else: response = "Your third eye slips out of your forehead and wanders its way to {}'s location. Just a matter of time...".format( cmd.mentions[0].display_name) mutation_data = EwMutation(id_user=user_data.id_user, id_server=user_data.id_server, id_mutation=ewcfg.mutation_id_oneeyeopen) mutation_data.data = target_data.id_user mutation_data.persist() return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def bleedout(cmd): user_data = EwUser(member=cmd.message.author) mutations = user_data.get_mutations() if ewcfg.mutation_id_bleedingheart not in mutations: response = "You don't have an open enough wound to just gush your blood everywhere." elif user_data.bleed_storage == 0: response = "There's nothing to bleed. Sounds like someone has a persecution complex..." elif user_data.bleed_storage > user_data.slimes: #don't think this is possible, but just in case response = "Wait, wouldn't that kill you? Better not." else: response = "You clutch your malformed heart and squeeze as hard as you can. The intense pain makes you fall to your knees, and your slime drops in spurts to the floor under you as you gasp desperately for relief. You have been bled dry." poi = ewcfg.id_to_poi.get(user_data.poi) district_data = EwDistrict(id_server=cmd.message.guild.id, district=poi.id_poi) user_data.change_slimes(n=-user_data.bleed_storage, source=ewcfg.source_bleeding) district_data.change_slimes(n=user_data.bleed_storage, source=ewcfg.source_bleeding) user_data.bleed_storage = 0 user_data.persist() district_data.persist() return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def reroll_last_mutation(cmd): last_mutation_counter = -1 last_mutation = "" user_data = EwUser(member = cmd.message.author) market_data = EwMarket(id_server = user_data.id_server) response = "" if cmd.message.channel.name != ewcfg.channel_slimeoidlab: response = "You require the advanced equipment at the Slimeoid Lab to modify your mutations." return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) if user_data.life_state == ewcfg.life_state_corpse: response = "How do you expect to mutate without exposure to slime, dumbass?" return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) mutations = user_data.get_mutations() if len(mutations) == 0: response = "You have not developed any specialized mutations yet." return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) for id_mutation in mutations: mutation_data = EwMutation(id_server = user_data.id_server, id_user = user_data.id_user, id_mutation = id_mutation) if mutation_data.mutation_counter > last_mutation_counter: last_mutation_counter = mutation_data.mutation_counter last_mutation = id_mutation reroll_fatigue = EwStatusEffect(id_status = ewcfg.status_rerollfatigue_id, user_data = user_data) poudrins_needed = 2 ** int(reroll_fatigue.value) poudrins = ewitem.find_item_all(item_search = ewcfg.item_id_slimepoudrin, 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_item) poudrins_have = len(poudrins) if poudrins_have < poudrins_needed: response = "You need {} slime poudrin{} to replace a mutation, but you only have {}.".format(poudrins_needed, "" if poudrins_needed == 1 else "s", poudrins_have) return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) else: for delete in range(poudrins_needed): ewitem.item_delete(id_item = poudrins.pop(0).get('id_item')) # Remove Poudrins market_data.donated_poudrins += poudrins_needed market_data.persist() user_data.poudrin_donations += poudrins_needed user_data.persist() reroll_fatigue.value = int(reroll_fatigue.value) + 1 reroll_fatigue.persist() mutation_data = EwMutation(id_server = user_data.id_server, id_user = user_data.id_user, id_mutation = last_mutation) new_mutation = random.choice(list(ewcfg.mutation_ids)) while new_mutation in mutations: new_mutation = random.choice(list(ewcfg.mutation_ids)) mutation_data.id_mutation = new_mutation mutation_data.time_lastuse = int(time.time()) mutation_data.persist() response = "After several minutes long elevator descents, in the depths of some basement level far below the laboratory's lobby, you lay down on a reclined medical chair. A SlimeCorp employee finishes the novel length terms of service they were reciting and asks you if you have any questions. You weren’t listening so you just tell them to get on with it so you can go back to getting slime. They oblige.\nThey grab a butterfly needle and carefully stab you with it, draining some strangely colored slime from your bloodstream. Almost immediately, the effects of your last mutation fade away… but, this feeling of respite is fleeting. The SlimeCorp employee writes down a few notes, files away the freshly drawn sample, and soon enough you are stabbed with syringes. This time, it’s already filled with some bizarre, multi-colored serum you’ve never seen before. The effects are instantaneous. {}\nYou hand off {} of your hard-earned poudrins to the SlimeCorp employee for their troubles.".format(ewcfg.mutations_map[new_mutation].str_acquire, poudrins_needed) return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def check_farm(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)) response = "" levelup_response = "" mutations = user_data.get_mutations() # Checking availability of check farm 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 = "Do you remember planting anything here in this barren wasteland? No, you don’t. Idiot." else: poi = ewcfg.id_to_poi.get(user_data.poi) district_data = EwDistrict(district = poi.id_poi, id_server = user_data.id_server) if district_data.is_degraded(): response = "{} has been degraded by shamblers. You can't {} here anymore.".format(poi.str_name, cmd.tokens[0]) return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) if user_data.poi == ewcfg.poi_id_jr_farms: farm_id = ewcfg.poi_id_jr_farms elif user_data.poi == ewcfg.poi_id_og_farms: farm_id = ewcfg.poi_id_og_farms else: # if it's the farm in arsonbrook farm_id = ewcfg.poi_id_ab_farms farm = EwFarm( id_server = cmd.guild.id, id_user = cmd.message.author.id, farm = farm_id ) if farm.time_lastsow == 0: response = "You missed a step, you haven’t planted anything here yet." elif farm.action_required == ewcfg.farm_action_none: if farm.phase == ewcfg.farm_phase_reap: response = "Your crop is ready for the harvest." elif farm.phase == ewcfg.farm_phase_sow: response = "You only just planted the seeds. Check back later." else: if farm.slimes_onreap < ewcfg.reap_gain: response = "Your crop looks frail and weak." elif farm.slimes_onreap < ewcfg.reap_gain + 3 * ewcfg.farm_slimes_peraction: response = "Your crop looks small and generally unremarkable." elif farm.slimes_onreap < ewcfg.reap_gain + 6 * ewcfg.farm_slimes_peraction: response = "Your crop seems to be growing well." else: response = "Your crop looks powerful and bursting with nutrients." else: farm_action = ewcfg.id_to_farm_action.get(farm.action_required) response = farm_action.str_check await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def cultivate(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)) response = "" levelup_response = "" mutations = user_data.get_mutations() # Checking availability of irrigate action if user_data.life_state != ewcfg.life_state_juvenile: response = "Only Juveniles of pure heart and with nothing better to do can tend to their crops." elif cmd.message.channel.name not in [ewcfg.channel_jr_farms, ewcfg.channel_og_farms, ewcfg.channel_ab_farms]: response = "Do you remember planting anything here in this barren wasteland? No, you don’t. Idiot." else: poi = ewcfg.id_to_poi.get(user_data.poi) district_data = EwDistrict(district = poi.id_poi, id_server = user_data.id_server) if district_data.is_degraded(): response = "{} has been degraded by shamblers. You can't {} here anymore.".format(poi.str_name, cmd.tokens[0]) return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) if user_data.poi == ewcfg.poi_id_jr_farms: farm_id = ewcfg.poi_id_jr_farms elif user_data.poi == ewcfg.poi_id_og_farms: farm_id = ewcfg.poi_id_og_farms else: # if it's the farm in arsonbrook farm_id = ewcfg.poi_id_ab_farms farm = EwFarm( id_server = cmd.guild.id, id_user = cmd.message.author.id, farm = farm_id ) farm_action = ewcfg.cmd_to_farm_action.get(cmd.tokens[0].lower()) if farm.time_lastsow == 0: response = "You missed a step, you haven’t planted anything here yet." elif farm.action_required != farm_action.id_action: response = farm_action.str_execute_fail farm.slimes_onreap -= ewcfg.farm_slimes_peraction farm.slimes_onreap = max(farm.slimes_onreap, 0) farm.persist() else: response = farm_action.str_execute # gvs - farm actions award more slime farm.slimes_onreap += ewcfg.farm_slimes_peraction * 2 farm.action_required = ewcfg.farm_action_none farm.persist() await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def waft(cmd): user_data = EwUser(member=cmd.message.author) mutations = user_data.get_mutations() if ewcfg.mutation_id_aposematicstench not in mutations: response = "You stink, but not that badly. Get Aposematic Stench before you try that." else: user_data.applyStatus(ewcfg.status_repelled_id) response = "You clench as hard as you can, and your pores excrete a mushroom cloud of pure, olive green musk. It's so caustic you might not have eyebrows anymore. You should be immune from monsters, though!" return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def piss(cmd): user_data = EwUser(member=cmd.message.author) mutations = user_data.get_mutations() if ewcfg.mutation_id_enlargedbladder in mutations: response = "You unzip your dick and just start pissing all over the goddamn f*****g floor. God, you’ve waited so long for this moment, and it’s just as perfect as you could have possibly imagined. You love pissing so much." else: response = "You lack the moral fiber necessary for urination." await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def fursuit(cmd): user_data = EwUser(member=cmd.message.author) mutations = user_data.get_mutations() market_data = EwMarket(id_server=cmd.message.server.id) if ewcfg.mutation_id_organicfursuit in mutations: days_until = -market_data.day % 31 response = "With a basic hairy palm reading, you determine that you'll be particularly powerful in {} day{}.".format( days_until, "s" if days_until is not 1 else "") else: response = "You're about as hairless as an egg, my friend." await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def cultivate(cmd): user_data = EwUser(member=cmd.message.author) response = "" levelup_response = "" mutations = user_data.get_mutations() # Checking availability of irrigate 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 = "Do you remember planting anything here in this barren wasteland? No, you don’t. Idiot." else: 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) farm_action = ewcfg.cmd_to_farm_action.get(cmd.tokens[0].lower()) if farm.time_lastsow == 0: response = "You missed a step, you haven’t planted anything here yet." elif farm.action_required != farm_action.id_action: response = farm_action.str_execute_fail farm.slimes_onreap -= ewcfg.farm_slimes_peraction farm.slimes_onreap = max(farm.slimes_onreap, 0) farm.persist() else: response = farm_action.str_execute farm.slimes_onreap += ewcfg.farm_slimes_peraction farm.action_required = ewcfg.farm_action_none farm.persist() await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def disembark(cmd): # can only use movement commands in location channels 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]))) user_data = EwUser(member = cmd.message.author) response = "" resp_cont = ewutils.EwResponseContainer(client = cmd.client, id_server = user_data.id_server) # prevent ghosts currently inhabiting other players from moving on their own if user_data.get_inhabitee(): response = "You might want to **{}** of the poor soul you've been tormenting first.".format(ewcfg.cmd_letgo) return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) # can only disembark when you're on a transport vehicle elif user_data.poi in ewcfg.transports: transport_data = EwTransport(id_server = user_data.id_server, poi = user_data.poi) response = "{}ing.".format(cmd.tokens[0][1:].lower()).capitalize() stop_poi = ewcfg.id_to_poi.get(transport_data.current_stop) # if stop_poi.is_subzone: # stop_poi = ewcfg.id_to_poi.get(stop_poi.mother_district) if ewmap.inaccessible(user_data = user_data, poi = stop_poi): return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, "You're not allowed to go there (bitch).")) # 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]: return user_data = EwUser(member = cmd.message.author) transport_data = EwTransport(id_server = user_data.id_server, poi = transport_data.poi) # cancel move, if the user has left the transport while waiting for movement to be completed (e.g. by dying) if user_data.poi != transport_data.poi: return stop_poi = ewcfg.id_to_poi.get(transport_data.current_stop) # juvies can't swim if transport_data.current_stop == ewcfg.poi_id_slimesea and user_data.life_state != ewcfg.life_state_corpse: if user_data.life_state == ewcfg.life_state_kingpin: response = "You try to heave yourself over the railing as you're hit by a sudden case of sea sickness. You puke into the sea and sink back on deck." response = ewutils.formatMessage(cmd.message.author, response) return await ewutils.send_message(cmd.client, cmd.message.channel, response) user_data.poi = ewcfg.poi_id_slimesea user_data.trauma = ewcfg.trauma_id_environment die_resp = user_data.die(cause = ewcfg.cause_drowning) user_data.persist() resp_cont.add_response_container(die_resp) response = "{} jumps over the railing of the ferry and promptly drowns in the slime sea.".format(cmd.message.author.display_name) resp_cont.add_channel_response(channel = ewcfg.channel_slimesea, response = response) resp_cont.add_channel_response(channel = ewcfg.channel_ferry, response = response) await ewrolemgr.updateRoles(client = cmd.client, member = cmd.message.author) # they also can't fly elif transport_data.transport_type == ewcfg.transport_type_blimp and not stop_poi.is_transport_stop and user_data.life_state != ewcfg.life_state_corpse: user_mutations = user_data.get_mutations() if user_data.life_state == ewcfg.life_state_kingpin: response = "Your life flashes before your eyes, as you plummet towards your certain death. A lifetime spent being a piece of shit and playing videogames all day. You close your eyes and... BOING! You open your eyes again to see a crew of workers transporting the trampoline that broke your fall. You get up and dust yourself off, sighing heavily." response = ewutils.formatMessage(cmd.message.author, response) resp_cont.add_channel_response(channel = stop_poi.channel, response = response) user_data.poi = stop_poi.id_poi user_data.persist() await ewrolemgr.updateRoles(client = cmd.client, member = cmd.message.author) return await resp_cont.post() elif ewcfg.mutation_id_lightasafeather in user_mutations: response = "With a running jump you launch yourself out of the blimp and begin falling to your soon-to-be demise... but then a strong updraft breaks your fall and you land unscathed. " response = ewutils.formatMessage(cmd.message.author, response) resp_cont.add_channel_response(channel = stop_poi.channel, response = response) user_data.poi = stop_poi.id_poi user_data.persist() await user_data.move_inhabitants(id_poi = stop_poi.id_poi) await ewrolemgr.updateRoles(client = cmd.client, member = cmd.message.author) return await resp_cont.post() district_data = EwDistrict(id_server = user_data.id_server, district = stop_poi.id_poi) district_data.change_slimes(n = user_data.slimes) district_data.persist() user_data.poi = stop_poi.id_poi user_data.trauma = ewcfg.trauma_id_environment die_resp = user_data.die(cause = ewcfg.cause_falling) user_data.persist() resp_cont.add_response_container(die_resp) response = "SPLAT! A body collides with the asphalt with such force, that it is utterly annihilated, covering bystanders in blood and slime and guts." resp_cont.add_channel_response(channel = stop_poi.channel, response = response) await ewrolemgr.updateRoles(client = cmd.client, member = cmd.message.author) # update user location, if move successful else: # if stop_poi.is_subzone: # stop_poi = ewcfg.id_to_poi.get(stop_poi.mother_district) if ewmap.inaccessible(user_data = user_data, poi = stop_poi): return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, "You're not allowed to go there (bitch).")) user_data.poi = stop_poi.id_poi user_data.persist() await user_data.move_inhabitants(id_poi = stop_poi.id_poi) response = "You enter {}".format(stop_poi.str_name) await ewrolemgr.updateRoles(client = cmd.client, member = cmd.message.author) await ewutils.send_message(cmd.client, ewutils.get_channel(cmd.guild, stop_poi.channel), ewutils.formatMessage(cmd.message.author, response)) # SWILLDERMUK await ewutils.activate_trap_items(stop_poi.id_poi, user_data.id_server, user_data.id_user) return return await resp_cont.post() else: response = "You are not currently riding any transport." return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
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))
async def haunt(cmd): time_now = int(time.time()) response = "" resp_cont = ewutils.EwResponseContainer(id_server = cmd.guild.id) if cmd.mentions_count > 1: response = "You can only spook one person at a time. Who do you think you are, the Lord of Ghosts?" else: haunted_data = None member = None if cmd.mentions_count == 0 and cmd.tokens_count > 1: server = cmd.guild member = server.get_member(ewutils.getIntToken(cmd.tokens)) haunted_data = EwUser(member = member) elif cmd.mentions_count == 1: member = cmd.mentions[0] haunted_data = EwUser(member = member) if member: # Get the user and target data from the database. user_data = EwUser(member = cmd.message.author) market_data = EwMarket(id_server = cmd.guild.id) target_mutations = haunted_data.get_mutations() target_poi = ewcfg.id_to_poi.get(haunted_data.poi) target_is_shambler = haunted_data.life_state == ewcfg.life_state_shambler target_is_inhabitted = haunted_data.id_user == user_data.get_inhabitee() if user_data.life_state != ewcfg.life_state_corpse: # Only dead players can haunt. response = "You can't haunt now. Try {}.".format(ewcfg.cmd_suicide) elif haunted_data.life_state == ewcfg.life_state_kingpin: # Disallow haunting of generals. response = "He is too far from the sewers in his ivory tower, and thus cannot be haunted." elif (time_now - user_data.time_lasthaunt) < ewcfg.cd_haunt: # Disallow haunting if the user has haunted too recently. response = "You're being a little TOO spooky lately, don't you think? Try again in {} seconds.".format(int(ewcfg.cd_haunt-(time_now-user_data.time_lasthaunt))) elif ewutils.channel_name_is_poi(cmd.message.channel.name) == False: response = "You can't commit violence from here." elif target_poi.pvp == False: #Require the target to be in a PvP area, and flagged if it's a remote haunt response = "{} is not mired in the ENDLESS WAR right now.".format(member.display_name) elif haunted_data.life_state == ewcfg.life_state_corpse: # Dead players can't be haunted. response = "{} is already dead.".format(member.display_name) elif haunted_data.life_state == ewcfg.life_state_grandfoe: # Grand foes can't be haunted. response = "{} is invulnerable to ghosts.".format(member.display_name) elif haunted_data.life_state == ewcfg.life_state_enlisted or haunted_data.life_state == ewcfg.life_state_juvenile or haunted_data.life_state == ewcfg.life_state_shambler: haunt_power_multiplier = 1 # power to the ancients ghost_age = time_now - user_data.time_lastdeath if ghost_age > 60 * 60 * 24 * 7: # dead for longer than if ghost_age > 60 * 60 * 24 * 365: # one friggin year haunt_power_multiplier *= 2.5 if ghost_age > 60 * 60 * 24 * 90: # three months haunt_power_multiplier *= 2 elif ghost_age > 60 * 60 * 24 * 30: # one month haunt_power_multiplier *= 1.5 else: # one week haunt_power_multiplier *= 1.25 # vitriol as virtue list_ids = [] for quadrant in ewcfg.quadrant_ids: quadrant_data = ewquadrants.EwQuadrant(id_server=cmd.guild.id, id_user=cmd.message.author.id, quadrant=quadrant) if quadrant_data.id_target != -1 and quadrant_data.check_if_onesided() is False: list_ids.append(quadrant_data.id_target) if quadrant_data.id_target2 != -1 and quadrant_data.check_if_onesided() is False: list_ids.append(quadrant_data.id_target2) if haunted_data.id_user in list_ids: # any mutual quadrants haunt_power_multiplier *= 1.2 if haunted_data.faction and ((not user_data.faction) or (user_data.faction != haunted_data.faction)): # opposite faction (or no faction at all) haunt_power_multiplier *= 1.2 if user_data.id_killer == haunted_data.id_user: # haunting your murderer/buster haunt_power_multiplier *= 1.2 # places of power. if haunted_data.poi in [ewcfg.poi_id_thevoid, ewcfg.poi_id_wafflehouse, ewcfg.poi_id_blackpond]: haunt_power_multiplier *= 2 elif haunted_data.poi in ewmap.get_void_connection_pois(cmd.guild.id): haunt_power_multiplier *= 1.25 # glory to the vanquished target_kills = ewstats.get_stat(user = haunted_data, metric = ewcfg.stat_kills) if target_kills > 5: haunt_power_multiplier *= 1.25 + ((target_kills - 5) / 100) # 1% per kill after 5 else: haunt_power_multiplier *= 1 + (target_kills * 5 / 100) # 5% per kill if time_now - haunted_data.time_lastkill < (60 * 15): haunt_power_multiplier *= 1.5 # wet hands # misc if ewcfg.weather_map.get(market_data.weather) == ewcfg.weather_foggy: haunt_power_multiplier *= 1.1 if not haunted_data.has_soul: haunt_power_multiplier *= 1.2 # uncomment this after moon mechanics update # if (market_data.day % 31 == 15 and market_data.clock >= 20) or (market_data.day % 31 == 16 and market_data.clock <= 6): # haunt_power_multiplier *= 2 # divide haunt power by 2 if not in same area if user_data.poi != haunted_data.poi: haunt_power_multiplier /= 2 # Double Halloween #haunt_power_multiplier *= 4 haunted_slimes = int((haunted_data.slimes / ewcfg.slimes_hauntratio) * haunt_power_multiplier) slimes_lost = int(haunted_slimes / 5) # hauntee only loses 1/5th of what the ghost gets as antislime if ewcfg.mutation_id_coleblooded in target_mutations: haunted_slimes = -10000 if user_data.slimes > haunted_slimes: haunted_slimes = user_data.slimes haunted_data.change_slimes(n = -slimes_lost, source = ewcfg.source_haunted) user_data.change_slimes(n = -haunted_slimes, source = ewcfg.source_haunter) market_data.negaslime -= haunted_slimes user_data.time_lasthaunt = time_now user_data.busted = False resp_cont.add_member_to_update(cmd.message.author) # Persist changes to the database. user_data.persist() haunted_data.persist() market_data.persist() response = "{} has been haunted by the ghost of {}! Slime has been lost! {} antislime congeals within you.".format(member.display_name, cmd.message.author.display_name, haunted_slimes) if ewcfg.mutation_id_coleblooded in target_mutations: response = "{} has been haunted by the ghost of {}! Their exorcising coleslaw blood purges {} antislime from your being! Better not do that again.".format(member.display_name, cmd.message.author.display_name, -haunted_slimes) haunted_channel = ewcfg.id_to_poi.get(haunted_data.poi).channel haunt_message = "You feel a cold shiver run down your spine" if cmd.tokens_count > 2: haunt_message_content = re.sub("<.+>" if cmd.mentions_count == 1 else "\d{17,}", "", cmd.message.content[(len(cmd.tokens[0])):]).strip() # Cut down really big messages so discord doesn't crash if len(haunt_message_content) > 500: haunt_message_content = haunt_message_content[:-500] haunt_message += " and faintly hear the words \"{}\"".format(haunt_message_content) haunt_message += ". {} slime evaporates from your body.".format(slimes_lost) if ewcfg.mutation_id_coleblooded in target_mutations: haunt_message += " The ghost that did it wails in agony as their ectoplasm boils in your coleslaw blood!" haunt_message = ewutils.formatMessage(member, haunt_message) resp_cont.add_channel_response(haunted_channel, haunt_message) else: # No mentions, or mentions we didn't understand. response = "Your spookiness is appreciated, but ENDLESS WAR didn\'t understand that name." # Send the response to the player. resp_cont.add_channel_response(cmd.message.channel.name, response) await resp_cont.post()
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))
async def reap(cmd): user_data = EwUser(member = cmd.message.author) if user_data.life_state == ewcfg.life_state_shambler: response = "You lack the higher brain functions required to {}.".format(cmd.tokens[0]) return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) forcereap = False if cmd.tokens[0] == ewcfg.cmd_reap_alt: if cmd.message.author.guild_permissions.administrator: forcereap = True else: return response = "" levelup_response = "" mutations = user_data.get_mutations() cosmetic_abilites = ewutils.get_cosmetic_abilities(id_user = cmd.message.author.id, id_server = cmd.guild.id) poi = ewcfg.id_to_poi.get(user_data.poi) # check if the user has a farming tool equipped weapon_item = EwItem(id_item=user_data.weapon) weapon = ewcfg.weapon_map.get(weapon_item.item_props.get("weapon_type")) has_tool = False if weapon is not None: if ewcfg.weapon_class_farming in weapon.classes: has_tool = True # Checking availability of reap action if user_data.life_state != ewcfg.life_state_juvenile and not has_tool: response = "Only Juveniles of pure heart and with nothing better to do can farm." elif cmd.message.channel.name not in [ewcfg.channel_jr_farms, ewcfg.channel_og_farms, ewcfg.channel_ab_farms]: response = "Do you remember planting anything here in this barren wasteland? No, you don’t. Idiot." else: poi = ewcfg.id_to_poi.get(user_data.poi) district_data = EwDistrict(district = poi.id_poi, id_server = user_data.id_server) if district_data.is_degraded(): response = "{} has been degraded by shamblers. You can't {} here anymore.".format(poi.str_name, cmd.tokens[0]) return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) if user_data.poi == ewcfg.poi_id_jr_farms: farm_id = ewcfg.poi_id_jr_farms elif user_data.poi == ewcfg.poi_id_og_farms: farm_id = ewcfg.poi_id_og_farms else: # if it's the farm in arsonbrook farm_id = ewcfg.poi_id_ab_farms farm = EwFarm( id_server = cmd.guild.id, id_user = cmd.message.author.id, farm = farm_id ) if farm.time_lastsow == 0: response = "You missed a step, you haven’t planted anything here yet." else: cur_time_min = time.time() / 60 time_grown = cur_time_min - farm.time_lastsow if farm.phase != ewcfg.farm_phase_reap and not forcereap: response = "Patience is a virtue and you are morally bankrupt. Just wait, asshole." else: # Reaping if (time_grown > ewcfg.crops_time_to_grow * 16) and not forcereap: # about 2 days response = "You eagerly cultivate your crop, but what’s this? It’s dead and wilted! It seems as though you’ve let it lay fallow for far too long. Pay better attention to your farm next time. You gain no slime." farm.time_lastsow = 0 # 0 means no seeds are currently planted farm.persist() else: user_initial_level = user_data.slimelevel slime_gain = farm.slimes_onreap controlling_faction = ewutils.get_subzone_controlling_faction(user_data.poi, user_data.id_server) if controlling_faction != "" and controlling_faction == user_data.faction: slime_gain *= 2 if has_tool and weapon.id_weapon == ewcfg.weapon_id_hoe: slime_gain *= 1.5 if ewcfg.mutation_id_greenfingers in mutations: slime_gain *= 1.2 if user_data.poi == ewcfg.poi_id_jr_farms: slime_gain = int(slime_gain / 4) #trauma = ewcfg.trauma_map.get(user_data.trauma) #if trauma != None and trauma.trauma_class == ewcfg.trauma_class_slimegain: # slime_gain *= (1 - 0.5 * user_data.degradation / 100) slime_gain = max(0, round(slime_gain)) response = "You reap what you’ve sown. Your investment has yielded {:,} slime, ".format(slime_gain) # Determine if an item is found. unearthed_item = False unearthed_item_amount = 0 unearthed_item_chance = 50 / ewcfg.unearthed_item_rarity # 1 in 30 chance if ewcfg.mutation_id_lucky in mutations or ewcfg.cosmeticAbility_id_lucky in cosmetic_abilites: unearthed_item_chance *= 1.33 if random.random() < unearthed_item_chance: unearthed_item = True unearthed_item_amount = 1 if random.randint(1, 3) != 1 else 2 # 33% chance of extra drop if unearthed_item == True: # If there are multiple possible products, randomly select one. item = random.choice(ewcfg.mine_results) item_props = ewitem.gen_item_props(item) if item is not None: for creation in range(unearthed_item_amount): ewitem.item_create( item_type = item.item_type, id_user = cmd.message.author.id, id_server = cmd.guild.id, item_props = item_props ) if unearthed_item_amount == 1: response += "a {}, ".format(item.str_name) elif unearthed_item_amount == 2: response += "two {}s, ".format(item.str_name) # Determine what crop is grown. vegetable = ewcfg.food_map.get(farm.crop) if vegetable is None: vegetable = random.choice(ewcfg.vegetable_list) item_props = ewitem.gen_item_props(vegetable) # Create and give a bushel of whatever crop was grown, unless it's a metal crop. if item_props.get('id_food') in [ewcfg.item_id_metallicaps, ewcfg.item_id_steelbeans, ewcfg.item_id_aushucks]: metallic_crop_ammount = 1 if random.randrange(10) == 0: metallic_crop_ammount = 5 if random.randrange(2) == 0 else 6 if has_tool and weapon.id_weapon == ewcfg.weapon_id_pitchfork: metallic_crop_ammount *= 2 for vcreate in range(metallic_crop_ammount): ewitem.item_create( id_user=cmd.message.author.id, id_server=cmd.guild.id, item_type=vegetable.item_type, item_props=item_props ) if metallic_crop_ammount == 1: response += "and a single {}!".format(vegetable.str_name) else: response += "and a bushel or two of {}!".format(vegetable.str_name) # if random.randrange(10) == 0: # for vcreate in range(6): # ewitem.item_create( # id_user=cmd.message.author.id, # id_server=cmd.guild.id, # item_type=vegetable.item_type, # item_props=item_props # ) # # response += "and a bushel of {}!".format(vegetable.str_name) # else: # response += "and a bushel of... hey, what the hell! You didn't reap anything! Must've been some odd seeds..." else: unearthed_vegetable_amount = 3 if has_tool and weapon.id_weapon == ewcfg.weapon_id_pitchfork: unearthed_vegetable_amount *= 2 for vcreate in range(unearthed_vegetable_amount): ewitem.item_create( id_user = cmd.message.author.id, id_server = cmd.guild.id, item_type = vegetable.item_type, item_props = item_props ) response += "and a bushel of {}!".format(vegetable.str_name) levelup_response = user_data.change_slimes(n = slime_gain, source = ewcfg.source_farming) was_levelup = True if user_initial_level < user_data.slimelevel else False # Tell the player their slime level increased. if was_levelup: response += "\n\n" + levelup_response user_data.hunger += ewcfg.hunger_perfarm # Flag the user for PvP #enlisted = True if user_data.life_state == ewcfg.life_state_enlisted else False # user_data.time_expirpvp = ewutils.calculatePvpTimer(user_data.time_expirpvp, ewcfg.time_pvp_farm, enlisted) user_data.persist() farm.time_lastsow = 0 # 0 means no seeds are currently planted farm.persist() await ewrolemgr.updateRoles(client = cmd.client, member = cmd.message.author) await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def scavenge(cmd): market_data = EwMarket(id_server=cmd.message.author.server.id) user_data = EwUser(member=cmd.message.author) mutations = user_data.get_mutations() time_now = int(time.time()) response = "" time_since_last_scavenge = time_now - user_data.time_lastscavenge # Kingpins can't scavenge. if user_data.life_state == ewcfg.life_state_kingpin or user_data.life_state == ewcfg.life_state_grandfoe: return # ghosts cant scavenge if user_data.life_state == ewcfg.life_state_corpse: return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, "What would you want to do that for? You're a ghost, you have no need for such lowly materialistic possessions like slime. You only engage in intellectual pursuits now. {} if you want to give into your base human desire to see numbers go up." .format(ewcfg.cmd_revive))) # currently not active - no cooldown if time_since_last_scavenge < ewcfg.cd_scavenge: return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, "Slow down, you filthy hyena.")) # Scavenge only in location channels if ewmap.channel_name_is_poi(cmd.message.channel.name) == True: if user_data.hunger >= user_data.get_hunger_max(): return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, "You are too exhausted to scrounge up scraps of slime off the street! Go get some grub!" )) else: district_data = EwDistrict(district=user_data.poi, id_server=cmd.message.author.server.id) user_initial_level = user_data.slimelevel # add scavenged slime to user if ewcfg.mutation_id_trashmouth in mutations: time_since_last_scavenge *= 3 time_since_last_scavenge = min(max(1, time_since_last_scavenge), 30) scavenge_mod = 0.003 * (time_since_last_scavenge**0.9) if ewcfg.mutation_id_whitenationalist in mutations and market_data.weather == "snow": scavenge_mod *= 1.5 if ewcfg.mutation_id_webbedfeet in mutations: district_slimelevel = len(str(district_data.slimes)) scavenge_mod *= max(1, min(district_slimelevel - 3, 4)) scavenge_yield = math.floor(scavenge_mod * district_data.slimes) levelup_response = user_data.change_slimes( n=scavenge_yield, source=ewcfg.source_scavenging) district_data.change_slimes(n=-1 * scavenge_yield, source=ewcfg.source_scavenging) district_data.persist() if levelup_response != "": response += levelup_response + "\n\n" #response += "You scrape together {} slime from the streets.\n\n".format(scavenge_yield) if cmd.tokens_count > 1: item_search = ewutils.flattenTokenListToString(cmd.tokens[1:]) loot_resp = ewitem.item_lootspecific( id_server=user_data.id_server, id_user=user_data.id_user, item_search=item_search) response += loot_resp else: loot_multiplier = 1.0 + ewitem.get_inventory_size( owner=user_data.poi, id_server=user_data.id_server) loot_chance = loot_multiplier / ewcfg.scavenge_item_rarity if ewcfg.mutation_id_dumpsterdiver in mutations: loot_chance *= 10 if random.random() < loot_chance: loot_resp = ewitem.item_lootrandom( id_server=user_data.id_server, id_user=user_data.id_user) response += loot_resp # Fatigue the scavenger. hunger_cost_mod = ewutils.hunger_cost_mod(user_data.slimelevel) extra = hunger_cost_mod - int( hunger_cost_mod ) # extra is the fractional part of hunger_cost_mod user_data.hunger += ewcfg.hunger_perscavenge * int(hunger_cost_mod) if extra > 0: # if hunger_cost_mod is not an integer # there's an x% chance that an extra stamina is deducted, where x is the fractional part of hunger_cost_mod in percent (times 100) if random.randint(1, 100) <= extra * 100: user_data.hunger += ewcfg.hunger_perscavenge user_data.time_lastscavenge = time_now user_data.persist() if not response == "": await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) else: return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, "You'll find no slime here, this place has been picked clean. Head into the city to try and scavenge some slime." ))
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))
async def order(cmd): user_data = EwUser(member=cmd.message.author) mutations = user_data.get_mutations() if user_data.life_state == ewcfg.life_state_shambler and user_data.poi != ewcfg.poi_id_nuclear_beach_edge: response = "You lack the higher brain functions required to {}.".format( cmd.tokens[0]) return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) market_data = EwMarket(id_server=cmd.guild.id) currency_used = 'slime' current_currency_amount = user_data.slimes #poi = ewmap.fetch_poi_if_coordless(cmd.message.channel.name) poi = ewcfg.id_to_poi.get(user_data.poi) if poi is None or len(poi.vendors) == 0 or ewutils.channel_name_is_poi( cmd.message.channel.name) == False: # Only allowed in the food court. response = "There’s nothing to buy here. If you want to purchase some items, go to a sub-zone with a vendor in it, like the food court, the speakeasy, or the bazaar." else: poi = ewcfg.id_to_poi.get(user_data.poi) district_data = EwDistrict(district=poi.id_poi, id_server=user_data.id_server) shambler_multiplier = 1 #for speakeasy during shambler times if district_data.is_degraded( ) and poi.id_poi != ewcfg.poi_id_nuclear_beach_edge: if poi.id_poi == ewcfg.poi_id_speakeasy: shambler_multiplier = 4 else: response = "{} has been degraded by shamblers. You can't {} here anymore.".format( poi.str_name, cmd.tokens[0]) return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) #value = ewutils.flattenTokenListToString(cmd.tokens[1:2]) #if cmd.tokens_count > 1: # value = cmd.tokens[1] # value = value.lower() value = None togo = False if cmd.tokens_count > 1: for token in cmd.tokens[1:]: if token.startswith('<@') == False and token.lower( ) not in "togo": # togo can be spelled together or separate value = token break for token in cmd.tokens[1:]: if token.lower( ) in "togo": # lets people get away with just typing only to or only go (or only t etc.) but whatever togo = True break # Finds the item if it's an EwGeneralItem. if value == "mylittleponyfigurine": value = random.choice(ewcfg.furniture_pony) item = ewcfg.item_map.get(value) item_type = ewcfg.it_item if item != None: item_id = item.id_item name = item.str_name # Finds the item if it's an EwFood item. if item == None: item = ewcfg.food_map.get(value) item_type = ewcfg.it_food if item != None: item_id = item.id_food name = item.str_name # Finds the item if it's an EwCosmeticItem. if item == None: item = ewcfg.cosmetic_map.get(value) item_type = ewcfg.it_cosmetic if item != None: item_id = item.id_cosmetic name = item.str_name if item == None: item = ewcfg.furniture_map.get(value) item_type = ewcfg.it_furniture if item != None: item_id = item.id_furniture name = item.str_name if item_id in ewcfg.furniture_pony: item.vendors = [ewcfg.vendor_bazaar] if item == None: item = ewcfg.weapon_map.get(value) item_type = ewcfg.it_weapon if item != None: item_id = item.id_weapon name = item.str_weapon if item != None: item_type = item.item_type # Gets a vendor that the item is available and the player currently located in try: current_vendor = (set(item.vendors).intersection( set(poi.vendors))).pop() except: current_vendor = None # Check if the item is available in the current bazaar item rotation if current_vendor == ewcfg.vendor_bazaar: if item_id not in market_data.bazaar_wares.values(): if item_id in ewcfg.furniture_pony and "mylittleponyfigurine" in market_data.bazaar_wares.values( ): pass else: current_vendor = None if current_vendor == ewcfg.vendor_downpourlaboratory: currency_used = 'brainz' current_currency_amount = user_data.gvs_currency if current_vendor is None or len(current_vendor) < 1: response = "Check the {} for a list of items you can {}.".format( ewcfg.cmd_menu, ewcfg.cmd_order) else: response = "" value = item.price if random.randrange( 5 ) == 0 and ewcfg.mutation_id_stickyfingers in mutations: value = 0 premium_purchase = True if item_id in ewcfg.premium_items else False if premium_purchase: togo = True # Just in case they order a premium food item, don't make them eat it right then and there. if ewcfg.cd_premium_purchase > (int( time.time()) - user_data.time_lastpremiumpurchase): response = "That item is in very limited stock! The vendor asks that you refrain from purchasing it for a day or two." return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) elif ewcfg.cd_new_player > (int(time.time()) - user_data.time_joined): response = "You've only been in the city for a few days. The vendor doesn't trust you with that item very much..." return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) stock_data = None company_data = None # factor in the current stocks for vendor in item.vendors: if vendor in ewcfg.vendor_stock_map: stock = ewcfg.vendor_stock_map.get(vendor) company_data = EwCompany(id_server=user_data.id_server, stock=stock) stock_data = EwStock(id_server=user_data.id_server, stock=stock) if stock_data is not None: value *= (stock_data.exchange_rate / ewcfg.default_stock_exchange_rate)**0.2 controlling_faction = ewutils.get_subzone_controlling_faction( user_data.poi, user_data.id_server) if controlling_faction != "" and poi.id_poi != ewcfg.poi_id_nuclear_beach_edge: # prices are halved for the controlling gang if controlling_faction == user_data.faction: value /= 2 # and 4 times as much for enemy gangsters elif user_data.faction != "": value *= 4 # raise shambled speakeasy price 4 times value *= shambler_multiplier # Raise the price for togo ordering. This gets lowered back down later if someone does togo ordering on a non-food item by mistake. if togo: value *= 1.5 if current_vendor == ewcfg.vendor_breakroom and user_data.faction == ewcfg.faction_slimecorp: value = 0 value = int(value) food_ordered = False target_data = None # Kingpins eat free. if (user_data.life_state == ewcfg.life_state_kingpin or user_data.life_state == ewcfg.life_state_grandfoe ) and item_type == ewcfg.it_food: value = 0 if value > current_currency_amount: # Not enough money. response = "A {} costs {:,} {}, and you only have {:,}.".format( name, value, currency_used, current_currency_amount) else: mutations = user_data.get_mutations() if random.randrange( 5 ) == 0 and ewcfg.mutation_id_stickyfingers in mutations: value = 0 if item_type == ewcfg.it_food: food_ordered = True food_items = ewitem.inventory( id_user=cmd.message.author.id, id_server=cmd.guild.id, item_type_filter=ewcfg.it_food) target = None target_data = None if not togo: # cant order togo for someone else, you can just give it to them in person if cmd.mentions_count == 1: target = cmd.mentions[0] if target.id == cmd.message.author.id: target = None if target != None: target_data = EwUser(member=target) if target_data.life_state == ewcfg.life_state_corpse and target_data.get_possession( ): response = "How are you planning to feed them while they're possessing you?" return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, response)) elif target_data.poi != user_data.poi: response = "You can't order anything for them because they aren't here!" return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, response)) if len(food_items) >= user_data.get_food_capacity( ) and target_data == None and togo: # user_data never got persisted so the player won't lose money unnecessarily response = "You can't carry any more food than that." return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) elif item_type == ewcfg.it_weapon: weapons_held = ewitem.inventory( id_user=user_data.id_user, id_server=cmd.guild.id, item_type_filter=ewcfg.it_weapon) if len(weapons_held) >= user_data.get_weapon_capacity( ): response = "You can't carry any more weapons." return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) elif user_data.life_state == ewcfg.life_state_corpse: response = "Ghosts can't hold weapons." return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) item_props = ewitem.gen_item_props(item) customtext = cmd.message.content[(len(cmd.tokens[0]) + len(cmd.tokens[1]) + 2):] if item.item_type == ewcfg.it_furniture and "custom" in item_props.get( 'id_furniture'): if customtext == "": response = "You need to specify the customization text before buying a custom item. Come on, isn't that self-evident?" return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) # Only food should have the value multiplied. If someone togo orders a non-food item by mistake, lower it back down. if not food_ordered and togo: value = int(value / 1.5) if currency_used == 'slime': user_data.change_slimes(n=-value, source=ewcfg.source_spending) elif currency_used == 'brainz': user_data.gvs_currency -= value if company_data is not None: company_data.recent_profits += value company_data.persist() if item.str_name == "arcade cabinet": item_props['furniture_desc'] = random.choice( ewcfg.cabinets_list) elif item.item_type == ewcfg.it_furniture: if "custom" in item_props.get('id_furniture'): item_props['furniture_name'] = item_props[ 'furniture_name'].format(custom=customtext) item_props['furniture_desc'] = item_props[ 'furniture_desc'].format(custom=customtext) item_props['furniture_look_desc'] = item_props[ 'furniture_look_desc'].format( custom=customtext) item_props['furniture_place_desc'] = item_props[ 'furniture_place_desc'].format( custom=customtext) item.str_name = item.str_name.format( custom=customtext) id_item = ewitem.item_create(item_type=item_type, id_user=cmd.message.author.id, id_server=cmd.guild.id, stack_max=-1, stack_size=0, item_props=item_props) if value == 0: response = "You swipe a {} from the counter at {}.".format( item.str_name, current_vendor) else: response = "You slam {:,} {} down on the counter at {} for {}.".format( value, currency_used, current_vendor, item.str_name) if food_ordered and not togo: item_data = EwItem(id_item=id_item) # Eat food on the spot! if target_data != None: target_player_data = EwPlayer( id_user=target_data.id_user) if value == 0: response = "You swipe a {} from the counter at {} and give it to {}.".format( item.str_name, current_vendor, target_player_data.display_name) else: response = "You slam {:,} slime down on the counter at {} for {} and give it to {}.".format( value, current_vendor, item.str_name, target_player_data.display_name) response += "\n\n*{}*: ".format( target_player_data.display_name ) + target_data.eat(item_data) target_data.persist() asyncio.ensure_future( ewutils.decrease_food_multiplier( user_data.id_user)) else: if value == 0: response = "You swipe a {} from the counter at {} and eat it right on the spot.".format( item.str_name, current_vendor) else: response = "You slam {:,} slime down on the counter at {} for {} and eat it right on the spot.".format( value, current_vendor, item.str_name) user_player_data = EwPlayer( id_user=user_data.id_user) response += "\n\n*{}*: ".format( user_player_data.display_name) + user_data.eat( item_data) user_data.persist() asyncio.ensure_future( ewutils.decrease_food_multiplier( user_data.id_user)) if premium_purchase: user_data.time_lastpremiumpurchase = int(time.time()) user_data.persist() else: response = "Check the {} for a list of items you can {}.".format( ewcfg.cmd_menu, ewcfg.cmd_order) # Send the response to the player. await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def devour(cmd): user_data = EwUser(member=cmd.message.author) item_search = ewutils.flattenTokenListToString(cmd.tokens[1:]) item_sought = ewitem.find_item(id_server=cmd.message.guild.id, id_user=cmd.message.author.id, item_search=item_search) mutations = user_data.get_mutations() if ewcfg.mutation_id_trashmouth not in mutations: response = "Wait, what? Quit trying to put everything in your mouth." elif item_sought: item_obj = EwItem(id_item=item_sought.get('id_item')) if (item_obj.item_type not in [ewcfg.it_cosmetic, ewcfg.it_furniture, ewcfg.it_food] and item_obj.item_props.get('id_item') != 'slimepoudrin' ) or item_obj.item_props.get('id_cosmetic') == 'soul': response = "You swallow the {} whole, but after realizing this might be a mistake, you cough it back up.".format( item_sought.get('name')) elif item_obj.soulbound == True: response = "You attempt to consume the {}, but you realize it's soulbound and that you were about to eat your own existnece. Your life flashes before your eyes, so you decide to stop.".format( item_sought.get('name')) else: str_eat = "You unhinge your gaping maw and shove the {} right down, no chewing or anything. It's about as nutritious as you'd expect.".format( item_sought.get('name')) if item_obj.item_type == ewcfg.it_cosmetic: recover_hunger = 100 elif item_obj.item_type == ewcfg.it_furniture: furn = ewcfg.furniture_map.get( item_obj.item_props.get('id_furniture')) if furn.acquisition != ewcfg.acquisition_bazaar: recover_hunger = 100 elif furn.price < 500: recover_hunger = 0 elif furn.price < 5000: recover_hunger = 50 elif furn.price < 1000000: recover_hunger = 320 else: recover_hunger = 16000 elif item_obj.item_type == ewcfg.it_food: if item_obj.item_props.get('perishable') != None: perishable_status = item_obj.item_props.get('perishable') if perishable_status == 'true' or perishable_status == '1': item_is_non_perishable = False else: item_is_non_perishable = True else: item_is_non_perishable = False user_has_spoiled_appetite = ewcfg.mutation_id_spoiledappetite in mutations item_has_expired = float(getattr(item_obj, "time_expir", 0)) < time.time() if item_has_expired and not (user_has_spoiled_appetite or item_is_non_perishable): response = "You realize that the food you were trying to eat is already spoiled. Ugh, not eating that." return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) # ewitem.item_drop(food_item.id_item) recover_hunger = item_obj.item_props.get('recover_hunger') else: recover_hunger = 100 item_obj.item_props = { 'id_food': "convertedfood", 'food_name': "", 'food_desc': "", 'recover_hunger': recover_hunger, 'inebriation': 0, 'str_eat': str_eat, 'time_expir': time.time() + ewcfg.std_food_expir, 'time_fridged': 0, 'perishable': True, } response = user_data.eat(item_obj) user_data.persist() elif item_search == "": response = "Devour what?" else: response = "Are you sure you have that item?" return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def mine(cmd): market_data = EwMarket(id_server=cmd.message.author.server.id) user_data = EwUser(member=cmd.message.author) mutations = user_data.get_mutations() time_now = int(time.time()) response = "" # Kingpins can't mine. if user_data.life_state == ewcfg.life_state_kingpin or user_data.life_state == ewcfg.life_state_grandfoe: return # ghosts cant mine (anymore) if user_data.life_state == ewcfg.life_state_corpse: return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, "You can't mine while you're dead. Try {}.".format( ewcfg.cmd_revive))) # Enlisted players only mine at certain times. if user_data.life_state == ewcfg.life_state_enlisted: if user_data.faction == ewcfg.faction_rowdys and ( market_data.clock < 8 or market_data.clock > 17): return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, "Rowdies only mine in the daytime. Wait for full daylight at 8am." .format(ewcfg.cmd_revive))) if user_data.faction == ewcfg.faction_killers and ( market_data.clock < 20 and market_data.clock > 5): return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, "Killers only mine under cover of darkness. Wait for nightfall at 8pm." .format(ewcfg.cmd_revive))) # Mine only in the mines. if cmd.message.channel.name in [ ewcfg.channel_mines, ewcfg.channel_cv_mines, ewcfg.channel_tt_mines ]: if user_data.hunger >= user_data.get_hunger_max(): return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, "You've exhausted yourself from mining. You'll need some refreshment before getting back to work." )) else: printgrid = False hunger_cost_mod = ewutils.hunger_cost_mod(user_data.slimelevel) extra = hunger_cost_mod - int( hunger_cost_mod ) # extra is the fractional part of hunger_cost_mod if user_data.poi not in mines_map: response = "You can't mine here! Go to the mines in Juvie's Row, Toxington, or Cratersville!" return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) elif user_data.id_server not in mines_map.get(user_data.poi): init_grid(user_data.poi, user_data.id_server) printgrid = True grid_cont = mines_map.get(user_data.poi).get(user_data.id_server) grid = grid_cont.grid #minesweeper = False if cmd.tokens_count < 2: response = "Please specify which vein to mine." await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) return await print_grid(cmd) else: #minesweeper = True #grid_multiplier = grid_cont.cells_mined ** 0.4 #flag = False row = -1 col = -1 for token in cmd.tokens[1:]: if token.lower() == "reset": user_data.hunger += ewcfg.hunger_perminereset * int( hunger_cost_mod) if random.random() < extra: user_data.hunger += ewcfg.hunger_perminereset user_data.persist() init_grid(user_data.poi, user_data.id_server) return await print_grid(cmd) if row < 1 or col < 1: coords = token.lower() for char in coords: if char in ewcfg.alphabet: col = ewcfg.alphabet.index(char) coords = coords.replace(char, "") try: row = int(coords) except: row = -1 row -= 1 if row not in range(len(grid)) or col not in range( len(grid[row])): response = "Invalid vein." await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) return await print_grid(cmd) mining_yield = 0 mining_accident = False slimes_pertile = ewcfg.slimes_pertile for current_row in range(max(0, row - 1), min(row + 2, len(grid))): for current_col in range( max(0, col - 1), min(col + 2, len(grid[current_row]))): symbol_prev = get_cell_symbol( grid[current_row][current_col]) slimes_fromtile = slimes_pertile if current_row == row and current_col == col: slimes_fromtile *= 2 mining_yield += max( 0, min(slimes_fromtile, grid[current_row][current_col])) grid[current_row][current_col] -= slimes_fromtile if grid[current_row][ current_col] < -60 * ewcfg.slimes_pertile: mining_accident = True if get_cell_symbol( grid[current_row][current_col]) != symbol_prev: printgrid = True if mining_accident: user_data.change_slimes(n=-(user_data.slimes * 0.5)) user_data.persist() init_grid(user_data.poi, user_data.id_server) response = "You have lost an arm and a leg in a mining accident. Tis but a scratch." await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) return await print_grid(cmd) if mining_yield == 0: user_data.hunger += ewcfg.hunger_permine * int( hunger_cost_mod) user_data.persist() response = "This vein has already been mined dry." await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) if printgrid: return await print_grid(cmd) else: return has_pickaxe = False if user_data.weapon >= 0: weapon_item = EwItem(id_item=user_data.weapon) weapon = ewcfg.weapon_map.get( weapon_item.item_props.get("weapon_type")) if weapon.id_weapon == ewcfg.weapon_id_pickaxe: has_pickaxe = True # Determine if an item is found. unearthed_item = False unearthed_item_amount = 0 # juvies get items 4 times as often as enlisted players unearthed_item_chance = 1 / ewcfg.unearthed_item_rarity if user_data.life_state == ewcfg.life_state_juvenile: unearthed_item_chance *= 2 if has_pickaxe == True: unearthed_item_chance *= 1.5 if ewcfg.mutation_id_lucky in mutations: unearthed_item_chance *= 1.33 if random.random() < unearthed_item_chance: unearthed_item = True unearthed_item_amount = 1 if random.randint( 1, 3) != 1 else 2 # 33% chance of extra drop if unearthed_item == True: # If there are multiple possible products, randomly select one. item = random.choice(ewcfg.mine_results) item_props = ewitem.gen_item_props(item) for creation in range(unearthed_item_amount): ewitem.item_create(item_type=item.item_type, id_user=cmd.message.author.id, id_server=cmd.message.server.id, item_props=item_props) if unearthed_item_amount == 1: response = "You unearthed a {}! ".format(item.str_name) elif unearthed_item_amount == 2: response = "You unearthed two (2) {}! ".format( item.str_name) ewstats.change_stat(user=user_data, metric=ewcfg.stat_lifetime_poudrins, n=unearthed_item_amount) ewutils.logMsg('{} has found {} {}(s)!'.format( cmd.message.author.display_name, item.str_name, unearthed_item_amount)) user_initial_level = user_data.slimelevel # Add mined slime to the user. slime_bylevel = ewutils.slime_bylevel(user_data.slimelevel) #mining_yield = math.floor((slime_bylevel / 10) + 1) #alternate_yield = math.floor(200 + slime_bylevel ** (1 / math.e)) #mining_yield = min(mining_yield, alternate_yield) if has_pickaxe == True: mining_yield *= 2 # Fatigue the miner. user_data.hunger += ewcfg.hunger_permine * int(hunger_cost_mod) if extra > 0: # if hunger_cost_mod is not an integer # there's an x% chance that an extra stamina is deducted, where x is the fractional part of hunger_cost_mod in percent (times 100) if random.randint(1, 100) <= extra * 100: user_data.hunger += ewcfg.hunger_permine levelup_response = user_data.change_slimes( n=mining_yield, source=ewcfg.source_mining) was_levelup = True if user_initial_level < user_data.slimelevel else False # Tell the player their slime level increased and/or they unearthed an item. if was_levelup: response += levelup_response user_data.persist() if printgrid: await print_grid(cmd) else: response = "You can't mine here! Go to the mines in Juvie's Row, Toxington, or Cratersville!" if len(response) > 0: await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def reap(cmd): user_data = EwUser(member=cmd.message.author) response = "" levelup_response = "" mutations = user_data.get_mutations() poi = ewcfg.id_to_poi.get(user_data.poi) # Checking availability of reap action if user_data.life_state != ewcfg.life_state_juvenile: response = "Only Juveniles of pure heart and with nothing better to do can farm." elif user_data.poi not in [ ewcfg.poi_id_jr_farms, ewcfg.poi_id_og_farms, ewcfg.poi_id_ab_farms ]: response = "Do you remember planting anything here in this barren wasteland? No, you don’t. Idiot." else: if user_data.poi == ewcfg.poi_id_jr_farms: farm_id = ewcfg.poi_id_jr_farms elif user_data.poi == ewcfg.poi_id_og_farms: farm_id = ewcfg.poi_id_og_farms else: # if it's the farm in arsonbrook farm_id = ewcfg.poi_id_ab_farms farm = EwFarm(id_server=cmd.message.server.id, id_user=cmd.message.author.id, farm=farm_id) if farm.time_lastsow == 0: response = "You missed a step, you haven’t planted anything here yet." else: cur_time_min = time.time() / 60 time_grown = cur_time_min - farm.time_lastsow if farm.phase != ewcfg.farm_phase_reap: response = "Patience is a virtue and you are morally bankrupt. Just wait, asshole." else: # Reaping if time_grown > ewcfg.crops_time_to_grow * 16: # about 2 days response = "You eagerly cultivate your crop, but what’s this? It’s dead and wilted! It seems as though you’ve let it lay fallow for far too long. Pay better attention to your farm next time. You gain no slime." else: user_initial_level = user_data.slimelevel slime_gain = farm.slimes_onreap if poi.is_subzone: district_data = EwDistrict( district=poi.mother_district, id_server=cmd.message.server.id) else: district_data = EwDistrict( district=poi.id_poi, id_server=cmd.message.server.id) if district_data.controlling_faction != "" and district_data.controlling_faction == user_data.faction: slime_gain *= 2 response = "You reap what you’ve sown. Your investment has yielded {} slime, ".format( slime_gain) # Determine if an item is found. unearthed_item = False unearthed_item_amount = 0 unearthed_item_chance = 50 / ewcfg.unearthed_item_rarity # 1 in 30 chance if ewcfg.mutation_id_lucky in mutations: unearthed_item_chance *= 1.33 if random.random() < unearthed_item_chance: unearthed_item = True unearthed_item_amount = 1 if random.randint( 1, 3) != 1 else 2 # 33% chance of extra drop if unearthed_item == True: # If there are multiple possible products, randomly select one. item = random.choice(ewcfg.mine_results) item_props = ewitem.gen_item_props(item) if item is not None: for creation in range(unearthed_item_amount): ewitem.item_create( item_type=item.item_type, id_user=cmd.message.author.id, id_server=cmd.message.server.id, item_props=item_props) if unearthed_item_amount == 1: response += "a {}, ".format(item.str_name) elif unearthed_item_amount == 2: response += "two {}s, ".format(item.str_name) # Determine what crop is grown. vegetable = ewcfg.food_map.get(farm.crop) if vegetable is None: vegetable = random.choice(ewcfg.vegetable_list) item_props = ewitem.gen_item_props(vegetable) # Create and give a bushel of whatever crop was grown. for vcreate in range(3): ewitem.item_create(id_user=cmd.message.author.id, id_server=cmd.message.server.id, item_type=vegetable.item_type, item_props=item_props) response += "and a bushel of {}!".format( vegetable.str_name) levelup_response = user_data.change_slimes( n=slime_gain, source=ewcfg.source_farming) was_levelup = True if user_initial_level < user_data.slimelevel else False # Tell the player their slime level increased. if was_levelup: response += "\n\n" + levelup_response user_data.hunger += ewcfg.hunger_perfarm user_data.persist() farm.time_lastsow = 0 # 0 means no seeds are currently planted farm.persist() await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def data(cmd): response = "" user_data = None member = None resp_cont = ewutils.EwResponseContainer(id_server=cmd.message.server.id) if len(cmd.tokens) > 1 and cmd.mentions_count == 0: user_data = EwUser(member=cmd.message.author) soughtenemy = " ".join(cmd.tokens[1:]).lower() enemy = find_enemy(soughtenemy, user_data) if enemy != None: if enemy.attacktype != ewcfg.enemy_attacktype_unarmed: response = "{} is a level {} enemy. They have {} slime, and attack with their {}.".format( enemy.display_name, enemy.level, enemy.slimes, enemy.attacktype) else: response = "{} is a level {} enemy. They have {} slime.".format( enemy.display_name, enemy.level, enemy.slimes) else: response = "ENDLESS WAR didn't understand that name." resp_cont.add_channel_response(cmd.message.channel.name, response) elif cmd.mentions_count == 0: user_data = EwUser(member=cmd.message.author) slimeoid = EwSlimeoid(member=cmd.message.author) mutations = user_data.get_mutations() cosmetics = ewitem.inventory(id_user=cmd.message.author.id, id_server=cmd.message.server.id, item_type_filter=ewcfg.it_cosmetic) adorned_cosmetics = [] for cosmetic in cosmetics: cos = EwItem(id_item=cosmetic.get('id_item')) if cos.item_props['adorned'] == 'true': hue = ewcfg.hue_map.get(cos.item_props.get('hue')) adorned_cosmetics.append((hue.str_name + " " if hue != None else "") + cosmetic.get('name')) poi = ewcfg.id_to_poi.get(user_data.poi) if poi != None: response = "You find yourself {} {}. ".format( poi.str_in, poi.str_name) # return my data if user_data.life_state == ewcfg.life_state_corpse: response += "You are a level {} deadboi.".format( user_data.slimelevel) else: response += "You are a level {} slimeboi.".format( user_data.slimelevel) coinbounty = int(user_data.bounty / ewcfg.slimecoin_exchangerate) weapon_item = EwItem(id_item=user_data.weapon) weapon = ewcfg.weapon_map.get( weapon_item.item_props.get("weapon_type")) if weapon != None: response += " {} {}{}.".format( ewcfg.str_weapon_married_self if user_data.weaponmarried == True else ewcfg.str_weapon_wielding_self, ("" if len(weapon_item.item_props.get("weapon_name")) == 0 else "{}, ".format(weapon_item.item_props.get("weapon_name"))), weapon.str_weapon) if user_data.weaponskill >= 5: response += " {}".format( weapon.str_weaponmaster_self.format( rank=(user_data.weaponskill - 4))) trauma = ewcfg.weapon_map.get(user_data.trauma) # if trauma is not gathered from weapon_map, get it from attack_type_map if trauma == None: trauma = ewcfg.attack_type_map.get(user_data.trauma) if trauma != None: response += " {}".format(trauma.str_trauma_self) response_block = "" for mutation in mutations: mutation_flavor = ewcfg.mutations_map[mutation] response_block += "{} ".format(mutation_flavor.str_describe_self) if len(response_block) > 0: response += "\n\n" + response_block resp_cont.add_channel_response(cmd.message.channel.name, response) response = "" response_block = "" user_kills = ewstats.get_stat(user=user_data, metric=ewcfg.stat_kills) enemy_kills = ewstats.get_stat(user=user_data, metric=ewcfg.stat_pve_kills) if user_kills > 0 and enemy_kills > 0: response_block += "You have {:,} confirmed kills, and {:,} confirmed hunts. ".format( user_kills, enemy_kills) elif user_kills > 0: response_block += "You have {:,} confirmed kills. ".format( user_kills) elif enemy_kills > 0: response_block += "You have {:,} confirmed hunts. ".format( enemy_kills) if coinbounty != 0: response_block += "SlimeCorp offers a bounty of {:,} SlimeCoin for your death. ".format( coinbounty) if len(adorned_cosmetics) > 0: response_block += "You have a {} adorned. ".format( ewutils.formatNiceList(adorned_cosmetics, 'and')) if user_data.hunger > 0: response_block += "You are {}% hungry. ".format( round(user_data.hunger * 100.0 / user_data.get_hunger_max(), 1)) if user_data.busted and user_data.life_state == ewcfg.life_state_corpse: response_block += "You are busted and therefore cannot leave the sewers until your next !haunt. " statuses = user_data.getStatusEffects() for status in statuses: status_effect = EwStatusEffect(id_status=status, user_data=user_data) if status_effect.time_expire > time.time( ) or status_effect.time_expire == -1: status_flavor = ewcfg.status_effects_def_map.get(status) if status_flavor is not None: response_block += status_flavor.str_describe_self + " " if (slimeoid.life_state == ewcfg.slimeoid_state_active) and ( user_data.life_state != ewcfg.life_state_corpse): response_block += "You are accompanied by {}, a {}-foot-tall Slimeoid. ".format( slimeoid.name, str(slimeoid.level)) if len(response_block) > 0: response += "\n" + response_block response += "\n\nhttps://ew.krakissi.net/stats/player.html?pl={}".format( user_data.id_user) resp_cont.add_channel_response(cmd.message.channel.name, response) else: member = cmd.mentions[0] resp_cont = gen_data_text(id_user=member.id, id_server=member.server.id, display_name=member.display_name, channel_name=cmd.message.channel.name) # Send the response to the player. resp_cont.format_channel_response(cmd.message.channel.name, cmd.message.author) await resp_cont.post() await ewrolemgr.updateRoles(client=cmd.client, member=cmd.message.author) if member != None: await ewrolemgr.updateRoles(client=cmd.client, member=member)
async def weather_tick(id_server=None): if id_server != None: try: market_data = EwMarket(id_server=id_server) if market_data.weather == ewcfg.weather_sunny: exposed_pois = [] exposed_pois.extend(ewcfg.capturable_districts) exposed_pois.extend(ewcfg.outskirts) exposed_pois = tuple(exposed_pois) users = ewutils.execute_sql_query( "SELECT id_user FROM users WHERE id_server = %s AND {poi} IN %s AND {life_state} > 0" .format(poi=ewcfg.col_poi, life_state=ewcfg.col_life_state), (id_server, exposed_pois)) for user in users: try: user_data = EwUser(id_user=user[0], id_server=id_server) if user_data.life_state == ewcfg.life_state_kingpin: continue else: mutations = user_data.get_mutations() if ewcfg.mutation_id_airlock in mutations: user_data.hunger -= min(user_data.hunger, 5) except: ewutils.logMsg( "Error occurred in weather tick for server {}". format(id_server)) if market_data.weather != ewcfg.weather_bicarbonaterain: return exposed_pois = [] exposed_pois.extend(ewcfg.capturable_districts) exposed_pois.extend(ewcfg.outskirts) exposed_pois = tuple(exposed_pois) client = ewutils.get_client() server = client.get_guild(id_server) users = ewutils.execute_sql_query( "SELECT id_user FROM users WHERE id_server = %s AND {poi} IN %s AND {life_state} > 0" .format(poi=ewcfg.col_poi, life_state=ewcfg.col_life_state), (id_server, exposed_pois)) deathreport = "" resp_cont = ewutils.EwResponseContainer(id_server=id_server) for user in users: user_data = EwUser(id_user=user[0], id_server=id_server) if user_data.life_state == ewcfg.life_state_kingpin: continue user_poi = ewcfg.id_to_poi.get(user_data.poi) player_data = EwPlayer(id_server=user_data.id_server, id_user=user_data.id_user) protected = False slimeoid_protected = False if user_data.weapon >= 0: weapon_item = EwItem(id_item=user_data.weapon) if weapon_item.item_props.get( 'weapon_type') in ewcfg.rain_protection: protected = True cosmetics = ewitem.inventory( id_user=user_data.id_user, id_server=id_server, item_type_filter=ewcfg.it_cosmetic) for cosmetic in cosmetics: cosmetic_data = EwItem(id_item=cosmetic.get('id_item')) if cosmetic_data.item_props.get( 'id_cosmetic') in ewcfg.rain_protection: if cosmetic_data.item_props.get('adorned') == 'true': protected = True elif cosmetic_data.item_props.get( 'slimeoid') == 'true': slimeoid_protected = True if not protected: if user_data.life_state == ewcfg.life_state_shambler: slime_gain = (ewcfg.slimes_shambler - user_data.slimes) / 10 slime_gain = max(0, int(slime_gain)) user_data.change_slimes(n=slime_gain, source=ewcfg.source_weather) else: if random.random() < 0.01: user_data.degradation += 1 user_data.persist() if not slimeoid_protected: slimeoid_data = EwSlimeoid(id_user=user_data.id_user, id_server=id_server) if slimeoid_data.life_state != ewcfg.slimeoid_state_active: continue slimeoid_response = "" if random.randrange(10) < slimeoid_data.level: slimeoid_response = "*{uname}*: {slname} cries out in pain, as it's hit by the bicarbonate rain.".format( uname=player_data.display_name, slname=slimeoid_data.name) else: item_props = { 'context': ewcfg.context_slimeoidheart, 'subcontext': slimeoid_data.id_slimeoid, 'item_name': "Heart of {}".format(slimeoid_data.name), 'item_desc': "A poudrin-like crystal. If you listen carefully you can hear something that sounds like a faint heartbeat." } ewitem.item_create(id_user=str(user_data.id_user), id_server=id_server, item_type=ewcfg.it_item, item_props=item_props) slimeoid_data.die() slimeoid_data.persist() slimeoid_response = "*{uname}*: {slname} lets out a final whimper as it's dissolved by the bicarbonate rain. {skull} You quickly pocket its heart.".format( uname=player_data.display_name, slname=slimeoid_data.name, skull=ewcfg.emote_slimeskull) resp_cont.add_channel_response(user_poi.channel, slimeoid_response) for poi in exposed_pois: district_data = EwDistrict(district=poi, id_server=id_server) slimes_to_erase = district_data.slimes * 0.01 * ewcfg.weather_tick_length slimes_to_erase = max(slimes_to_erase, ewcfg.weather_tick_length * 1000) slimes_to_erase = min(district_data.slimes, slimes_to_erase) #round up or down, randomly weighted remainder = slimes_to_erase - int(slimes_to_erase) if random.random() < remainder: slimes_to_erase += 1 slimes_to_erase = int(slimes_to_erase) district_data.change_slimes(n=-slimes_to_erase, source=ewcfg.source_weather) district_data.persist() enemies = ewutils.execute_sql_query( "SELECT id_enemy FROM enemies WHERE id_server = %s AND {poi} IN %s AND {life_state} = %s AND {weathertype} != %s" .format(poi=ewcfg.col_enemy_poi, life_state=ewcfg.col_enemy_life_state, weathertype=ewcfg.col_enemy_weathertype), (id_server, exposed_pois, ewcfg.enemy_lifestate_alive, ewcfg.enemy_weathertype_rainresist)) for enemy in enemies: enemy_data = EwEnemy(id_enemy=enemy[0]) enemy_poi = ewcfg.id_to_poi.get(enemy_data.poi) slimes_to_erase = enemy_data.slimes * 0.01 * ewcfg.weather_tick_length slimes_to_erase = max(slimes_to_erase, ewcfg.weather_tick_length * 1000) slimes_to_erase = min(enemy_data.slimes, slimes_to_erase) #round up or down, randomly weighted remainder = slimes_to_erase - int(slimes_to_erase) if random.random() < remainder: slimes_to_erase += 1 slimes_to_erase = int(slimes_to_erase) enemy_data.change_slimes(n=-slimes_to_erase, source=ewcfg.source_weather) enemy_data.persist() response = "{name} takes {slimeloss:,} damage from the bicarbonate rain.".format( name=enemy_data.display_name, slimeloss=slimes_to_erase) resp_cont.add_channel_response(enemy_poi.channel, response) if enemy_data.slimes <= 0: ewhunting.delete_enemy(enemy_data) deathreport = "{skull} {name} is dissolved by the bicarbonate rain. {skull}".format( skull=ewcfg.emote_slimeskull, name=enemy_data.display_name) resp_cont.add_channel_response(enemy_poi.channel, deathreport) await resp_cont.post() except: ewutils.logMsg( "Error occurred in weather tick for server {}".format( id_server))
async def flag(cmd): market_data = EwMarket(id_server=cmd.message.author.server.id) user_data = EwUser(member=cmd.message.author) mutations = user_data.get_mutations() time_now = int(time.time()) response = "" # Kingpins can't mine. if user_data.life_state == ewcfg.life_state_kingpin or user_data.life_state == ewcfg.life_state_grandfoe: return # ghosts cant mine (anymore) if user_data.life_state == ewcfg.life_state_corpse: return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, "You can't mine while you're dead. Try {}.".format( ewcfg.cmd_revive))) # Enlisted players only mine at certain times. if user_data.life_state == ewcfg.life_state_enlisted: if user_data.faction == ewcfg.faction_rowdys and ( market_data.clock < 8 or market_data.clock > 17): return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, "Rowdies only mine in the daytime. Wait for full daylight at 8am." .format(ewcfg.cmd_revive))) if user_data.faction == ewcfg.faction_killers and ( market_data.clock < 20 and market_data.clock > 5): return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, "Killers only mine under cover of darkness. Wait for nightfall at 8pm." .format(ewcfg.cmd_revive))) # Mine only in the mines. if cmd.message.channel.name in [ ewcfg.channel_mines, ewcfg.channel_cv_mines, ewcfg.channel_tt_mines ]: if user_data.hunger >= user_data.get_hunger_max(): return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage( cmd.message.author, "You've exhausted yourself from mining. You'll need some refreshment before getting back to work." )) else: if user_data.poi not in mines_map: response = "You can't mine here! Go to the mines in Juvie's Row, Toxington, or Cratersville!" return await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) elif user_data.id_server not in mines_map.get(user_data.poi): init_grid_ms(user_data.poi, user_data.id_server) grid_cont = mines_map.get(user_data.poi).get(user_data.id_server) grid = grid_cont.grid if cmd.tokens_count < 2: response = "Please specify which vein to mine." await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) return await print_grid_ms(cmd) grid_multiplier = grid_cont.cells_mined**0.4 row = -1 col = -1 for token in cmd.tokens[1:]: if row < 1 or col < 1: coords = token.lower() for char in coords: if char in ewcfg.alphabet: col = ewcfg.alphabet.index(char) coords = coords.replace(char, "") try: row = int(coords) except: row = -1 row -= 1 if row not in range(len(grid)): response = "Invalid vein." await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) return await print_grid_ms(cmd) if col not in range(len(grid[row])): response = "Invalid vein." await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) return await print_grid_ms(cmd) if grid[row][col] in [ ewcfg.cell_empty_marked, ewcfg.cell_mine_marked ]: if grid[row][col] == ewcfg.cell_empty_marked: grid[row][col] = ewcfg.cell_empty elif grid[row][col] == ewcfg.cell_mine_marked: grid[row][col] = ewcfg.cell_mine return await print_grid_ms(cmd) if grid[row][col] == ewcfg.cell_empty_open: response = "This vein has already been mined dry." await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) return await print_grid_ms(cmd) if grid[row][col] == ewcfg.cell_mine: grid[row][col] = ewcfg.cell_mine_marked return await print_grid_ms(cmd) grid[row][col] = ewcfg.cell_empty_marked return await print_grid_ms(cmd) else: response = "You can't mine here! Go to the mines in Juvie's Row, Toxington, or Cratersville!" if len(response) > 0: await ewutils.send_message( cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
async def event_tick(id_server): time_now = int(time.time()) resp_cont = ewutils.EwResponseContainer(id_server=id_server) try: data = ewutils.execute_sql_query( "SELECT {id_event} FROM world_events WHERE {time_expir} <= %s AND {time_expir} > 0 AND id_server = %s" .format( id_event=ewcfg.col_id_event, time_expir=ewcfg.col_time_expir, ), ( time_now, id_server, )) for row in data: try: event_data = EwWorldEvent(id_event=row[0]) event_def = ewcfg.event_type_to_def.get(event_data.event_type) response = event_def.str_event_end if event_def else "" if event_data.event_type == ewcfg.event_type_minecollapse: user_data = EwUser( id_user=event_data.event_props.get('id_user'), id_server=id_server) mutations = user_data.get_mutations() if user_data.poi == event_data.event_props.get('poi'): player_data = EwPlayer(id_user=user_data.id_user) response = "*{}*: You have lost an arm and a leg in a mining accident. Tis but a scratch.".format( player_data.display_name) if random.randrange(4) == 0: response = "*{}*: Big John arrives just in time to save you from your mining accident!\nhttps://cdn.discordapp.com/attachments/431275470902788107/743629505876197416/mine2.jpg".format( player_data.display_name) else: if ewcfg.mutation_id_lightminer in mutations: response = "*{}*: You instinctively jump out of the way of the collapsing shaft, not a scratch on you. Whew, really gets your blood pumping.".format( player_data.display_name) else: user_data.change_slimes( n=-(user_data.slimes * 0.5)) user_data.persist() # check if any void connections have expired, if so pop it and create a new one elif event_data.event_type == ewcfg.event_type_voidconnection: void_poi = ewcfg.id_to_poi.get(ewcfg.poi_id_thevoid) void_poi.neighbors.pop(event_data.event_props.get('poi'), "") create_void_connection(id_server) if len(response) > 0: poi = event_data.event_props.get('poi') channel = event_data.event_props.get('channel') if channel != None: # in shambaquarium the event happens in the user's DMs if event_data.event_type == ewcfg.event_type_shambaquarium: client = ewutils.get_client() channel = client.get_guild(id_server).get_member( int(channel)) resp_cont.add_channel_response(channel, response) elif poi != None: poi_def = ewcfg.id_to_poi.get(poi) if poi_def != None: resp_cont.add_channel_response( poi_def.channel, response) else: for ch in ewcfg.hideout_channels: resp_cont.add_channel_response(ch, response) delete_world_event(event_data.id_event) except: ewutils.logMsg( "Error in event tick for server {}".format(id_server)) await resp_cont.post() except: ewutils.logMsg("Error in event tick for server {}".format(id_server))
async def sow(cmd): user_data = EwUser(member = cmd.message.author) if user_data.life_state == ewcfg.life_state_shambler: response = "You lack the higher brain functions required to {}.".format(cmd.tokens[0]) return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) # check if the user has a farming tool equipped weapon_item = EwItem(id_item=user_data.weapon) weapon = ewcfg.weapon_map.get(weapon_item.item_props.get("weapon_type")) has_tool = False if weapon is not None: if ewcfg.weapon_class_farming in weapon.classes: has_tool = True # Checking availability of sow action if user_data.life_state != ewcfg.life_state_juvenile and not has_tool: response = "Only Juveniles of pure heart and with nothing better to do can farm." elif cmd.message.channel.name not in [ewcfg.channel_jr_farms, ewcfg.channel_og_farms, ewcfg.channel_ab_farms]: response = "The cracked, filthy concrete streets around you would be a pretty terrible place for a farm. Try again on more arable land." else: poi = ewcfg.id_to_poi.get(user_data.poi) district_data = EwDistrict(district = poi.id_poi, id_server = user_data.id_server) if district_data.is_degraded(): response = "{} has been degraded by shamblers. You can't {} here anymore.".format(poi.str_name, cmd.tokens[0]) return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) if user_data.poi == ewcfg.poi_id_jr_farms: farm_id = ewcfg.poi_id_jr_farms elif user_data.poi == ewcfg.poi_id_og_farms: farm_id = ewcfg.poi_id_og_farms else: # if it's the farm in arsonbrook farm_id = ewcfg.poi_id_ab_farms farm = EwFarm( id_server = cmd.guild.id, id_user = cmd.message.author.id, farm = farm_id ) if farm.time_lastsow > 0: response = "You’ve already sown something here. Try planting in another farming location. If you’ve planted in all three farming locations, you’re shit out of luck. Just wait, asshole." else: it_type_filter = None # gangsters can only plant poudrins if cmd.tokens_count > 1 and user_data.life_state == ewcfg.life_state_juvenile: item_search = ewutils.flattenTokenListToString(cmd.tokens[1:]) # if the item selected was a vegetable, use a food only filter in find_item for v in ewcfg.vegetable_list: if item_search in v.id_food or item_search in v.str_name: it_type_filter = ewcfg.it_food break else: item_search = "slimepoudrin" item_sought = ewitem.find_item(item_search = item_search, id_user = cmd.message.author.id, id_server = cmd.guild.id if cmd.guild is not None else None, item_type_filter = it_type_filter) if item_sought == None: response = "You don't have anything to plant! Try collecting a poudrin." else: slimes_onreap = ewcfg.reap_gain item_data = EwItem(id_item = item_sought.get("id_item")) if item_data.item_type == ewcfg.it_item: if item_data.item_props.get("id_item") == ewcfg.item_id_slimepoudrin: vegetable = random.choice(ewcfg.vegetable_list) slimes_onreap *= 2 elif item_data.item_props.get("context") == ewcfg.context_slimeoidheart: vegetable = random.choice(ewcfg.vegetable_list) slimes_onreap *= 2 slimeoid_data = EwSlimeoid(id_slimeoid = item_data.item_props.get("subcontext")) slimeoid_data.delete() else: response = "The soil has enough toxins without you burying your trash here." return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) elif item_data.item_type == ewcfg.it_food: food_id = item_data.item_props.get("id_food") vegetable = ewcfg.food_map.get(food_id) if ewcfg.vendor_farm not in vegetable.vendors: response = "It sure would be nice if {}s grew on trees, but alas they do not. Idiot.".format(item_sought.get("name")) return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) elif user_data.life_state != ewcfg.life_state_juvenile: response = "You lack the knowledge required to grow {}.".format(item_sought.get("name")) return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) else: response = "The soil has enough toxins without you burying your trash here." return await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response)) mutations = user_data.get_mutations() growth_time = ewcfg.crops_time_to_grow if user_data.life_state == ewcfg.life_state_juvenile: growth_time /= 2 if ewcfg.mutation_id_greenfingers in mutations: growth_time /= 1.5 hours = int(growth_time / 60) minutes = int(growth_time % 60) str_growth_time = "{} hour{}{}".format(hours, "s" if hours > 1 else "", " and {} minutes".format(minutes) if minutes > 0 else "") # Sowing response = "You sow a {} into the fertile soil beneath you. It will grow in about {}.".format(item_sought.get("name"), str_growth_time) farm.time_lastsow = int(time.time() / 60) # Grow time is stored in minutes. farm.time_lastphase = int(time.time()) farm.slimes_onreap = slimes_onreap farm.crop = vegetable.id_food farm.phase = ewcfg.farm_phase_sow farm.action_required = ewcfg.farm_action_none farm.sow_life_state = user_data.life_state ewitem.item_delete(id_item = item_sought.get('id_item')) # Remove Poudrins farm.persist() await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
def gen_data_text(id_user=None, id_server=None, display_name=None, channel_name=None): resp_cont = ewutils.EwResponseContainer(id_server=id_server) response = "" user_data = EwUser(id_user=id_user, id_server=id_server) slimeoid = EwSlimeoid(id_user=id_user, id_server=id_server) mutations = user_data.get_mutations() cosmetics = ewitem.inventory(id_user=user_data.id_user, id_server=user_data.id_server, item_type_filter=ewcfg.it_cosmetic) adorned_cosmetics = [] for cosmetic in cosmetics: cos = EwItem(id_item=cosmetic.get('id_item')) if cos.item_props['adorned'] == 'true': hue = ewcfg.hue_map.get(cos.item_props.get('hue')) adorned_cosmetics.append((hue.str_name + " " if hue != None else "") + cosmetic.get('name')) if user_data.life_state == ewcfg.life_state_grandfoe: poi = ewcfg.id_to_poi.get(user_data.poi) if poi != None: response = "{} is {} {}.".format(display_name, poi.str_in, poi.str_name) else: response = "You can't discern anything useful about {}.".format( display_name) resp_cont.add_channel_response(channel_name, response) else: # return somebody's score if user_data.life_state == ewcfg.life_state_corpse: response = "{} is a level {} deadboi.".format( display_name, user_data.slimelevel) else: response = "{} is a level {} slimeboi.".format( display_name, user_data.slimelevel) coinbounty = int(user_data.bounty / ewcfg.slimecoin_exchangerate) weapon_item = EwItem(id_item=user_data.weapon) weapon = ewcfg.weapon_map.get( weapon_item.item_props.get("weapon_type")) if weapon != None: response += " {} {}{}.".format( ewcfg.str_weapon_married if user_data.weaponmarried == True else ewcfg.str_weapon_wielding, ("" if len(weapon_item.item_props.get("weapon_name")) == 0 else "{}, ".format(weapon_item.item_props.get("weapon_name"))), weapon.str_weapon) if user_data.weaponskill >= 5: response += " {}".format( weapon.str_weaponmaster.format( rank=(user_data.weaponskill - 4))) trauma = ewcfg.weapon_map.get(user_data.trauma) # if trauma is not gathered from weapon_map, get it from attack_type_map if trauma == None: trauma = ewcfg.attack_type_map.get(user_data.trauma) if trauma != None: response += " {}".format(trauma.str_trauma) response_block = "" for mutation in mutations: mutation_flavor = ewcfg.mutations_map[mutation] response_block += "{} ".format(mutation_flavor.str_describe_other) if len(response_block) > 0: response += "\n\n" + response_block resp_cont.add_channel_response(channel_name, response) response = "" response_block = "" user_kills = ewstats.get_stat(user=user_data, metric=ewcfg.stat_kills) enemy_kills = ewstats.get_stat(user=user_data, metric=ewcfg.stat_pve_kills) if user_kills > 0 and enemy_kills > 0: response_block += "They have {:,} confirmed kills, and {:,} confirmed hunts. ".format( user_kills, enemy_kills) elif user_kills > 0: response_block += "They have {:,} confirmed kills. ".format( user_kills) elif enemy_kills > 0: response_block += "They have {:,} confirmed hunts. ".format( enemy_kills) if coinbounty != 0: response_block += "SlimeCorp offers a bounty of {:,} SlimeCoin for their death. ".format( coinbounty) if len(adorned_cosmetics) > 0: response_block += "They have a {} adorned. ".format( ewutils.formatNiceList(adorned_cosmetics, 'and')) statuses = user_data.getStatusEffects() for status in statuses: status_effect = EwStatusEffect(id_status=status, user_data=user_data) if status_effect.time_expire > time.time( ) or status_effect.time_expire == -1: status_flavor = ewcfg.status_effects_def_map.get(status) if status_flavor is not None: response_block += status_flavor.str_describe + " " if (slimeoid.life_state == ewcfg.slimeoid_state_active) and ( user_data.life_state != ewcfg.life_state_corpse): response_block += "They are accompanied by {}, a {}-foot-tall Slimeoid.".format( slimeoid.name, str(slimeoid.level)) if len(response_block) > 0: response += "\n" + response_block response += "\n\nhttps://ew.krakissi.net/stats/player.html?pl={}".format( id_user) resp_cont.add_channel_response(channel_name, response) return resp_cont
async def explode(damage = 0, district_data = None): id_server = district_data.id_server poi = district_data.name client = get_client() server = client.get_server(id_server) resp_cont = EwResponseContainer(id_server = id_server) response = "" channel = ewcfg.id_to_poi.get(poi).channel life_states = [ewcfg.life_state_juvenile, ewcfg.life_state_enlisted, ewcfg.life_state_executive] users = district_data.get_players_in_district(life_states = life_states) enemies = district_data.get_enemies_in_district() # damage players for user in users: user_data = EwUser(id_user = user, id_server = id_server) mutations = user_data.get_mutations() if True: player_data = EwPlayer(id_user = user_data.id_user) response = "{} is blown back by the explosion’s sheer force! They lose {} slime!!".format(player_data.display_name, damage) resp_cont.add_channel_response(channel, response) slimes_damage = damage if user_data.slimes < slimes_damage + user_data.bleed_storage: # die in the explosion district_data.change_slimes(n = user_data.slimes, source = ewcfg.source_killing) district_data.persist() slimes_dropped = user_data.totaldamage + user_data.slimes explode_damage = slime_bylevel(user_data.slimelevel) user_data.die(cause = ewcfg.cause_killing) #user_data.change_slimes(n = -slimes_dropped / 10, source = ewcfg.source_ghostification) user_data.persist() response = "Alas, {} was caught too close to the blast. They are consumed by the flames, and die in the explosion.".format(player_data.display_name) resp_cont.add_channel_response(channel, response) if ewcfg.mutation_id_spontaneouscombustion in mutations: sub_explosion = await explode(explode_damage, district_data) resp_cont.add_response_container(sub_explosion) await ewrolemgr.updateRoles(client = client, member = server.get_member(user_data.id_user)) else: # survive slime_splatter = 0.5 * slimes_damage district_data.change_slimes(n = slime_splatter, source = ewcfg.source_killing) district_data.persist() slimes_damage -= slime_splatter user_data.bleed_storage += slimes_damage user_data.change_slimes(n = -slime_splatter, source = ewcfg.source_killing) user_data.persist() # damage enemies for enemy in enemies: enemy_data = EwEnemy(id_enemy = enemy, id_server = id_server) if True: response = "{} is blown back by the explosion’s sheer force! They lose {} slime!!".format(enemy_data.display_name, damage) resp_cont.add_channel_response(channel, response) slimes_damage = damage if enemy_data.slimes < slimes_damage + enemy_data.bleed_storage: # die in the explosion district_data.change_slimes(n = enemy_data.slimes, source = ewcfg.source_killing) district_data.persist() # slimes_dropped = enemy_data.totaldamage + enemy_data.slimes # explode_damage = ewutils.slime_bylevel(enemy_data.level) response = "Alas, {} was caught too close to the blast. They are consumed by the flames, and die in the explosion.".format(enemy_data.display_name) response += "\n\n" + ewhunting.drop_enemy_loot(enemy_data, district_data) resp_cont.add_channel_response(channel, response) enemy_data.life_state = ewcfg.enemy_lifestate_dead enemy_data.persist() else: # survive slime_splatter = 0.5 * slimes_damage district_data.change_slimes(n = slime_splatter, source = ewcfg.source_killing) district_data.persist() slimes_damage -= slime_splatter enemy_data.bleed_storage += slimes_damage enemy_data.change_slimes(n = -slime_splatter, source = ewcfg.source_killing) enemy_data.persist() return resp_cont