1.1 --- a/Source/CheckersGame.m Wed Jul 09 17:07:45 2008 -0700
1.2 +++ b/Source/CheckersGame.m Mon Jul 14 21:46:09 2008 -0700
1.3 @@ -71,7 +71,7 @@
1.4 - (Piece*) pieceForPlayer: (int)playerNum
1.5 {
1.6 Piece *p = [[Piece alloc] init];
1.7 - p.bounds = CGRectMake(0,0,floor(_grid.spacing.width),floor(_grid.spacing.height));
1.8 + p.bounds = CGRectMake(0,0,floor(_board.spacing.width),floor(_board.spacing.height));
1.9 p.style = (playerNum ?kPieceStyle2 :kPieceStyle1);
1.10 p.owner = [self.players objectAtIndex: playerNum];
1.11 p.name = playerNum ?@"2" :@"1";
1.12 @@ -87,29 +87,29 @@
1.13
1.14 - (void) setUpBoard
1.15 {
1.16 - RectGrid *grid = [[RectGrid alloc] initWithRows: 8 columns: 8 frame: _board.bounds];
1.17 - _grid = grid;
1.18 - [_board addSublayer: _grid];
1.19 - CGPoint pos = _grid.position;
1.20 - pos.x = floor((_board.bounds.size.width-grid.frame.size.width)/2);
1.21 - grid.position = pos;
1.22 - grid.allowsMoves = YES;
1.23 - grid.allowsCaptures = NO;
1.24 - grid.cellColor = CreateGray(0.0, 0.25);
1.25 - grid.altCellColor = CreateGray(1.0, 0.25);
1.26 - grid.lineColor = nil;
1.27 - grid.reversed = ! [[self.players objectAtIndex: 0] isLocal];
1.28 + RectGrid *board = [[RectGrid alloc] initWithRows: 8 columns: 8 frame: _table.bounds];
1.29 + _board = board;
1.30 + [_table addSublayer: _board];
1.31 + CGPoint pos = _board.position;
1.32 + pos.x = floor((_table.bounds.size.width-board.frame.size.width)/2);
1.33 + board.position = pos;
1.34 + board.allowsMoves = YES;
1.35 + board.allowsCaptures = NO;
1.36 + board.cellColor = CreateGray(0.0, 0.5);
1.37 + board.altCellColor = CreateGray(1.0, 0.25);
1.38 + board.lineColor = nil;
1.39 + board.reversed = ! [[self.players objectAtIndex: 0] isLocal];
1.40
1.41 for( int i=0; i<32; i++ ) {
1.42 int row = i/4;
1.43 - [_grid addCellAtRow: row column: 2*(i%4) + (row&1)];
1.44 + [_board addCellAtRow: row column: 2*(i%4) + (row&1)];
1.45 }
1.46 - [_grid release]; // its superlayer still retains it
1.47 + [_board release]; // its superlayer still retains it
1.48 }
1.49
1.50 - (NSString*) initialStateString {return @"111111111111--------222222222222";}
1.51 -- (NSString*) stateString {return _grid.stateString;}
1.52 -- (void) setStateString: (NSString*)state {_grid.stateString = state;}
1.53 +- (NSString*) stateString {return _board.stateString;}
1.54 +- (void) setStateString: (NSString*)state {_board.stateString = state;}
1.55
1.56 - (Piece*) makePieceNamed: (NSString*)name
1.57 {
1.58 @@ -178,7 +178,7 @@
1.59
1.60 - (Player*) checkForWinner
1.61 {
1.62 - NSCountedSet *remaining = _grid.countPiecesByPlayer;
1.63 + NSCountedSet *remaining = _board.countPiecesByPlayer;
1.64 if( remaining.count==1 )
1.65 return [remaining anyObject];
1.66 else
1.67 @@ -192,7 +192,7 @@
1.68 for( NSString *ident in [move componentsSeparatedByString: @"-"] ) {
1.69 while( [ident hasSuffix: @"!"] || [ident hasSuffix: @"*"] )
1.70 ident = [ident substringToIndex: ident.length-1];
1.71 - GridCell *dst = [_grid cellWithName: ident];
1.72 + GridCell *dst = [_board cellWithName: ident];
1.73 if( dst == nil )
1.74 return NO;
1.75 if( src && ! [self animateMoveFrom: src to: dst] )