async def revive(cmd, player_auto=None): time_now = int(time.time()) response = "" if cmd.message.channel.name != ewcfg.channel_endlesswar and cmd.message.channel.name != ewcfg.channel_sewers and player_auto is None: response = "Come to me. I hunger. #{}.".format(ewcfg.channel_sewers) else: if player_auto: player_data = EwUser(id_server=cmd.guild.id, id_user=player_auto) else: player_data = EwUser(member=cmd.message.author) # time_until_revive = (player_data.time_lastdeath + 600) - time_now time_until_revive = (player_data.time_lastdeath) - time_now if time_until_revive > 0 and player_auto is None: response = "ENDLESS WAR is not ready to {} you yet ({}s).".format( cmd.tokens[0], time_until_revive) return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) slimeoid = EwSlimeoid(member=cmd.message.author) if player_data.life_state == ewcfg.life_state_corpse: market_data = EwMarket(id_server=cmd.guild.id) # Endless War collects his fee. # fee = (player_data.slimecoin / 10) # player_data.change_slimecoin(n = -fee, coinsource = ewcfg.coinsource_revival) # market_data.slimes_revivefee += fee # player_data.busted = False # Preserve negaslime if player_data.slimes < 0: # market_data.negaslime += player_data.slimes player_data.change_slimes(n=-player_data.slimes) # set to 0 # reset slimelevel to zero player_data.slimelevel = 0 # Set time of last revive. This used to provied spawn protection, but currently isn't used. player_data.time_lastrevive = time_now if False: #player_data.degradation >= 100: player_data.life_state = ewcfg.life_state_shambler player_data.change_slimes(n=0.5 * ewcfg.slimes_shambler) player_data.trauma = "" poi_death = poi_static.id_to_poi.get(player_data.poi_death) if move_utils.inaccessible(poi=poi_death, user_data=player_data): player_data.poi = ewcfg.poi_id_endlesswar else: player_data.poi = poi_death.id_poi else: # Set life state. This is what determines whether the player is actually alive. player_data.life_state = ewcfg.life_state_juvenile # Give player some initial slimes. player_data.change_slimes(n=ewcfg.slimes_onrevive) # Get the player out of the sewers. player_data.poi = ewcfg.poi_id_endlesswar # Give newly spawned juvies a foul odour player_data.applyStatus(ewcfg.status_repelled_id) # Turn player's negaslimeoid into a core if they have one if slimeoid.sltype == ewcfg.sltype_nega: # Only create a negaslimeoid core if the negaslimeoid is fully conjured if slimeoid.life_state != ewcfg.slimeoid_state_forming: # Turn negaslimeoid into a negaslimeoid core item_props = { 'context': ewcfg.context_negaslimeoidheart, 'subcontext': slimeoid.id_slimeoid, 'item_name': "Core of {}".format(slimeoid.name), 'item_desc': "A smooth, inert rock. If you listen carefully you can hear otherworldly whispering." } bknd_item.item_create(id_user=ewcfg.channel_sewers, id_server=cmd.guild.id, item_type=ewcfg.it_item, item_props=item_props) # Kill the slimeoid and set player's active_slimeoid to -1 slimeoid.die() slimeoid.persist() player_data.active_slimeoid = -1 player_data.persist() market_data.persist() # Shower every district in the city with slime from the sewers. sewer_data = EwDistrict(district=ewcfg.poi_id_thesewers, id_server=cmd.guild.id) # the amount of slime showered is divided equally amongst the districts districts_amount = len(poi_static.capturable_districts) geyser_amount = int(0.5 * sewer_data.slimes / districts_amount) # Get a list of all the districts for poi in poi_static.capturable_districts: district_data = EwDistrict(district=poi, id_server=cmd.guild.id) district_data.change_slimes(n=geyser_amount) sewer_data.change_slimes(n=-1 * geyser_amount) district_data.persist() sewer_data.persist() sewer_inv = bknd_item.inventory(id_user=sewer_data.name, id_server=sewer_data.id_server) for item in sewer_inv: district = ewcfg.poi_id_slimesea if random.random() < 0.5: district = random.choice(poi_static.capturable_districts) bknd_item.give_item(id_item=item.get("id_item"), id_user=district, id_server=sewer_data.id_server) await ewrolemgr.updateRoles(client=cmd.client, member=cmd.message.author) response = '{slime4} Geysers of fresh slime erupt from every manhole in the city, showering their surrounding districts. {slime4} {name} has been reborn in slime. {slime4}'.format( slime4=ewcfg.emote_slime4, name=cmd.message.author.display_name) else: response = 'You\'re not dead just yet.' # deathreport = "You were {} by {}. {}".format(kill_descriptor, cmd.message.author.display_name, ewcfg.emote_slimeskull) # deathreport = "{} ".format(ewcfg.emote_slimeskull) + fe_utils.formatMessage(member, deathreport) if slimeoid.life_state == ewcfg.slimeoid_state_active and slimeoid.sltype != ewcfg.sltype_nega: reunite = "" brain = sl_static.brain_map.get(slimeoid.ai) reunite += brain.str_revive.format(slimeoid_name=slimeoid.name) new_poi = poi_static.id_to_poi.get(player_data.poi) revivechannel = fe_utils.get_channel(cmd.guild, new_poi.channel) reunite = fe_utils.formatMessage(cmd.message.author, reunite) await fe_utils.send_message(cmd.client, revivechannel, reunite) # Send the response to the player. await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def destroy_slimeoid(cmd): user_data = EwUser(member=cmd.message.author) slimeoid_data = EwSlimeoid(member=cmd.message.author) # Check of the player is alive if user_data.life_state != ewcfg.life_state_corpse: response = "You... want to destroy your Slimeoid? That's, like, sorta illegal." # Check if the player isn't at Waffle House as a ghost elif user_data.life_state == ewcfg.life_state_corpse and cmd.message.channel.name != ewcfg.channel_wafflehouse: response = "Slimeoids don't f**k with ghosts." # Check if the player has a slimeoid elif slimeoid_data.life_state == ewcfg.slimeoid_state_none: response = "Good news! You don't have a Slimeoid. So no need to destroy one." # If all of those don't work else: # Creates each type-specific heart. Also turns the slimeoid's type into a string, for flavor text purposes. if slimeoid_data.sltype == ewcfg.sltype_lab: # Creates string "Slimeoid" slimeoid_type = "Slimeoid" # Forming slimeoids DON'T drop hearts if slimeoid_data.life_state != ewcfg.slimeoid_state_forming: # Creates the item props for the slimeoid heart 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." } # Creates the item in downtown bknd_item.item_create(id_user=ewcfg.channel_downtown, id_server=cmd.guild.id, item_type=ewcfg.it_item, item_props=item_props) else: # Creates string "Negaslimeoid" slimeoid_type = "Negaslimeoid" # Forming negaslimeoids DON'T drop cores if slimeoid_data.life_state != ewcfg.slimeoid_state_forming: # Creates the item props for the negaslimeoid core item_props = { 'context': ewcfg.context_negaslimeoidheart, 'subcontext': slimeoid_data.id_slimeoid, 'item_name': "Core of {}".format(slimeoid_data.name), 'item_desc': "A smooth, inert rock. If you listen carefully you can hear otherworldly whispering." } # Creates the item at Waffle House bknd_item.item_create(id_user=ewcfg.channel_wafflehouse, id_server=cmd.guild.id, item_type=ewcfg.it_item, item_props=item_props) cosmetics = bknd_item.inventory(id_user=cmd.message.author.id, id_server=cmd.guild.id, item_type_filter=ewcfg.it_cosmetic) # get the cosmetics worn by the slimeoid for item in cosmetics: cos = EwItem(id_item=item.get('id_item')) if cos.item_props.get('slimeoid') == 'true': cos.item_props['slimeoid'] = 'false' cos.persist() # Craft the response response = "You think upon your past and spiritually connect with {} the {}. With the Ouija® Board in front of you, you spell out the forbidden words: \n\n\"lol\" \"lmao\" \n\nYour former companion is rended across space and time. All that remains is their {}, though unobtainable by you. {}".format( slimeoid_data.name, slimeoid_type, "heart" if slimeoid_type == "Slimeoid" else "core", ewcfg.emote_slimeskull) # Kill the slimeoid and persist slimeoid_data.die() slimeoid_data.persist() user_data.active_slimeoid = -1 # Take some of the player's negaslime for destroying a slimeoid. if user_data.slimes < 0: user_data.slimes -= user_data.slimes / 10 user_data.persist() # Go to final response # Final response await send_response(response, cmd)