Solitaire by: Chris Page Software Wrangler Claris Corporation Send comments, bug reports to: chris_page@powershare.claris.com This game and its source code are free. You may freely distribute them, but you may not sell them for a profit. Built for BeOS dr6. About The Game ============== This is the game called Klondike. The objective is to place all the cards in sorted stacks (from Ace to King), one for each suit. To move a card, drag it. If it is a legal move, the destination will hilite. As a shortcut, you may also double-click a card to move it--if there are any legal moves. There is no undo, so be careful to think it through before you make a move, especially when using the double-click shortcut. To deal a new hand, click the deck. When you have reached the bottom of the deck, click again to begin at the top of the deck (if there are cards left in the deck, there will be a white marker in the deck rectangle, otherwise the rectangle will be empty). If you reach a point where winning is obvious, the game will play out automatically. This happens when all the cards are face-up and there are no cards in the deck or the hand. If you try to close the game window or quit the game, you will be asked for confirmation. In addition, you can click "New Game" to begin a new game. Double-Clicking --------------- When using the double-click shortcut, legal moves are searched for as follows: Cards in the hand: if it is an Ace it is placed on a foundation, otherwise the columns are searched, then the foundations. Cards in a column: the foundations are searched first, then the columns. The columns are always searched left-to-right. Cheating -------- Note that it is against the rules to split columns (move a card other than the top or bottom face-up card of a column), but it is permitted by the program. You decide whether you want to cheat. About The Sources ================= Although the sources are provided to serve as an example of programming the BeOS, this is essentially a rough-draft and is not the best example of the use of either C++ or BeOS APIs. For example, there is too much use of "friend" and public data members (for my tastes). I'd like to point out one specific example of where I'd consider a reorganization: the game view objects are BView subclasses and instantiate child views using public enums from the child views to determine the frame rectangles of the child views. This is because the BView object constructor is given a rect and there is no (convenient) opportunity for a BView descendent to determine its own dimensions. Perhaps putting the entire implementation of game "views" into the subclasses of BView is the wrong way to go. Perhaps there should be another hierarchy of objects that know how to do their own layout and create the BViews. What I'm thinking is that even though the Be APIs use objects that are deceptively like a framework, perhaps we should not use them as such, and instead have a separate framework of objects that manage the OS objects. Something to think about. The project is divided into four groups of sources: Application The application and game window. Debugging Debugging utilities. These allow you to trace program execution to standard-out. Change the definition of "DEBUG" to "1" or "0" in "SolitaireHeaders.h" to turn debugging on and off. To see the trace, start the application using a terminal window (e.g. type "Solitaire" at the BASH prompt). You may also use ">" to record the trace to a file. Model Objects that represent the game model. The model objects know nothing about the visual representation of the game or user input. As a matter of fact, the CardModel object doesn't even keep track of whether it is face-up or face-down; that is determined by the CardView object. View Objects that represent the game visually and handle user input. These objects know something (more than they should) about the game model. NOTE: the CardView object was originally a BView descendant, but I couldn't see a way to make views transparent to draw the cards with round rectangles and show the surface of the card or table behind. Other files in the project folder: Solitaire The game application. Solitaire Icons The IconWorld file that defines the application icon and flags. Solitaire.proj The Metrowerks Be IDE project file. This was built with the version dated Jan 6, 1996. If you wish to build the project without Be IDE, you will have to create a make file. SolitaireHeaders.h The project-wide header. This defines "DEBUG" to control debugging features and #includes to make it convenient to place "beep()" calls in the code for debugging purposes. Disclaimer ========== As with any software, there may be bugs. Chris Page and Claris Corporation take no responsibility for any damage done through your use of this software: use at your own risk.