from chunk import Chunk

class Master(object):
    def __init__(self, **kwargs):
        self.seed = 1.0
        self.quality = 1
        self.minz = 63
        self.maxz = 119
        
        for key, value in kwargs.iteritems():
            setattr(self, key, value)

        self.chunks = {}

    def get_temperature(self, x, y):
        return 0.5

    def get_humidity(self, x, y):
        return 0.5

    def __getitem__(self, *largs):
        largs = largs[0]
        assert len(largs) >= 3

        x, y, z = largs
        chunk = self.chunks.setdefault((x, y, z), Chunk(self, x, y, z))

        if not chunk.loaded:
            if not chunk.load():
                assert chunk.generate()

        return chunk
