redribben icon

oldWinCheck

redribben | PRO | 11/02/15 11:25:34 PM UTC | 0 ⭐ | 7461 👁️ | Never ⏰ | []
Objective C |

0 B

|

None

|

0 👍

/

0 👎

- (void)checkForWin {
    if (([[xoSpots objectAtIndex:0]  isEqual: @"x"]) && ([[xoSpots objectAtIndex:1]  isEqual: @"x"]) && ([[xoSpots objectAtIndex:2]  isEqual: @"x"])) {
        [self gameOver:1];
    }
    else if (([[xoSpots objectAtIndex:3]  isEqual: @"x"]) && ([[xoSpots objectAtIndex:4]  isEqual: @"x"]) && ([[xoSpots objectAtIndex:5]  isEqual: @"x"])) {
        [self gameOver:1];
    }
    else if (([[xoSpots objectAtIndex:6]  isEqual: @"x"]) && ([[xoSpots objectAtIndex:7]  isEqual: @"x"]) && ([[xoSpots objectAtIndex:8]  isEqual: @"x"])) {
        [self gameOver:1];
    }
    else if (([[xoSpots objectAtIndex:0]  isEqual: @"x"]) && ([[xoSpots objectAtIndex:3]  isEqual: @"x"]) && ([[xoSpots objectAtIndex:6]  isEqual: @"x"])) {
        [self gameOver:1];
    }
    else if (([[xoSpots objectAtIndex:1]  isEqual: @"x"]) && ([[xoSpots objectAtIndex:4]  isEqual: @"x"]) && ([[xoSpots objectAtIndex:7]  isEqual: @"x"])) {
        [self gameOver:1];
    }
    else if (([[xoSpots objectAtIndex:2]  isEqual: @"x"]) && ([[xoSpots objectAtIndex:5]  isEqual: @"x"]) && ([[xoSpots objectAtIndex:8]  isEqual: @"x"])) {
        [self gameOver:1];
    }
    else if (([[xoSpots objectAtIndex:0]  isEqual: @"x"]) && ([[xoSpots objectAtIndex:4]  isEqual: @"x"]) && ([[xoSpots objectAtIndex:8]  isEqual: @"x"])) {
        [self gameOver:1];
    }
    else if (([[xoSpots objectAtIndex:2]  isEqual: @"x"]) && ([[xoSpots objectAtIndex:4]  isEqual: @"x"]) && ([[xoSpots objectAtIndex:6]  isEqual: @"x"])) {
        [self gameOver:1];
    }
    else if (([[xoSpots objectAtIndex:0]  isEqual: @"o"]) && ([[xoSpots objectAtIndex:1]  isEqual: @"o"]) && ([[xoSpots objectAtIndex:2]  isEqual: @"o"])) {
        [self gameOver:0];
    }
    else if (([[xoSpots objectAtIndex:3]  isEqual: @"o"]) && ([[xoSpots objectAtIndex:4]  isEqual: @"o"]) && ([[xoSpots objectAtIndex:5]  isEqual: @"o"])) {
        [self gameOver:0];
    }
    else if (([[xoSpots objectAtIndex:6]  isEqual: @"o"]) && ([[xoSpots objectAtIndex:7]  isEqual: @"o"]) && ([[xoSpots objectAtIndex:8]  isEqual: @"o"])) {
        [self gameOver:0];
    }
    else if (([[xoSpots objectAtIndex:0]  isEqual: @"o"]) && ([[xoSpots objectAtIndex:3]  isEqual: @"o"]) && ([[xoSpots objectAtIndex:6]  isEqual: @"o"])) {
        [self gameOver:0];
    }
    else if (([[xoSpots objectAtIndex:1]  isEqual: @"o"]) && ([[xoSpots objectAtIndex:4]  isEqual: @"o"]) && ([[xoSpots objectAtIndex:7]  isEqual: @"o"])) {
        [self gameOver:0];
    }
    else if (([[xoSpots objectAtIndex:2]  isEqual: @"o"]) && ([[xoSpots objectAtIndex:5]  isEqual: @"o"]) && ([[xoSpots objectAtIndex:8]  isEqual: @"o"])) {
        [self gameOver:0];
    }
    else if (([[xoSpots objectAtIndex:0]  isEqual: @"o"]) && ([[xoSpots objectAtIndex:4]  isEqual: @"o"]) && ([[xoSpots objectAtIndex:8]  isEqual: @"o"])) {
        [self gameOver:0];
    }
    else if (([[xoSpots objectAtIndex:2]  isEqual: @"o"]) && ([[xoSpots objectAtIndex:4]  isEqual: @"o"]) && ([[xoSpots objectAtIndex:6]  isEqual: @"o"])) {
        [self gameOver:0];
    }
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎