00001 00002 00003 00004 00005 00006 00007 00008 00009 #include "FCSDebugMove.h" 00010 #include "FCHelpingAlgorithms.h" 00011 00012 FCSDebugMove::FCSDebugMove() : FCSMove() 00013 { 00014 m_Foundation = 0; 00015 m_NumberOfCardsInSequence = 0; 00016 m_NumberOfCardsFlipped = 0; 00017 m_SourceFreecell = 0; 00018 m_DestinationFreecell = 0; 00019 m_SourceStack = 0; 00020 m_DestinationStack = 0; 00021 m_Type = FCS_MOVE_TYPE_NULL; 00022 } 00023 00024 FCSDebugMove::~FCSDebugMove() 00025 { 00026 } 00027 00028 void FCSDebugMove::Copy(FCSMove* Move) 00029 { 00030 m_Foundation = Move->GetFoundation(); 00031 m_NumberOfCardsInSequence = Move->GetNumberOfCardsInSequence(); 00032 m_NumberOfCardsFlipped = Move->GetNumberOfCardsFlipped(); 00033 m_SourceFreecell = Move->GetSourceFreecell(); 00034 m_DestinationFreecell = Move->GetDestFreecell(); 00035 m_SourceStack = Move->GetSourceStack(); 00036 m_DestinationStack = Move->GetDestStack(); 00037 m_Type = Move->GetType(); 00038 } 00039 00040 unsigned char FCSDebugMove::GetSourceStack() 00041 { 00042 return m_SourceStack; 00043 } 00044 00045 unsigned char FCSDebugMove::GetSourceFreecell() 00046 { 00047 return m_SourceFreecell; 00048 } 00049 00050 unsigned char FCSDebugMove::GetDestStack() 00051 { 00052 return m_DestinationStack; 00053 } 00054 00055 unsigned char FCSDebugMove::GetDestFreecell() 00056 { 00057 return m_DestinationFreecell; 00058 } 00059 00060 unsigned char FCSDebugMove::GetFoundation() 00061 { 00062 return m_Foundation; 00063 } 00064 00065 FCSMoveTypes FCSDebugMove::GetType() 00066 { 00067 return m_Type; 00068 } 00069 00070 unsigned char FCSDebugMove::GetNumberOfCardsInSequence() 00071 { 00072 return m_NumberOfCardsInSequence; 00073 } 00074 00075 unsigned char FCSDebugMove::GetNumberOfCardsFlipped() 00076 { 00077 return m_NumberOfCardsFlipped; 00078 } 00079 00080 void FCSDebugMove::SetSourceStack(unsigned char Value) 00081 { 00082 m_SourceStack = Value; 00083 } 00084 00085 void FCSDebugMove::SetSourceFreecell(unsigned char Value) 00086 { 00087 m_SourceFreecell = Value; 00088 } 00089 00090 void FCSDebugMove::SetDestStack(unsigned char Value) 00091 { 00092 m_DestinationStack = Value; 00093 } 00094 00095 void FCSDebugMove::SetDestFreecell(unsigned char Value) 00096 { 00097 m_DestinationFreecell = Value; 00098 } 00099 00100 void FCSDebugMove::SetFoundation(unsigned char Value) 00101 { 00102 m_Foundation = Value; 00103 } 00104 00105 void FCSDebugMove::SetType(FCSMoveTypes Value) 00106 { 00107 m_Type = Value; 00108 } 00109 00110 void FCSDebugMove::SetNumberOfCardsInSequence(unsigned char Value) 00111 { 00112 m_NumberOfCardsInSequence = Value; 00113 } 00114 00115 void FCSDebugMove::SetNumberOfCardsFlipped(unsigned char Value) 00116 { 00117 m_NumberOfCardsFlipped = Value; 00118 } 00119 00120 FCSDebugMoveStack::FCSDebugMoveStack() : FCSMoveStack() 00121 { 00122 m_Moves = new FCSDebugMove[m_MaxNumberOfMoves]; 00123 } 00124 00125 FCSDebugMoveStack::~FCSDebugMoveStack() 00126 { 00127 delete [] m_Moves; 00128 } 00129 00130 FCSMoveStack* FCSDebugMoveStack::Copy() 00131 { 00132 FCSDebugMoveStack* ReturnStack = new FCSDebugMoveStack(); 00133 00134 ReturnStack->m_MaxNumberOfMoves = m_MaxNumberOfMoves; 00135 ReturnStack->m_NumberOfMoves = m_NumberOfMoves; 00136 for(int a=0;a<m_MaxNumberOfMoves;a++) 00137 ReturnStack->m_Moves[a].Copy(&(m_Moves[a])); 00138 00139 return ReturnStack; 00140 } 00141 00142 void FCSDebugMoveStack::Push(FCSMove* Move) 00143 { 00144 // If all the moves inside the stack are taken then resize the move vector 00145 if (m_NumberOfMoves == m_MaxNumberOfMoves) 00146 { 00147 m_MaxNumberOfMoves += max((m_MaxNumberOfMoves >> 3), FCS_MOVE_STACK_GROW_BY); 00148 Realloc<FCSDebugMove>(&m_Moves, m_NumberOfMoves, m_MaxNumberOfMoves); 00149 } 00150 00151 m_Moves[m_NumberOfMoves++].Copy(Move); 00152 } 00153 00154 int FCSDebugMoveStack::Pop(FCSMove** Move) 00155 { 00156 if (m_NumberOfMoves > 0) 00157 { 00158 (*Move)->Copy(&(m_Moves[--m_NumberOfMoves])); 00159 return 0; 00160 } 00161 else 00162 { 00163 return 1; 00164 } 00165 }