implemented all of the core game logic