From 33b34108e591224a03b00a6b593e63d052d0b857 Mon Sep 17 00:00:00 2001 From: AKreuzer Date: Sun, 26 May 2024 15:28:47 +0200 Subject: [PATCH] start balcony --- buildings/Facade.py | 8 +++++++- buildings/elements/Balcony.py | 13 +++++++++++-- params.yml | 10 +++++++++- utils/Enums.py | 2 +- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/buildings/Facade.py b/buildings/Facade.py index ea53ae7..715e88d 100644 --- a/buildings/Facade.py +++ b/buildings/Facade.py @@ -3,6 +3,7 @@ from utils.Enums import COLLUMN_STYLE from gdpc import Editor, Block, geometry, Transform from buildings.geometry.Vertice import Vertice from buildings.elements.Window import Window +from buildings.elements.Balcony import Balcony class Facade: def __init__(self, rdata, vertices : list[Vertice], height : int, length : int, is_inner_or_outer : COLLUMN_STYLE): @@ -36,7 +37,12 @@ class Facade: return Window(self.rdata["windows"] ,max_width, max_height) - def build_inter_floor(self, vertice : Vertice): + def get_balcony(self) -> Balcony: + len = rd.randint(self.rdata["balcony"]["size"]["min_len"], self.rdata["balcony"]["size"]["max_len"]) + max_width = self.length-2*self.padding + return Balcony(len, max_width, self.window) + + def build_inter_floor(self): if self.has_inter_floor: geometry.placeCuboid(self.editor,(0,self.height,-1),(self.length,self.height,-1),Block(self.materials[4], {"facing": "south", "half": "top"})) diff --git a/buildings/elements/Balcony.py b/buildings/elements/Balcony.py index 55691ab..fb13129 100644 --- a/buildings/elements/Balcony.py +++ b/buildings/elements/Balcony.py @@ -1,4 +1,13 @@ +import random as rd +from buildings.elements.Window import Window + class Balcony: - def __init__(self, length, width): + def __init__(self, rdata, length : int, max_width : int, windows : Window): + self.rdata = rdata self.length = length - self.width = width \ No newline at end of file + self.max_width = max_width + self.windows = windows + + def has_multiple_balcony(self): + if self.max_width < self.rdata["balcony"]["multiple"]["min_width"]: return False + return self.rdata["balcony"]["multiple"]["proba"] >= rd.random() \ No newline at end of file diff --git a/params.yml b/params.yml index 7cd9afc..687615f 100644 --- a/params.yml +++ b/params.yml @@ -40,4 +40,12 @@ buildings: top: 1 top_and_bottom: 1 inter_floor: 0.5 - balcony: 0.25 \ No newline at end of file + balcony: + proba : 0.25 + size: + min_len : 1 + max_len : 3 + min_width : 3 + multiple: + min_width: 5 + proba: 0.5 \ No newline at end of file diff --git a/utils/Enums.py b/utils/Enums.py index 4da1c62..2927857 100644 --- a/utils/Enums.py +++ b/utils/Enums.py @@ -15,4 +15,4 @@ class COLLUMN_STYLE(Enum): class BORDER_RADIUS(Enum): NONE = 0 TOP = 1 - TOP_AND_BOTTOM = 2 \ No newline at end of file + TOP_AND_BOTTOM = 2 \ No newline at end of file