예제 #1
0
def test_vector_line():
    assert list(line(O, O)) == [O]
    assert list(line(O, 4 * X)) == [O, X, 2 * X, 3 * X, 4 * X]
    assert list(line(O, Vector(3, 1, 0))) == [O, X, 2 * X + Y, 3 * X + Y]
    assert list(line(O, Vector(
        1, 2, 3))) == [O, Y + Z, Vector(1, 1, 2),
                       Vector(1, 2, 3)]
예제 #2
0
def smile(player_pos):
    height = player_pos + 3*Y

    left_anchor = height - 3*Z
    right_anchor = height + 4*Z

    yield list(line(left_anchor, right_anchor))
    yield list(line(left_anchor, left_anchor - 2*Z + 2*Y))
    yield list(line(right_anchor, right_anchor + 2*Z + 2    *Y))
예제 #3
0
def test_blocks_set_sequence_same():
    conn = mock.MagicMock()
    l = list(line(O, 4 * X))
    picraft.block.Blocks(conn)[l] = Block(0, 0)
    for v in l:
        conn.send.assert_any_call('world.setBlock(%d,%d,%d,0,0)' %
                                  (v.x, v.y, v.z))
예제 #4
0
def test_blocks_set_sequence_different():
    conn = mock.MagicMock()
    l = list(line(O, 4 * X))
    blocks = [Block(1, 1) for v in l]
    picraft.block.Blocks(conn)[l] = blocks
    for v in l:
        conn.send.assert_any_call('world.setBlock(%d,%d,%d,1,1)' %
                                  (v.x, v.y, v.z))
예제 #5
0
def test_blocks_get_sequence():
    l = list(line(O, 4 * X))
    conn = mock.MagicMock()
    conn.transact.return_value = '1,1'
    assert picraft.block.Blocks(conn)[l] == [Block(1, 1) for v in l]
    for v in l:
        conn.transact.assert_any_call('world.getBlockWithData(%d,%d,%d)' %
                                      (v.x, v.y, v.z))
예제 #6
0
def prep_surface():
    surface = []
    for z in range(0, (high_corner.z - low_corner.z)):
        surface.extend(list(line(low_corner + z*Z, low_corner2 + z*Z)))

    w.blocks[surface] = Block('wool')

    for y in range(1,20):
        airfill(surface, y)
예제 #7
0
def draw_lines(old_state, lines):
    new_state = {
        v: Block('brick_block')
        for line_start, line_finish in lines
        for v in line(line_start, line_finish)
        }
    with world.connection.batch_start():
        for v, b in track_changes(old_state, new_state).items():
            world.blocks[v] = b
    return new_state
예제 #8
0
w = World(host=hostname)

#allow time to go back to the game
sleep(3)

origin = Vector(45,7,-9);

## Build stares

base_of_stairs = [origin, origin + 3*X]

for y in range(0, 10):
    left_stair = base_of_stairs[0] + y*Z + y*Y
    right_stair = base_of_stairs[1] + y*Z + y*Y
    stairs = list(line(left_stair, right_stair))
    w.blocks[stairs] = Block("planks")

    w.blocks[left_stair, right_stair] = Block("stone")
    w.blocks[left_stair + 1*Y, right_stair + 1*Y] = Block("fence")
    w.blocks[left_stair + 2*Y, right_stair + 2*Y] = Block("glowstone")

low_corner = Vector(31,16,0)
rink = lines([
    low_corner,
    low_corner + 25*X,
    low_corner + 25*X + 25*Z,
    low_corner + 25*Z
])

w.blocks[rink] = Block("wool")
예제 #9
0
def test_vector_line():
    assert list(line(O, O)) == [O]
    assert list(line(O, 4*X)) == [O, X, 2*X, 3*X, 4*X]
    assert list(line(4*X, O)) == [4*X, 3*X, 2*X, X, O]
    assert list(line(O, Vector(3, 1, 0))) == [O, X, 2*X + Y, 3*X + Y]
    assert list(line(O, Vector(1, 2, 3))) == [O, Y + Z, Vector(1, 1, 2), Vector(1, 2, 3)]