Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

FCTalonState.cpp

Go to the documentation of this file.
00001 #include <string.h>
00002 #include <stdlib.h>
00003 #include <stdio.h>
00004 #include "FCTalonState.h"
00005 #include "FCSTalonStateWithLocations.h"
00006 
00014 
00015 /****************************
00016 Need to figure out a way to link this with the same globals in FCState.cpp
00017 *****************************/
00019 const char * const FreecellsPrefixes[] = { "FC:", "Freecells:", "Freecell:", ""};
00021 const char * const FoundationsPrefixes[] = { "Decks:", "Deck:", "Founds:", "Foundations:", "Foundation:", "Found:", ""};
00022 
00024 const char * const TalonPrefixes[] = { "Talon:", "Queue:" , ""};
00026 const char * const NumberOfRedealsPrefixes[] = { "Num-Redeals:", "Redeals-Num:", "Redeals-Number:", ""};
00027 
00028 #ifdef WIN32
00029 #define strncasecmp(a,b,c) (strnicmp((a),(b),(c)))
00030 #endif
00031 
00032 FCSTalonStateData::FCSTalonStateData()
00033 {
00034     memset(m_TalonParams, 0, sizeof(m_TalonParams));
00035 }
00036 
00037 FCSTalonStateData::~FCSTalonStateData()
00038 {
00039 }
00040 
00041 void FCSTalonStateData::Copy(FCSTalonStateData* Data)
00042 {
00043     memcpy(m_TalonParams, Data->m_TalonParams, 3);
00044     m_KlondikeTalonLength = Data->m_KlondikeTalonLength;
00045 }
00046 
00047 int FCSTalonStateData::Compare(const FCSTalonStateData* TalonData)
00048 {
00049     if (m_KlondikeTalonLength < TalonData->m_KlondikeTalonLength)
00050         return -1;
00051 
00052     if (m_KlondikeTalonLength > TalonData->m_KlondikeTalonLength)
00053         return 1;
00054 
00055     return memcmp(m_TalonParams, TalonData->m_TalonParams, FC_TALON_NUMBER_OF_TALON_PARAMETERS);
00056 }
00057 
00058 void FCSTalonStateData::SetKlondikeNumberOfRedealsLeft(char RedealsLeft)
00059 {
00060     m_TalonParams[FC_TALON_PARAM_KLONDIKE_NUMBER_OF_REDEALS_LEFT] = RedealsLeft;
00061 }
00062 
00063 char FCSTalonStateData::GetKlondikeNumberOfRedealsLeft()
00064 {
00065     return m_TalonParams[FC_TALON_PARAM_KLONDIKE_NUMBER_OF_REDEALS_LEFT];
00066 }
00067 
00068 void FCSTalonStateData::SetTalonPosition(char Position)
00069 {
00070     m_TalonParams[FC_TALON_PARAM_POSITION] = Position;
00071 }
00072 
00073 char FCSTalonStateData::GetTalonPosition()
00074 {
00075     return m_TalonParams[FC_TALON_PARAM_POSITION];
00076 }
00077 
00078 void FCSTalonStateData::SetTalonLength(char Length)
00079 {
00080     m_TalonParams[FC_TALON_PARAM_LENGTH] = Length;
00081 }
00082 
00083 char FCSTalonStateData::GetTalonLength()
00084 {
00085     return m_TalonParams[FC_TALON_PARAM_LENGTH];
00086 }
00087 
00088 void FCSTalonStateData::SetKlondikeTalonLength(char Length)
00089 {
00090     m_KlondikeTalonLength = Length;
00091 }
00092 
00093 char FCSTalonStateData::GetKlondikeTalonLength()
00094 {
00095     return m_KlondikeTalonLength;
00096 }
00097 
00098 void FCSTalonStateData::SetKlondikeTalonStackPosition(char Position)
00099 {
00100     m_TalonParams[FC_TALON_PARAM_KLONDIKE_STACK_POSITION] = Position;
00101 }
00102 
00103 char FCSTalonStateData::GetKlondikeTalonStackPosition()
00104 {
00105     return m_TalonParams[FC_TALON_PARAM_KLONDIKE_STACK_POSITION];
00106 }
00107 
00108 void FCSTalonStateData::SetKlondikeTalonQueuePosition(char Position)
00109 {
00110     m_TalonParams[FC_TALON_PARAM_KLONDIKE_QUEUE_POSITION] = Position;
00111 }
00112 
00113 char FCSTalonStateData::GetKlondikeTalonQueuePosition()
00114 {
00115     return m_TalonParams[FC_TALON_PARAM_KLONDIKE_QUEUE_POSITION];
00116 }
00117 
00118 void FCSTalonStateData::KlondikeTalonRedealBare()
00119 {
00120     m_TalonParams[FC_TALON_PARAM_KLONDIKE_STACK_POSITION] = -1;
00121     m_TalonParams[FC_TALON_PARAM_KLONDIKE_QUEUE_POSITION] = 0;
00122 }
00123 
00124 
00125 int MD5TalonStateDataHashAlgorithm::Hash(const FCSTalonStateData* key)
00126 {
00127     unsigned char HashValue[MD5_HASHBYTES];
00128     int RealHashValue;
00129 
00130     //hash the talon cards
00131     m_MD5Hash.Init();
00132     m_MD5Hash.Update((unsigned char*)((FCSTalonStateData*)key)->GetTalon(0), ((FCSTalonStateData*)key)->GetTalon(0)->GetClassSize() * ((FCSTalonStateData*)key)->GetKlondikeTalonLength());
00133     m_MD5Hash.Final(HashValue);
00134     RealHashValue = (*(int*)HashValue);
00135 
00136     if (RealHashValue < 0)
00137     {
00138         // This is a bit mask that nullifies the sign bit of the
00139         // number so it will always be positive
00140         RealHashValue &= (~(1<<((sizeof(RealHashValue)<<3)-1)));
00141     }
00142 
00143     return RealHashValue;
00144 }
00145 
00146 
00147 FCSTalonStateWithLocations::FCSTalonStateWithLocations() : FCSStateWithLocations()
00148 {
00149 }
00150 
00151 FCSTalonStateWithLocations::~FCSTalonStateWithLocations()
00152 {
00153 }
00154 
00155 FCSStateWithLocations* FCSTalonStateWithLocations::CreateInitialState(const char *String, int NumberOfFreecells, 
00156                                                     int NumberOfStacks, int NumberOfDecks, FCSTalonType TalonType)
00157 {
00158     FCSTalonStateWithLocations* ReturnState;
00159 
00160     int DecksIndex[4], c, i;
00161     const char * Str;
00162     FCSCard* Card = FCSCard::Create();
00163     bool FirstLine = true,
00164          PrefixFound;
00165 
00166     const char * const * Prefixes;
00167 
00168     ReturnState = (FCSTalonStateWithLocations*)CreateStateWithLocations();
00169     ReturnState->Initialize(NumberOfStacks);
00170 
00171     Str = String;
00172 
00173     if (TalonType == FCS_TALON_KLONDIKE)
00174         ReturnState->GetTalonData()->SetKlondikeNumberOfRedealsLeft(-1);
00175 
00176     for(int s=0;s<NumberOfStacks;s++)
00177     {
00178         // Move to the next stack
00179         if (!FirstLine)
00180         {
00181             while((*Str) != '\n')
00182                 Str++;
00183 
00184             Str++;
00185         }
00186         FirstLine = false;
00187 
00188         Prefixes = FreecellsPrefixes;
00189         PrefixFound = false;
00190         for(i=0;Prefixes[i][0] != '\0'; i++)
00191         {
00192             if (!strncasecmp(Str, Prefixes[i], strlen(Prefixes[i])))
00193             {
00194                 PrefixFound = true;
00195                 Str += strlen(Prefixes[i]);
00196                 break;
00197             }
00198         }
00199 
00200         if (PrefixFound)
00201         {
00202             for(c=0;c<NumberOfFreecells;c++)
00203             {
00204                 ReturnState->EmptyFreecell(c);
00205             }
00206             for(c=0;c<NumberOfFreecells;c++)
00207             {
00208                 if (c!=0)
00209                 {
00210                     while(
00211                             ((*Str) != ' ') && 
00212                             ((*Str) != '\t') && 
00213                             ((*Str) != '\n') && 
00214                             ((*Str) != '\r')
00215                          )
00216                     {
00217                         Str++;
00218                     }
00219                     if ((*Str == '\n') || (*Str == '\r'))
00220                     {
00221                         break;
00222                     }
00223                     Str++;
00224                 }
00225 
00226                 while ((*Str == ' ') || (*Str == '\t'))
00227                 {
00228                     Str++;
00229                 }
00230                 if ((*Str == '\r') || (*Str == '\n'))
00231                     break;
00232 
00233                 if ((*Str == '*') || (*Str == '-'))
00234                 {
00235                     Card->EmptyCard();
00236                 }
00237                 else
00238                 {
00239                     Card->User2Perl(Str);
00240                 }
00241 
00242                 ReturnState->PutCardInFreecell(c, Card);
00243             }
00244 
00245             while ((*Str != '\n') && (*Str != '\0'))
00246             {
00247                 Str++;
00248             }
00249             s--;
00250             continue;
00251         }
00252 
00253         Prefixes = FoundationsPrefixes;
00254         PrefixFound = false;
00255         for(i=0;Prefixes[i][0] != '\0'; i++)
00256         {
00257             if (!strncasecmp(Str, Prefixes[i], strlen(Prefixes[i])))
00258             {
00259                 PrefixFound = true;
00260                 Str += strlen(Prefixes[i]);
00261                 break;
00262             }
00263         }
00264 
00265         if (PrefixFound)
00266         {
00267             int d;
00268 
00269             for(d=0;d<NumberOfDecks*4;d++)
00270             {
00271                 ReturnState->SetFoundation(d, 0);
00272             }
00273 
00274             for(d=0;d<4;d++)
00275             {
00276                 DecksIndex[d] = 0;
00277             }
00278             while (1)
00279             {
00280                 while((*Str == ' ') || (*Str == '\t'))
00281                     Str++;
00282                 if ((*Str == '\n') || (*Str == '\r'))
00283                     break;
00284                 d = FCSCard::User2PerlSuit(Str);
00285                 Str++;
00286                 while (*Str == '-')
00287                     Str++;
00288                 c = FCSCard::User2PerlCardNumber(Str);
00289                 while (
00290                         (*Str != ' ') && 
00291                         (*Str != '\t') && 
00292                         (*Str != '\n') && 
00293                         (*Str != '\r')
00294                       )
00295                 {
00296                     Str++;
00297                 }
00298 
00299                 ReturnState->SetFoundation(DecksIndex[d]*4+d, c);
00300                 DecksIndex[d]++;
00301                 if (DecksIndex[d] >= NumberOfDecks)
00302                 {
00303                     DecksIndex[d] = 0;
00304                 }
00305             }
00306             s--;
00307             continue;
00308         }
00309 
00310         Prefixes = TalonPrefixes;
00311         PrefixFound = false;
00312         for(i=0;Prefixes[i][0] != '\0'; i++)
00313         {
00314             if (!strncasecmp(Str, Prefixes[i], strlen(Prefixes[i])))
00315             {
00316                 PrefixFound = true;
00317                 Str += strlen(Prefixes[i]);
00318                 break;
00319             }
00320         }
00321 
00322         if (PrefixFound)
00323         {
00324             // Input the Talon
00325             int TalonSize;
00326 
00327             TalonSize = MAX_NUM_DECKS*52+16;
00328             ReturnState->CreateTalons(TalonSize);
00329             ReturnState->GetTalonData()->SetTalonPosition(0);
00330 
00331             for(c=0 ; c < TalonSize ; c++)
00332             {
00333                 // Move to the next card
00334                 if (c!=0)
00335                 {
00336                     while(
00337                         ((*Str) != ' ') && 
00338                         ((*Str) != '\t') && 
00339                         ((*Str) != '\n') && 
00340                         ((*Str) != '\r')
00341                     )
00342                     {
00343                         Str++;
00344                     }
00345                     if ((*Str == '\n') || (*Str == '\r'))
00346                         break;
00347                 }
00348 
00349                 while ((*Str == ' ') || (*Str == '\t'))
00350                     Str++;
00351 
00352                 if ((*Str == '\n') || (*Str == '\r'))
00353                     break;
00354 
00355                 Card->User2Perl(Str);
00356                 ReturnState->GetTalon(c)->Copy(Card);
00357             }
00358             ReturnState->GetTalonData()->SetTalonLength(c);
00359 
00360             if (TalonType == FCS_TALON_KLONDIKE)
00361             {
00362                 ReturnState->GetTalonData()->SetKlondikeTalonLength(ReturnState->GetTalonData()->GetTalonLength());
00363                 ReturnState->GetTalonData()->SetKlondikeTalonStackPosition(-1);
00364                 ReturnState->GetTalonData()->SetKlondikeTalonQueuePosition(0);
00365             }
00366 
00367             s--;
00368             continue;
00369         }
00370 
00371         Prefixes = NumberOfRedealsPrefixes;
00372         PrefixFound = false;
00373         for(i=0;Prefixes[i][0] != '\0'; i++)
00374         {
00375             if (!strncasecmp(Str, Prefixes[i], strlen(Prefixes[i])))
00376             {
00377                 PrefixFound = true;
00378                 Str += strlen(Prefixes[i]);
00379                 break;
00380             }
00381         }
00382 
00383         if (PrefixFound)
00384         {
00385             while ((*Str < '0') && (*Str > '9') && (*Str != '\n'))
00386                 Str++;
00387 
00388             if (*Str != '\n')
00389             {
00390                 int NumberOfRedeals = atoi(Str);
00391                 if (TalonType == FCS_TALON_KLONDIKE)
00392                 {
00393                     ReturnState->GetTalonData()->SetKlondikeNumberOfRedealsLeft( (NumberOfRedeals < 0) ? (-1) : ((NumberOfRedeals > 127) ? 127 : NumberOfRedeals) );
00394                 }
00395             }
00396             s--;
00397             continue;
00398         }
00399 
00400         for(c=0 ; c < MAX_NUM_CARDS_IN_A_STACK ; c++)
00401         {
00402             // Move to the next card
00403             if (c!=0)
00404             {
00405                 while(
00406                     ((*Str) != ' ') && 
00407                     ((*Str) != '\t') && 
00408                     ((*Str) != '\n') && 
00409                     ((*Str) != '\r')
00410                 )
00411                 {
00412                     Str++;
00413                 }
00414                 if ((*Str == '\n') || (*Str == '\r'))
00415                 {
00416                     break;
00417                 }
00418             }
00419 
00420             while ((*Str == ' ') || (*Str == '\t'))
00421             {
00422                 Str++;
00423             }
00424             if ((*Str == '\n') || (*Str == '\r'))
00425             {
00426                 break;
00427             }
00428             Card->User2Perl(Str);
00429 
00430             ReturnState->PushCardIntoStack(s, Card);
00431         } 
00432     }
00433 
00434     //this is needed becuase the "card type" is dymanic and can't be just a local variable
00435     delete Card;
00436 
00437     return ReturnState;
00438 }
00439 
00440 int FCSTalonStateWithLocations::CheckStateValidity(int NumberOfFreecells, int NumberOfStacks, 
00441                                                    int NumberOfDecks, FCSCard** MisplacedCard, FCSTalonType TalonType)
00442 {
00443     int Cards[4][14];
00444     int c, d;
00445 
00446     // Initialize all cards to 0
00447     for(d=0;d<4;d++)
00448         for(c=1;c<=13;c++)
00449             Cards[d][c] = 0;
00450 
00451     // Mark the cards in the decks
00452     for(d=0;d<NumberOfDecks*4;d++)
00453         for (c=1; c<=GetFoundation(d); c++)
00454             Cards[d%4][c]++;
00455 
00456     // Mark the cards in the freecells
00457     for(int f=0;f<NumberOfFreecells;f++)
00458         if (GetFreecellCardNumber(f) != 0)
00459             Cards[GetFreecellCardSuit(f)][GetFreecellCardNumber(f)]++;
00460 
00461     // Mark the cards in the stacks
00462     for(int s=0;s<NumberOfStacks;s++)
00463     {
00464         for (c=0; c<GetStackLength(s); c++)
00465         {
00466             if (GetStackCardNumber(s, c) == 0)
00467             {
00468                 (*MisplacedCard) = FCSCard::Create();
00469                 (*MisplacedCard)->EmptyCard();
00470                 return 3;
00471             }
00472             Cards[GetStackCardSuit(s, c)][GetStackCardNumber(s, c)]++;
00473         }
00474     }
00475 
00476     // Mark the cards in the (gypsy) talon
00477     if ((TalonType == FCS_TALON_GYPSY) || (TalonType == FCS_TALON_KLONDIKE))
00478     {
00479         for(c = ((TalonType == FCS_TALON_GYPSY) ? GetTalonData()->GetTalonPosition() : 0) ; 
00480             c < ((TalonType == FCS_TALON_GYPSY) ? GetTalonData()->GetTalonLength() : GetTalonData()->GetKlondikeTalonLength()); 
00481             c++)
00482         {
00483             if (!GetTalon(c)->IsEmptyCard())
00484                 Cards[GetTalon(c)->GetSuit()][GetTalon(c)->GetCardNumber()]++;
00485         }
00486     }
00487 
00488     // Now check if there are extra or missing cards
00489     for(d=0;d<4;d++)
00490     {
00491         for(c=1;c<=13;c++)
00492         {
00493             if (Cards[d][c] != NumberOfDecks)
00494             {
00495                 (*MisplacedCard) = FCSCard::Create();
00496                 (*MisplacedCard)->SetSuit(d);
00497                 (*MisplacedCard)->SetCardNumber(c);
00498                 return (Cards[d][c] < NumberOfDecks) ? 1 : 2;
00499             }
00500         }
00501     }
00502 
00503     return 0;
00504 }
00505 
00506 void FCSTalonStateWithLocations::StateAsString(char* String, FCSDebugDisplayInfo* DebugInfo)
00507 {
00508     char Freecells[10], Decks[MAX_NUM_DECKS*4][10], StackCards[10];
00509     bool CardNumberIsNull;
00510     int MaxNumberOfCards, NumberOfCards, Length, b, s;
00511 
00512     FCSCard* TempCard;
00513 
00514     char Str2[128], Str3[128], *PtrStr2, *PtrStr3, *Str, a;
00515 
00516     int StackLocations[MAX_NUM_STACKS];
00517     int FreecellLocations[MAX_NUM_FREECELLS];
00518 
00519     if (DebugInfo->m_DisplayDebugOptions & DEBUG_CANONIZED_ORDER_OUTPUT)
00520     {
00521         for(a=0;a<DebugInfo->m_NumberOfStacks;a++)
00522             StackLocations[a] = a;
00523 
00524         for(a=0;a<DebugInfo->m_NumberOfFreecells;a++)
00525             FreecellLocations[a] = a;
00526     }
00527     else
00528     {
00529         for(a=0;a<DebugInfo->m_NumberOfStacks;a++)
00530             StackLocations[m_StackLocations[a]] = a;
00531 
00532         for(a=0;a<DebugInfo->m_NumberOfFreecells;a++)
00533             FreecellLocations[m_FreecellLocations[a]] = a;
00534     }
00535 
00536     for(a=0;a<DebugInfo->m_NumberOfDecks*4;a++)
00537     {
00538         FCSCard::Perl2UserCardNumber(GetFoundation(a), Decks[a], &CardNumberIsNull,
00539                                     (DebugInfo->m_DisplayDebugOptions & DEBUG_DISPLAY_10_AS_T), 0, DebugInfo->m_DisplayDebug);
00540         if (Decks[a][0] == ' ')
00541             Decks[a][0] = '0';
00542     }
00543 
00544     Str = String;
00545 
00546     if (!(DebugInfo->m_DisplayDebugOptions & DEBUG_IS_OUTPUT_PARSEABLE))
00547     {
00548         for(a=0;a<((DebugInfo->m_NumberOfFreecells/4)+(DebugInfo->m_NumberOfFreecells%4 != 0));a++)
00549         {
00550             PtrStr2 = Str2;
00551             PtrStr3 = Str3;
00552             for(b=0;b<min(DebugInfo->m_NumberOfFreecells-a*4, 4);b++)
00553             {
00554                 TempCard = GetFreecellCard(m_FreecellLocations[a*4+b]);
00555                 PtrStr2 += sprintf(PtrStr2, "%3s ", 
00556                     TempCard->Perl2User(Freecells, (DebugInfo->m_DisplayDebugOptions & DEBUG_DISPLAY_10_AS_T),
00557                                         DebugInfo->m_DisplayDebug)
00558                     );
00559                 PtrStr3 += sprintf(PtrStr3, "--- ");
00560             }
00561             if (a < DebugInfo->m_NumberOfDecks)
00562             {
00563                 Str += sprintf(Str, "%-16s        H-%1s C-%1s D-%1s S-%1s\n",
00564                     Str2,
00565                     Decks[a*4],
00566                     Decks[a*4+1],
00567                     Decks[a*4+2],
00568                     Decks[a*4+3]);                    
00569             }
00570             else
00571             {
00572                 Str += sprintf(Str, "%s\n", Str2);
00573             }
00574             Str += sprintf(Str, "%s\n", Str3);
00575         }
00576         for(;a<DebugInfo->m_NumberOfDecks;a++)
00577         {
00578             Str += sprintf(Str, "%-16s        H-%1s C-%1s D-%1s S-%1s\n",
00579                     "",
00580                     Decks[a*4],
00581                     Decks[a*4+1],
00582                     Decks[a*4+2],
00583                     Decks[a*4+3]);    
00584         }
00585         *(Str++) = '\n';
00586         *(Str++) = '\n';
00587         *Str = '\0';
00588 
00589         for(s=0;s<DebugInfo->m_NumberOfStacks;s++)
00590         {
00591             Str += sprintf(Str, " -- ");
00592         }
00593         *(Str++) = '\n';
00594         *Str = '\0';
00595 
00596         MaxNumberOfCards = 0;
00597         for(s=0;s<DebugInfo->m_NumberOfStacks;s++)
00598             if (GetStackLength(StackLocations[s]) > MaxNumberOfCards)
00599                 MaxNumberOfCards = GetStackLength(StackLocations[s]);
00600 
00601         for(NumberOfCards=0;NumberOfCards<MaxNumberOfCards;NumberOfCards++)
00602         {
00603             for(s = 0; s<DebugInfo->m_NumberOfStacks; s++)
00604             {
00605                 if (NumberOfCards >= GetStackLength(StackLocations[s]))
00606                 {
00607                     strcpy(Str, "    ");
00608                     Str += strlen(Str);
00609                 }
00610                 else
00611                 {
00612                     TempCard = GetStackCard(StackLocations[s], NumberOfCards);
00613                     Str += sprintf(Str, "%3s ", 
00614                         TempCard->Perl2User(StackCards, (DebugInfo->m_DisplayDebugOptions & DEBUG_DISPLAY_10_AS_T), 
00615                                             DebugInfo->m_DisplayDebug));                   
00616                 }
00617             }
00618             strcpy(Str, "\n");
00619             Str += strlen(Str);
00620         }
00621 
00622         //output the talons
00623         if (DebugInfo->m_TalonType == FCS_TALON_KLONDIKE)
00624         {
00625             strcpy(Str, "\n");
00626             Str += strlen(Str);
00627 
00628             for (a = 0; a < GetTalonData()->GetKlondikeTalonLength(); a++)
00629             {
00630                 TempCard = GetTalon(a);
00631                 Str += sprintf(Str, "%3s ", TempCard->Perl2User(StackCards, (DebugInfo->m_DisplayDebugOptions & DEBUG_DISPLAY_10_AS_T), 
00632                                             DebugInfo->m_DisplayDebug));
00633             }
00634 
00635             strcpy(Str, "\n");
00636             Str += strlen(Str);
00637         }
00638     }
00639     else
00640     {
00641 
00642         Str += sprintf(Str, "Foundations: ");
00643         for(a=0;a<DebugInfo->m_NumberOfDecks;a++)
00644         {
00645             Str += sprintf(Str,
00646                 "H-%s C-%s D-%s S-%s ",
00647                 Decks[a*4],
00648                 Decks[a*4+1],
00649                 Decks[a*4+2],
00650                 Decks[a*4+3]
00651                 );
00652         }
00653         Str += sprintf(Str, "\nFreecells: ");
00654     
00655         for(a=0;a<DebugInfo->m_NumberOfFreecells;a++)
00656         {
00657             TempCard = GetFreecellCard(FreecellLocations[a]);
00658             Str += sprintf(Str, "%3s", 
00659                 TempCard->Perl2User(Freecells, (DebugInfo->m_DisplayDebugOptions & DEBUG_DISPLAY_10_AS_T), 
00660                                     DebugInfo->m_DisplayDebug)          
00661                 );
00662             if (a < DebugInfo->m_NumberOfFreecells-1)
00663             {
00664                 *(Str++) = ' ';
00665                 *Str = '\0';
00666             }
00667         }
00668 
00669         *(Str++) = '\n';
00670         *Str = '\0';
00671 
00672         //output the talons
00673         if (DebugInfo->m_TalonType == FCS_TALON_KLONDIKE)
00674         {
00675             Str += sprintf(Str, "Talons: ");
00676             for (a = 0; a < GetTalonData()->GetKlondikeTalonLength(); a++)
00677             {
00678                 TempCard = GetTalon(a);
00679                 Str += sprintf(Str, "%3s ", TempCard->Perl2User(StackCards, (DebugInfo->m_DisplayDebugOptions & DEBUG_DISPLAY_10_AS_T), 
00680                                             DebugInfo->m_DisplayDebug));
00681             }
00682         }
00683 
00684         *(Str++) = '\n';
00685         *Str = '\0';
00686 
00687         for(s=0;s<DebugInfo->m_NumberOfStacks;s++)
00688         {
00689             strcpy(Str, ": ");
00690             Str += strlen(Str);
00691 
00692             Length = GetStackLength(StackLocations[s]);
00693             for(NumberOfCards=0;NumberOfCards<Length;NumberOfCards++)
00694             {
00695                 TempCard = GetStackCard(StackLocations[s], NumberOfCards);
00696                 TempCard->Perl2User(StackCards, (DebugInfo->m_DisplayDebugOptions & DEBUG_DISPLAY_10_AS_T),
00697                                     DebugInfo->m_DisplayDebug);
00698 
00699                 strcpy(Str, StackCards);
00700                 Str += strlen(Str);
00701                 if (NumberOfCards < Length-1)
00702                 {
00703                     strcpy(Str, " ");
00704                     Str += strlen(Str);
00705                 }
00706             }
00707             strcpy(Str,"\n");
00708             Str += strlen(Str);
00709         }
00710     }
00711 }
00712 
00713 FCSCard* FCSTalonStateWithLocations::GetTalon(int Position)
00714 {
00715     return GetTalonData()->GetTalon(Position);
00716 }
00717 
00718 FCSTalonStateData* CreateTalonStateData()
00719 {
00720     switch (GlobalStateType)
00721     {
00722     case FC_TALON_DEBUG_STATE:
00723         return new FCSDebugTalonStateData();
00724     case FC_TALON_COMPACT_STATE:
00725         return new FCSCompactTalonStateData();
00726     case FC_TALON_INDIRECT_STATE:
00727         return new FCSIndirectTalonStateData();
00728     default:
00729         return NULL;
00730     }
00731 
00732     return NULL;
00733 }

Generated on Sat Nov 5 11:20:16 2005 for Cpp Freecell Solver by  doxygen 1.4.4