Commit Graph

58 Commits

Author SHA1 Message Date
Michael Meyer
70008fc684 Fix: movement tests
Movement tests weren't working because terrain was being positioned one
square to the left of where it was expected, and the error message
printed something other than the expected coordinates.

I wasn't able to figure out why they were like this in the first place
(referring to one spot to the left of the hero with <u.ux-2, u.uy>), so
it's quite possible that I am missing some context here, but the test
failed consistently for me before making these changes, and now works.
2022-08-26 18:08:37 +03:00
Pasi Kallinen
723ee6d1f6 Expose selection bounds to lua 2022-08-26 13:07:52 +03:00
Pasi Kallinen
f45e79e1a0 Fix medusa levels
My recent commit broke medusa-3 and medusa-4, so fix those.

Make des.stair and des.ladder also accept hash-coordinate:
  des.stair("up", {8, 10});
2022-04-01 08:53:15 +03:00
Pasi Kallinen
6eadff01b8 Lua: selection get and rndcoord changes 2022-03-22 10:45:20 +02:00
Pasi Kallinen
27898340b9 Lua: coordinate tweaking
Make selection rndcoord return a table with x and y keys.
Allow (most) coordinate parameters accept such a table.
Fix selection and des lua tests broken by the above changes and
an earlier change, because selections tried to set terrain
at column 0, and it now causes a complaint.
2022-03-22 09:16:19 +02:00
Pasi Kallinen
b271826147 Add test for selection subtraction 2022-03-14 19:06:51 +02:00
Pasi Kallinen
c0dc72b3d2 Test for replace_terrain coordinates 2021-09-03 08:27:17 +03:00
Pasi Kallinen
cf44cb3382 Handle buried zombifying corpses
When a zombifying corpse is buried, allow it to zombify and
dig itself out of the ground.

Also allow wishing for zombifying corpses.
2021-09-02 20:54:36 +03:00
Pasi Kallinen
f43bfc3f71 Lua: diagonals for selection floodfill 2021-08-15 13:50:28 +03:00
Pasi Kallinen
1c401960aa Move movement tests
Rushing will go along a snaking corridor.
2021-08-09 16:13:12 +03:00
Pasi Kallinen
f5b617eaca More movement tests
Rush behaves different in ROOM vs CORR; in corridors, it'll
turn 90 degrees, but will not go in the opposite direction
from when it started.
2021-08-08 19:30:59 +03:00
Pasi Kallinen
4f594659dc More movement tests 2021-07-30 18:40:57 +03:00
Pasi Kallinen
78854aeda6 More movement tests 2021-07-30 18:09:28 +03:00
Pasi Kallinen
b080ea12c2 Debug flag allowing overwriting stairs
And using it in the movement tests, so running doesn't stop
at stairs.
2021-07-30 16:35:36 +03:00
Pasi Kallinen
7bfbe0fba9 Lua: Allow setting debug_flags 2021-07-29 07:36:08 +03:00
Pasi Kallinen
19599fa751 Add more movement tests 2021-07-28 20:47:12 +03:00
Pasi Kallinen
65b320de39 Start of movement tests
Adds the following lua functions:

- nh.pushkey("x")
    Pushes a key into the command queue. Support is spotty,
    currently only the keys handled in rhack.
- nh.doturn()
    Runs one turn of main loop, or if optional boolean param
    is true, until g.multi == 0
- nh.monster_generation(false)
    Disable monster generation, and kill off all monsters.

Adds a testmove.lua script to test hero movement. Currently
covers only hjklyubn and HJKLYUBN.
2021-07-28 19:19:40 +03:00
Pasi Kallinen
83c2eb5645 Add more shop tests 2021-07-25 22:52:42 +03:00
nhmall
50f9db55e5 add .gitattributes to test 2021-07-24 16:27:39 -04:00
Pasi Kallinen
120a8c0173 Add shop creation test script 2021-07-24 20:29:15 +03:00
Pasi Kallinen
7f39d53ad3 Lua: improve level testing
Add des.finalize_level() used for testing in conjunction with
des.reset_level().
Add nhc.DLB to return 0 or 1 if DLB was defined at compile-time.
Change the test_lev.lua to give more informative messages instead of
just lua error when required file doesn't exist.
Add bigrm-11 to the level tests.
2021-07-24 10:49:06 +03:00
Pasi Kallinen
dbac44596e Lua: Allow boolean params in level_init 2021-07-22 18:02:58 +03:00
Pasi Kallinen
932b6d03c9 Lua: Make des.monster use boolean params 2021-07-22 11:05:40 +03:00
Pasi Kallinen
76bb205367 Add some plural/an tests 2021-07-17 23:29:30 +03:00
copperwater
fa3041c9f9 Make g.coder->lvl_is_joined a boolean
Its value is only used as a boolean, so there's no real need to keep it
as a confusing int.

Shouldn't be a save-breaking change; it doesn't look like g.coder is
saved.
2021-02-19 17:09:41 +02:00
Pasi Kallinen
1b7faaf661 Add couple more config tests 2021-02-13 11:51:25 +02:00
Pasi Kallinen
b1097df86d Make runmode option complain, add some tests for it 2021-02-12 19:41:46 +02:00
Pasi Kallinen
cc25f40d69 Add lua tests for config file parsing
Bare-bones for now, more tests needed.
2021-02-10 19:22:16 +02:00
Pasi Kallinen
30b59acc40 More wish tests 2020-11-30 15:07:44 +02:00
Pasi Kallinen
a8ed1ab5fd Test wishing "bags of tricks" 2020-11-30 12:06:37 +02:00
Pasi Kallinen
74565c890d Split readobjnam into multiple functions
Also add several new tests for it
2020-11-29 19:08:30 +02:00
copperwater
0fef8fce9f Unify all special level filling options
The existing system was a confusing mess of competing names (filled,
needfill, prefilled, etc) that had varying semantics, with prefilled
being the worst offender as it meant at least three different things in
various contexts. This commit unifies everything in the code under
"needfill", and everything in Lua under "filled", which defaults to 0
everywhere.

This also removes the second argument to fill_special_room; that
function now just checks the needfill of the room it's passed. As
before, a filled == 2 value is used for a special room to indicate that
the room should set the appropriate level flag, but shouldn't actually
be stocked with anything (for instance, King Arthur's throne room); the
difference is that this now comes directly from the lua script instead
of being manipulated within sp_lev.c.

The prefilled argument had one use case that is occasionally used in the
level files: if the level designer had specified an ordinary region with
prefilled = 1, it would become a room to control monster arrivals on a
level -- monsters that arrive within the bounds of a room are supposed
to stay there.
However, not all of the places where the comments indicated this was
being used were using it correctly; I tested this by letting a few
monsters fall through the knox portal (they're supposed to be
constrained to the entry room) and waiting a hundred turns, then going
through the portal; they were not constrained to the room and had
"wandered" through its walls.
Instead of trying to maintain this special case, I have added an
optional "arrival_room" boolean argument to des.region, which forces it
to create a room for the purposes of constraining monster arrival.

I have gone through and replaced occurrences of prefilled in lua files
with the appropriate filled option (or arrival, as needed). In some
cases, that resulted in questionable regions such as a filled ordinary
area in a non-themeroom (I just dropped the filled=1), or an area which
didn't do anything, not even lighting (which I deleted).
2020-09-27 18:54:15 +03:00
Pasi Kallinen
52a15daaf6 Tests: Wishing for sprig of wolfsbane etc 2020-04-21 20:00:26 +03:00
Pasi Kallinen
28c3478ae6 Add test for selection.iterate 2020-04-13 20:29:06 +03:00
Pasi Kallinen
d78dcdcb9b Allow matching any wall map terrain in lua scripts
When matching a terrain, allow using a "w" placeholder that matches
any solid wall:

For example:
   local s = selection.match([[w.w]]);
would match all floor locations with a wall to the left and right of it.
The walls can be solid stone, horizontal, vertical, etc.

This applies to selection.match(), selection.filter_mapchar(), and
des.replace_terrain()
2020-04-13 20:00:34 +03:00
Pasi Kallinen
596ba4bb8a Fix des tests 2020-03-21 14:03:03 +02:00
Pasi Kallinen
2fc9c02f88 lua special level feature flags
Allow des.feature() to set rm flags for the special features.
2020-03-06 20:30:15 +02:00
Pasi Kallinen
54ca0c2211 Lua tests for map and room contents 2020-03-04 22:07:10 +02:00
Pasi Kallinen
c9b21e36a7 Add lua selection match method
Also improve the replace_terrain command parameters.
2020-03-02 16:17:53 +02:00
Pasi Kallinen
297863d4bc Fix room tests 2020-03-01 10:28:19 +02:00
Pasi Kallinen
22528d31f5 Allow coord in place of x and y in special level lua script 2020-02-28 22:14:36 +02:00
Pasi Kallinen
816079c8dd Lua: accept different params for gold function 2020-02-26 17:57:47 +02:00
Pasi Kallinen
dc70132da8 Change lua selection floodfill and add some tests 2020-02-22 18:35:41 +02:00
Pasi Kallinen
fe3dae85d5 Make lua selection filter_mapchar create a new selection 2020-02-22 17:51:29 +02:00
Pasi Kallinen
50eaf95c27 Make lua selection grow create a new selection 2020-02-22 16:58:45 +02:00
Pasi Kallinen
6648ecfe04 Make lua selection randline create a new selection 2020-02-22 16:34:50 +02:00
Pasi Kallinen
b3f337bdf6 Make lua selection rect and fillrect create a new selection 2020-02-22 15:23:30 +02:00
Pasi Kallinen
44f7d44e94 Make lua selection line create a new selection
... instead of modifying the one given as a parameter.

Also add some tests for it.
2020-02-22 14:23:36 +02:00
Pasi Kallinen
00a32c6039 Make lua selection percent filter create a new selection
... instead of modifying the one given as a parameter.

Also add some tests for it.
2020-02-22 13:31:47 +02:00
Pasi Kallinen
42a05e9595 Make lua selection boolean opers create a new selection
... instead of modifying one of the given selections.

Also add tests for the operations.
2020-02-22 12:17:03 +02:00