diff --git a/data.py b/data.py index a3e2052..e644ffb 100644 --- a/data.py +++ b/data.py @@ -1,4 +1,4 @@ -from colours import * +from colours import DARK, BOLD, DARK_GRAY, YELLOW, RED, WHITE from console import supported_chars diff --git a/events.py b/events.py index aacc5b2..51915ad 100644 --- a/events.py +++ b/events.py @@ -40,4 +40,4 @@ def boom(server, x, y): server.splash_damage(x, y, radius*2, blast_strength/3) - return new_blocks \ No newline at end of file + return new_blocks diff --git a/items.py b/items.py index 2d7f0bf..4bd1498 100644 --- a/items.py +++ b/items.py @@ -66,4 +66,4 @@ def items_to_render_objects(items, x, offset): objects.append(object_) - return objects \ No newline at end of file + return objects diff --git a/main.py b/main.py index 672af71..013a5f7 100644 --- a/main.py +++ b/main.py @@ -80,7 +80,6 @@ def setdown(): def game(server, settings, benchmarks): dt = 0 # Tick - df = 0 # Frame dc = 0 # Cursor ds = 0 # Selector dpos = False @@ -286,14 +285,14 @@ def game(server, settings, benchmarks): events += new_events new_blocks = {} - for i in range(int(dt)): + for _ in range(int(dt)): new_blocks.update(process_events(events, server)) if new_blocks: server.set_blocks(new_blocks) # If no block below, kill player try: - block = server.map_[x][y+1] + _ = server.map_[x][y+1] except IndexError: alive = False diff --git a/mobs.py b/mobs.py index 74607ab..cde2343 100644 --- a/mobs.py +++ b/mobs.py @@ -30,7 +30,7 @@ def update(mobs, players, map_, last_tick): new_items = {} for mob_id, mob in mobs.items(): - mx, my, x_vel = mob['x'], mob['y'], mob['x_vel'] + mx, my = mob['x'], mob['y'] if mob['health'] <= 0: removed_mobs.append(mob_id) @@ -64,7 +64,7 @@ def update(mobs, players, map_, last_tick): def spawn(mobs, players, map_, x_start_range, y_start_range, x_end_range, y_end_range): - log("spawning", x_start_range, x_end_range, m='mobs'); + log('spawning', x_start_range, x_end_range, m='mobs') n_mobs_to_spawn = random.randint(0, 5) if random.random() < mob_rate else 0 new_mobs = {} diff --git a/network.py b/network.py index e428e86..33918ca 100644 --- a/network.py +++ b/network.py @@ -53,7 +53,7 @@ def receive(sock): d = bytes() try: - for i in range(length // bufsize): + for _ in range(length // bufsize): d += sock.recv(bufsize) time.sleep(0.001) d += sock.recv(length % bufsize) @@ -107,7 +107,7 @@ def start(data_handler, port): HOST, PORT = '0.0.0.0', int(port) server = ThreadedTCPServer((HOST, PORT), requestHandlerFactory(data_handler)) - ip, port = server.server_address + _, port = server.server_address # Start a thread with the server -- that thread will then start one # more thread for each request diff --git a/pathfinding.py b/pathfinding.py index f8c39d5..8440ed4 100644 --- a/pathfinding.py +++ b/pathfinding.py @@ -33,4 +33,4 @@ def pathfind_towards_delta(entity, delta, map_): updated = True - return updated, kill_entity \ No newline at end of file + return updated, kill_entity diff --git a/player.py b/player.py index f3ee45b..ac0da3a 100644 --- a/player.py +++ b/player.py @@ -44,7 +44,7 @@ def get_pos_delta_on_input(inp, map_, x, y, jump, flight): return dx, dy, jump -def get_pos_delta(dx, x, y, map_, flight): +def get_pos_delta(dx, x, y, map_, flight=False): player_slice = map_[x] diff --git a/render.py b/render.py index 0ddc95d..f3d28bf 100644 --- a/render.py +++ b/render.py @@ -1,7 +1,7 @@ from math import pi, cos, sin, sqrt, modf, radians -from colours import * -from console import * +from colours import colour_str, uncolour_str, rgb, round_to_palette, lightness, bold, RED, CYAN, BLUE +from console import supported_chars, DEBUG, POS_STR, CLS_END_LN from data import lighting, world_gen, blocks, timings from terrain import is_solid @@ -104,7 +104,6 @@ def obj_pixel(x, y, objects): if object_: model = object_['model'] - width = len(model) height = len(model[0]) dx = x - object_['x'] @@ -240,7 +239,7 @@ def get_light_colour(x, y, world_x, map_, slice_heights, lights, colour_behind, else: - light = CYAN if any(map(lambda l: lit(world_x, x, y, l) < 1, lights)) else hsv_to_rgb(colour_behind) + light = CYAN if any(map(lambda l: lit(world_x + x, y, l) < 1, lights)) else hsv_to_rgb(colour_behind) return light diff --git a/render_interface.py b/render_interface.py index 8c938c9..9d11482 100644 --- a/render_interface.py +++ b/render_interface.py @@ -55,4 +55,4 @@ def get_light_level(*args): log('Not implemented: Python get_light_level function', m='warning') log('{}'.format(result), m='lighting') - return result \ No newline at end of file + return result diff --git a/server.py b/server.py index e7fdb9d..c45f2c5 100644 --- a/server.py +++ b/server.py @@ -322,7 +322,7 @@ def spawn_mobs(self, n_mob_spawn_cycles, bk_objects, sky_colour, day, lights): render_interface.create_lighting_buffer(width, height, x_start, y_start, self._map, self._slice_heights, bk_objects, sky_colour, day, lights) - for i in range(n_mob_spawn_cycles): + for _ in range(n_mob_spawn_cycles): mobs.spawn(self._meta['mobs'], self._meta['players'], self._map, x_start, y_start, x_end, y_end) def update_items(self): diff --git a/server_interface.py b/server_interface.py index 39b6938..f413ca7 100644 --- a/server_interface.py +++ b/server_interface.py @@ -337,15 +337,13 @@ def _event_logout(self, error=None): self.game = False def _event_error(self, error): - self.error = 'Error from server: ' + error['event'] + ': ' + event['message'] + self.error = 'Error from server: ' + error['event'] + ': ' + error['message'] log(self.error) self.game = False # Main loop methods: def get_chunks(self, chunk_list): - slices_its_loading = ((chunk_num + chunk * chunk_size) for chunk in chunk_list for chunk_num in range(chunk_size)) - self.handle(self._send('get_chunks', [chunk_list])) self.view_change = True diff --git a/terrain_gen.py b/terrain_gen.py index 1d42124..31a6915 100644 --- a/terrain_gen.py +++ b/terrain_gen.py @@ -26,7 +26,7 @@ class TerrainCache(OrderedDict): Beyond which it replaces the oldest item. """ def __init__(self, *args, **kwds): - self._limit = kwds.pop("limit", None) + self._limit = kwds.pop('limit', None) OrderedDict.__init__(self, *args, **kwds) self._check_limit() @@ -81,7 +81,7 @@ def gen_hill_chunk_features(chunk_pos, chunk_features_in_range, seed): def gen_biome_slice_features(x, chunk_features_in_range, slice_features, seed): slice_biome = ('normal', None) - slice_biome_distance_to_centre = float("inf") + slice_biome_distance_to_centre = float('inf') if chunk_features_in_range.get('biomes') is not None: for biome in chunk_features_in_range.get('biomes'): @@ -248,7 +248,7 @@ def gen_cave_features(features, chunk_pos, meta): if features[chunk_pos].get('cave') is None: # Perform cellular automata - for i in range(ca_iterations): + for _ in range(ca_iterations): new_air_points = set() for x in range(air_points_x_min, air_points_x_max): @@ -274,7 +274,6 @@ def generate_slice_features(features, chunk_pos, meta, feature_generator, featur log("generate_slice_features range", chunk_pos - feature_buffer[0], chunk_pos + world_gen['chunk_size'] + feature_buffer[1], m=1) # Generate dictionary of chunk-features (features on chunk positions) within the feature_buffer range. - chunk_n = ceil(chunk_pos / world_gen['chunk_size']) feature_buffer_chunk = (ceil(feature_buffer[0] / world_gen['chunk_size']) * world_gen['chunk_size'], ceil(feature_buffer[1] / world_gen['chunk_size']) * world_gen['chunk_size']) feature_buffer_range = range(chunk_pos - feature_buffer_chunk[0], @@ -283,8 +282,6 @@ def generate_slice_features(features, chunk_pos, meta, feature_generator, featur for x in range(chunk_pos - feature_buffer[0], chunk_pos + world_gen['chunk_size'] + feature_buffer[1]): - slice_chunk_pos = (x // world_gen['chunk_size']) * world_gen['chunk_size'] - if features.get(x) is None: # Init to empty, so 'no features' is cached. features[x] = {} @@ -339,4 +336,4 @@ def gen_chunk_features(chunk_n, meta): generate_slice_features(FEATURES, chunk_pos, meta, gen_grass_features, 'grass', (0, 0)) generate_slice_features(FEATURES, chunk_pos, meta, gen_ore_features, 'ores', MAX_ORE_RANGE) - return FEATURES \ No newline at end of file + return FEATURES diff --git a/translate_data.py b/translate_data.py index ed6da4b..68124af 100644 --- a/translate_data.py +++ b/translate_data.py @@ -72,4 +72,4 @@ def main(): if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/ui.py b/ui.py index c8f9e08..0fe36dc 100644 --- a/ui.py +++ b/ui.py @@ -1,7 +1,6 @@ from nbinput import BlockingInput, UP, DOWN, RIGHT, LEFT from console import CLS, REDRAW, WIDTH, HEIGHT, SHOW_CUR, HIDE_CUR -from colours import * -from console import * +from colours import colour_str, TERM_YELLOW, TERM_RED, BOLD from data import help_data import saves