refactor code to make one player function that takes different argument depending on turn