diff -r 3eb7be1dd7b6 -r 45c82a071aca Source/CheckersGame.m --- a/Source/CheckersGame.m Mon Mar 10 17:30:57 2008 -0700 +++ b/Source/CheckersGame.m Wed May 28 12:47:10 2008 -0700 @@ -30,46 +30,34 @@ @implementation CheckersGame -- (void) addPieces: (NSString*)imageName - toGrid: (Grid*)grid - forPlayer: (int)playerNum - rows: (NSRange)rows - alternating: (BOOL)alternating +- (Piece*) pieceForPlayer: (int)playerNum { - Piece *prototype = [[Piece alloc] initWithImageNamed: imageName scale: floor(grid.spacing.width * 0.8)]; - prototype.owner = [self.players objectAtIndex: playerNum]; - unsigned cols=grid.columns; - for( unsigned row=rows.location; row)srcHolder to: (id)dstHolder { @@ -101,8 +133,12 @@ { Square *src=(Square*)srcHolder, *dst=(Square*)dstHolder; int playerIndex = self.currentPlayer.index; + + if( self.currentMove.length==0 ) + [self.currentMove appendString: src.name]; + [self.currentMove appendString: dst.name]; + BOOL isKing = ([bit valueForKey: @"King"] != nil); - PlaySound(isKing ?@"Funk" :@"Tink"); // "King" a piece that made it to the last row: @@ -154,4 +190,22 @@ } +- (BOOL) applyMoveString: (NSString*)move +{ + int length = move.length; + if( length<4 || (length&1) ) + return NO; + GridCell *src = nil; + for( int i=0; i 0 ) + if( ! [self animateMoveFrom: src to: dst] ) + return NO; + src = dst; + } + return YES; +} + + @end