finished basic game logic