How to decide is dark or bright turn in Function Click called in player Controller

Hi ,

here is the player Controller where we call this entire " Click" function called sown in pictures below , So how can i decide if it is Dark or bright turn chess pieces i mean how to switch turns and how to go about setting the allowed moves…???

Thank you.