1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/Source/Game+Protected.h Thu Jul 03 17:44:30 2008 -0700
1.3 @@ -0,0 +1,65 @@
1.4 +//
1.5 +// Game+Protected.h
1.6 +// YourMove
1.7 +//
1.8 +// Created by Jens Alfke on 7/3/08.
1.9 +// Copyright 2008 Jens Alfke. All rights reserved.
1.10 +//
1.11 +
1.12 +
1.13 +#import "Game.h"
1.14 +#import "Player.h"
1.15 +#import "Turn.h"
1.16 +#import "Bit.h"
1.17 +#import "BitHolder.h"
1.18 +
1.19 +
1.20 +/** Game API for subclasses to use / override */
1.21 +@interface Game (Protected)
1.22 +
1.23 +/** Should return a string describing the initial state of a new game.
1.24 + The default value is an empty string. */
1.25 +- (NSString*) initialStateString;
1.26 +
1.27 +
1.28 +#pragma mark Abstract methods for subclasses to implement:
1.29 +
1.30 +/** Called by -setBoard: Should all all necessary Grids/Pieces/Cards/etc. to _board.
1.31 + This method is always called during initialization of a new Game, and may be called
1.32 + again afterwards, for example if the board area is resized. */
1.33 +- (void) setUpBoard;
1.34 +
1.35 +/** Should return the winning player, if the current position is a win, else nil.
1.36 + Default implementation returns nil. */
1.37 +- (Player*) checkForWinner;
1.38 +
1.39 +
1.40 +#pragma mark Protected methods for subclasses to call:
1.41 +
1.42 +/** Sets the number of players in the game. Subclass initializers should call this. */
1.43 +- (void) setNumberOfPlayers: (unsigned)n;
1.44 +
1.45 +/** Animate a piece moving from src to dst. Used in implementing -applyMoveString:. */
1.46 +- (BOOL) animateMoveFrom: (CALayer<BitHolder>*)src to: (CALayer<BitHolder>*)dst;
1.47 +
1.48 +/** Animate a piece being placed in dst. Used in implementing -applyMoveString:. */
1.49 +- (BOOL) animatePlacementIn: (CALayer<BitHolder>*)dst;
1.50 +
1.51 +/** Checks for a winner and advances to the next player. */
1.52 +- (void) endTurn;
1.53 +
1.54 +@end
1.55 +
1.56 +
1.57 +/** Optional Game API for tracking the history of a game, and being able to replay moves. */
1.58 +@interface Game (State)
1.59 +
1.60 +/** A string describing the current state of the game (the positions of all pieces,
1.61 + orderings of cards, player scores, ... */
1.62 +@property (copy) NSString* stateString;
1.63 +
1.64 +/** Add a move to the game based on the contents of the string.
1.65 + The string must have been returned by -currentMove at some point. */
1.66 +- (BOOL) applyMoveString: (NSString*)move;
1.67 +
1.68 +@end