Use a separate function to check if the user won

The if statement which checks if the game should be marked as won is
becoming too complicated. Move it to a separate function in order to
improve readability.

Signed-off-by: Marcus Karlsson <mk@acc.umu.se>