Refactors functions and code, and alters game loop

Updates the functions and code for a more DRY and pure function-based
approach. It also alters the game loop to account for the total number
of turns and the game also still being played, and makes it more
efficient and less redundant.