completed game functionalities and end-game function