我目前有一个单人棋盘游戏,有一个人类玩家和三个 AI 玩家。我想将其更改为四个人类玩家。我怎样才能从下面的代码中实现这一点?我可以简单地对第一行“currentplayer ==3”使用和 OR 语句并将其读取为“currentplayer == 3 | 1”
if (currentPlayer == 3 && ([currentTokens count])){
for (int count = 0; count < [currentTokens count]; count++) {
Token *token = (Token*)[currentTokens objectAtIndex:count];
[token setUserInteractionEnabled:YES];
}
}
else if ([currentTokens count])//For NonHuman Players
{
// NSLog(@"Break3.3");
int arrLength = [currentTokens count];
// NSLog(@"Break3.4 and %i",arrLength);
////////////////// AI for NON HUMAN AT OCCURENCE OF SIX OF DICE////////////
Token *nonHumanToken;
int tokenAtHomeCount = 0;
if (firstDiceValue == 6) {
for (int count = 0; count < [currentTokens count]; count++) {
Token *selectedToken = (Token*)[currentTokens objectAtIndex:count];
if (selectedToken.isAtHome) {
tokenAtHomeCount++;
nonHumanToken = (Token*)[currentTokens objectAtIndex:count];
break;
}
}
if (!tokenAtHomeCount) {
nonHumanToken = (Token*)[currentTokens objectAtIndex:(arc4random()%arrLength)];
}
}
else{
nonHumanToken = (Token*)[currentTokens objectAtIndex:(arc4random()%arrLength)];
}
////////////////////////////////
[self performSelector:@selector(courseOfActionWithDelay:) withObject:nonHumanToken afterDelay:1.5];
// [self moveToken:nonHumanToken Till:firstDiceValue];
if ([currentTokens count]) {
[self DisplayMessageForMovingTokens:currentPlayer];
}
}