00001 00002 00003 00004 00005 00006 00007 00008 00009 #include <string.h> 00010 #include "FCDebugState.h" 00011 #include "FCHelpingAlgorithms.h" 00012 00013 00014 FCSDebugCard::FCSDebugCard() 00015 { 00016 EmptyCard(); 00017 } 00018 00019 FCSDebugCard::~FCSDebugCard() 00020 { 00021 } 00022 00023 void FCSDebugCard::Copy(FCSCard* Card) 00024 { 00025 m_CardNumber = ((FCSDebugCard*)Card)->m_CardNumber; 00026 m_Flags = ((FCSDebugCard*)Card)->m_Flags; 00027 m_Suit = ((FCSDebugCard*)Card)->m_Suit; 00028 } 00029 00030 void FCSDebugCard::EmptyCard() 00031 { 00032 m_CardNumber = 0; 00033 m_Suit = 0; 00034 m_Flags = 0; 00035 } 00036 00037 bool FCSDebugCard::IsEmptyCard() 00038 { 00039 if ((m_CardNumber == 0) && (m_Suit == 0) && (m_Flags == 0)) 00040 return true; 00041 00042 return false; 00043 } 00044 00045 char FCSDebugCard::GetCardNumber() 00046 { 00047 return m_CardNumber; 00048 } 00049 00050 char FCSDebugCard::GetSuit() 00051 { 00052 return m_Suit; 00053 } 00054 00055 char FCSDebugCard::GetFlipped() 00056 { 00057 return m_Flags; 00058 } 00059 00060 void FCSDebugCard::SetSuit(char Suit) 00061 { 00062 m_Suit = Suit; 00063 } 00064 00065 void FCSDebugCard::SetCardNumber(char CardNumber) 00066 { 00067 m_CardNumber = CardNumber; 00068 } 00069 00070 void FCSDebugCard::SetFlipped(char Flipped) 00071 { 00072 m_Flags = Flipped; 00073 } 00074 00075 int FCSDebugCard::GetClassSize() 00076 { 00077 return sizeof(FCSDebugCard); 00078 } 00079 00080 FCSDebugStack::FCSDebugStack() 00081 { 00082 m_NumberOfCards = 0; 00083 } 00084 00085 int FCSDebugStack::Compare(FCSDebugStack* Stack) 00086 { 00087 int CompareValue; 00088 00089 if (m_NumberOfCards > Stack->m_NumberOfCards) 00090 return 1; 00091 else if (m_NumberOfCards < Stack->m_NumberOfCards) 00092 return -1; 00093 00094 for (int a=0;a<MAX_NUM_CARDS_IN_A_STACK;a++) 00095 { 00096 if ( (CompareValue = m_Cards[a].Compare(&(Stack->m_Cards[a]))) != 0) 00097 return CompareValue; 00098 } 00099 00100 return 0; 00101 } 00102 00103 FCSDebugState::FCSDebugState() 00104 { 00105 memset(m_Foundations, 0, MAX_NUM_DECKS*4); 00106 } 00107 00108 int FCSDebugState::GetClassSize() 00109 { 00110 return sizeof(FCSDebugState); 00111 } 00112 00113 int FCSDebugState::StackCompare(int StackPosition1, int StackPosition2) 00114 { 00115 FCSDebugCard Card1 = m_Stacks[StackPosition1].m_Cards[0]; 00116 FCSDebugCard Card2 = m_Stacks[StackPosition2].m_Cards[0]; 00117 00118 return Card1.Compare(&Card2); 00119 } 00120 00121 int FCSDebugState::Compare(FCSDebugState* State) 00122 { 00123 int CompareValue, a; 00124 for (a = 0;a<MAX_NUM_STACKS;a++) 00125 if ( (CompareValue = m_Stacks[a].Compare(&(State->m_Stacks[a]))) != 0) 00126 return CompareValue; 00127 00128 for (a = 0;a<MAX_NUM_FREECELLS;a++) 00129 if ( (CompareValue = m_Freecells[a].Compare(&(State->m_Freecells[a]))) != 0) 00130 return CompareValue; 00131 00132 return memcmp(m_Foundations, State->m_Foundations, MAX_NUM_DECKS*4); 00133 } 00134