Digging routine is probably the most complicated of actions. There are actions for variety of floor and wall types, but also for all game objects. However it's now quite easy to handle game objects, because Damage can be used to generate simple "pick-axe" damage to objects, much like kicking does. Floors and walls (terrain) can produce different results, because there isn't just one floor type (like in Nethack for example). You can do all sorts of special stuff like digging on ice and fall through in icy water.
With terrain tiles I had to create a test function that generates all terrain tiles and then just went on checking what happens when you dig each tile. That way I could clear the confusion caused by rather complicated data-driven approach... but I guess that's the best way to do things anyway: test everything you possibly can figure out.