Implemented a bunch of game logic