Exemple #1
0
async def give_kingpins_slime_and_decay_capture_points(id_server):
	resp_cont_decay_loop = ewutils.EwResponseContainer(client = ewutils.get_client(), id_server = id_server)

	for kingpin_role in [ewcfg.role_rowdyfucker, ewcfg.role_copkiller]:
		kingpin = ewutils.find_kingpin(id_server = id_server, kingpin_role = kingpin_role)

		if kingpin is not None:
			total_slimegain = 0
			for id_district in ewcfg.capturable_districts:

				district = EwDistrict(id_server = id_server, district = id_district)

				# if the kingpin is controlling this district give the kingpin slime based on the district's property class
				if district.controlling_faction == (ewcfg.faction_killers if kingpin.faction == ewcfg.faction_killers else ewcfg.faction_rowdys):
					poi = ewcfg.id_to_poi.get(id_district)

					slimegain = ewcfg.district_control_slime_yields[poi.property_class]

					# increase slimeyields by 10 percent per friendly neighbor
					friendly_mod = 1 + 0.1 * district.get_number_of_friendly_neighbors()
					total_slimegain += slimegain * friendly_mod

			kingpin.change_slimes(n = total_slimegain)
			kingpin.persist()

			ewutils.logMsg(kingpin_role + " just received %d" % total_slimegain + " slime for their captured districts.")

	# Decay capture points.
	for id_district in ewcfg.capturable_districts:
		district = EwDistrict(id_server = id_server, district = id_district)

		responses =  district.decay_capture_points()
		resp_cont_decay_loop.add_response_container(responses)
		district.persist()
Exemple #2
0
async def print_grid(cmd):
    grid_str = ""
    user_data = EwUser(member=cmd.message.author)
    poi = user_data.poi
    id_server = cmd.message.server.id
    time_now = int(time.time())
    if poi in mines_map:
        grid_map = mines_map.get(poi)
        if id_server not in grid_map:
            init_grid_ms(poi, id_server)
        grid_cont = grid_map.get(id_server)

        grid = grid_cont.grid

        grid_str += "   "
        for j in range(len(grid[0])):
            grid_str += "{} ".format(ewcfg.alphabet[j])
        grid_str += "\n"
        for i in range(len(grid)):
            row = grid[i]
            if i + 1 < 10:
                grid_str += " "

            grid_str += "{} ".format(i + 1)
            for j in range(len(row)):
                cell = row[j]
                cell_str = get_cell_symbol(cell)
                grid_str += cell_str + " "
            grid_str += "{}".format(i + 1)
            grid_str += "\n"

        grid_str += "   "
        for j in range(len(grid[0])):
            grid_str += "{} ".format(ewcfg.alphabet[j])

        grid_edit = "\n```\n{}\n```".format(grid_str)
        #grid_edit = grid_str
        if time_now > grid_cont.time_last_posted + 10 or grid_cont.times_edited > 8 or grid_cont.message == "":
            grid_cont.message = await ewutils.send_message(
                cmd.client, cmd.message.channel,
                ewutils.formatMessage(cmd.message.author, grid_edit))
            grid_cont.time_last_posted = time_now
            grid_cont.times_edited = 0
        else:
            await ewutils.edit_message(
                cmd.client, grid_cont.message,
                ewutils.formatMessage(cmd.message.author, grid_edit))
            grid_cont.times_edited += 1

        if grid_cont.wall_message == "":
            wall_channel = ewcfg.mines_wall_map.get(poi)
            resp_cont = ewutils.EwResponseContainer(id_server=id_server)
            resp_cont.add_channel_response(wall_channel, grid_edit)
            msg_handles = await resp_cont.post()
            grid_cont.wall_message = msg_handles[0]
        else:
            await ewutils.edit_message(cmd.client, grid_cont.wall_message,
                                       grid_edit)
Exemple #3
0
async def event_tick(id_server):
    time_now = int(time.time())
    resp_cont = ewutils.EwResponseContainer(id_server=id_server)
    if True:
        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:
            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_data.event_type == ewcfg.event_type_minecollapse:
                user_data = EwUser(
                    id_user=event_data.event_props.get('id_user'),
                    id_server=id_server)
                if user_data.poi == event_data.event_props.get('poi'):
                    user_data.change_slimes(n=-(user_data.slimes * 0.5))
                    user_data.persist()

                    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 len(response) > 0:
                poi = event_data.event_props.get('poi')
                channel = event_data.event_props.get('channel')
                if channel != None:
                    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)

        await resp_cont.post()

    else:
        ewutils.logMsg("Error in event tick for server {}".format(id_server))
Exemple #4
0
    def change_capture_lock(self, progress):
        resp_cont = ewutils.EwResponseContainer(id_server=self.id_server)

        progress_before = self.time_unlock

        self.time_unlock += progress

        if self.time_unlock < 0:
            self.time_unlock == 0

        progress_after = self.time_unlock

        if (progress_after // ewcfg.capture_lock_milestone) != (
                progress_before // ewcfg.capture_lock_milestone):
            time_mins = ewutils.formatNiceTime(seconds=progress_after,
                                               round_to_minutes=True)
            if progress < 0:
                if progress_before >= 15 * 60 >= progress_after:
                    message = "{district} will unlock for capture in {time}.".format(
                        district=ewcfg.id_to_poi[self.name].str_name,
                        time=time_mins)
                    channels = ewcfg.hideout_channels

                    for ch in channels:
                        resp_cont.add_channel_response(channel=ch,
                                                       response=message)

                elif progress_before >= 5 * 60 >= progress_after:
                    message = "{district} will unlock for capture in {time}.".format(
                        district=ewcfg.id_to_poi[self.name].str_name,
                        time=time_mins)
                    channels = ewcfg.hideout_channels

                    for ch in channels:
                        resp_cont.add_channel_response(channel=ch,
                                                       response=message)

                message = "{district} will unlock for capture in {time}.".format(
                    district=ewcfg.id_to_poi[self.name].str_name,
                    time=time_mins)

                channels = [ewcfg.id_to_poi[self.name].channel]

                for ch in channels:
                    resp_cont.add_channel_response(channel=ch,
                                                   response=message)

        if self.time_unlock == 0 and progress < 0:
            chip_cont = self.change_capture_points(progress=-1,
                                                   actor=ewcfg.actor_decay)
            resp_cont.add_response_container(chip_cont)

        return resp_cont
Exemple #5
0
	def decay_capture_points(self):
		resp_cont_decay = ewutils.EwResponseContainer(client = ewutils.get_client(), id_server = self.id_server)
		if self.capture_points > 0:
				#and self.time_unlock == 0:

			neighbors = ewcfg.poi_neighbors[self.name]
			all_neighbors_friendly = self.all_neighbors_friendly()

			decay = -math.ceil(ewcfg.limit_influence_a / (ewcfg.ticks_per_day * ewcfg.decay_modifier))
			#decay = -math.ceil(ewcfg.max_capture_points_a / (ewcfg.ticks_per_day * ewcfg.decay_modifier))

			slimeoids = ewutils.get_slimeoids_in_poi(poi = self.name, id_server = self.id_server, sltype = ewcfg.sltype_nega)
			
			nega_present = len(slimeoids) > 0

			poi = ewcfg.id_to_poi.get(self.name)
			father_poi = ewcfg.id_to_poi.get(poi.father_district)
			num_districts = len(ewutils.get_street_list(poi.father_district))

			if nega_present:
				decay *= 1.5
			if self.capture_points + (decay * 3) > (ewcfg.limit_influence[father_poi.property_class])/num_districts:
				decay *= 3

			if self.controlling_faction == "" or (not self.all_neighbors_friendly() and self.capture_points > ewcfg.limit_influence[father_poi.property_class]/num_districts) or nega_present:  # don't decay if the district is completely surrounded by districts controlled by the same faction
				# reduces the capture progress at a rate with which it arrives at 0 after 1 in-game day
				#if (self.capture_points + int(decay) < ewcfg.min_influence[self.property_class] and self.capture_points >= ewcfg.min_influence[self.property_class]) and not nega_present and self.controlling_faction != "":
				#	responses = self.change_capture_points(self.capture_points - ewcfg.min_influence[self.property_class], ewcfg.actor_decay)
				#else:
				responses = self.change_capture_points(int(decay), ewcfg.actor_decay)
				resp_cont_decay.add_response_container(responses)

		#if self.capture_points < 0:
		#	self.capture_points = 0

		if self.capture_points <= 0:
			if self.controlling_faction != "":  # if it was owned by a faction

				message = "The {faction} have lost control over {district} because of sheer negligence.".format(
					faction = self.controlling_faction,
					district = ewcfg.id_to_poi[self.name].str_name
				)
				channels = [ewcfg.id_to_poi[self.name].channel] + ewcfg.hideout_channels
				for ch in channels:
					resp_cont_decay.add_channel_response(channel = ch, response = message)
			responses = self.change_ownership("", ewcfg.actor_decay)
			resp_cont_decay.add_response_container(responses)
			self.capturing_faction = ""
		return resp_cont_decay
Exemple #6
0
    def change_capture_lock(self, progress):
        resp_cont = ewutils.EwResponseContainer(id_server=self.id_server)

        progress_before = self.time_unlock

        self.time_unlock += progress

        if self.time_unlock < 0:
            self.time_unlock == 0

        progress_after = self.time_unlock

        if (progress_after // ewcfg.capture_lock_milestone) != (
                progress_before // ewcfg.capture_lock_milestone):
            time_mins = round(progress_after / 60)
            if progress < 0:
                if progress_before >= 15 * 60 >= progress_after:
                    message = "{district} will unlock for capture in {time} minutes.".format(
                        district=ewcfg.id_to_poi[self.name].str_name,
                        time=time_mins)
                    channels = ewcfg.hideout_channels

                    for ch in channels:
                        resp_cont.add_channel_response(channel=ch,
                                                       response=message)

                elif progress_before >= 5 * 60 >= progress_after:
                    message = "{district} will unlock for capture in {time} minutes.".format(
                        district=ewcfg.id_to_poi[self.name].str_name,
                        time=time_mins)
                    channels = ewcfg.hideout_channels

                    for ch in channels:
                        resp_cont.add_channel_response(channel=ch,
                                                       response=message)

                message = "{district} will unlock for capture in {time} minutes.".format(
                    district=ewcfg.id_to_poi[self.name].str_name,
                    time=time_mins)

                channels = [ewcfg.id_to_poi[self.name].channel]

                for ch in channels:
                    resp_cont.add_channel_response(channel=ch,
                                                   response=message)

        return resp_cont
Exemple #7
0
    def decay_capture_points(self):
        resp_cont_decay = ewutils.EwResponseContainer(
            client=ewutils.get_client(), id_server=self.id_server)
        if self.capture_points > 0:

            neighbors = ewcfg.poi_neighbors[self.name]
            all_neighbors_friendly = self.all_neighbors_friendly()

            decay = -math.ceil(ewcfg.max_capture_points_a /
                               (ewcfg.ticks_per_day * ewcfg.decay_modifier))

            slimeoids = ewutils.get_slimeoids_in_poi(poi=self.name,
                                                     id_server=self.id_server,
                                                     sltype=ewcfg.sltype_nega)

            nega_present = len(slimeoids) > 0

            if nega_present:
                decay *= 1.5

            if self.controlling_faction == "" or not all_neighbors_friendly or nega_present:  # don't decay if the district is completely surrounded by districts controlled by the same faction
                # reduces the capture progress at a rate with which it arrives at 0 after 1 in-game day
                responses = self.change_capture_points(int(decay),
                                                       ewcfg.actor_decay)
                resp_cont_decay.add_response_container(responses)

        if self.capture_points < 0:
            self.capture_points = 0

        if self.capture_points == 0:
            if self.controlling_faction != "":  # if it was owned by a faction

                message = "The {faction} have lost control over {district} because of sheer negligence.".format(
                    faction=self.controlling_faction,
                    district=ewcfg.id_to_poi[self.name].str_name)
                channels = [ewcfg.id_to_poi[self.name].channel
                            ] + ewcfg.hideout_channels
                for ch in channels:
                    resp_cont_decay.add_channel_response(channel=ch,
                                                         response=message)
            responses = self.change_ownership("", ewcfg.actor_decay)
            resp_cont_decay.add_response_container(responses)
            self.capturing_faction = ""

        return resp_cont_decay
Exemple #8
0
async def slimeball_tick(id_server):
	resp_cont = ewutils.EwResponseContainer(id_server = id_server)

	for id_game in sb_games:
		game = sb_games.get(id_game)
		if game == None:
			continue
		if game.id_server == id_server:
			if len(game.players) > 0:
				for player in game.players:
					resp_cont.add_response_container(player.move())

				resp_cont.add_response_container(game.move_ball())

			else:
				poi_data = ewcfg.id_to_poi.get(game.poi)
				response = "Slimeball game ended with score purple {} : {} pink.".format(game.score_purple, game.score_pink)
				resp_cont.add_channel_response(poi_data.channel, response)
					
				game.kill()

	await resp_cont.post()
Exemple #9
0
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 move_loop(self):
		response = ""
		poi_data = ewcfg.id_to_poi.get(self.poi)
		last_messages = []
		while not ewutils.TERMINATE:

			district_data = EwDistrict(district = self.poi, id_server = self.id_server)

			if district_data.is_degraded():
				return

			transport_line = ewcfg.id_to_transport_line[self.current_line]
			client = ewutils.get_client()
			resp_cont = ewutils.EwResponseContainer(client = client, id_server = self.id_server)

			if self.current_stop == transport_line.last_stop:
				self.current_line = transport_line.next_line
				self.persist()
			else:
				schedule = transport_line.schedule[self.current_stop]
				await asyncio.sleep(schedule[0])
				for message in last_messages:
					try:
						await message.delete()
						pass
					except:
						ewutils.logMsg("Failed to delete message while moving transport {}.".format(transport_line.str_name))
				self.current_stop = schedule[1]
				self.persist()

				stop_data = ewcfg.id_to_poi.get(self.current_stop)

				# announce new stop inside the transport
				# if stop_data.is_subzone:
				# 	stop_mother = ewcfg.id_to_poi.get(stop_data.mother_district)
				# 	response = "We have reached {}.".format(stop_mother.str_name)
				# else:
				response = "We have reached {}.".format(stop_data.str_name)

				next_line = transport_line

				if stop_data.is_transport_stop:
					response += " You may exit now."

				if stop_data.id_poi == transport_line.last_stop:
					next_line = ewcfg.id_to_transport_line[transport_line.next_line]
					response += " This {} will proceed on {}.".format(self.transport_type, next_line.str_name.replace("The", "the"))
				else:
					next_stop = ewcfg.id_to_poi.get(transport_line.schedule.get(stop_data.id_poi)[1])
					if next_stop.is_transport_stop:
						# if next_stop.is_subzone:
						# 	stop_mother = ewcfg.id_to_poi.get(next_stop.mother_district)
						# 	response += " The next stop is {}.".format(stop_mother.str_name)
						# else:
						response += " The next stop is {}.".format(next_stop.str_name)
				resp_cont.add_channel_response(poi_data.channel, response)

				# announce transport has arrived at the stop
				if stop_data.is_transport_stop:
					response = "{} has arrived. You may board now.".format(next_line.str_name)
					resp_cont.add_channel_response(stop_data.channel, response)
				elif self.transport_type == ewcfg.transport_type_ferry:
					response = "{} sails by.".format(next_line.str_name)
					resp_cont.add_channel_response(stop_data.channel, response)
				elif self.transport_type == ewcfg.transport_type_blimp:
					response = "{} flies overhead.".format(next_line.str_name)
					resp_cont.add_channel_response(stop_data.channel, response)


				last_messages = await resp_cont.post()
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))
Exemple #12
0
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))
Exemple #13
0
async def capture_tick(id_server):
	# the variables might apparently be accessed before assignment if i didn't declare them here
	cursor = None
	conn_info = None

	resp_cont_capture_tick = ewutils.EwResponseContainer(client = ewutils.get_client(), id_server = id_server)

	all_districts = ewcfg.capturable_districts


	if len(all_districts) > 0:  # if all_districts isn't empty
		server = ewcfg.server_list[id_server]
		time_old = time.time()

		for district in all_districts:
			district_name = district
			dist = EwDistrict(id_server = id_server, district = district_name)

			if dist.time_unlock > 0 and not dist.all_neighbors_friendly():
				responses = dist.change_capture_lock(progress = -ewcfg.capture_tick_length)
				resp_cont_capture_tick.add_response_container(responses)
				dist.persist()

			if dist.time_unlock > 0:
				continue

			# no more automatic capping
			continue

			controlling_faction = dist.controlling_faction

			gangsters_in_district = dist.get_players_in_district(min_slimes = ewcfg.min_slime_to_cap, life_states = [ewcfg.life_state_enlisted], ignore_offline = True)
					

			slimeoids = ewutils.get_slimeoids_in_poi(poi = district_name, id_server = id_server, sltype = ewcfg.sltype_nega)
			
			nega_present = len(slimeoids) > 0
#			if nega_present:
#				continue

			# the faction that's actively capturing the district this tick
			# if no players are present, it's None, if only players of one faction (ignoring juvies and ghosts) are,
			# it's the faction's name, i.e. 'rowdys' or 'killers', and if both are present, it's 'both'
			faction_capture = None

			# how much progress will be made. is higher the more people of one faction are in a district, and is 0 if both teams are present
			capture_speed = 0

			# number of players actively capturing
			num_capturers = 0

			dc_stat_increase_list = []

			# checks if any players are in the district and if there are only players of the same faction, i.e. progress can happen
			for player in gangsters_in_district:
				player_id = player
				user_data = EwUser(id_user = player_id, id_server = id_server)
				player_faction = user_data.faction

				mutations = user_data.get_mutations()

				try:
					player_online = server.get_member(player_id).status != discord.Status.offline
				except:
					player_online = False

				#ewutils.logMsg("Online status checked. Time elapsed: %f" % (time.time() - time_old) + " Server: %s" % id_server + " Player: %s" % player_id + " Status: %s" % ("online" if player_online else "offline"))

				if player_online:
					if faction_capture not in [None, player_faction]:  # if someone of the opposite faction is in the district
						faction_capture = 'both'  # standstill, gang violence has to happen
						capture_speed = 0
						num_capturers = 0
						dc_stat_increase_list.clear()

					else:  # if the district isn't already controlled by the player's faction and the capture isn't halted by an enemy
						faction_capture = player_faction
						player_capture_speed = 1
						if ewcfg.mutation_id_lonewolf in mutations and len(gangsters_in_district) == 1:
							player_capture_speed *= 2
						if ewcfg.mutation_id_patriot in mutations:
							player_capture_speed *= 2
							

						capture_speed += player_capture_speed
						num_capturers += 1
						dc_stat_increase_list.append(player_id)


			if faction_capture not in ['both', None]:  # if only members of one faction is present
				if district_name in ewcfg.capturable_districts:
					friendly_neighbors = dist.get_number_of_friendly_neighbors()
					if dist.all_neighbors_friendly():
						capture_speed = 0
					elif dist.controlling_faction == faction_capture:
						capture_speed *= 1 + 0.1 * friendly_neighbors
					else:
						capture_speed /= 1 + 0.1 * friendly_neighbors

					capture_progress = dist.capture_points

					if faction_capture != dist.capturing_faction:
						capture_progress *= -1

					capture_speed *= ewcfg.baseline_capture_speed


					if dist.capture_points < dist.max_capture_points:
						for stat_recipient in dc_stat_increase_list:
							ewstats.change_stat(
								id_server = id_server,
								id_user = stat_recipient,
								metric = ewcfg.stat_capture_points_contributed,
								n = ewcfg.capture_tick_length * capture_speed
							)

					if faction_capture == dist.capturing_faction:  # if the faction is already in the process of capturing, continue
						responses = dist.change_capture_points(ewcfg.capture_tick_length * capture_speed, faction_capture, num_capturers)
						resp_cont_capture_tick.add_response_container(responses)

					elif dist.capture_points == 0 and dist.controlling_faction == "":  # if it's neutral, start the capture
						responses =  dist.change_capture_points(ewcfg.capture_tick_length * capture_speed, faction_capture, num_capturers)
						resp_cont_capture_tick.add_response_container(responses)

						dist.capturing_faction = faction_capture

					# lower the enemy faction's progress to revert it to neutral (or potentially get it onto your side without becoming neutral first)
					else:  # if the (de-)capturing faction is not in control
						responses =  dist.change_capture_points(-(ewcfg.capture_tick_length * capture_speed * ewcfg.decapture_speed_multiplier), faction_capture)
						resp_cont_capture_tick.add_response_container(responses)

					dist.persist()
Exemple #14
0
async def annex(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 = ""
    resp_cont = ewutils.EwResponseContainer(id_server=cmd.message.server.id)
    time_now = int(time.time())

    poi = ewcfg.id_to_poi.get(user_data.poi)

    if user_data.life_state == ewcfg.life_state_corpse:
        response = "You ineffectively try shaking your can of spraypaint to whip up some sick graffiti. Alas, you’re all outta slime. " \
                         "They should really make these things compatible with ectoplasm."
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    if not (len(user_data.faction) > 0
            and user_data.life_state == ewcfg.life_state_enlisted):
        response = "Juveniles are too chickenshit to make graffiti and risk getting busted by the cops. F****n’ losers."
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    if user_data.poi in [
            ewcfg.poi_id_rowdyroughhouse, ewcfg.poi_id_copkilltown
    ]:
        response = "There’s no point, the rest of your gang has already covered this place in spraypaint. Focus on exporting your graffiti instead."
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    if user_data.poi == ewcfg.poi_id_juviesrow:
        response = "Nah, the Rowdys and Killers have both agreed this is neutral ground. You don’t want to start a diplomatic crisis, " \
                         "just stick to spraying down sick graffiti and splattering your rival gang across the pavement in the other districts."
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    if not user_data.poi in ewcfg.capturable_districts:
        response = "This zone cannot be captured."
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    district_data = EwDistrict(id_server=user_data.id_server,
                               district=user_data.poi)

    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 district_data.time_unlock > 0:
        response = "You can’t spray graffiti here yet, it’s too soon after your rival gang extended their own cultural dominance over it. Try again in {}.".format(
            ewutils.formatNiceTime(seconds=district_data.time_unlock,
                                   round_to_minutes=True))
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    if district_data.all_neighbors_friendly():
        response = "What the hell are you doing, dude? You can’t put down any graffiti here, it’s been completely overrun by your rival gang. " \
                         "You can only spray districts that have at least one unfriendly neighbor, duh!"
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    users_in_district = district_data.get_players_in_district(
        life_states=[ewcfg.life_state_enlisted],
        ignore_offline=True,
        pvp_only=True)

    allies_in_district = district_data.get_players_in_district(
        factions=[user_data.faction],
        life_states=[ewcfg.life_state_enlisted],
        ignore_offline=True,
        pvp_only=True)

    if len(users_in_district) > len(allies_in_district):
        response = "Holy shit, deal with your rival gangsters first! You can’t spray graffiti while they’re on the prowl!"
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    mutations = user_data.get_mutations()

    slimes_spent = ewutils.getIntToken(tokens=cmd.tokens, allow_all=True)
    capture_discount = 1

    if ewcfg.mutation_id_lonewolf in mutations:
        if user_data.time_expirpvp > time_now:
            if len(users_in_district) == 1:
                capture_discount *= 0.8
        else:
            if len(users_in_district) == 0:
                capture_discount *= 0.8

    if ewcfg.mutation_id_patriot in mutations:
        capture_discount *= 0.8

    if slimes_spent == None:
        response = "How much slime do you want to spend on spraying graffiti in this district?"
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    if slimes_spent < 0:
        slimes_spent = user_data.slimes

    if slimes_spent > user_data.slimes:
        response = "You don't have that much slime, retard."
        return await ewutils.send_message(
            cmd.client, cmd.message.channel,
            ewutils.formatMessage(cmd.message.author, response))

    num_lock = len(allies_in_district)
    if user_data.time_expirpvp < time_now:
        num_lock += 1

    if (district_data.controlling_faction not in [
            "", user_data.faction
    ]) or (district_data.capturing_faction not in ["", user_data.faction]):
        slimes_decap = min(district_data.capture_points,
                           int(slimes_spent / capture_discount))
        decap_resp = district_data.change_capture_points(
            progress=-slimes_decap, actor=user_data.faction, num_lock=num_lock)
        resp_cont.add_response_container(decap_resp)

        user_data.change_slimes(n=-slimes_decap * capture_discount,
                                source=ewcfg.source_spending)
        slimes_spent -= slimes_decap * capture_discount

    slimes_cap = min(
        district_data.max_capture_points - district_data.capture_points,
        int(slimes_spent / capture_discount))
    cap_resp = district_data.change_capture_points(progress=slimes_cap,
                                                   actor=user_data.faction,
                                                   num_lock=num_lock)
    resp_cont.add_response_container(cap_resp)

    user_data.change_slimes(n=-slimes_cap * capture_discount,
                            source=ewcfg.source_spending)

    # Flag the user for PvP
    user_data.time_expirpvp = ewutils.calculatePvpTimer(
        user_data.time_expirpvp, ewcfg.time_pvp_annex, True)

    user_data.persist()
    district_data.persist()
    await ewrolemgr.updateRoles(client=cmd.client, member=cmd.message.author)

    return await resp_cont.post()
Exemple #15
0
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 disembark(cmd):
	# can only use movement commands in location channels
	if ewmap.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)

	# can only disembark when you're on a transport vehicle
	if 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()

		# 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
			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:
			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
				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
			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:
			user_data.poi = transport_data.current_stop
			user_data.persist()
			response = "You enter {}".format(stop_poi.str_name)
			await ewrolemgr.updateRoles(client = cmd.client, member = cmd.message.author)
			return await ewutils.send_message(cmd.client, ewutils.get_channel(cmd.message.server, stop_poi.channel), ewutils.formatMessage(cmd.message.author, response))
		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))
Exemple #17
0
	def die(self, cause = None):
		time_now = int(time.time())

		ewutils.end_trade(self.id_user)

		resp_cont = ewutils.EwResponseContainer(id_server = self.id_server)

		client = ewcfg.get_client()
		server = client.get_server(self.id_server)

		deathreport = ''
		
		# remove ghosts inhabiting player
		self.remove_inhabitation()

		# Make The death report
		deathreport = ewutils.create_death_report(cause = cause, user_data = self)
		resp_cont.add_channel_response(ewcfg.channel_sewers, deathreport)

		poi = ewcfg.id_to_poi.get(self.poi)
		if cause == ewcfg.cause_weather:
			resp_cont.add_channel_response(poi.channel, deathreport)

		# Grab necessary data for spontaneous combustion before stat reset
		explosion_block_list = [ewcfg.cause_leftserver, ewcfg.cause_cliff]
		user_hasCombustion = False
		if (cause not in explosion_block_list) and (poi.pvp):
			if ewcfg.mutation_id_spontaneouscombustion in self.get_mutations():
				user_hasCombustion = True
				explode_damage = ewutils.slime_bylevel(self.slimelevel) / 5
				explode_district = ewdistrict.EwDistrict(district = self.poi, id_server = self.id_server)
				explode_poi_channel = ewcfg.id_to_poi.get(self.poi).channel

		if cause == ewcfg.cause_busted:
			self.busted = True
			self.poi = ewcfg.poi_id_thesewers
			#self.slimes = int(self.slimes * 0.9)
		else:
			self.busted = False  # reset busted state on normal death; potentially move this to ewspooky.revive
			self.slimes = 0
			self.slimelevel = 1
			self.clear_mutations()
			self.clear_allstatuses()
			self.totaldamage = 0
			self.bleed_storage = 0
			self.hunger = 0
			self.inebriation = 0
			self.bounty = 0
			self.time_lastdeath = time_now		
	
			# if self.life_state == ewcfg.life_state_shambler:
			# 	self.degradation += 1
			# else:
			# 	self.degradation += 5

			ewstats.increment_stat(user = self, metric = ewcfg.stat_lifetime_deaths)
			ewstats.change_stat(user = self, metric = ewcfg.stat_lifetime_slimeloss, n = self.slimes)

			if cause == ewcfg.cause_cliff:
				pass
			else:
				if self.life_state == ewcfg.life_state_juvenile: # If you were a Juvenile.
					item_fraction = 4
					food_fraction = 4
					cosmetic_fraction = 4

				else:  # If you were a Gangster.
					item_fraction = 2
					food_fraction = 2
					cosmetic_fraction = 2
					self.slimecoin = int(self.slimecoin) - (int(self.slimecoin) / 10)

				ewitem.item_dropsome(id_server = self.id_server, id_user = self.id_user, item_type_filter = ewcfg.it_item, fraction = item_fraction) # Drop a random fraction of your items on the ground.
				ewitem.item_dropsome(id_server = self.id_server, id_user = self.id_user, item_type_filter = ewcfg.it_food, fraction = food_fraction) # Drop a random fraction of your food on the ground.

				ewitem.item_dropsome(id_server = self.id_server, id_user = self.id_user, item_type_filter = ewcfg.it_cosmetic, fraction = cosmetic_fraction) # Drop a random fraction of your unadorned cosmetics on the ground.
				ewitem.item_dedorn_cosmetics(id_server = self.id_server, id_user = self.id_user) # Unadorn all of your adorned hats.
				self.freshness = 0

				ewitem.item_dropsome(id_server = self.id_server, id_user = self.id_user, item_type_filter = ewcfg.it_weapon, fraction = 1) # Drop random fraction of your unequipped weapons on the ground.
				ewutils.weaponskills_clear(id_server = self.id_server, id_user = self.id_user, weaponskill = ewcfg.weaponskill_max_onrevive)

			self.life_state = ewcfg.life_state_corpse
			self.poi_death = self.poi
			self.poi = ewcfg.poi_id_thesewers
			self.weapon = -1
			self.time_expirpvp = 0

		if cause == ewcfg.cause_killing_enemy:  # If your killer was an Enemy. Duh.
			ewstats.increment_stat(user = self, metric = ewcfg.stat_lifetime_pve_deaths)

		if cause == ewcfg.cause_leftserver:
			ewitem.item_dropall(id_server=self.id_server, id_user=self.id_user)

		self.sap = 0
		self.hardened_sap = 0
		self.attack = 0
		self.defense = 0
		self.speed = 0

		ewutils.moves_active[self.id_user] = 0
		ewutils.active_target_map[self.id_user] = ""
		ewutils.active_restrictions[self.id_user] = 0
		ewstats.clear_on_death(id_server = self.id_server, id_user = self.id_user)

		self.persist()

		if cause not in explosion_block_list: # Run explosion after location/stat reset, to prevent looping onto self
			if user_hasCombustion:
				explode_resp = "\n{} spontaneously combusts, horribly dying in a fiery explosion of slime and shrapnel!! Oh, the humanity!\n".format(server.get_member(self.id_user).display_name)
				ewutils.logMsg("")
				resp_cont.add_channel_response(explode_poi_channel, explode_resp)

				explosion = ewutils.explode(damage = explode_damage, district_data = explode_district)
				resp_cont.add_response_container(explosion)

		#ewitem.item_destroyall(id_server = self.id_server, id_user = self.id_user)

		ewutils.logMsg('server {}: {} was killed by {} - cause was {}'.format(self.id_server, self.id_user, self.id_killer, cause))

		return(resp_cont)
Exemple #18
0
	def move(self):
		resp_cont = ewutils.EwResponseContainer(id_server = self.id_server)
		abs_x = abs(self.velocity[0])
		abs_y = abs(self.velocity[1])
		abs_sum = abs_x + abs_y
		if abs_sum == 0:
			return resp_cont

		if random.random() * abs_sum < abs_x:
			move = [self.velocity[0] / abs_x, 0]
		else:
			move = [0, self.velocity[1] / abs_y]


		move_vector = ewutils.EwVector2D(move)
		position_vector = ewutils.EwVector2D(self.coords)

		destination_vector = position_vector.add(move_vector)

		global sb_games
		game_data = sb_games.get(self.id_game)

		player_data = EwPlayer(id_user = self.id_user)
		response = ""
		ball_contact = False
		for i in range(-1, 2):
			for j in range(-1, 2):
				neighbor_direction = [i, j]
				neighbor_vector = ewutils.EwVector2D(neighbor_direction)
				if move_vector.scalar_product(neighbor_vector) > 0:
					neighbor_position = position_vector.add(neighbor_vector)
					if neighbor_position.vector == game_data.ball_coords:
						ball_contact = True
						break

		if ball_contact:
			game_data.ball_velocity = [round(5 * self.velocity[0]), round(5 * self.velocity[1])]
			game_data.last_contact = self.id_player
			self.velocity = [0, 0]
			response = "{} has kicked the ball in direction {}!".format(player_data.display_name, game_data.ball_velocity)

		elif game_data.coords_free(destination_vector.vector):
			self.coords = destination_vector.vector

		elif game_data.out_of_bounds(destination_vector.vector):
			self.velocity = [0, 0]
			response = "{} has walked against the outer bounds and stopped at {}.".format(player_data.display_name, self.coords)
		else:
			vel = self.velocity

			for p in game_data.players:
				if p.coords == destination_vector.vector:
					self.velocity = p.velocity
					p.velocity = vel
					other_player_data = EwPlayer(id_user = p.id_user)
					response = "{} has collided with {}.".format(player_data.display_name, other_player_data.display_name)
					break			
					
		if len(response) > 0:
			poi_data = ewcfg.id_to_poi.get(game_data.poi)
			resp_cont.add_channel_response(poi_data.channel, response)

		return resp_cont
Exemple #19
0
	def move_ball(self):
		resp_cont = ewutils.EwResponseContainer(id_server = self.id_server)
		abs_x = abs(self.ball_velocity[0])
		abs_y = abs(self.ball_velocity[1])
		abs_sum = abs_x + abs_y
		if abs_sum == 0:
			return resp_cont

		move = [self.ball_velocity[0], self.ball_velocity[1]]
		whole_move_vector = ewutils.EwVector2D(move)

		response = ""
		while abs_sum != 0:
			if random.random() * abs_sum < abs_x:
				part_move = [move[0] / abs_x, 0]
			else:
				part_move = [0, move[1] / abs_y]

			

			move_vector = ewutils.EwVector2D(part_move)
			position_vector = ewutils.EwVector2D(self.ball_coords)

			destination_vector = position_vector.add(move_vector)

			player_contact = False
			for i in range(-1, 2):
				for j in range(-1, 2):
					neighbor_direction = [i, j]
					neighbor_vector = ewutils.EwVector2D(neighbor_direction)
					if move_vector.scalar_product(neighbor_vector) > 0:
						neighbor_position = position_vector.add(neighbor_vector)
						player = self.player_at_coords(neighbor_position.vector)
						if player != -1:
							self.ball_velocity = [0, 0]
							self.last_contact = player
							player_contact = True
							break

			if player_contact:
				break

			elif self.coords_free(destination_vector.vector):
				self.ball_coords = destination_vector.vector
			elif self.out_of_bounds(destination_vector.vector):
				for i in range(2):
					if part_move[i] != 0:
						whole_move_vector.vector[i] *= -1
						self.ball_velocity[i] *= -1


			if self.is_goal():

				global sb_slimeballerid_to_player

				scoring_player = sb_slimeballerid_to_player.get(self.last_contact)
				if scoring_player != None:
					player_data = EwPlayer(id_user = scoring_player.id_user)
				else:
					player_data = None

				if self.is_goal_purple():

					if player_data != None:
						response = "{} scored a goal for the pink team!".format(player_data.display_name)
					else:
						response = "The pink team scored a goal!"
					self.score_pink += 1
				elif self.is_goal_pink():

					if player_data != None:
						response = "{} scored a goal for the purple team!".format(player_data.display_name)
					else:
						response = "The purple team scored a goal!"
					self.score_purple += 1


				self.ball_velocity = [0, 0]
				self.ball_coords = get_starting_position("")
				self.last_contact = -1
				break

			else:
				whole_move_vector = whole_move_vector.subtract(move_vector)
				abs_x = abs(whole_move_vector.vector[0])
				abs_y = abs(whole_move_vector.vector[1])
				abs_sum = abs_x + abs_y
				move = whole_move_vector.vector

		for i in range(2):
			if self.ball_velocity[i] > 0:
				self.ball_velocity[i] -= 1
			elif self.ball_velocity[i] < 0:
				self.ball_velocity[i] += 1

		if len(response) > 0:
			poi_data = ewcfg.id_to_poi.get(self.poi)
			resp_cont.add_channel_response(poi_data.channel, response)

		return resp_cont
Exemple #20
0
async def browse_zines(cmd):
	if len(cmd.tokens) > 1:
		sort_token = cmd.tokens[1].replace("_", "")

	else:
		sort_token = "null"

	poi = ewcfg.chname_to_poi.get(cmd.message.channel.name)

	if not poi.write_manuscript:
		response = "You can't browse for zines here! Try going to the cafe. If you're looking for educational zines, try the colleges. If you can't read, then you might want to try the comic shop."

		await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))

	else:
		if not sort_token.isdigit():
			book_list = []
			resp_cont = ewutils.EwResponseContainer(id_server=cmd.message.server.id)
			query_suffix = ""
			query_sort = "id_book"
			more_selects = ""
			quality = "= 1"

			if cmd.message.channel.name in ["nlac-university", "neo-milwaukee-state"]:
				query_suffix = "AND b.genre = 1 "

			elif cmd.message.channel.name in ["glocksbury-comics"]:
				query_suffix = "AND b.genre = 2 "

			if sort_token in ("bookname", "name", "title", "booktitle", "zinename", "zinetitle"):
				query_sort = "title"

			elif sort_token in ("author", "authorname", "artist", "artistname", "illustrator"):
				query_sort = "author"

			elif sort_token in ("date", "datepublished", "day", "time", "published", "publish", "publishdate"):
				query_sort = "date_published"
				more_selects = ", b.date_published"

			elif sort_token in ewcfg.book_genres:
				genre = ""

				for i in [i for i, x in enumerate(ewcfg.book_genres) if x == sort_token]:
					genre = i

				query_suffix = "AND b.genre = {} ".format(genre)

			elif sort_token in ('reverse', 'inverse', 'descend', 'desc', 'descending', 'backwards'):
				query_sort += " DESC"

			elif sort_token in ('length', 'len', 'pages', 'long', 'longest'):
				query_sort = "length DESC"
				more_selects = ", b.length"

			elif sort_token in ('sales', 'sale', 'sell', 'bestsellers', 'topsellers', 'bestselling'):
				query_sort = "sales DESC"
				more_selects = ", b.sales"

			elif sort_token in ('rating', 'quality', 'ratings', 'rate', 'f***s', 'rate', 'f**k', 'toprated', 'best', 'highestrated'):
				query_sort = "rating DESC, rates DESC"
				more_selects = ", b.rating, b.rates"

			elif sort_token in ('bad', 'terrible', 'shit', 'shitty', 'worst', 'worstrated', 'bottom'):
				quality = "= 2"

			elif sort_token in ('all', 'every'):
				quality = "> 0"
				query_suffix = ""
				query_sort = "id_book"
				more_selects = ""

			if len(cmd.tokens) > 2:
				if cmd.tokens[2] in ('reverse', 'inverse', 'descend', 'desc', 'descending', 'backwards'):
					if not query_sort.endswith(" DESC"):
						query_sort += " DESC"

					else:
						query_sort = query_sort[:len(query_sort)-5]+" ASC"
			try:
				conn_info = ewutils.databaseConnect()
				conn = conn_info.get('conn')
				cursor = conn.cursor()

				cursor.execute((
						"SELECT b.id_book, b.title, b.author{} ".format(more_selects) +
						"FROM books AS b " +
						"WHERE b.id_server = %s AND b.book_state {} {}".format(quality, query_suffix) +
						"ORDER BY b.{}".format(query_sort)
				), (
					cmd.message.server.id,
				))

				data = cursor.fetchall()
				if data != None:
					for row in data:
						more_info = ""

						if query_sort.startswith("date_published"):
							more_info = " (Published on day {})".format(row[3])

						elif query_sort.startswith("length"):
							more_info = " (Length: {} characters)".format(row[3])

						elif query_sort.startswith("sales"):
							more_info = " (Sales: {} copies)".format(row[3])

						elif query_sort.startswith("rating"):
							if row[3] == '0' and row[4] == 0:
								more_info = " (Rating: No f***s given yet)"

							else:
								more_info = " (Rating: {} f***s across {} ratings)".format(row[3], row[4])

						book_list.append("\n{}: {} by {}{}".format(
							row[0],
							row[1].replace("`", "").replace("\n",""),
							row[2].replace("`", "").replace("\n",""),
							more_info,
						))

			finally:
				# Clean up the database handles.
				cursor.close()
				ewutils.databaseClose(conn_info)

			if len(book_list) != 0:
				resp_num = 0
				resp_count = 0
				resp_list = []

				# weird looking loop (i assure you it works tho)
				for book in book_list:
					resp_count += 1

					if len(resp_list) != resp_num+1:
						resp_list.append("")
					resp_list[resp_num] += book

					if resp_count == 10:
						resp_count = 0
						resp_num += 1

				for resp_block in resp_list:
					resp_cont.add_channel_response(cmd.message.channel.name, resp_block)

				# Send the response to the player.
				resp_cont.format_channel_response(cmd.message.channel.name, cmd.message.author)

				await resp_cont.post(channel=cmd.message.channel)
			else:
				response = "There aren't any zines in circulation at the moment."

				await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
		else:
			id_book = int(sort_token)

			if int_is_zine(id_book, cmd.message.server.id):
				book = EwBook(id_book=id_book)
				title = book.title
				author = book.author
				genre = ewcfg.book_genres[book.genre]

				response = "\n{} is a {} zine by {}.\n".format(title, genre, author)

				cover = book.book_pages.get(0, "")
				pages = book.pages
				length = book.length
				date = book.date_published

				response += "It is {} pages and {:,} characters long and was published on Day {}. ".format(pages, length, date)

				sales = book.sales
				rating = book.rating
				rates = book.rates

				if sales == 0:
					response += "It has not yet been bought by anyone.\n"

				else:
					response += "It has sold {:,} copies.\n".format(sales)

				if rates == 0:
					response += "Nobody has given it any f***s.\n"

				else:
					response += "It has received {} ratings with an average of {} f***s given out of 5.\n".format(rates, rating)

				if cover != "":
					if genre == "p**n":
						response += "The cover looks like this: ||{}||".format(cover)
					else:
						response += "The cover looks like this: {}".format(cover)

			else:
				response = "That's not a valid zine ID."

			await ewutils.send_message(cmd.client, cmd.message.channel, ewutils.formatMessage(cmd.message.author, response))
Exemple #21
0
async def haunt(cmd):
    time_now = int(time.time())
    response = ""
    resp_cont = ewutils.EwResponseContainer(id_server=cmd.message.server.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?"
    elif cmd.mentions_count == 1:
        # Get the user and target data from the database.
        user_data = EwUser(member=cmd.message.author)

        member = cmd.mentions[0]
        haunted_data = EwUser(member=member)
        market_data = EwMarket(id_server=cmd.message.server.id)
        target_isshambler = haunted_data.life_state == ewcfg.life_state_shambler

        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 ewmap.channel_name_is_poi(cmd.message.channel.name) == False:
            response = "You can't commit violence from here."
        elif time_now > haunted_data.time_expirpvp and not target_isshambler:
            # Require the target to be flagged for PvP
            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:
            # Target can be haunted by the player.
            haunted_slimes = int(haunted_data.slimes / ewcfg.slimes_hauntratio)
            # if user_data.poi == haunted_data.poi:  # when haunting someone face to face, there is no cap and you get double the amount
            # 	haunted_slimes *= 2
            if haunted_slimes > ewcfg.slimes_hauntmax:
                haunted_slimes = ewcfg.slimes_hauntmax

            #if -user_data.slimes < haunted_slimes:  # cap on for how much you can haunt
            #	haunted_slimes = -user_data.slimes

            haunted_data.change_slimes(n=-haunted_slimes,
                                       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

            user_data.time_expirpvp = ewutils.calculatePvpTimer(
                user_data.time_expirpvp,
                (int(time.time()) + ewcfg.time_pvp_attack))
            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!".format(
                member.display_name, cmd.message.author.display_name)

            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(
                    "<.+>", "",
                    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 += "."
            haunt_message = ewutils.formatMessage(member, haunt_message)
            resp_cont.add_channel_response(haunted_channel, haunt_message)
        else:
            # Some condition we didn't think of.
            response = "You cannot haunt {}.".format(member.display_name)
    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()
Exemple #22
0
	def change_ownership(self, new_owner, actor, client = None):  # actor can either be a faction, "decay", or "init"
		resp_cont_owner = ewutils.EwResponseContainer(client = ewutils.get_client(), id_server = self.id_server)

		factions = ["", ewcfg.faction_killers, ewcfg.faction_rowdys]

		if new_owner in factions:
			server = ewcfg.server_list[self.id_server]
			channel_str = ewcfg.id_to_poi[self.name].channel
			channel = ewutils.get_channel(server = server, channel_name = channel_str)

			if channel is not None and channel.topic:  # tests if the topic is neither None nor empty
				initialized = False

				# initialize channel topic control statuses
				for faction in factions:
					if ewcfg.control_topics[faction] in channel.topic:
						initialized = True

				if not initialized:
					new_topic = channel.topic + " " + ewcfg.control_topics[new_owner]

				# replace the the string of the previously controlling faction with that of the new one.
				else:
					new_topic = channel.topic.replace(ewcfg.control_topics[self.controlling_faction], ewcfg.control_topics[new_owner])

				if client is None:
					client = ewutils.get_client()


				if client is not None:
					resp_cont_owner.add_channel_topic(channel = channel_str, topic = new_topic)

			if self.controlling_faction != new_owner:  # if the controlling faction actually changed
				if new_owner != "":  # if it was captured by a faction instead of being de-captured or decayed
					countdown_message = ""
					if self.time_unlock > 0:
						countdown_message = "It will unlock for capture again in {}.".format(ewutils.formatNiceTime(seconds = self.time_unlock, round_to_minutes = True))
					message = "{faction} just captured {district}. {countdown}".format(
						faction = self.capturing_faction.capitalize(),
						district = ewcfg.id_to_poi[self.name].str_name,
						countdown = countdown_message
					)
					channels = [ewcfg.id_to_poi[self.name].channel] + ewcfg.hideout_channels
					
					for ch in channels:
						resp_cont_owner.add_channel_response(channel = ch, response = message)
				else:  # successful de-capture or full decay
					if actor != ewcfg.actor_decay:
						message = "{faction} just wrested control over {district} from the {other_faction}.".format(
							faction = actor.capitalize(),
							district = ewcfg.id_to_poi[self.name].str_name,
							other_faction = self.controlling_faction  # the faction that just lost control
						)
						channels = [ewcfg.id_to_poi[self.name].channel] + ewcfg.hideout_channels
						
						for ch in channels:
							resp_cont_owner.add_channel_response(channel = ch, response = message)

				self.controlling_faction = new_owner

		return resp_cont_owner
Exemple #23
0
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
Exemple #24
0
    def change_capture_points(
            self, progress, actor):  # actor can either be a faction or "decay"
        progress_percent_before = int(self.capture_points /
                                      self.max_capture_points * 100)

        self.capture_points += progress

        resp_cont_change_cp = ewutils.EwResponseContainer(
            client=ewutils.get_client(), id_server=self.id_server)

        # ensures that the value doesn't exceed the bounds
        if self.capture_points < 0:
            self.capture_points = 0
        elif self.capture_points > self.max_capture_points:
            self.capture_points = self.max_capture_points

        progress_percent_after = int(self.capture_points /
                                     self.max_capture_points * 100)

        # display a message if it's reached a certain amount
        if (progress_percent_after // ewcfg.capture_milestone) != (
                progress_percent_before // ewcfg.capture_milestone
        ):  # if a progress milestone was reached
            if progress > 0:  # if it was a positive change
                if ewcfg.capture_milestone <= progress_percent_after < ewcfg.capture_milestone * 2:  # if its the first milestone
                    message = "{faction} have started capturing {district}. Current progress: {progress}%".format(
                        faction=self.capturing_faction.capitalize(),
                        district=ewcfg.id_to_poi[self.name].str_name,
                        progress=progress_percent_after)
                    channels = [ewcfg.id_to_poi[self.name].channel]

                    for ch in channels:
                        resp_cont_change_cp.add_channel_response(
                            channel=ch, response=message)
                else:
                    # alert both factions of significant capture progress
                    if progress_percent_after >= 30 > progress_percent_before:  # if the milestone of 30% was just reached
                        message = "{faction} are capturing {district}.".format(
                            faction=self.capturing_faction.capitalize(),
                            district=ewcfg.id_to_poi[self.name].str_name,
                            progress=progress_percent_after)
                        if self.controlling_faction == ewcfg.faction_rowdys:
                            channels = [ewcfg.channel_rowdyroughhouse]
                        elif self.controlling_faction == ewcfg.faction_killers:
                            channels = [ewcfg.channel_copkilltown]
                        else:
                            channels = ewcfg.hideout_channels

                        for ch in channels:
                            resp_cont_change_cp.add_channel_response(
                                channel=ch, response=message)

                    if self.controlling_faction != actor:  # if it's not already owned by that faction
                        message = "{faction} continue to capture {district}. Current progress: {progress}%".format(
                            faction=self.capturing_faction.capitalize(),
                            district=ewcfg.id_to_poi[self.name].str_name,
                            progress=progress_percent_after)
                        channels = [ewcfg.id_to_poi[self.name].channel]

                        for ch in channels:
                            resp_cont_change_cp.add_channel_response(
                                channel=ch, response=message)
                    else:
                        message = "{faction} are renewing their grasp on {district}. Current control level: {progress}%".format(
                            faction=self.capturing_faction.capitalize(),
                            district=ewcfg.id_to_poi[self.name].str_name,
                            progress=progress_percent_after)
                        channels = [ewcfg.id_to_poi[self.name].channel]

                        for ch in channels:
                            resp_cont_change_cp.add_channel_response(
                                channel=ch, response=message)
            else:  # if it was a negative change
                if self.controlling_faction != "":  # if the district is owned by a faction
                    if progress_percent_after < 20 <= progress_percent_before:
                        message = "{faction}' control of {district} is slipping.".format(
                            faction=self.controlling_faction.capitalize(),
                            district=ewcfg.id_to_poi[self.name].str_name,
                            progress=progress_percent_after)
                        channels = ewcfg.hideout_channels
                        for ch in channels:
                            resp_cont_change_cp.add_channel_response(
                                channel=ch, response=message)

                    elif progress_percent_after < 50 <= progress_percent_before and actor != ewcfg.actor_decay:
                        message = "{faction} are de-capturing {district}.".format(
                            faction=actor.capitalize(),
                            district=ewcfg.id_to_poi[self.name].str_name,
                            progress=progress_percent_after)
                        channels = ewcfg.hideout_channels

                        for ch in channels:
                            resp_cont_change_cp.add_channel_response(
                                channel=ch, response=message)

                    message = "{faction}' control of {district} has decreased. Remaining control level: {progress}%".format(
                        faction=self.capturing_faction.capitalize(),
                        district=ewcfg.id_to_poi[self.name].str_name,
                        progress=progress_percent_after)
                    channels = [ewcfg.id_to_poi[self.name].channel]

                    for ch in channels:
                        resp_cont_change_cp.add_channel_response(
                            channel=ch, response=message)
                else:  # if it's an uncontrolled district
                    message = "{faction}' capture progress of {district} has decreased. Remaining progress: {progress}%".format(
                        faction=self.capturing_faction.capitalize(),
                        district=ewcfg.id_to_poi[self.name].str_name,
                        progress=progress_percent_after)
                    channels = [ewcfg.id_to_poi[self.name].channel]

                    for ch in channels:
                        resp_cont_change_cp.add_channel_response(
                            channel=ch, response=message)

        # if capture_points is at its maximum value (or above), assign the district to the capturing faction
        if self.capture_points == self.max_capture_points and self.controlling_faction != actor:
            responses = self.change_ownership(self.capturing_faction, actor)
            resp_cont_change_cp.add_response_container(responses)

        # if the district has decayed or been de-captured and it wasn't neutral anyway, make it neutral
        elif self.capture_points == 0 and self.controlling_faction != "":
            responses = self.change_ownership("", actor)
            resp_cont_change_cp.add_response_container(responses)

        return resp_cont_change_cp
Exemple #25
0
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))
Exemple #26
0
	def change_capture_points(self, progress, actor, num_lock = 0):  # actor can either be a faction or "decay"
		district_poi = ewcfg.id_to_poi.get(self.name)
		invasion_response = ""
		max_capture = ewcfg.limit_influence[district_poi.property_class]
		progress_percent_before = int(self.capture_points / max_capture * 100)

		if actor == 'slimecorp':
			progress /= 3

		self.capture_points += progress

		resp_cont_change_cp = ewutils.EwResponseContainer(client = ewutils.get_client(), id_server = self.id_server)

		# ensures that the value doesn't exceed the bounds
		if self.capture_points < 0:
			self.capture_points = 0


		if self.cap_side == "" and actor != ewcfg.actor_decay:
			self.cap_side = actor


		if self.capture_points <= 0:
			self.cap_side = ""
			self.controlling_faction = ""


		elif self.capture_points > self.max_capture_points:
			self.capture_points = self.max_capture_points
		#where we're going we don't need roads

		progress_percent_after = int(self.capture_points / max_capture * 100)

		#if num_lock > 0 \
		#and self.capture_points == max_capture \
		#and progress > 0 \
		#and self.property_class in ewcfg.capture_locks \
		#and self.time_unlock == 0:
		#	base_time_unlock = ewcfg.capture_locks.get(self.property_class)
		#	responses = self.change_capture_lock(base_time_unlock + (num_lock - 1) * ewcfg.capture_lock_per_gangster)
		#	resp_cont_change_cp.add_response_container(responses)

		if actor != ewcfg.actor_decay:
			self.capturing_faction = actor


		if self.controlling_faction == "" and progress > 0 and self.cap_side == actor and self.capture_points + progress > (ewcfg.min_influence[district_poi.property_class]):
			self.controlling_faction = actor
			invasion_response = "{} just captured {}.".format(self.capturing_faction.capitalize(), district_poi.str_name)


		# display a message if it's reached a certain amount
		if (progress_percent_after // ewcfg.capture_milestone) != (progress_percent_before // ewcfg.capture_milestone):  # if a progress milestone was reached
			if progress > 0:  # if it was a positive change
				if ewcfg.capture_milestone <= progress_percent_after < ewcfg.capture_milestone * 2:  # if its the first milestone
					message = "{faction} have started capturing {district}. Current progress: {progress}%".format(
						faction = self.capturing_faction.capitalize(),
						district = district_poi.str_name,
						progress = progress_percent_after
					)
					channels = [district_poi.channel]

					for ch in channels:
						resp_cont_change_cp.add_channel_response(channel = ch, response = message)
				else:
					# alert both factions of significant capture progress
					if progress_percent_after >= 30 > progress_percent_before:  # if the milestone of 30% was just reached
						message = "{faction} are capturing {district}.".format(
							faction = self.capturing_faction.capitalize(),
							district = district_poi.str_name,
							progress = progress_percent_after
						)
						if self.controlling_faction == ewcfg.faction_rowdys:
							channels = [ewcfg.channel_rowdyroughhouse]
						elif self.controlling_faction == ewcfg.faction_killers:
							channels = [ewcfg.channel_copkilltown]
						else:
							channels = ewcfg.hideout_channels

						for ch in channels:
							resp_cont_change_cp.add_channel_response(channel = ch, response = message)

					if self.controlling_faction != actor:  # if it's not already owned by that faction
						message = "{faction} continue to capture {district}. Current progress: {progress}%".format(
							faction = self.capturing_faction.capitalize(),
							district = ewcfg.id_to_poi[self.name].str_name,
							progress = progress_percent_after
						)
						channels = [district_poi.channel]
						
						for ch in channels:
							resp_cont_change_cp.add_channel_response(channel = ch, response = message)
					else:
						message = "{faction} are renewing their grasp on {district}. Current control level: {progress}%".format(
							faction = self.capturing_faction.capitalize(),
							district = district_poi.str_name,
							progress = progress_percent_after
						)
						channels = [district_poi.channel]
						
						for ch in channels:
							resp_cont_change_cp.add_channel_response(channel = ch, response = message)
			else:  # if it was a negative change
				if self.controlling_faction != "":  # if the district is owned by a faction
					if progress_percent_after < 50 <= progress_percent_before:
						message = "{faction}' control of {district} is slipping.".format(
							faction = self.controlling_faction.capitalize(),
							district = district_poi.str_name,
							progress = progress_percent_after
						)
						channels = ewcfg.hideout_channels
						for ch in channels:
							resp_cont_change_cp.add_channel_response(channel = ch, response = message)

					elif progress_percent_after < 75 <= progress_percent_before and actor != ewcfg.actor_decay:
						message = "{faction} are de-capturing {district}.".format(
							faction = actor.capitalize(),
							district = district_poi.str_name,
							progress = progress_percent_after
						)
						channels = ewcfg.hideout_channels
						
						for ch in channels:
							resp_cont_change_cp.add_channel_response(channel = ch, response = message)

					message = "{faction}' control of {district} has decreased. Remaining control level: {progress}%".format(
						faction = self.controlling_faction.capitalize(),
						district = district_poi.str_name,
						progress = progress_percent_after
					)
					channels = [district_poi.channel]
					
					for ch in channels:
						resp_cont_change_cp.add_channel_response(channel = ch, response = message)
				else:  # if it's an uncontrolled district
					message = "{faction}' capture progress of {district} has decreased. Remaining progress: {progress}%".format(
						faction = self.capturing_faction.capitalize(),
						district = district_poi.str_name,
						progress = progress_percent_after
					)
					channels = [district_poi.channel]

					if invasion_response != "":
						for ch in channels:
							resp_cont_change_cp.add_channel_response(channel = ch, response = invasion_response)

		if progress < 0 and self.capture_points == 0:
			self.capturing_faction = ""

		# if capture_points is at its maximum value (or above), assign the district to the capturing faction
		#if self.capture_points > max_capture:
		#	responses = self.change_ownership(self.capturing_faction, actor)
		#	resp_cont_change_cp.add_response_container(responses)

		# if the district has decayed or been de-captured and it wasn't neutral anyway, make it neutral
		#elif self.capture_points == 0 and self.controlling_faction != "":
		#	responses = self.change_ownership("", actor)
		#	resp_cont_change_cp.add_response_container(responses)
		#return
		return resp_cont_change_cp