00001 00002 00003 00004 00005 00006 00007 00008 00009 #include <string.h> 00010 #include "FCCompactState.h" 00011 #include "FCHelpingAlgorithms.h" 00012 00013 FCSCompactCard::FCSCompactCard() 00014 { 00015 EmptyCard(); 00016 } 00017 00018 FCSCompactCard::~FCSCompactCard() 00019 { 00020 } 00021 00022 void FCSCompactCard::Copy(FCSCard* Card) 00023 { 00024 m_Card = ((FCSCompactCard*)Card)->m_Card; 00025 } 00026 00027 void FCSCompactCard::EmptyCard() 00028 { 00029 m_Card = 0; 00030 } 00031 00032 bool FCSCompactCard::IsEmptyCard() 00033 { 00034 return (m_Card == 0); 00035 } 00036 00037 char FCSCompactCard::GetCardNumber() 00038 { 00039 return (m_Card & 0x0F); 00040 } 00041 00042 char FCSCompactCard::GetSuit() 00043 { 00044 return ((m_Card >> 4) & 0x03); 00045 } 00046 00047 char FCSCompactCard::GetFlipped() 00048 { 00049 return (m_Card >> 6); 00050 } 00051 00052 void FCSCompactCard::SetSuit(char Suit) 00053 { 00054 m_Card = ((m_Card&0x4F)|(Suit<<4)); 00055 00056 } 00057 00058 void FCSCompactCard::SetCardNumber(char CardNumber) 00059 { 00060 m_Card = ((m_Card&0xF0)|CardNumber); 00061 } 00062 00063 void FCSCompactCard::SetFlipped(char Flipped) 00064 { 00065 m_Card = ((m_Card&0x3F)|(Flipped<<6)); 00066 } 00067 00068 int FCSCompactCard::GetClassSize() 00069 { 00070 return sizeof(FCSCompactCard); 00071 } 00072 00073 00074 int FCSCompactState::GetClassSize() 00075 { 00076 return sizeof(FCSCompactState); 00077 } 00078 00079 int FCSCompactState::StackCompare(int StackPosition1, int StackPosition2) 00080 { 00081 FCSCompactCard Card1 = m_Data[StackPosition1+1]; 00082 FCSCompactCard Card2 = m_Data[StackPosition2+1]; 00083 00084 return Card1.Compare(&Card2); 00085 } 00086 00087 int FCSCompactState::Compare(FCSCompactState* State) 00088 { 00089 int CompareValue; 00090 for (int a = 0;a<MAX_NUM_STACKS*(MAX_NUM_CARDS_IN_A_STACK+1)+MAX_NUM_FREECELLS+4*MAX_NUM_DECKS;a++) 00091 if ( (CompareValue = m_Data[a].Compare(&(State->m_Data[a]))) != 0) 00092 return CompareValue; 00093 00094 return 0; 00095 } 00096