Base for win detection

untested, unsure if any bugs exist.
thinks to work on marked with //THIS