Exemple #1
0
 def to_block_map(self) -> BlockMap:
     block_map = BlockMap(size=self.size)
     for block_entry in self.blocks:
         palette_index = block_entry.state
         palette_entry = self.palette[palette_index]
         block_map[block_entry.pos] = palette_entry.block
     return block_map
Exemple #2
0
def test_block_map_printing_with_one_block_on_top_floor():
    bm = BlockMap(size=(3, 3, 3))
    bm[1, 2, 1] = Block("stone")
    s1 = str(bm)
    s2 = textwrap.dedent(
        """
                ...
                .0.
                ...

                ...
                ...
                ...

                ...
                ...
                ...
        """
    ).strip()
    assert s1 == s2
Exemple #3
0
def test_block_map_printing_with_different_blocks_in_a_row():
    bm = BlockMap(size=(3, 3, 3))
    bm[1, 1, 0] = Block("stone")
    bm[1, 1, 1] = Block("dirt")
    bm[1, 1, 2] = Block("grass")
    s1 = str(bm)
    s2 = textwrap.dedent(
        """
                ...
                ...
                ...

                ...
                012
                ...

                ...
                ...
                ...
        """
    ).strip()
    assert s1 == s2
Exemple #4
0
def test_block_map_printing_with_many_of_one_type_of_block():
    bm = BlockMap(size=(3, 3, 3))
    bm[1, 0, 1] = Block("stone")
    bm[1, 1, 1] = Block("stone")
    bm[1, 2, 1] = Block("stone")
    s1 = str(bm)
    s2 = textwrap.dedent(
        """
                ...
                .0.
                ...

                ...
                .0.
                ...

                ...
                .0.
                ...
        """
    ).strip()
    assert s1 == s2
Exemple #5
0
def test_block_map_using_tuple_for_size():
    bm = BlockMap(size=(3, 3, 3))
    assert bm.size == Position.from_xyz(3, 3, 3)
Exemple #6
0
def test_block_map_set_block_with_position():
    bm = BlockMap(size=(3, 3, 3))
    bm[1, 1, 1] = Block("stone")
    assert bm[1, 1, 1] == Block("stone")