Source/HexchequerGame.m
changeset 7 428a194e3e59
parent 1 3eb7be1dd7b6
child 10 6c78cc6bd7a6
     1.1 --- a/Source/HexchequerGame.m	Mon Mar 10 17:30:57 2008 -0700
     1.2 +++ b/Source/HexchequerGame.m	Sun Mar 16 15:06:47 2008 -0700
     1.3 @@ -32,18 +32,31 @@
     1.4  
     1.5  - (Grid*) x_makeGrid
     1.6  {
     1.7 -    HexGrid *grid = [[[HexGrid alloc] initWithRows: 9 columns: 9 frame: _board.bounds] autorelease];
     1.8 +    HexGrid *grid = [[HexGrid alloc] initWithRows: 9 columns: 9 frame: _board.bounds];
     1.9 +    _grid = grid;
    1.10      CGPoint pos = grid.position;
    1.11      pos.x = floor((_board.bounds.size.width-grid.frame.size.width)/2);
    1.12      grid.position = pos;
    1.13 -    [grid addCellsInHexagon];
    1.14      grid.allowsMoves = YES;
    1.15      grid.allowsCaptures = NO;      // no land-on captures, that is
    1.16      grid.cellColor = CreateGray(1.0, 0.25);
    1.17      grid.lineColor = kTranslucentLightGrayColor;
    1.18      
    1.19 -    [self addPieces: @"Green Ball.png" toGrid: grid forPlayer: 0 rows: NSMakeRange(0,2) alternating: NO];
    1.20 -    [self addPieces: @"Red Ball.png"   toGrid: grid forPlayer: 1 rows: NSMakeRange(7,2) alternating: NO];
    1.21 +    [grid addCellsInHexagon];
    1.22 +    for( int y=0; y<9; y++ ) {
    1.23 +        for( int x=0; x<9; x++ ) {
    1.24 +            GridCell *cell = [_grid cellAtRow: y column: x];
    1.25 +            if( cell )
    1.26 +                [_cells addObject: cell];
    1.27 +        }
    1.28 +    }
    1.29 +    self.stateString = @"111111111111111111-------------------------222222222222222222";
    1.30 +    
    1.31 +    [self performSelector: @selector(applyMoveString:) withObject: @"C4D4" afterDelay: 2.0];
    1.32 +    [self performSelector: @selector(applyMoveString:) withObject: @"G3F3" afterDelay: 5.0];
    1.33 +    [self performSelector: @selector(applyMoveString:) withObject: @"D4E4" afterDelay: 8.0];
    1.34 +    [self performSelector: @selector(applyMoveString:) withObject: @"F3D4" afterDelay: 11.0];
    1.35 +    
    1.36      return grid;
    1.37  }
    1.38  
    1.39 @@ -64,8 +77,12 @@
    1.40  {
    1.41      Hex *src=(Hex*)srcHolder, *dst=(Hex*)dstHolder;
    1.42      int playerIndex = self.currentPlayer.index;
    1.43 -    BOOL isKing = ([bit valueForKey: @"King"] != nil);
    1.44 +
    1.45 +    if( self.currentMove.length==0 )
    1.46 +        [self.currentMove appendString: src.name];
    1.47 +    [self.currentMove appendString: dst.name];
    1.48      
    1.49 +    BOOL isKing = ([bit valueForKey: @"King"] != nil);    
    1.50      PlaySound(isKing ?@"Funk" :@"Tink");
    1.51  
    1.52      // "King" a piece that made it to the last row: