Source/GoGame.m
changeset 20 7c9ecb09a612
parent 10 6c78cc6bd7a6
child 21 2eb229411d73
     1.1 --- a/Source/GoGame.m	Thu Jul 03 17:44:30 2008 -0700
     1.2 +++ b/Source/GoGame.m	Fri Jul 18 13:26:59 2008 -0700
     1.3 @@ -48,31 +48,31 @@
     1.4  - (void) setUpBoard
     1.5  {
     1.6      int dimensions = [[self class] dimensions];
     1.7 -    CGSize size = _board.bounds.size;
     1.8 +    CGSize size = _table.bounds.size;
     1.9      CGFloat boardSide = MIN(size.width,size.height);
    1.10 -    RectGrid *grid = [[RectGrid alloc] initWithRows: dimensions columns: dimensions 
    1.11 +    RectGrid *board = [[RectGrid alloc] initWithRows: dimensions columns: dimensions 
    1.12                                                frame: CGRectMake(floor((size.width-boardSide)/2),
    1.13                                                                  floor((size.height-boardSide)/2),
    1.14                                                                  boardSide,boardSide)];
    1.15 -    _grid = grid;
    1.16 +    _board = board;
    1.17      /*
    1.18      grid.backgroundColor = GetCGPatternNamed(@"Wood.jpg");
    1.19      grid.borderColor = kTranslucentLightGrayColor;
    1.20      grid.borderWidth = 2;
    1.21      */
    1.22 -    grid.lineColor = kTranslucentGrayColor;
    1.23 -    grid.cellClass = [GoSquare class];
    1.24 -    [grid addAllCells];
    1.25 -    ((GoSquare*)[grid cellAtRow: 2 column: 2]).dotted = YES;
    1.26 -    ((GoSquare*)[grid cellAtRow: 6 column: 6]).dotted = YES;
    1.27 -    ((GoSquare*)[grid cellAtRow: 2 column: 6]).dotted = YES;
    1.28 -    ((GoSquare*)[grid cellAtRow: 6 column: 2]).dotted = YES;
    1.29 -    grid.usesDiagonals = grid.allowsMoves = grid.allowsCaptures = NO;
    1.30 -    [_board addSublayer: grid];
    1.31 -    [grid release];
    1.32 +    board.lineColor = kTranslucentGrayColor;
    1.33 +    board.cellClass = [GoSquare class];
    1.34 +    [board addAllCells];
    1.35 +    ((GoSquare*)[board cellAtRow: 2 column: 2]).dotted = YES;
    1.36 +    ((GoSquare*)[board cellAtRow: 6 column: 6]).dotted = YES;
    1.37 +    ((GoSquare*)[board cellAtRow: 2 column: 6]).dotted = YES;
    1.38 +    ((GoSquare*)[board cellAtRow: 6 column: 2]).dotted = YES;
    1.39 +    board.usesDiagonals = board.allowsMoves = board.allowsCaptures = NO;
    1.40 +    [_table addSublayer: board];
    1.41 +    [board release];
    1.42      
    1.43 -    CGRect gridFrame = grid.frame;
    1.44 -    CGFloat pieceSize = (int)grid.spacing.width & ~1;  // make sure it's even
    1.45 +    CGRect gridFrame = board.frame;
    1.46 +    CGFloat pieceSize = (int)board.spacing.width & ~1;  // make sure it's even
    1.47      CGFloat captureHeight = gridFrame.size.height-4*pieceSize;
    1.48      _captured[0] = [[Stack alloc] initWithStartPos: CGPointMake(2*pieceSize,0)
    1.49                                             spacing: CGSizeMake(0,pieceSize)
    1.50 @@ -82,7 +82,7 @@
    1.51                                        CGRectGetMinY(gridFrame)+3*pieceSize,
    1.52                                        2*pieceSize, captureHeight);
    1.53      _captured[0].zPosition = kPieceZ+1;
    1.54 -    [_board addSublayer: _captured[0]];
    1.55 +    [_table addSublayer: _captured[0]];
    1.56      [_captured[0] release];
    1.57      
    1.58      _captured[1] = [[Stack alloc] initWithStartPos: CGPointMake(0,captureHeight)
    1.59 @@ -93,7 +93,7 @@
    1.60                                        CGRectGetMinY(gridFrame)+pieceSize,
    1.61                                        2*pieceSize, captureHeight);
    1.62      _captured[1].zPosition = kPieceZ+1;
    1.63 -    [_board addSublayer: _captured[1]];
    1.64 +    [_table addSublayer: _captured[1]];
    1.65      [_captured[1] release];
    1.66  
    1.67      PreloadSound(@"Pop");
    1.68 @@ -107,7 +107,7 @@
    1.69  - (Piece*) pieceForPlayer: (int)index
    1.70  {
    1.71      NSString *imageName = index ?@"bot086.png" :@"bot089.png";
    1.72 -    CGFloat pieceSize = (int)(_grid.spacing.width * 0.9) & ~1;  // make sure it's even
    1.73 +    CGFloat pieceSize = (int)(_board.spacing.width * 0.9) & ~1;  // make sure it's even
    1.74      Piece *stone = [[Piece alloc] initWithImageNamed: imageName scale: pieceSize];
    1.75      stone.owner = [self.players objectAtIndex: index];
    1.76      return [stone autorelease];
    1.77 @@ -191,11 +191,11 @@
    1.78  
    1.79  - (NSString*) stateString
    1.80  {
    1.81 -    int n = _grid.rows;
    1.82 +    int n = _board.rows;
    1.83      unichar state[n*n];
    1.84      for( int y=0; y<n; y++ )
    1.85          for( int x=0; x<n; x++ ) {
    1.86 -            Bit *bit = [_grid cellAtRow: y column: x].bit;
    1.87 +            Bit *bit = [_board cellAtRow: y column: x].bit;
    1.88              unichar ch;
    1.89              if( bit==nil )
    1.90                  ch = '-';
    1.91 @@ -209,7 +209,7 @@
    1.92  - (void) setStateString: (NSString*)state
    1.93  {
    1.94      NSLog(@"Go: setStateString: '%@'",state);
    1.95 -    int n = _grid.rows;
    1.96 +    int n = _board.rows;
    1.97      for( int y=0; y<n; y++ )
    1.98          for( int x=0; x<n; x++ ) {
    1.99              int i = y*n+x;
   1.100 @@ -219,7 +219,7 @@
   1.101                  if( index==0 || index==1 )
   1.102                      piece = [self pieceForPlayer: index];
   1.103              }
   1.104 -            [_grid cellAtRow: y column: x].bit = piece;
   1.105 +            [_board cellAtRow: y column: x].bit = piece;
   1.106          }
   1.107  }
   1.108  
   1.109 @@ -227,7 +227,7 @@
   1.110  - (BOOL) applyMoveString: (NSString*)move
   1.111  {
   1.112      NSLog(@"Go: applyMoveString: '%@'",move);
   1.113 -    return [self animatePlacementIn: [_grid cellWithName: move]];
   1.114 +    return [self animatePlacementIn: [_board cellWithName: move]];
   1.115  }
   1.116  
   1.117