Refactor game win logic into function for clarity.