Spaces:
Running
Running
File size: 1,830 Bytes
87b3b3a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
describe("Map.Dungeon", function() {
var names = ["Digger", "Uniform"];
var buildDungeonTests = function(name) {
var ctor = ROT.Map[name];
ROT.RNG.setSeed(1234);
var map = new ctor();
map.create();
var rooms = map.getRooms();
var corridors = map.getCorridors();
describe(name, function() {
it("should generate >0 rooms", function() {
expect(rooms.length).toBeGreaterThan(0);
});
it("all rooms should have at least one door", function() {
for (var i=0;i<rooms.length;i++) {
var room = rooms[i];
var doorCount = 0;
room.create(function(x, y, value) {
if (value == 2) { doorCount++ }
})
expect(doorCount).toBeGreaterThan(0);
}
});
it("all rooms should have at least one wall", function() {
for (var i=0;i<rooms.length;i++) {
var room = rooms[i];
var wallCount = 0;
room.create(function(x, y, value) {
if (value == 1) { wallCount++ }
})
expect(wallCount).toBeGreaterThan(0);
}
});
it("all rooms should have at least one empty cell", function() {
for (var i=0;i<rooms.length;i++) {
var room = rooms[i];
var emptyCount = 0;
room.create(function(x, y, value) {
if (value == 0) { emptyCount++ }
})
expect(emptyCount).toBeGreaterThan(0);
}
});
it("should generate >0 corridors", function() {
expect(corridors.length).toBeGreaterThan(0);
});
it("all corridors should have at least one empty cell", function() {
for (var i=0;i<corridors.length;i++) {
var corridor = corridors[i];
var emptyCount = 0;
corridor.create(function(x, y, value) {
if (value == 0) { emptyCount++ }
})
expect(emptyCount).toBeGreaterThan(0);
}
});
});
}
while (names.length) {
var name = names.shift();
buildDungeonTests(name);
}
});
|