aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BerryClient/__main__.py9
-rw-r--r--BerryClient/addons/blockworld.py4
-rw-r--r--BerryClient/core.py1
-rw-r--r--BerryClient/models/House.py8
-rw-r--r--BerryClient/models/HouseTest.py41
-rw-r--r--BerryClient/models/Wall.py3
6 files changed, 61 insertions, 5 deletions
diff --git a/BerryClient/__main__.py b/BerryClient/__main__.py
index 3817cee..6916048 100644
--- a/BerryClient/__main__.py
+++ b/BerryClient/__main__.py
@@ -1,6 +1,9 @@
import click
+import logging
+import sys
from BerryClient.core import BerryCore
+from BerryClient.models.HouseTest import HouseTest
@click.group()
def main():
@@ -13,3 +16,9 @@ def run(host: str, port: int):
ins = BerryCore(host, port)
ins.run()
+
+@main.command()
+def test():
+ t = HouseTest()
+ t.setUp()
+ t.test_change_wall_material()
diff --git a/BerryClient/addons/blockworld.py b/BerryClient/addons/blockworld.py
index 2de6fd5..ad9b9ab 100644
--- a/BerryClient/addons/blockworld.py
+++ b/BerryClient/addons/blockworld.py
@@ -16,6 +16,10 @@ class BlockWorld:
def set_block(self, x, y, z, block):
pos = (x, y, z)
+
+ default_str = "default:"
+ if block.startswith(default_str):
+ block = block[len(default_str):]
block_obj = MATERIAL_MAPPING[block]
self.core.setBlock(*pos, block_obj.id)
diff --git a/BerryClient/core.py b/BerryClient/core.py
index afe26c1..1a06d19 100644
--- a/BerryClient/core.py
+++ b/BerryClient/core.py
@@ -89,4 +89,3 @@ class BerryCore:
while self.running:
process_events(self)
-
diff --git a/BerryClient/models/House.py b/BerryClient/models/House.py
index ce4d2e8..241fbd8 100644
--- a/BerryClient/models/House.py
+++ b/BerryClient/models/House.py
@@ -46,7 +46,7 @@ class House:
self.roof.build()
def change_wall_material(self, new_material_id: str):
- wallFront.material_id = new_material_id
- wallLeft.material_id = new_material_id
- wallRight.material_id = new_material_id
- wallBack.material_id = new_material_id
+ self.wallFront.material_id = new_material_id
+ self.wallLeft.material_id = new_material_id
+ self.wallRight.material_id = new_material_id
+ self.wallBack.material_id = new_material_id
diff --git a/BerryClient/models/HouseTest.py b/BerryClient/models/HouseTest.py
new file mode 100644
index 0000000..b4a676c
--- /dev/null
+++ b/BerryClient/models/HouseTest.py
@@ -0,0 +1,41 @@
+import logging
+
+from BerryClient.models.House import House
+
+class HouseTest:
+
+ house: House = None
+ def __init__(self):
+ pass
+
+ def setUp(self):
+ self.house = House((0,0,0), None)
+
+ def test_change_wall_material(self):
+ material_tests = [
+ "stone",
+ "brick",
+ "air",
+ ]
+
+ for material in material_tests:
+ print(f"Testing {material} ...", end="")
+
+ walls = [
+ self.house.wallFront,
+ self.house.wallLeft,
+ self.house.wallRight,
+ self.house.wallBack,
+ ]
+ self.house.change_wall_material(material)
+
+ success = True
+ for wall in walls:
+ if wall.material_id != material:
+ success = False
+ break
+
+ if success:
+ print(f"\rTesting {material} SUCCESS")
+ else:
+ print(f"\rTesting {material} FAILURE")
diff --git a/BerryClient/models/Wall.py b/BerryClient/models/Wall.py
index 9904ebb..07c259e 100644
--- a/BerryClient/models/Wall.py
+++ b/BerryClient/models/Wall.py
@@ -1,3 +1,6 @@
+import logging
+
+log = logging.getLogger(__name__)
class Wall:
width: int = 6