I have a poker game where 2 to 5 players join the game before the start button is pressed.They are added to a players arrays array as objects containing userid and username.
I need to populate my currentUser with the player object then on a button click(call/raise/fold) move to the next in the array to give illusion of the game moving seat to seat
When the start button is clicked i set the current user to the first element in the array which works.
$thisPokergame->State['CurrentUser'] = RESET($thisPokergame->State['Players']);
then im trying this
if($thisPokergame->State['CurrentUser'] == end($thisPokergame->State['Players']))
{
$thisPokergame->State['CurrentUser'] = reset($thisPokergame->State['Players']);
}
else{
$thisPokergame->State['CurrentUser'] = next($thisPokergame->State['Players']);;
}
the if works by itself e.g if its the last player in the array it set current user to the the first and so does the statement inside the else.
When i put them together i get currentuser as false and i cant see the reason. anyone have a solution or better way to do it?