Skip to main content
  1. Posts/

Day 70a

OldDays seitan-spin cucumber ruby

The tests are working.
The tests are working.

In which we burn some corpses. Mostly evil ones.


Test every day
#

Continuing the UnderworldEnabled work, with the next two situations where a character is sent to the underworld:

  • Your corpse is burned while you’re still online and with positive karma
  • Your corpse is burned while you’re still online and of Evil alignment, and fail a constitution saving throw

So we need the character to be killed, and then have their corpse burn. Time to pull out an old Kesmai mainstay, naphtha. In the game, it came in ceramic bottles and always ignited when the bottle was thrown (I guess it’s assumed there is always a spark nearby to ignite it). The game also didn’t care if you threw something along an unreasonable path, so throw bottle north south is a valid way to break a bottle at your feet.

features/config_file.feature
416
417
418
419
420
421
422
423
424
425
426
427
428
429
Scenario: UnderworldEnabled True, online karmicly challenged burnt corpse goes there
    Given I use the "minimal" database
    And I set "UnderworldEnabled" in the config file to "True"
    And I add player and character "TestBadCorpse01"
    And I set the character's current karma to "1"
    And I set the character's current HP to "1"
    And I put a naphtha in the the character's right hand
    And I put a naphtha in the the character's left hand
    And the server is started
    When I log on as "TestBadCorpse01"
    And I enter the game
    And I throw a bottle in my cell
    And I speak "this is fine"
    Then I saw a message "The world dissolves around you."

Nothing too interesting here, and it works. As always, there is the negative test as well (where UnderworldEnabled is false). For the “You’re evil and you fail a constitution throw” case, I set the character’s constitution to 1 to guarantee failure.

42 scenarios (42 passed)
338 steps (338 passed)
12m58.058s

Tackle a TODO every other day
#

# TODO - verify combat damage in-game?

To verify the display of combat damage in the game itself, we’ll need to set up some actual combat. Since I don’t intend to abuse the innocent Test Dog, let’s spawn in some wolves.

features/config_file.feature
364
365
366
367
368
369
370
371
372
373
374
375
376
Scenario: DisplayCombatDamage True, I can enable and see combat damage
    Given I use the "minimal" database
    And I set "DisplayCombatDamage" in the config file to "True"
    And I add player and character "TestCombat01"
    And I add an immediate NPC spawn of a wolf on the spawn point
    And the server is started
    When I log on as "TestCombat01"
    And I enter the chat
    And I issue the display combat damage command
    And I enter the game from chat
    And I wait for "wolf" to appear
    And I attack the "wolf"
    Then I saw numerical combat damage

As usual, the work involved was more research than code. Using wolves was a bit of a cheat, since the spawn will actually be “3 wolves”, identified as such until they are in the same cell as the player; then the display changes to three “wolf” lines, and my “wait for wolf” code is satisfied. I did get to simplify the database push a bit by writing this little piece of code:

features/lib/db/sql_misc.rb
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
def db_insert_from_hash(table_name, db_hash)
  field_names = []
  values = []
  db_hash.keys.each do |key|
    field_names << "[#{key.to_s}]"
    if db_hash[key].is_a?(String)
      values << "'#{db_hash[key]}'"
    elsif db_hash[key].nil?
      values << 'NULL'
    else
      values << db_hash[key].to_s
    end
  end
  query = "INSERT [dbo].[#{table_name}] (#{field_names.join(', ')}) " +
          "VALUES (#{values.join(', ')})"
end

As long as my hashes represent all required values, I can use that to convert them to SQL INSERT statements. I’m sure it’ll get a little more complicated over time, but it sufficed from the spawn zone entry.

And I can even refactor all of the existing database code to use this method.

Tomorrow.


Useful Stuff
#


More to come
More to come

Day 70a code - tests