summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-08-04 17:41:04 -0400
committerJules Laplace <jules@okfoc.us>2014-08-04 17:41:04 -0400
commite2e1565f5cd3154c0f515dbe3d88c9943dd0580e (patch)
treede7ad8f6d9951ef9642142e799881221adbb129d /test
parentbe7412073a5e0b6641f125f29d254315f50bc95c (diff)
group walls and render using 'wireframe' look
Diffstat (limited to 'test')
-rw-r--r--test/06-test-grouper.js129
1 files changed, 125 insertions, 4 deletions
diff --git a/test/06-test-grouper.js b/test/06-test-grouper.js
index 1707e4c..41ed0b0 100644
--- a/test/06-test-grouper.js
+++ b/test/06-test-grouper.js
@@ -29,10 +29,12 @@ var east = new Rect( new vec(2,6), new vec(1,5) )
var corner = new Rect( new vec(3,7), new vec(3,7) )
var peninsula = new Rect( new vec(4,6), new vec(6,8) )
-var rect_room = new Room({ id: "rect", rect: rect, height: 2 })
-var east_room = new Room({ id: "east", rect: east, height: 2 })
-var corner_room = new Room({ id: "corner", rect: corner, height: 2 })
-var peninsula_room = new Room({ id: "peninsula", rect: peninsula, height: 2 })
+var rect_room = new Room({ id: "rect", rect: rect, height: 2 })
+var east_room = new Room({ id: "east", rect: east, height: 2 })
+var corner_room = new Room({ id: "corner", rect: corner, height: 2 })
+var peninsula_room = new Room({ id: "peninsula", rect: peninsula, height: 2 })
+var peninsula_taller = new Room({ id: "peninsula", rect: peninsula, height: 3 })
+var peninsula_shorter = new Room({ id: "peninsula", rect: peninsula, height: 1 })
var taller_room = new Room({ id: "taller", rect: rect, height: 3 })
@@ -118,4 +120,123 @@ describe('grouper(rect,east)', function(){
})
})
+describe('grouper(rect,corner)', function(){
+ reset()
+ Rooms.add( rect_room )
+ Rooms.add( corner_room )
+ rebuild()
+
+ var collections = Rooms.grouper.collect()
+
+ describe('#group(rect,corner)', function(){
+ var front_walls = Rooms.grouper.group([], collections, FRONT)
+ var back_walls = Rooms.grouper.group([], collections, BACK)
+ var left_walls = Rooms.grouper.group([], collections, LEFT)
+ var right_walls = Rooms.grouper.group([], collections, RIGHT)
+
+ it("left has 2 walls", function(){
+ assert.equal(2, left_walls.length)
+ })
+ it("right has 2 walls", function(){
+ assert.equal(2, right_walls.length)
+ })
+ it("front has 2 walls", function(){
+ assert.equal(2, front_walls.length)
+ })
+ it("back has 2 walls", function(){
+ assert.equal(2, back_walls.length)
+ })
+ it("front/right walls are one narrow, one wide", function(){
+ assert.equal(4, front_walls[0].vec.length())
+ assert.equal(2, front_walls[1].vec.length())
+ assert.equal(2, right_walls[0].vec.length())
+ assert.equal(4, right_walls[1].vec.length())
+ })
+ it("back/left walls are one wide, one narrow", function(){
+ assert.equal(2, back_walls[0].vec.length())
+ assert.equal(4, back_walls[1].vec.length())
+ assert.equal(4, left_walls[0].vec.length())
+ assert.equal(2, left_walls[1].vec.length())
+ })
+ })
+})
+
+describe('grouper(rect,corner,peninsula)', function(){
+ reset()
+ Rooms.add( rect_room )
+ Rooms.add( corner_room )
+ Rooms.add( peninsula_room )
+ rebuild()
+
+ var collections = Rooms.grouper.collect()
+
+ describe('#collect(rect,corner,peninsula)', function(){
+ it("should find an appropriate number of wall segments", function(){
+ assert.equal(3, collections[FRONT].length)
+ assert.equal(4, collections[BACK].length)
+ assert.equal(5, collections[LEFT].length)
+ assert.equal(5, collections[RIGHT].length)
+ })
+ })
+
+ describe('#group(rect,corner,peninsula)', function(){
+ var front_walls = Rooms.grouper.group([], collections, FRONT)
+ var back_walls = Rooms.grouper.group([], collections, BACK)
+ var left_walls = Rooms.grouper.group([], collections, LEFT)
+ var right_walls = Rooms.grouper.group([], collections, RIGHT)
+
+ it("left has 3 walls", function(){
+ assert.equal(3, left_walls.length)
+ })
+ it("right has 4 walls", function(){
+ assert.equal(4, right_walls.length)
+ })
+ it("front has 2 walls", function(){
+ assert.equal(2, front_walls.length)
+ })
+ it("back has 4 walls", function(){
+ assert.equal(4, back_walls.length)
+ })
+ })
+})
+
+
+describe('grouper(rect,corner,peninsula_taller)', function(){
+ reset()
+ Rooms.add( rect_room )
+ Rooms.add( corner_room )
+ Rooms.add( peninsula_taller )
+ rebuild()
+
+ var collections = Rooms.grouper.collect()
+
+ describe('#collect(rect,corner,peninsula_taller)', function(){
+ it("should find an appropriate number of wall segments", function(){
+ assert.equal(5, collections[FRONT].length)
+ assert.equal(4, collections[BACK].length)
+ assert.equal(6, collections[LEFT].length)
+ assert.equal(6, collections[RIGHT].length)
+ })
+ })
+
+ describe('#group(rect,corner,peninsula_taller)', function(){
+ var front_walls = Rooms.grouper.group([], collections, FRONT)
+ var back_walls = Rooms.grouper.group([], collections, BACK)
+ var left_walls = Rooms.grouper.group([], collections, LEFT)
+ var right_walls = Rooms.grouper.group([], collections, RIGHT)
+
+ it("left has 4 walls", function(){
+ assert.equal(4, left_walls.length)
+ })
+ it("right has 5 walls", function(){
+ assert.equal(5, right_walls.length)
+ })
+ it("front has 3 walls", function(){
+ assert.equal(3, front_walls.length)
+ })
+ it("back has 4 walls", function(){
+ assert.equal(4, back_walls.length)
+ })
+ })
+})