finished almost all of the game logic