Focus and chance die backend code

The back-end of #87 and #88 should be complete.