The purpose of this project is to create a Freecell variant using pointers and stacks. This is accomplished in my code through various ways, but the result is a text version of Freecell!
My game differs from the standard Freecell game in that the cards are dealt horizontally instead of vertical. You can access a card through the command menu, by selecting it by it's row and column, then choosing it's destination the same way.
The source is easily compiled via a makefile.
weazl@wezlbox:~/projects$ make cc -Wall -c -o main.o main.c cc -Wall -c -o display.o display.c cc -Wall -c -o listmanip.o listmanip.c cc -Wall -c -o nodemanip.o nodemanip.c cc -Wall -c -o menu.o menu.c cc -Wall -c -o create.o create.c cc -Wall -c -o shuffle.o shuffle.c cc -Wall -c -o display2.o display2.c cc -Wall -c -o displaytest.o displaytest.c cc -Wall -c -o board.o board.c cc -Wall -g -o freecell main.o display.o listmanip.o nodemanip.o menu.o create.o shuffle.o display2.o displaytest.o board.o -lncurses cc -Wall -g -o freecell main.o display.o listmanip.o nodemanip.o menu.o create.o shuffle.o display2.o displaytest.o board.o -lncurses
Freecell is similar to solitaire in that your goal is to complete the foundations in an ordered suit from ace up. The main difference is that all of the cards are dealt - there is no draw ability. To balance this out though, there are four temporary card locations that you can move your selection to.
The game ends when all of the cards are on the foundations.
Here is what the text version of the game looks like.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- T1 T2 T3 T4 F5 F6 F7 F8 C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 C13 C14 C15 R1: 6H AS JS 3S 3D 3H 6S R2: 2H 8S 8H 3C AD KD KC R3: 8C 7S QH 9H 2D 5H 4H R4: 6D KS 7H 4C 7D 8D JD R5: JC 9D QC 5S TC 5D R6: 2C 2C AH 9C TH QS R7: 9S 7C JH 5C 4S QD R8: 4D AC 6C TD KH TS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Commands: 1 - move a card 2 - store a card in a temporary pile 3 - send a card to a foundation 4 - quit What shall you do?
If for example, you want to make a valid move TS to QS, you would follow this procedure.
Commands: 1 - move a card 2 - store a card in a temporary pile 3 - send a card to a foundation 4 - quit What shall you do? 1 Enter the source row number: 8 Enter the source column number: 6 Enter the destination row number: 7 Enter the destination column number: 7
The screen would then update to show the card in it's new position.
My biggest mistake was biting off more than I could chew - I decided to create the game graphically - which looks really good! But it turned into a monster of a project. I do understand pointers fairly well though now because of this, even though there were many challenges along the way.