refactoring player code in C++