diff -r 45c82a071aca -r 6c78cc6bd7a6 Source/DemoBoardView.m --- a/Source/DemoBoardView.m Wed May 28 12:47:10 2008 -0700 +++ b/Source/DemoBoardView.m Thu Jul 03 17:44:30 2008 -0700 @@ -26,15 +26,6 @@ #import "QuartzUtils.h" -/** WARNING: THIS CODE REQUIRES GARBAGE COLLECTION! - ** This sample application uses Objective-C 2.0 garbage collection. - ** Therefore, the source code in this file does NOT perform manual object memory management. - ** If you reuse any of this code in a process that isn't garbage collected, you will need to - ** add all necessary retain/release/autorelease calls, and implement -dealloc methods, - ** otherwise unpleasant leakage will occur! - **/ - - @implementation DemoBoardView @@ -46,6 +37,14 @@ static NSString* sCurrentGameName = @"CheckersGame"; +- (IBAction) toggleRemoteOpponent: (id)sender +{ + NSAssert(self.game.currentTurn==0,@"Game has already begun"); + Player *opponent = [self.game.players objectAtIndex: 1]; + opponent.local = !opponent.local; +} + + - (void) startGameNamed: (NSString*)gameClassName { [super startGameNamed: gameClassName]; @@ -112,19 +111,26 @@ { Game *game = self.game; if( object == game ) { - NSLog(@"maxTurn = %u, currentTurn=%u", self.game.maxTurn,self.game.currentTurn); + NSLog(@"maxTurn = %u, currentTurn = %u", + self.game.maxTurn,self.game.currentTurn); + NSLog(@"Game state = '%@'", self.game.stateString); + _turnSlider.maxValue = self.game.maxTurn; _turnSlider.numberOfTickMarks = self.game.maxTurn+1; Player *p = game.winner; NSString *msg; if( p ) { + // The game is won [[NSSound soundNamed: @"Sosumi"] play]; - msg = @"%@ wins! Congratulations!"; + if( self.game.local ) + msg = @"%@ wins! Congratulations!"; + else + msg = p.local ?@"You Win! Congratulations!" :@"You Lose ... :-("; } else { + // Otherwise go on to the next turn: p = game.currentPlayer; msg = @"Your turn, %@"; - NSLog(@"Game state = '%@'", self.game.stateString); } _headline.string = [NSString stringWithFormat: msg, p.name]; } @@ -149,13 +155,6 @@ } -- (IBAction) enterFullScreen: (id)sender -{ - [super enterFullScreen: sender]; - [self startGameNamed: sCurrentGameName]; // restart game so it'll use the new size -} - - #pragma mark - #pragma mark NSAPPLICATION DELEGATE: