Source/GoGame.m
changeset 24 db8640a38faf
parent 22 4cb50131788f
child 27 b0affce7beb1
     1.1 --- a/Source/GoGame.m	Thu Jul 31 11:18:13 2008 -0700
     1.2 +++ b/Source/GoGame.m	Thu Jul 31 20:01:26 2008 -0700
     1.3 @@ -34,6 +34,14 @@
     1.4  
     1.5  + (int) dimensions {return 19;}
     1.6  
     1.7 ++ (const GridCoord*) spotCoords
     1.8 +{
     1.9 +    static GridCoord const sSpots[10]={ { 3,3}, { 3,9}, { 3,15},
    1.10 +                                        { 9,3}, { 9,9}, { 9,15},
    1.11 +                                        {15,3}, {15,9}, {15,15}, {NSNotFound,NSNotFound} };
    1.12 +    return sSpots;
    1.13 +}
    1.14 +
    1.15  - (id) init
    1.16  {
    1.17      self = [super init];
    1.18 @@ -63,12 +71,11 @@
    1.19      */
    1.20      board.lineColor = kTranslucentGrayColor;
    1.21      board.cellClass = [GoSquare class];
    1.22 +    board.usesDiagonals = board.allowsMoves = board.allowsCaptures = NO;
    1.23      [board addAllCells];
    1.24 -    ((GoSquare*)[board cellAtRow: 2 column: 2]).dotted = YES;
    1.25 -    ((GoSquare*)[board cellAtRow: 6 column: 6]).dotted = YES;
    1.26 -    ((GoSquare*)[board cellAtRow: 2 column: 6]).dotted = YES;
    1.27 -    ((GoSquare*)[board cellAtRow: 6 column: 2]).dotted = YES;
    1.28 -    board.usesDiagonals = board.allowsMoves = board.allowsCaptures = NO;
    1.29 +    const GridCoord *spots = [[self class] spotCoords];
    1.30 +    for( int i=0; spots[i].row!=NSNotFound; i++ )
    1.31 +        ((GoSquare*)[board cellAtRow: spots[i].row column: spots[i].col]).dotted = YES;
    1.32      [_table addSublayer: board];
    1.33      [board release];
    1.34      
    1.35 @@ -261,10 +268,21 @@
    1.36  @implementation Go9Game
    1.37  + (NSString*) displayName   {return @"Go (9x9)";}
    1.38  + (int) dimensions          {return 9;}
    1.39 ++ (const GridCoord*) spotCoords
    1.40 +{
    1.41 +    static GridCoord const sSpots[6]= { {2,2}, {2,6}, {4,4}, {6,2}, {6,6}, {NSNotFound,NSNotFound} };
    1.42 +    return sSpots;
    1.43 +}
    1.44  @end
    1.45  
    1.46  
    1.47  @implementation Go13Game
    1.48  + (NSString*) displayName   {return @"Go (13x13)";}
    1.49  + (int) dimensions          {return 13;}
    1.50 ++ (const GridCoord*) spotCoords
    1.51 +{
    1.52 +    static GridCoord const sSpots[6] = { { 2,2}, { 2,10}, {6,6},
    1.53 +                                         {10,2}, {10,10}, {NSNotFound,NSNotFound} };
    1.54 +    return sSpots;
    1.55 +}
    1.56  @end