This is my first Android game App and I'm a bit stuck at the moment.
So, basically what I have is a card game, which consists of a total of 6 turns. 1 st turn=player 1, 2nd turn=player 2, 3rd turn = player 1 and so on.
What I thought at first, was to handle each players turn inside a while loop which stated: WHILE (round<=6), and initialize variable round at 0.
Inside that WHILE loop I had an if(turn=1){ display player 1s available actions and cards on screen and set onclicklisteners and increment variable round by 1 upon a click}, else if (turn=2){ do the same but for player 2}.
This, clearly doesn't work, considering the while loop doesn't wait for the player to click a button or a card, and I find myself in a diabolical infinite loop :(.
So, I've been searching for a solution for a couple of days now, and I can't seem to find something very enlightening.
I would really appreciate if anyone could recommend some sort of solution or any source of information I could read on to get a possible solution.
Thank you.
Your not going to want to do this with a loop. Your best bet is to look into the State Design Pattern.
Using this pattern you will have different states for a "turn". Then when the user clicks a button or a card, the state of the turn changes. Then the "turn" object has listeners to transact the changes, like whose turn it is.
Without seeing some actual code, I cannot give you a code example.