async def get_quadrants(cmd): response = "" author = cmd.message.author if cmd.mentions_count > 0: member = cmd.mentions[0] else: member = author for quadrant in ewcfg.quadrant_ids: quadrant_data = EwQuadrant(id_server=cmd.guild.id, id_user=member.id, quadrant=quadrant) if quadrant_data.id_target != -1: response += "\n" response += get_quadrant(cmd, quadrant) if response == "": response = "{} quadrants are completely empty. " + ewcfg.emote_broken_heart if cmd.mentions_count > 0: response = response.format("Their") else: response = response.format("Your") user_data = EwUser(id_user=member.id, id_server=member.guild.id) if user_data.has_soul == 0: response = "{} can't truly form any bonds without {} soul." if cmd.mentions_count > 0: response = response.format("They", "their") else: response = response.format("You", "your") return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def clear_quadrant(cmd): response = "" author = cmd.message.author quadrant = None user_data = EwUser(id_user=author.id, id_server=author.guild.id) if user_data.life_state == ewcfg.life_state_shambler: response = "You lack the higher brain functions required to {}.".format( cmd.tokens[0]) return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) for token in cmd.tokens[1:]: if token.lower() in quad_static.quadrants_map: quadrant = quad_static.quadrants_map[token.lower()] if quadrant is not None: break if quadrant is None: response = "Please select a quadrant for your romantic feelings." return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) quadrant_data = EwQuadrant(id_server=author.guild.id, id_user=author.id, quadrant=quadrant.id_quadrant) if quadrant_data.id_target != -1: target_member_data = cmd.guild.get_member(quadrant_data.id_target) target_member_data_2 = None if quadrant_data.id_target2 != -1: target_member_data_2 = cmd.guild.get_member( quadrant_data.id_target) quadrant_data = EwQuadrant(id_server=author.guild.id, id_user=author.id, quadrant=quadrant.id_quadrant, id_target=-1, id_target2=-1) quadrant_data.persist() response = "You break up with {}. Maybe it's for the best...".format( target_member_data.display_name) if target_member_data_2 != None: response = "You break up with {} and {}. Maybe it's for the best...".format( target_member_data.display_name, target_member_data_2.display_name) else: response = "You haven't filled out that quadrant, bitch." return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))
async def haunt(cmd): time_now = int(time.time()) response = "" resp_cont = 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 = poi_static.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 = 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 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 weather_static.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 if ewcfg.dh_active: 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.clear_status(id_status=ewcfg.status_busted_id) 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 = poi_static.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 = fe_utils.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()
def get_quadrant(cmd, id_quadrant): author = cmd.message.author quadrant = quad_static.quadrants_map[id_quadrant] if cmd.mentions_count == 0: quadrant_data = EwQuadrant(id_server=author.guild.id, id_user=author.id, quadrant=quadrant.id_quadrant) if author.guild.get_member(quadrant_data.id_target) is None: quadrant_data.id_target = -1 if author.guild.get_member(quadrant_data.id_target2) is None: quadrant_data.id_target2 = -1 quadrant_data.persist() if quadrant_data.id_target == -1: response = "You have no one in this quadrant." else: onesided = quadrant_data.check_if_onesided() if quadrant.id_quadrant == ewcfg.quadrant_policitous and quadrant_data.id_target2 != -1: target_name = "{} and {}".format( author.guild.get_member( quadrant_data.id_target).display_name, author.guild.get_member( quadrant_data.id_target2).display_name) else: target_name = author.guild.get_member( quadrant_data.id_target).display_name if not onesided: response = quadrant.resp_view_relationship_self.format( target_name) else: response = quadrant.resp_view_onesided_self.format(target_name) else: member = cmd.mentions[0] quadrant_data = EwQuadrant(id_server=member.guild.id, id_user=member.id, quadrant=quadrant.id_quadrant) if author.guild.get_member(quadrant_data.id_target) is None: quadrant_data.id_target = -1 if author.guild.get_member(quadrant_data.id_target2) is None: quadrant_data.id_target2 = -1 quadrant_data.persist() if quadrant_data.id_target == "": response = "They have no one in this quadrant." else: onesided = quadrant_data.check_if_onesided() if quadrant.id_quadrant == ewcfg.quadrant_policitous and quadrant_data.id_target2 != -1: target_name = "{} and {}".format( author.guild.get_member( quadrant_data.id_target).display_name, author.guild.get_member( quadrant_data.id_target2).display_name) else: target_name = author.guild.get_member( quadrant_data.id_target).display_name if not onesided: response = quadrant.resp_view_relationship.format( member.display_name, target_name) else: response = quadrant.resp_view_onesided.format( member.display_name, target_name) return response
async def add_quadrant(cmd): response = "" author = cmd.message.author quadrant = None user_data = EwUser(id_user=author.id, id_server=author.guild.id) if user_data.life_state == ewcfg.life_state_shambler: response = "You lack the higher brain functions required to {}.".format( cmd.tokens[0]) return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) for token in cmd.tokens[1:]: if token.lower() in quad_static.quadrants_map: quadrant = quad_static.quadrants_map[token.lower()] if quadrant is not None: break if quadrant is None: response = "Please select a quadrant for your romantic feelings." return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) if cmd.mentions_count == 0: response = "Please select a target for your romantic feelings." return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) if user_data.has_soul == 0: response = "A soulless juvie can only desperately reach for companionship, they will never find it." return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response)) target = cmd.mentions[0].id target2 = None if quadrant.id_quadrant == ewcfg.quadrant_policitous and cmd.mentions_count > 1: target2 = cmd.mentions[1].id quadrant_data = EwQuadrant(id_server=author.guild.id, id_user=author.id, quadrant=quadrant.id_quadrant, id_target=target, id_target2=target2) onesided = quadrant_data.check_if_onesided() if onesided: comment = random.choice(ewcfg.quadrants_comments_onesided) resp_add = quadrant.resp_add_onesided else: comment = random.choice(ewcfg.quadrants_comments_relationship) resp_add = quadrant.resp_add_relationship if target2 is None: resp_add = resp_add.format(cmd.mentions[0].display_name) else: resp_add = resp_add.format("{} and {}".format( cmd.mentions[0].display_name, cmd.mentions[1].display_name)) response = "{} {}".format(resp_add, comment) return await fe_utils.send_message( cmd.client, cmd.message.channel, fe_utils.formatMessage(cmd.message.author, response))