Print Page

Wednesday, August 19, 2015

Scry Overflow

In any sufficiently advanced magic using culture there should be commodity magic items or spells capable of accessing the magic equivalent of Stack Overflow.

"How did we ever do magic before Scry Overflow?" the apprentice wizard asks while cut and pasting a demon summoning that goes horribly wrong.


Wednesday, August 12, 2015

Rails callback sequence with observers and model inheritance

 Cleaning up a tangle of callbacks I need to know the order they fire in to guide my refactoring. I ran this experiment in a tiny rails app with Rails 4.0.9 and the 'rails-observers' gem to match a legacy app I am working on, upgrading soon.

I made a mini rails app with two models, one inheriting from the other:

class Thingy < ActiveRecord::Base
  after_create :thingy_created_callback
  def thingy_created_callback     
    puts "thingy_after_create_callback"
  end 
end

class SpecialThingy < Thingy   
  after_create :special_thingy_created_callback
  def special_thingy_created_callback 
    puts "special_thingy_after_create_callback"
  end 
end

Made an observer to observe each:

class ThingyObserver < ActiveRecord::Observer   
  observe Thingy   
  puts "ThingyObserver loaded"
  def after_create(thingy)
    puts "ThingyObserver.after_create"
  end
end


class SpecialThingyObserver < ActiveRecord::Observer   
  observe SpecialThingy   
  puts "SpecialThingyObserver loaded"   
  def after_create(thingy)
    puts "SpecialThingyObserver.after_create" 
  end 
end

When creating an instance of SpecialThingy at console, I see the results in this order:

thingy_after_create_callback
special_thingy_after_create_callback
SpecialThingyObserver.after_create
ThingyObserver.after_create

Sunday, August 2, 2015

What's next in DunGen

Got in some work this morning on the graph styling. Will let you set colors, shapes and borders on nodes, and line width and color of edges. The first editor that I am maybe half done on will be for the overall graph, then a second pass will add to the individual node and edge editors so you can call out an important room in red or with a star shape, or put an arrow on the downhill end of a slide or make water edges blue. Thinking about custom defaults being different for particular types of nodes and edges too, but may not go into that.

Another thing that will be coming pretty soon is to add theme tagging to the hooks and oddities tables so that there can be different lists of set dressing in a castle vs a temple vs a creepy horror setting. You'll only generate a litter of corpses if going totally random or you want stuff like that.

Lastly, I'm thinking to add tweak buttons to the node editing dialog (+Trap), (+Hook) (+Monster) (+Treasure) (+Oddity), so you can just add  a roll for one of them, not a total reroll.

Still mulling ideas about other mapping styles, more monster lists to add in - maybe a branch that does EPT lists instead of D&D, maybe swap in lists tailored to particular OSR rules instead of my personal mish mash. One possible map style would be to draw up a set of semi-geomorphs and record for them the points at which room numbers would go, so they could be tiled onto a canvas, room numbers overlaid, and then contents generated to match the room numbering. The result would be a traditional looking map with some flexibility and nicer looking than I could probably procedurally generate from code.