From c6b792929779328e74319713f736c20912a03e15 Mon Sep 17 00:00:00 2001 From: NChrzaszcz-Admin Date: Wed, 1 Feb 2023 14:17:20 +0100 Subject: [PATCH 1/7] Change ambiguous name --- fr/naulan/supermariobros/src/maps/{engine.py => maps_engine.py} | 0 fr/naulan/supermariobros/test/maps_engine_test.py | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename fr/naulan/supermariobros/src/maps/{engine.py => maps_engine.py} (100%) diff --git a/fr/naulan/supermariobros/src/maps/engine.py b/fr/naulan/supermariobros/src/maps/maps_engine.py similarity index 100% rename from fr/naulan/supermariobros/src/maps/engine.py rename to fr/naulan/supermariobros/src/maps/maps_engine.py diff --git a/fr/naulan/supermariobros/test/maps_engine_test.py b/fr/naulan/supermariobros/test/maps_engine_test.py index 9a575e5..b0d63b8 100644 --- a/fr/naulan/supermariobros/test/maps_engine_test.py +++ b/fr/naulan/supermariobros/test/maps_engine_test.py @@ -1,7 +1,7 @@ from unittest import TestCase from fr.naulan.supermariobros.src.entities.player import Player -from fr.naulan.supermariobros.src.maps.engine import MapsEngine +from fr.naulan.supermariobros.src.maps.maps_engine import MapsEngine class MapsEngineTest(TestCase): From abf5196bba181b294827a6451d82151af3358ba9 Mon Sep 17 00:00:00 2001 From: NChrzaszcz-Admin Date: Wed, 1 Feb 2023 14:41:12 +0100 Subject: [PATCH 2/7] Change name of the file and object name --- .../src/maps/{maps_engine.py => maps_generator.py} | 6 +++--- fr/naulan/supermariobros/test/maps_engine_test.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) rename fr/naulan/supermariobros/src/maps/{maps_engine.py => maps_generator.py} (94%) diff --git a/fr/naulan/supermariobros/src/maps/maps_engine.py b/fr/naulan/supermariobros/src/maps/maps_generator.py similarity index 94% rename from fr/naulan/supermariobros/src/maps/maps_engine.py rename to fr/naulan/supermariobros/src/maps/maps_generator.py index 103f6fa..b213879 100644 --- a/fr/naulan/supermariobros/src/maps/maps_engine.py +++ b/fr/naulan/supermariobros/src/maps/maps_generator.py @@ -11,14 +11,14 @@ from fr.naulan.supermariobros.src.maps.type_of_map import TypeOfMap -class MapsEngine(object): +class MapsGenerator(object): SEPARATOR = ',' data = list() def new(self, raw_data: Union[str, List], name: str, have_header: bool = True) -> None: lines = raw_data.splitlines() if isinstance(raw_data, str) else raw_data - tile_width = len(lines[0 if not have_header else 1].split(MapsEngine.SEPARATOR)) + tile_width = len(lines[0 if not have_header else 1].split(MapsGenerator.SEPARATOR)) tile_height = len(lines) # Load camera @@ -36,7 +36,7 @@ def new(self, raw_data: Union[str, List], name: str, have_header: bool = True) - player = None sprites = LayeredUpdates() for y, line in enumerate(lines[0:] if have_header else lines): - columns = line.split(MapsEngine.SEPARATOR) + columns = line.split(MapsGenerator.SEPARATOR) for x, col in enumerate(columns): type_of_tile = int(col) if type_of_tile != TypeOfTile.EMPTY: diff --git a/fr/naulan/supermariobros/test/maps_engine_test.py b/fr/naulan/supermariobros/test/maps_engine_test.py index b0d63b8..66be480 100644 --- a/fr/naulan/supermariobros/test/maps_engine_test.py +++ b/fr/naulan/supermariobros/test/maps_engine_test.py @@ -1,7 +1,7 @@ from unittest import TestCase from fr.naulan.supermariobros.src.entities.player import Player -from fr.naulan.supermariobros.src.maps.maps_engine import MapsEngine +from fr.naulan.supermariobros.src.maps.maps_generator import MapsGenerator class MapsEngineTest(TestCase): @@ -9,7 +9,7 @@ def test_empty_map(self): """ Test with full empty tiles """ - maps_engine = MapsEngine() + maps_engine = MapsGenerator() raw_data = open("./res/matrices/empty.txt", "r") maps_engine.new(raw_data.readlines(), raw_data.name, False) @@ -23,7 +23,7 @@ def test_player(self): """ Test with only player on the map """ - maps_engine = MapsEngine() + maps_engine = MapsGenerator() raw_data = open("./res/matrices/player.txt", "r") maps_engine.new(raw_data.readlines(), raw_data.name, False) From 9170fad64367ba0418aad5879484798646e6dfc6 Mon Sep 17 00:00:00 2001 From: NChrzaszcz-Admin Date: Wed, 1 Feb 2023 16:52:35 +0100 Subject: [PATCH 3/7] Change load file --- .../supermariobros/test/maps_engine_test.py | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/fr/naulan/supermariobros/test/maps_engine_test.py b/fr/naulan/supermariobros/test/maps_engine_test.py index 66be480..83a928c 100644 --- a/fr/naulan/supermariobros/test/maps_engine_test.py +++ b/fr/naulan/supermariobros/test/maps_engine_test.py @@ -1,3 +1,5 @@ +import os + from unittest import TestCase from fr.naulan.supermariobros.src.entities.player import Player @@ -9,31 +11,29 @@ def test_empty_map(self): """ Test with full empty tiles """ - maps_engine = MapsGenerator() + maps_generator = MapsGenerator() - raw_data = open("./res/matrices/empty.txt", "r") - maps_engine.new(raw_data.readlines(), raw_data.name, False) - self.assertTrue(len(maps_engine.data) == 1, "Have a map generated") + with open(os.getcwd() + "/res/matrices/empty.txt", "r") as f: + maps_generator.new(f.readlines(), f.name, False) + self.assertTrue(len(maps_generator.data) == 1, "Have a map generated") - empty_map = maps_engine.data[0] + empty_map = maps_generator.data[0] self.assertTrue(len(empty_map.data) == 0, "Is really empty") - raw_data.close() def test_player(self): """ Test with only player on the map """ - maps_engine = MapsGenerator() + maps_generator = MapsGenerator() - raw_data = open("./res/matrices/player.txt", "r") - maps_engine.new(raw_data.readlines(), raw_data.name, False) - self.assertTrue(len(maps_engine.data) == 1, "Have a map generated") + with open(os.getcwd() + "/res/matrices/player.txt", "r") as f: + maps_generator.new(f.readlines(), f.name, False) + self.assertTrue(len(maps_generator.data) == 1, "Have a map generated") - player_map = maps_engine.data[0] + player_map = maps_generator.data[0] self.assertTrue(len(player_map.data) == 1, "Have player into the list of entities") self.assertTrue(isinstance(player_map.player, Player), "Is really a player ?") player = player_map.player self.assertTrue(player.x == 4*16, "Generated at a good position on x axis") self.assertTrue(player.y == 16, "Generated at a good position on y axis") - raw_data.close() From 553379a21a973ff10f179f8ec98fde5a21f421d3 Mon Sep 17 00:00:00 2001 From: NChrzaszcz-Admin Date: Wed, 1 Feb 2023 16:54:27 +0100 Subject: [PATCH 4/7] Add `test` directory for the runners --- fr/naulan/supermariobros/test/maps_engine_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fr/naulan/supermariobros/test/maps_engine_test.py b/fr/naulan/supermariobros/test/maps_engine_test.py index 83a928c..4c00a8e 100644 --- a/fr/naulan/supermariobros/test/maps_engine_test.py +++ b/fr/naulan/supermariobros/test/maps_engine_test.py @@ -13,7 +13,7 @@ def test_empty_map(self): """ maps_generator = MapsGenerator() - with open(os.getcwd() + "/res/matrices/empty.txt", "r") as f: + with open(os.getcwd() + "test/res/matrices/empty.txt", "r") as f: maps_generator.new(f.readlines(), f.name, False) self.assertTrue(len(maps_generator.data) == 1, "Have a map generated") @@ -26,7 +26,7 @@ def test_player(self): """ maps_generator = MapsGenerator() - with open(os.getcwd() + "/res/matrices/player.txt", "r") as f: + with open(os.getcwd() + "test/res/matrices/player.txt", "r") as f: maps_generator.new(f.readlines(), f.name, False) self.assertTrue(len(maps_generator.data) == 1, "Have a map generated") From bd95ece6bd0d0e5d34864c021c6be3f7c4bd849f Mon Sep 17 00:00:00 2001 From: NChrzaszcz-Admin Date: Wed, 1 Feb 2023 16:54:50 +0100 Subject: [PATCH 5/7] Add `test` directory for the runners --- fr/naulan/supermariobros/test/maps_engine_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fr/naulan/supermariobros/test/maps_engine_test.py b/fr/naulan/supermariobros/test/maps_engine_test.py index 4c00a8e..b72f9fd 100644 --- a/fr/naulan/supermariobros/test/maps_engine_test.py +++ b/fr/naulan/supermariobros/test/maps_engine_test.py @@ -13,7 +13,7 @@ def test_empty_map(self): """ maps_generator = MapsGenerator() - with open(os.getcwd() + "test/res/matrices/empty.txt", "r") as f: + with open(os.getcwd() + "/test/res/matrices/empty.txt", "r") as f: maps_generator.new(f.readlines(), f.name, False) self.assertTrue(len(maps_generator.data) == 1, "Have a map generated") @@ -26,7 +26,7 @@ def test_player(self): """ maps_generator = MapsGenerator() - with open(os.getcwd() + "test/res/matrices/player.txt", "r") as f: + with open(os.getcwd() + "/test/res/matrices/player.txt", "r") as f: maps_generator.new(f.readlines(), f.name, False) self.assertTrue(len(maps_generator.data) == 1, "Have a map generated") From c91e01e5a492b32577ae9a7841909dfe7d20515f Mon Sep 17 00:00:00 2001 From: NChrzaszcz-Admin Date: Wed, 1 Feb 2023 16:56:31 +0100 Subject: [PATCH 6/7] Add `test` directory for the runners --- fr/naulan/supermariobros/test/maps_engine_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fr/naulan/supermariobros/test/maps_engine_test.py b/fr/naulan/supermariobros/test/maps_engine_test.py index b72f9fd..8f3fd4c 100644 --- a/fr/naulan/supermariobros/test/maps_engine_test.py +++ b/fr/naulan/supermariobros/test/maps_engine_test.py @@ -13,7 +13,7 @@ def test_empty_map(self): """ maps_generator = MapsGenerator() - with open(os.getcwd() + "/test/res/matrices/empty.txt", "r") as f: + with open(os.getcwd() + "/fr/naulan/supermariobros/test/res/matrices/empty.txt", "r") as f: maps_generator.new(f.readlines(), f.name, False) self.assertTrue(len(maps_generator.data) == 1, "Have a map generated") @@ -26,7 +26,7 @@ def test_player(self): """ maps_generator = MapsGenerator() - with open(os.getcwd() + "/test/res/matrices/player.txt", "r") as f: + with open(os.getcwd() + "/fr/naulan/supermariobros/test/res/matrices/player.txt", "r") as f: maps_generator.new(f.readlines(), f.name, False) self.assertTrue(len(maps_generator.data) == 1, "Have a map generated") From cd06b41557cd4c8c129ff9d3af1909a1e6aad33f Mon Sep 17 00:00:00 2001 From: NChrzaszcz-Admin Date: Thu, 2 Feb 2023 16:29:46 +0100 Subject: [PATCH 7/7] Good for maps generation --- fr/naulan/supermariobros/src/res/matrices/0.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fr/naulan/supermariobros/src/res/matrices/0.txt b/fr/naulan/supermariobros/src/res/matrices/0.txt index 2a08b3e..e7c7747 100644 --- a/fr/naulan/supermariobros/src/res/matrices/0.txt +++ b/fr/naulan/supermariobros/src/res/matrices/0.txt @@ -1 +1,5 @@ -type_of_map:1 \ No newline at end of file +type_of_map:1 +0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0 +0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0 +0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0,0;0 +1;0,1;0,1;0,1;0,1;0,1;0,1;0,1;0,1;0,1;0,1;0,1;0,1;0,1;0,1;0,1;0,1;0,1;0,1;0,1;0,1;0,1;0,1;0,1;0,1;0,1;0,1;0,1;0,1;0,1;0 \ No newline at end of file