-1
我試圖找出誰是下一個玩家在回合制撲克遊戲。在Objective C中有沒有問題,但由於進出口新的PHP的,我不太清楚如何寫這個循環:你會如何在php中編寫這個objective-c循環?
for (int i = 0; i < [match.participants count]; i++)
{
nextParticipant = [participantsArray objectAtIndex:((currentIndex + 1 + i) % [match.participants count])];
if (nextParticipant.matchOutcome != GKTurnBasedMatchOutcomeQuit)
{
//NSLog(@"isn't quit %@", nextParticipant);
nextPlayer = nextParticipant;
break;
}
else
{
//NSLog(@"Player not active, continue the for loop to get the next player");
}
}
所以循環遍歷數組中的所有參與者。 currentIndex是前一位玩家的指數。
所以在每次回合後,玩家將他的信息和他的索引一起發送到服務器。因此,如果玩家4輪到他,那麼劇本應該將轉向玩家5,但只有當他處於活動狀態時(他的狀態設置爲4,參見下文)
我可以通過服務器獲得活動玩家:
$query = "SELECT player1Status, player2Status, player3Status, player4Status,player5Status,player6Status WHERE match_id='$match_id'";
while ($row = mysql_fetch_object($result)) {
$player1Status = $row['player1Status'];
$player2Status = $row['player2Status'];
$player3Status = $row['player3Status'];
$player4Status = $row['player4Status'];
$player5Status = $row['player5Status'];
$player6Status = $row['player6Status'];
}
而且我也有關於比賽的信息:
$numberOfPlayersInMatch
$currentPlayerIndex
我只是不知道如何把它放在一起的一個好辦法。任何幫助非常感謝。謝謝
真棒。謝謝 – BlackMouse 2012-03-19 15:19:05