In which we question a lot of what we’ve written.
Test Every Day #
Bless #
The Bless potion just combined a few different effects and is pretty trivial (if time-consuming) to test:
|
|
Wizard_Eye #
This is a lot more interesting. From the server code, in CreateCharacterEffect
:
|
|
So it creates an NPC clone of the target, puts the same wizard eye effect on the clone, hides the target in shadows indefinitely, brings the clone into the world at the same location as the target, and changes the target to a toad (or rat if they are a thief).
That’s a bunch of stuff to test; let’s try something simple first:
|
|
|
|
It works, although I’m starting to get uncomfortable with our lack of parsing on the output: there’s no distinction between the map, the character list, flavor text, and stats bar. False positives are definitely possible where we mistake text in one for text in another.
While we contemplate that, let’s go one step further:
|
|
And something else I’m not comfortable with: the way we handle multiple characters being used in a test. Interesting player interaction is going to take a lot of work; so let’s stop there for now.
Tackle a TODO every other day #
Empty Hands #
|
|
So I add a hook and tag the tests:
|
|
|
|
But then I realized that I already had a hook for clearing all of the player stuff in the database, and it’d be far simpler to just use that after every test than worry about whether I’d altered hands or effects or inventory or whatever.
|
|
New Player #
Rubocop’s been providing me with lots of additional TODOs. It didn’t like my db_insert_player
method, and neither did I:
|
|
So we move all of the defaults into the DEFAULT_PLAYER
hash:
|
|
And then we can make db_insert_player
nice and Rubocop-friendly:
|
|
Fix a Bug in the Legacy Code Every Fifth Day #
|
|
I can certainly add a burp to the server code (and I did, briefly); but that’s not where it belongs, is it?
|
|
…
|
|
The drinkDesc
is what’s intended to be shown to the player themselves when an item is drunk. So
let’s fix the test, not the server:
|
|
|
|
I use my nifty create_item_from_blank
method, using the existing item as the “blank”, to make a
new item with a changed field.
That works fine, but when I fix the player-in-the-same-cell test:
|
|
I still don’t see it. Maybe there really is a bug to fix on the server side!
The effect code calls uses SendToAllInSight
, so let’s add a bunch of debug to that:
|
|
After enabling all of the debug, we can see that the bitcount
index into the visCells
array is
behaving oddly.
12/23/2016 10:09:13 PM: {Unknown} SendToAllInSight from TestAle02_name considering relative cell -3, -3(bitcount 0)
12/23/2016 10:09:13 PM: {Unknown} SendToAllInSight from TestAle02_name considering relative cell -2, -3(bitcount 0)
12/23/2016 10:09:13 PM: {Unknown} SendToAllInSight from TestAle02_name considering relative cell -1, -3(bitcount 0)
12/23/2016 10:09:13 PM: {Unknown} SendToAllInSight from TestAle02_name considering relative cell 0, -3(bitcount 0)
12/23/2016 10:09:13 PM: {Unknown} SendToAllInSight from TestAle02_name considering relative cell 1, -3(bitcount 0)
12/23/2016 10:09:13 PM: {Unknown} SendToAllInSight from TestAle02_name considering relative cell 2, -3(bitcount 0)
12/23/2016 10:09:13 PM: {Unknown} SendToAllInSight from TestAle02_name considering relative cell 3, -3(bitcount 0)
12/23/2016 10:09:13 PM: {Unknown} SendToAllInSight from TestAle02_name considering relative cell -3, -2(bitcount 0)
12/23/2016 10:09:13 PM: {Unknown} SendToAllInSight from TestAle02_name considering relative cell -2, -2(bitcount 0)
12/23/2016 10:09:13 PM: {Unknown} SendToAllInSight from TestAle02_name considers relative cell -2, -2 in bounds.
12/23/2016 10:09:13 PM: {Unknown} SendToAllInSight from TestAle02_name considering relative cell -1, -2(bitcount 1)
12/23/2016 10:09:13 PM: {Unknown} SendToAllInSight from TestAle02_name considers relative cell -1, -2 in bounds.
12/23/2016 10:09:13 PM: {Unknown} SendToAllInSight from TestAle02_name considering relative cell 0, -2(bitcount 2)
12/23/2016 10:09:13 PM: {Unknown} SendToAllInSight from TestAle02_name considers relative cell 0, -2 in bounds.
Another look at the server code, and we see why: bitcount
is only incremented for cells that are
in bounds. Since our test map is quite small, and players are spawning near the edge, a portion of
their immediate area is out of bounds.
I could tweak the server code to behave the way I think it was intended to, but I feel certain that there are probably other edge-of-the-map issues waiting for me. So instead I’ll expand the test map so the players are always safely away from the edge.
|
|
12/24/2016 3:36:38 PM: {Unknown} SendToAllInSight from TestAle01_name considering relative cell -1, 0(bitcount 23)
12/24/2016 3:36:38 PM: {Unknown} SendToAllInSight from TestAle01_name considers relative cell -1, 0 in bounds.
12/24/2016 3:36:38 PM: {Unknown} SendToAllInSight from TestAle01_name considers relative cell -1, 0 visible?
12/24/2016 3:36:38 PM: {Unknown} SendToAllInSight from TestAle01_name considers relative cell -1, 0 non-null?
12/24/2016 3:36:38 PM: {Unknown} SendToAllInSight from TestAle01_name considering relative cell 0, 0(bitcount 24)
12/24/2016 3:36:38 PM: {Unknown} SendToAllInSight from TestAle01_name considers relative cell 0, 0 in bounds.
12/24/2016 3:36:38 PM: {Unknown} SendToAllInSight from TestAle01_name considers relative cell 0, 0 visible?
12/24/2016 3:36:38 PM: {Unknown} SendToAllInSight from TestAle01_name considers relative cell 0, 0 non-null?
12/24/2016 3:36:38 PM: {Unknown} SendToAllInSight from TestAle01_name considering TestAle02_name.
12/24/2016 3:36:38 PM: {Unknown} SendToAllInSight from TestAle01_name considering TestAle02_name further.
12/24/2016 3:36:38 PM: {Unknown} SendToAllInSight from TestAle01_name sending "TestAle01_name burps loudly." to TestAle02_name.
12/24/2016 3:36:38 PM: {Unknown} SendToAllInSight from TestAle01_name sending (filtered) "TestAle01_name burps loudly." to TestAle02_name.
12/24/2016 3:36:38 PM: {Unknown} SendToAllInSight from TestAle01_name considering TestAle01_name.
12/24/2016 3:36:38 PM: {Unknown} SendToAllInSight from TestAle01_name considering relative cell 1, 0(bitcount 25)
12/24/2016 3:36:38 PM: {Unknown} SendToAllInSight from TestAle01_name considers relative cell 1, 0 in bounds.
12/24/2016 3:36:38 PM: {Unknown} SendToAllInSight from TestAle01_name considers relative cell 1, 0 visible?
12/24/2016 3:36:38 PM: {Unknown} SendToAllInSight from TestAle01_name considers relative cell 1, 0 non-null?
Much better.
124 scenarios (124 passed)
1241 steps (1241 passed)
50m36.933s
Interesting Stuff #