我有Xcode版本6.1(6A1052d),我尝试将其与else分开并加上双括号,但没有一个有效。
##用于检查用户拥有的所有可能性。 ##
func checkForWin(){
这些都是可能的。
plays = int:int
var youWin = 1
var theyWin = 0
var whoWon = ["I":0,"you":1]
for (key,value) in whoWon {
if ((plays[0] == value && plays[1] == value && plays[2] == value && plays[3] == value)||
(plays[1] == value && plays[2] == value && plays[3] == value && plays[4] == value)||
(plays[2] == value && plays[3] == value && plays[4] == value && plays[5] == value)||
(plays[6] == value && plays[7] == value && plays[8] == value && plays[9] == value)||
(plays[7] == value && plays[8] == value && plays[9] == value && plays[10] == value)||
(plays[8] == value && plays[9] == value && plays[10] == value && plays[11] == value)||
(plays[12] == value && plays[13] == value && plays[14] == value && plays[15] == value)||
(plays[13] == value && plays[14] == value && plays[15] == value && plays[16] == value)||
(plays[14] == value && plays[15] == value && plays[16] == value && plays[17] == value)||
(plays[18] == value && plays[19] == value && plays[20] == value && plays[21] == value)||
(plays[19] == value && plays[20] == value && plays[21] == value && plays[22] == value)||
(plays[20] == value && plays[21] == value && plays[22] == value && plays[23] == value)||
(plays[24] == value && plays[25] == value && plays[26] == value && plays[27] == value)||
(plays[25] == value && plays[26] == value && plays[27] == value && plays[28] == value)||
(plays[26] == value && plays[27] == value && plays[28] == value && plays[29] == value)||
(plays[30] == value && plays[31] == value && plays[32] == value && plays[33] == value)||
(plays[31] == value && plays[32] == value && plays[33] == value && plays[34] == value)||
(plays[32] == value && plays[33] == value && plays[34] == value && plays[35] == value)||
(plays[0] == value && plays[6] == value && plays[12] == value && plays[18] == value)||
(plays[6] == value && plays[12] == value && plays[18] == value && plays[24] == value)||
(plays[12] == value && plays[18] == value && plays[24] == value && plays[30] == value)||
(plays[1] == value && plays[7] == value && plays[13] == value && plays[19] == value)||
(plays[7] == value && plays[13] == value && plays[19] == value && plays[25] == value)||
(plays[13] == value && plays[19] == value && plays[25] == value && plays[31] == value)||
(plays[2] == value && plays[8] == value && plays[14] == value && plays[20] == value)||
(plays[8] == value && plays[14] == value && plays[20] == value && plays[26] == value)||
(plays[14] == value && plays[20] == value && plays[26] == value && plays[32] == value)||
(plays[3] == value && plays[9] == value && plays[15] == value && plays[21] == value)||
(plays[9] == value && plays[15] == value && plays[21] == value && plays[27] == value)||
(plays[15] == value && plays[21] == value && plays[27] == value && plays[33] == value)||
(plays[4] == value && plays[10] == value && plays[16] == value && plays[22] == value)||
(plays[10] == value && plays[16] == value && plays[22] == value && plays[28] == value)||
(plays[16] == value && plays[22] == value && plays[28] == value && plays[34] == value)||
(plays[5] == value && plays[11] == value && plays[17] == value && plays[23] == value)||
(plays[11] == value && plays[17] == value && plays[23] == value && plays[29] == value)||
(plays[17] == value && plays[23] == value && plays[29] == value && plays[35] == value)||
(plays[18] == value && plays[13] == value && plays[8] == value && plays[3] == value)||
(plays[24] == value && plays[19] == value && plays[14] == value && plays[9] == value)||
(plays[19] == value && plays[14] == value && plays[9] == value && plays[4] == value)||
(plays[25] == value && plays[20] == value && plays[15] == value && plays[10] == value)
(plays[20] == value && plays[15] == value && plays[10] == value && plays[5] == value)||
(plays[31] == value && plays[26] == value && plays[21] == value && plays[16] == value)||
(plays[26] == value && plays[21] == value && plays[16] == value && plays[11] == value)||
(plays[32] == value && plays[27] == value && plays[22] == value && plays[17] == value)||
(plays[23] == value && plays[16] == value && plays[9] == value && plays[2] == value)||
(plays[29] == value && plays[22] == value && plays[15] == value && plays[8] == value)||
(plays[22] == value && plays[15] == value && plays[8] == value && plays[1] == value)||
(plays[35] == value && plays[28] == value && plays[21] == value && plays[14] == value)||
(plays[28] == value && plays[21] == value && plays[14] == value && plays[7] == value)||
(plays[21] == value && plays[14] == value && plays[7] == value && plays[0] == value)||
(plays[34] == value && plays[27] == value && plays[20] == value && plays[13] == value)||
(plays[27] == value && plays[20] == value && plays[13] == value && plays[6] == value)){
userMessage.hidden = false
userMessage.text = "Looks like \(key) won!"
resetBtn.hidden = false;
done = true;
}
}
}
答案 0 :(得分:2)
检查你的恶劣条件是否有' ||'在每个子条款之后
小贴士:看这里
(plays[25] == value && plays[20] == value && plays[15] == value && plays[10] == value)