1.1 --- a/Source/GoGame.m Mon Mar 10 17:30:57 2008 -0700
1.2 +++ b/Source/GoGame.m Wed Mar 12 15:49:36 2008 -0700
1.3 @@ -32,29 +32,20 @@
1.4 @implementation GoGame
1.5
1.6
1.7 -- (void) x_createDispenser: (NSString*)imageName position: (CGPoint)position forPlayer: (unsigned)playerNo
1.8 -{
1.9 - CGFloat pieceSize = (int)(_grid.spacing.width * 0.9) & ~1; // make sure it's even
1.10 - Piece *stone = [[Piece alloc] initWithImageNamed: imageName scale: pieceSize];
1.11 - stone.owner = [self.players objectAtIndex: playerNo];
1.12 - CGRect frame = {position, {1.5*pieceSize,1.5*pieceSize}};
1.13 - Dispenser *disp = [[Dispenser alloc] initWithPrototype: stone quantity: INT_MAX frame:frame];
1.14 - [_board addSublayer: disp];
1.15 - [disp release];
1.16 - [stone release];
1.17 -}
1.18 -
1.19 -
1.20 - (id) initWithBoard: (GGBLayer*)board
1.21 {
1.22 self = [super initWithBoard: board];
1.23 if (self != nil) {
1.24 [self setNumberOfPlayers: 2];
1.25 + [(Player*)[_players objectAtIndex: 0] setName: @"Red"];
1.26 + [(Player*)[_players objectAtIndex: 1] setName: @"White"];
1.27
1.28 CGSize size = board.bounds.size;
1.29 + CGFloat boardSide = MIN(size.width,size.height);
1.30 RectGrid *grid = [[RectGrid alloc] initWithRows: 9 columns: 9
1.31 - frame: CGRectMake((size.width-size.height+16)/2,8,
1.32 - size.height-16,size.height-16)];
1.33 + frame: CGRectMake(floor((size.width-boardSide)/2),
1.34 + floor((size.height-boardSide)/2),
1.35 + boardSide,boardSide)];
1.36 _grid = grid;
1.37 grid.backgroundColor = GetCGPatternNamed(@"Wood.jpg");
1.38 grid.borderColor = kTranslucentLightGrayColor;
1.39 @@ -72,15 +63,6 @@
1.40
1.41 CGRect gridFrame = grid.frame;
1.42 CGFloat pieceSize = (int)grid.spacing.width & ~1; // make sure it's even
1.43 - [self x_createDispenser: @"Red Ball.png"
1.44 - position: CGPointMake(CGRectGetMinX(gridFrame)-2*pieceSize,
1.45 - CGRectGetMinY(gridFrame))
1.46 - forPlayer: 0];
1.47 - [self x_createDispenser: @"White Ball.png"
1.48 - position: CGPointMake(CGRectGetMaxX(gridFrame)+0.5*pieceSize,
1.49 - CGRectGetMaxY(gridFrame)-1.5*pieceSize)
1.50 - forPlayer: 1];
1.51 -
1.52 CGFloat captureHeight = gridFrame.size.height-4*pieceSize;
1.53 _captured[0] = [[Stack alloc] initWithStartPos: CGPointMake(2*pieceSize,0)
1.54 spacing: CGSizeMake(0,pieceSize)
1.55 @@ -110,6 +92,18 @@
1.56 }
1.57
1.58
1.59 +- (Bit*) bitToPlaceInHolder: (id<BitHolder>)holder
1.60 +{
1.61 + if( holder.bit != nil || ! [holder isKindOfClass: [GoSquare class]] )
1.62 + return nil;
1.63 + NSString *imageName = self.currentPlayer.index ?@"White Ball.png" :@"Red Ball.png";
1.64 + CGFloat pieceSize = (int)(_grid.spacing.width * 0.9) & ~1; // make sure it's even
1.65 + Piece *stone = [[Piece alloc] initWithImageNamed: imageName scale: pieceSize];
1.66 + stone.owner = self.currentPlayer;
1.67 + return [stone autorelease];
1.68 +}
1.69 +
1.70 +
1.71 - (BOOL) canBit: (Bit*)bit moveFrom: (id<BitHolder>)srcHolder to: (id<BitHolder>)dstHolder
1.72 {
1.73 Square *dst=(Square*)dstHolder;