Exemplo n.º 1
0
    def set_trees(self, trees: List[Tree]) -> None:
        # =============================
        # INFORMATIONS :
        # -----------------------------
        # UTILITÉ :
        # Vérifie la cohérence de pluviometry_max puis l'assigne
        # -----------------------------
        # PRÉCONDITIONS (uniquement si DEBUG_MOD) :
        # - BIOME_PLUVIOMETRY_MIN <= pluviometry_max <= BIOME_PLUVIOMETRY_MAX
        # =============================
        if DEBUG_MOD:
            check_attribute_type_set(attribute_to_check=trees,
                                     type_to_check=list,
                                     name_of_attribute_to_check="_trees",
                                     object_destination=self)
            check_number_between_to_set(
                number_to_check=len(trees),
                min_value=BIOME_TREES_LEN_MIN,
                max_value=BIOME_TREES_LEN_MAX,
                name_of_attribute_to_check="len(_trees)",
                object_to_set=self)
            # Vérification que tous les éléments sont instance de Tree :
            i = 0
            while i < len(trees) and isinstance(trees[i], Tree):
                i += 1

            if i != len(trees):
                raise TypeError(
                    "Error: impossible to set _trees for a " +
                    type(self).__name__ + ":" +
                    "\n_trees must be a List[Tree] but element number " +
                    str(i) + " is a " + type(trees[i]).__name__ + ".")
        self._trees = trees
Exemplo n.º 2
0
 def set_spawn_probability(self, spawn_probability: float) -> None:
     if DEBUG_MOD:
         check_attribute_type_set(
             attribute_to_check=spawn_probability,
             type_to_check=float,
             name_of_attribute_to_check="_spawn_probability",
             object_destination=self
         )
         check_number_between_to_set(
             number_to_check=spawn_probability,
             min_value=0.0,
             max_value=1.0,
             name_of_attribute_to_check="_spawn_probability",
             object_to_set=self
         )
     self._spawn_probability = spawn_probability
Exemplo n.º 3
0
 def set_green(self, green: int) -> None:
     if DEBUG_MOD:
         check_attribute_type_set(
             attribute_to_check=green,
             type_to_check=int,
             name_of_attribute_to_check="_green",
             object_destination=self
         )
         check_number_between_to_set(
             number_to_check=green,
             min_value=COLOR_RGB_MIN,
             max_value=COLOR_RGB_MAX,
             name_of_attribute_to_check="_green",
             object_to_set=self
         )
     self._green = green
Exemplo n.º 4
0
 def set_red(self, red: int) -> None:
     if DEBUG_MOD:
         check_attribute_type_set(
             attribute_to_check=red,
             type_to_check=int,
             name_of_attribute_to_check="_red",
             object_destination=self
         )
         check_number_between_to_set(
             number_to_check=red,
             min_value=COLOR_RGB_MIN,
             max_value=COLOR_RGB_MAX,
             name_of_attribute_to_check="_red",
             object_to_set=self
         )
     self._red = red
Exemplo n.º 5
0
 def set_pluviometry_x(self, pluviometry_x: Optional[int]) -> None:
     if pluviometry_x is None:
         self._pluviometry_x = random.randint(SEED_ELEMENT_MIN,
                                              SEED_ELEMENT_MAX)
     else:
         if DEBUG_MOD:
             check_attribute_type_set(
                 attribute_to_check=pluviometry_x,
                 type_to_check=int,
                 name_of_attribute_to_check="_pluviometry_x",
                 object_destination=self)
             check_number_between_to_set(
                 number_to_check=pluviometry_x,
                 min_value=SEED_ELEMENT_MIN,
                 max_value=SEED_ELEMENT_MAX,
                 name_of_attribute_to_check="_pluviometry_x",
                 object_to_set=self)
         self._pluviometry_x = pluviometry_x
Exemplo n.º 6
0
 def set_temperature_y(self, temperature_y: Optional[int]) -> None:
     if temperature_y is None:
         self._temperature_y = random.randint(SEED_ELEMENT_MIN,
                                              SEED_ELEMENT_MAX)
     else:
         if DEBUG_MOD:
             check_attribute_type_set(
                 attribute_to_check=temperature_y,
                 type_to_check=int,
                 name_of_attribute_to_check="_temperature_y",
                 object_destination=self)
             check_number_between_to_set(
                 number_to_check=temperature_y,
                 min_value=SEED_ELEMENT_MIN,
                 max_value=SEED_ELEMENT_MAX,
                 name_of_attribute_to_check="_temperature_y",
                 object_to_set=self)
         self._temperature_y = temperature_y
Exemplo n.º 7
0
 def set_name(self, name: str) -> None:
     # =============================
     # INFORMATIONS :
     # -----------------------------
     # UTILITÉ :
     # Vérifie la cohérence de name puis le set
     # -----------------------------
     # PRÉCONDITIONS (uniquement si DEBUG_MOD) :
     # - BIOME_NAME_LEN_MIN <= len(name) <= BIOME_NAME_LEN_MAX
     # =============================
     if DEBUG_MOD:
         check_attribute_type_set(attribute_to_check=name,
                                  type_to_check=str,
                                  name_of_attribute_to_check="_name",
                                  object_destination=self)
         check_number_between_to_set(
             number_to_check=len(name),
             min_value=BIOME_NAME_LEN_MIN,
             max_value=BIOME_NAME_LEN_MAX,
             name_of_attribute_to_check="len(_name)",
             object_to_set=self)
     self._name = name
Exemplo n.º 8
0
 def set_temperature_max(self, temperature_max: float) -> None:
     # =============================
     # INFORMATIONS :
     # -----------------------------
     # UTILITÉ :
     # Vérifie la cohérence de temperature_max puis l'assigne
     # -----------------------------
     # PRÉCONDITIONS (uniquement si DEBUG_MOD) :
     # - BIOME_TEMPERATURE_MIN <= temperature_max <= BIOME_TEMPERATURE_MAX
     # =============================
     if DEBUG_MOD:
         check_attribute_type_set(
             attribute_to_check=temperature_max,
             type_to_check=float,
             name_of_attribute_to_check="_temperature_max",
             object_destination=self)
         check_number_between_to_set(
             number_to_check=temperature_max,
             min_value=BIOME_TEMPERATURE_MIN,
             max_value=BIOME_TEMPERATURE_MAX,
             name_of_attribute_to_check="_temperature_max",
             object_to_set=self)
     self._temperature_max = temperature_max
Exemplo n.º 9
0
 def set_pluviometry_max(self, pluviometry_max: float) -> None:
     # =============================
     # INFORMATIONS :
     # -----------------------------
     # UTILITÉ :
     # Vérifie la cohérence de pluviometry_max puis l'assigne
     # -----------------------------
     # PRÉCONDITIONS (uniquement si DEBUG_MOD) :
     # - BIOME_PLUVIOMETRY_MIN <= pluviometry_max <= BIOME_PLUVIOMETRY_MAX
     # =============================
     if DEBUG_MOD:
         check_attribute_type_set(
             attribute_to_check=pluviometry_max,
             type_to_check=float,
             name_of_attribute_to_check="_pluviometry_max",
             object_destination=self)
         check_number_between_to_set(
             number_to_check=pluviometry_max,
             min_value=BIOME_PLUVIOMETRY_MIN,
             max_value=BIOME_PLUVIOMETRY_MAX,
             name_of_attribute_to_check="_pluviometry_max",
             object_to_set=self)
     self._pluviometry_max = pluviometry_max