Commit Graph

80 Commits

Author SHA1 Message Date
Pasi Kallinen
b34b7e08a4 Fix lua reset_level
The lua des.reset_level() call did not reset the special level
coder, so some values were kept and couldn't be changed.
Adjust the movement tests for this change.
2026-01-28 10:06:58 +02:00
Pasi Kallinen
060c3de8eb Lua tests: code coverage for applying some items
Add a new debug flag prevent_pline, which prevents all messages
from going out to the UI. This prevents the tests from stopping
for -more-.
Add rudimentary tests for applying whistles, camera, and stethoscope.
2026-01-27 17:33:08 +02:00
Pasi Kallinen
11bed1f55b Lua tests: generation of each object
Test generation of every object, both via des.object and obj.new.
Expose FIRST_OBJECT and LAST_OBJECT numbers to lua.
Add lua nh.int_to_objname, a function to convert integer value to
object base name and class.
Allow creating new nethack lua object by specifying id and class.
2026-01-26 18:00:33 +02:00
Pasi Kallinen
92a8d1dab3 Lua tests: monster creation coverage
Expose constants NUMMONS, LOW_PM, and HIGH_PM to lua.
Allow converting an int to monster type name.
Create one of each type of monster in the lua tests.
2026-01-25 18:32:46 +02:00
Pasi Kallinen
f73d9ee704 Expose selection size description to lua 2026-01-25 15:18:51 +02:00
Pasi Kallinen
4bf1fb5c68 Lua tests: more special level code coverage 2026-01-25 14:50:02 +02:00
Pasi Kallinen
8ae3d0f6bc Lua tests: code coverage for selection room and gradient 2026-01-25 14:18:01 +02:00
Pasi Kallinen
68ba3955fd Lua tests: more code coverage for rooms 2026-01-25 13:49:10 +02:00
Pasi Kallinen
b5dd0eb894 Lua tests: more code coverage for traps 2026-01-23 18:24:28 +02:00
Pasi Kallinen
3b4ce60df4 Lua tests: more code coverage 2026-01-23 17:43:54 +02:00
Pasi Kallinen
49a87bd09c Lua pushkey and getlin
Allow lua nh.pushkey to push multiple keys,
make getlin return the keys in the command queue.
2026-01-22 18:16:55 +02:00
Pasi Kallinen
b9f8f845fc Test for drawbridge 2026-01-21 20:21:12 +02:00
Pasi Kallinen
c5dc08d23a Tests for gas_cloud, exclusion, levregion 2026-01-21 20:15:14 +02:00
SHIRAKATA Kentaro
bcf7bfc52e add a short README for test/ 2025-03-01 15:01:14 +09:00
Pasi Kallinen
cad4d87101 wishtest fix
left-over bit from testing
2024-03-16 17:09:54 +02:00
Pasi Kallinen
9d97835686 Minor wishing alias improvement
Previously when wishing for "ring of protection from shape shifters",
you got a random ring instead of the protection from shape changers,
because the string matching alias was "protection from shape shifters"
without the object class.  Now, we'll check if the wish matched any
object class, but not existing object or alias, and try matching
the aliases again, but only those of the already matching obj class.

Add an alias for the ring of increase accuracy: "ring of accuracy",
and tests for it.
2024-03-16 16:59:58 +02:00
Pasi Kallinen
744d64487b Helltweaks: improve lava river
The lava river will now draw another river, until a certain
amount of map locations have been turned into lava, so you don't
get a teensy "river" made out of 2 lava pools.

Add a lua selection method to count the number of locations
in the selection.
2023-01-30 17:10:39 +02:00
Pasi Kallinen
4af086be73 More interesting Gehennom levels
Instead of just plain old boring mazes, spice up Gehennom by
occasionally adding lava, iron bars, or even mines-style levels
(with lava, of course).

Of the fixed Gehennom levels, only Asmodeus' lair has been changed
to add some random lava pools.

Also some lua fixes and changes:
- Fixed a selection negation bounding box being wrong.
- Fixed a selection negated and ORed returning wrong results.
- des.map now returns a selection of the map grids it touched.
- When using des.map contents-function the commands following the
  map are not relative to it.
2023-01-10 12:20:21 +02:00
copperwater
f71bff3285 Standardize all core and obj functions with relative coords
This is a large iteration on a previous implementation of making
nh.getmap() parse its coordinates as relative to the last defined map or
room rather than absolute to the entire level. Now, everything in the
nh.* and obj.* functions interprets coords as relative rather than
absolute. (By default; if no map or room has been defined, or if the lua
code is executing after level creation is done, they will interpret the
coordinates as absolute).

The general motivation is basically the same - routines that use
absolute coordinates are difficult to use in level creation routines,
because then the designer has to remember to convert the relative
coordinate to an absolute one (and that was impossible before
nh.abscoord was added, particularly in themed rooms). And once
nh.getmap() takes relative coordinates, it would be very strange to have
all the other functions (setting timers, burying objects, etc) remain
with absolute ones.

In a couple places, code is changed to account for coordinates that are
relative to a *room* (which uses g.coder->croom->[lx,ly] as an offset,
instead of relative to a *map*, which uses [xstart,ystart].
Specifically, selection.iterate did not account for this, and without
this the ice themed room timer was not being started in the proper
place.

All tests are updated to respect the new behavior. Most of the modified
functions are not actually used anywhere in level files; the one
exception is starting a timer in a themed room, and that has been
adjusted.

Documentation updated as well to clarify when various things are tossing
around relative and absolute coordinates, both in comments and in
lua.adoc.
2022-08-31 18:26:05 +03:00
Michael Meyer
93842fbb1b Fix: overwriting stairs in movement tests
Like some of the other coordinates in testmove.lua (addressed in
70008fc), the attempt to overwrite the stairs was targeting a spot
one space to the left of the actual position of the stairs, causing it
to have no effect (discussion suggested this may have been a result of
99715e0).  Update it so the stairs are properly erased and won't
interfere with movement tests by stopping a running/rushing hero early.
2022-08-31 18:24:26 +03:00
Michael Meyer
e05f326d1c Add makesingular to test_src
There are already pretty solid tests of makeplural, so add some in the
other direction, since it's similarly complicated and has to implement
many of the same special cases and exceptions in the other direction.  I
originally tried just running the makeplural tests backwards to this
end, but several of them are tests to guarantee already-plural words
aren't further pluralized, so are not reversible.
2022-08-26 18:08:37 +03:00
Michael Meyer
3f3f530e43 Fix: test_src -eaux plurals
These plurals (e.g. "gateau" -> "gateaux") were added to makeplural and
makesingular in 0c0262e, so the test was outdated and failed.  I also
added another test for "Federal Bureau of Investigation", since 'bureau'
is an exception to the -eau rule (pluralizes as 'bureaus') and the
exception was originally implemented in a way that would have caused the
"Federal Bureau of Investigation" test to fail -- so it seems like a
good pitfall to test for.
2022-08-26 18:08:37 +03:00
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