60 lines
1.6 KiB
Python
60 lines
1.6 KiB
Python
|
from Lights.Lights import Light
|
||
|
from Objects.Objects import Object
|
||
|
from Objects.World import World
|
||
|
|
||
|
|
||
|
def test_world_put_object():
|
||
|
w = World(5, 5, 5, 3, 3, 3)
|
||
|
o = Object()
|
||
|
w.put_object(5, 5, 5, o)
|
||
|
|
||
|
assert w.chunks[1][1][1].content[0][0][0] == o, 'Put Object into world failed'
|
||
|
|
||
|
|
||
|
def test_world_get_object():
|
||
|
w = World(5, 5, 5, 3, 3, 3)
|
||
|
o = Object()
|
||
|
w.put_object(5, 5, 5, o)
|
||
|
|
||
|
assert w.get_object(5, 5, 5) == o, 'Put Object into world failed'
|
||
|
|
||
|
|
||
|
def test_world_put_visibility():
|
||
|
w = World(5, 5, 5, 3, 3, 3)
|
||
|
o = Object()
|
||
|
w.put_object(4, 5, 5, o)
|
||
|
w.put_object(6, 5, 5, o)
|
||
|
|
||
|
w.put_object(5, 4, 5, o)
|
||
|
w.put_object(5, 6, 5, o)
|
||
|
|
||
|
w.put_object(5, 5, 4, o)
|
||
|
w.put_object(5, 5, 6, o)
|
||
|
|
||
|
w.put_object(5, 5, 5, o)
|
||
|
|
||
|
assert w.chunks[1][1][1].visible[0][0][0] == 0, 'Initial visibility not set!'
|
||
|
|
||
|
assert w.chunks[1][1][1].visible[1][0][0] == 5, 'Neighbours visibility not set!'
|
||
|
assert w.chunks[1][1][1].visible[0][1][0] == 5, 'Neighbours visibility not set!'
|
||
|
assert w.chunks[1][1][1].visible[0][0][1] == 5, 'Neighbours visibility not set!'
|
||
|
|
||
|
assert w.chunks[0][1][1].visible[4][0][0] == 5, 'Neighbours visibility not set!'
|
||
|
assert w.chunks[1][0][1].visible[0][4][0] == 5, 'Neighbours visibility not set!'
|
||
|
assert w.chunks[1][1][0].visible[0][0][4] == 5, 'Neighbours visibility not set!'
|
||
|
|
||
|
|
||
|
def test_world_add_light():
|
||
|
w = World(5, 5, 5, 3, 3, 3)
|
||
|
l = Light()
|
||
|
|
||
|
w.add_light(1.5, 2, 3.7, l)
|
||
|
|
||
|
|
||
|
def test_world_remove_light():
|
||
|
w = World(5, 5, 5, 3, 3, 3)
|
||
|
l = Light()
|
||
|
|
||
|
w.add_light(1.5, 2, 3.7, l)
|
||
|
w.remove_light(l)
|