from src.map_module.worldmap import WorldMap
from src.map_module.map_builder.shapers._shaper import Shaper
from src.map_module.tile_types.floor_tiles.types import *


class FloorShaper(Shaper):

    """
    Generates ids for WorldMap's floors
    @:param wmap - map_module map that's being worked on
    @:param step - multiplier for x and y coordinate values of the map,
        the lower the step the smoother the map curve
    @:param z_seed - third value for the noise function,
        generated by a pseudo random number generator
    @:param dw_limit - limit value for deep water
    @:param sw_limit - limit value for shallow water
    @:param sn_limit - limit value for sand
    @:param gr_limit - limit value for grass
    @:param sr_limit - limit value for surface rock
    """
    def shape(self, wmap: WorldMap, step: float = 0.005, z_seed: float = 0,
              dw_limit: float = -0.07, sw_limit: float = 0.0,
              sn_limit: float = 0.04, gr_limit: float = 0.35,
              sr_limit: float = 0.5):

        for x in range(wmap.x_size):
            for y in range(wmap.y_size):
                v = self.noise_generator.noise3(x*step, y*step, z_seed)
                if v < dw_limit:
                    tile_id = DeepWaterFloorTile.id
                elif v < sw_limit:
                    tile_id = ShallowWaterFloorTile.id
                elif v < sn_limit:
                    tile_id = SandFloorTile.id
                elif v < gr_limit:
                    tile_id = GrassFloorTile.id
                elif v < sr_limit:
                    tile_id = SurfaceStoneFloorTile.id
                else:
                    tile_id = DeepStoneFloorTile.id
                wmap.floors[x, y] = tile_id
