This is Player.h in view mode; [Download] [Up]
/* Generated by Interface Builder */ #import <objc/Object.h> #import <appkit/Matrix.h> #import <appkit/Text.h> #import <objc/List.h> #import "CardsTracker.h" #import "CardView.h" #import "DistanceCardStackView.h" #import "DrawPileStackView.h" #import "HandTileView.h" #import "SafetyStacksView.h" #import "StackView.h" // There are two player objects in the game. // The player object and the game is designed for no more than two players. // // There two key areas of interest of this object, they are the // the card:movedFrom:to: and playMove methods. // The card:movedFrom:to: method comes from the drag coordinator. It is sent // by the drag coordinator whenever a card is dragged from one pile to another. // The card:movedFrom:to: method does some logic parsing and breaks the move down. // It then calls another method, playCard:fromHandPile:toBattlePile: for example, // to perform futher parsing and complete the move if appropriate. // The playMove method is sent to a Player object to compute and play a move. This // is the method sent to your opponent in response to your move. @interface Player:Object { // All of the objects listed below are set by the .nib // dearchiving method. SafetyStacksView *safetyPile; Matrix *otherScoreMatrix, *mainScoreMatrix; HandTileView *handPile; StackView *battlePile, *speedPile, *discardPile; DrawPileStackView *drawPile; DistanceCardStackView *distancePile; Text *messagesText; id opponent; id gameCoordinator; CardsTracker *cardsTracker; // These lists hold pointers to cards. Therefore when the // lists are erased the objects aren't freed, simply the // pointers to the objects are removed. // The safety and coup fouree lists hold the cards that are // shown in the safety view. List *safetyList, *coupFoureeList; // These variables hold the last known // cards at the top of the speed and battle // piles. They are used for coup fouree detection. // If we want to play a safety card that is // a remedy for a hazard and the hazard wasn't // then on the last play, then it is a // coup fouree. CardView *lastBattleCard, *lastSpeedCard; // These are flags used by the player. When the player // moves a card, and the move is accespted, the cardWasPlayedFlag // is set true. // If a saftey card was played the safetyWasPlayedFlag flag is set // true. BOOL cardWasPlayedFlag, safetyWasPlayedFlag; } +new; - free; // These methods set the outlets for instances of this // class. - setSafetyPile:( SafetyStacksView * )anObject; - setHand:( HandTileView * )anObject; - setBattlePile:( StackView * )anObject; - setSpeedPile:( StackView * )anObject; - setDistancePile:( DistanceCardStackView * )anObject; // These methods are usually called by the oppoent but sometimes // by the player. returns nil ( or an empty list) if no cards // are in the pile. - ( CardView * )battleCard; - ( CardView * )speedCard; - ( List * )safetyCards; // This method is called by the player's safety view to determine // if the card just added is a coup fouree. - ( BOOL )isCoupFouree:( CardView * )aCard; // These methods return various outlets of this object. // These methods are usually called by the game coordinator. - ( SafetyStacksView * )safetyPile; - ( Matrix * )otherScoreMatrix; - ( Matrix * )mainScoreMatrix; - ( HandTileView * )handPile; - ( StackView * )battlePile; - ( DrawPileStackView * )drawPile; - ( StackView * )speedPile; - ( StackView * )discardPile; - ( DistanceCardStackView * )distancePile; - opponent; // These methods are usually called by the game coordinator // during the course of the game. // Prepare for a new hand or game. - newHand; - newGame; // Draw a card and place it in hand. - drawCard; // This message comes from the drag coordinator and is only // sent to the "you" player. That player must decide if the // move is valid. If valid it must disconnect then connect // the card to the proper views. - card:( CardView * )aCard movedFrom:( CardHolder * )oldHolder to:( CardHolder * )newHolder; - playCard:( CardView * )aCard fromDrawPile:( CardHolder * )oldHolder toHandPile:( CardHolder * )newHolder; - playCard:( CardView * )aCard fromHandPile:( CardHolder * )oldHolder toDiscardPile:( CardHolder * )newHolder; - playCard:( CardView * )aCard fromHandPile:( CardHolder * )oldHolder toSpeedPile:( CardHolder * )newHolder; - playCard:( CardView * )aCard fromHandPile:( CardHolder * )oldHolder toBattlePile:( CardHolder * )newHolder; - playCard:( CardView * )aCard fromHandPile:( CardHolder * )oldHolder toSafetyPile:( CardHolder * )newHolder; - playCard:( CardView * )aCard fromHandPile:( CardHolder * )oldHolder toDistancePile:( CardHolder * )newHolder; - playCard:( CardView * )aCard fromHandPile:( CardHolder * )oldHolder toOpponentBattlePile:( CardHolder * )newHolder; - playCard:( CardView * )aCard fromHandPile:( CardHolder * )oldHolder toOpponentSpeedPile:( CardHolder * )newHolder; // Check to see of a distance card can be played. - ( BOOL )canPlayDistanceCard:( CardView * )aCard; // Does the player have the safety card? - ( BOOL )hasSafety:( int )aCard; // These methods are used to determine if the same // player can play a distance card. The methods also // account for the player having the right-of-way // safety card. - ( BOOL )battlePileAllowsMove; - ( BOOL )speedPileAllowsMove; - ( BOOL )speedPileAllowsMove:( CardView * )aCard; // Check to sum to see if it will end the hand or the game. - ( BOOL )sumWillEndHand:( int )aSum; - ( BOOL )sumWillExceedHand:( int )aSum ; - ( BOOL )sumWillEndGame:( int )aSum; // Returns wheather the player has drawn a card from the // draw pile. If he hasn't and the draw pile is empty then // the draw is considered to have ocurred. - ( BOOL )cardDrawn; // Completes the card move the player selected and // any maintenence required. - completeMove:( CardView * )aCard from:( CardHolder * )oldHolder to:( CardHolder * )newHolder; // These methods are used to sum the player's hand // and overall score respectivly. - sumHand; - sumOverall; // Message to the opponent to calculate and play his // next move. // If you want to add intelligence to the computer // algorithm then this is the method to examine. - playMove; // Can the player play a hand? // This is the player looking at himself. - ( BOOL )canPlay; // This is the opponent looking. It's a // guess. - ( BOOL )couldPlay; // Causes the player to play all of the // safeties in its hand. This is done at or // near the end of the game. - finishThoseSafeties; // Look at the card tracker and hand // to determine the number of this type of card // played. - ( int )numCardTypeObserved:( int )aCardType; @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.