I'm trying to create a sports simulation, and I currently have a large pool of Players (which is a class) populated into a List. Each Player has an Energy variable (int) and a "isOnTeam" bool.
What I'd like to do is create a function that basically creates two teams by pulling Players randomly out of this List and placing them onto a Team. However, I don't want the Player to be placed on a Team if 1) they have no energy and 2) they are already on a team.
I'm having the hardest time trying to conceptualize how this will work. How can I run through a List, pulling Players randomly that have energy and are not already have a team, and then having that function stop once each Team (2) is full?
Any help would be greatly appreciated!
What I'd like to do is create a function that basically creates two teams by pulling Players randomly out of this List and placing them onto a Team. However, I don't want the Player to be placed on a Team if 1) they have no energy and 2) they are already on a team.
I'm having the hardest time trying to conceptualize how this will work. How can I run through a List, pulling Players randomly that have energy and are not already have a team, and then having that function stop once each Team (2) is full?
Any help would be greatly appreciated!