Check if $game is defined to prevent errors

Fixes #223.