diff options
author | Darshan Shaligram <dshaligram@users.sourceforge.net> | 2010-01-05 01:31:26 +0530 |
---|---|---|
committer | Darshan Shaligram <dshaligram@users.sourceforge.net> | 2010-01-05 01:34:27 +0530 |
commit | ed85466e0202b396bb8d5469d2babd2a24664afc (patch) | |
tree | dc8803ffada803a7910d1cea36d96361c916f59d /crawl-ref/source/dat | |
parent | e88370a40d2cad80bf114500d42291f11dcff5fb (diff) | |
download | crawl-ref-ed85466e0202b396bb8d5469d2babd2a24664afc.tar.gz crawl-ref-ed85466e0202b396bb8d5469d2babd2a24664afc.zip |
Fix Shoal:$ generation bugs: stairs could be surrounded by deep water, hut entrances could be blocked by rock.
shoal-hut.lua test generates 1k Shoal:$ levels and verifies that the levels pass sanity tests.
Diffstat (limited to 'crawl-ref/source/dat')
-rw-r--r-- | crawl-ref/source/dat/clua/dungeon.lua | 33 | ||||
-rw-r--r-- | crawl-ref/source/dat/clua/iter.lua | 17 | ||||
-rw-r--r-- | crawl-ref/source/dat/clua/test.lua | 23 |
3 files changed, 68 insertions, 5 deletions
diff --git a/crawl-ref/source/dat/clua/dungeon.lua b/crawl-ref/source/dat/clua/dungeon.lua index 0a11bdd330..4359733855 100644 --- a/crawl-ref/source/dat/clua/dungeon.lua +++ b/crawl-ref/source/dat/clua/dungeon.lua @@ -182,6 +182,16 @@ function dgn.fnum_map(map) return fnmap end +-- Given a list of feature names, returns a dictionary mapping feature +-- numbers to true. +function dgn.feature_number_set(feature_names) + local dict = { } + for _, name in ipairs(feature_names) do + dict[dgn.fnum(name)] = true + end + return dict +end + -- Replaces all features matching function dgn.replace_feat(rmap) local cmap = dgn.fnum_map(rmap) @@ -197,6 +207,27 @@ function dgn.replace_feat(rmap) end end +function dgn.feature_set_fn(...) + local chosen_features = dgn.feature_number_set({ ... }) + return function (fnum) + return chosen_features[fnum] + end +end + +-- Finds all points in the map satisfying the supplied predicate. +function dgn.find_points(predicate) + local points = { } + for x = 0, dgn.GXM - 1 do + for y = 0, dgn.GYM - 1 do + local p = dgn.point(x, y) + if predicate(p) then + table.insert(points, p) + end + end + end + return points +end + -- Returns a function that returns true if the point specified is -- travel-passable and is not one of the features specified. function dgn.passable_excluding(...) @@ -395,7 +426,7 @@ dgn.good_scrolls = [[ w:10 scroll of acquirement / scroll of acquirement q:2 w:4 / scroll of acquirement q:3 w:1/ w:5 scroll of vorpalise weapon / - w:5 scroll of immolation / + w:5 scroll of immolation / w:5 scroll of vulnerability ]] diff --git a/crawl-ref/source/dat/clua/iter.lua b/crawl-ref/source/dat/clua/iter.lua index d9496bdb3c..e4d1409781 100644 --- a/crawl-ref/source/dat/clua/iter.lua +++ b/crawl-ref/source/dat/clua/iter.lua @@ -136,6 +136,11 @@ function iter.rect_iterator(top_corner, bottom_corner, filter, rvi) return iter.rectangle_iterator:new(top_corner, bottom_corner, filter, rvi) end +function iter.rect_size_iterator(top_corner, size, filter, rvi) + return iter.rect_iterator(top_corner, top_corner + size - dgn.point(1, 1), + filter, rvi) +end + function iter.mons_rect_iterator (top_corner, bottom_corner, filter) return iter.rect_iterator(top_corner, bottom_corner, iter.monster_filter(filter), true) end @@ -212,7 +217,7 @@ function iter.adjacent_iterator (ic, filter, center, rvi) local function check_adj (point) local _x, _y = point:xy() - local npoint = nil + local npoint = point if filter ~= nil then if rvi then @@ -246,8 +251,12 @@ function iter.mons_adjacent_iterator (ic, filter, center) return iter.adjacent_iterator(ic, iter.monster_filter(filter), center, true) end +function iter.adjacent_iterator_to(center, include_center, filter) + return iter.adjacent_iterator(include_center, filter, center, true) +end + ------------------------------------------------------------------------------- --- circle_iterator +-- Circle_iterator ------------------------------------------------------------------------------- function iter.circle_iterator (radius, ic, filter, center, rvi) @@ -449,7 +458,7 @@ end function iter.point_iterator:check_filter(point) if self.filter ~= nil then if self.filter(point) then - if self.rvi then + if self.rvi then return self.filter(point) else return point @@ -513,7 +522,7 @@ end function iter.invent_iterator:check_filter(item) if self.filter ~= nil then if self.filter(item) then - if self.rvi then + if self.rvi then return self.filter(item) else return item diff --git a/crawl-ref/source/dat/clua/test.lua b/crawl-ref/source/dat/clua/test.lua new file mode 100644 index 0000000000..404b2e1d1f --- /dev/null +++ b/crawl-ref/source/dat/clua/test.lua @@ -0,0 +1,23 @@ +-- Support code used primarily for tests. This is loaded only when running +-- tests, not during normal Crawl execution. + +util.namespace('test') + +test.FAILMAP = 'level-fail.map' + +function test.map_assert(condition, message) + if not condition then + debug.dump_map(test.FAILMAP) + assert(false, message .. " (map dumped to " .. test.FAILMAP .. ")") + end + return condition +end + +function test.regenerate_level(place) + if place then + debug.goto_place(place) + end + debug.flush_map_memory() + dgn.reset_level() + debug.generate_level() +end
\ No newline at end of file |