00001
00002
00003
00004
00005
00006
00007
00008
00009 #include <string.h>
00010 #include "MiscFreecellGameBoards.h"
00011
00016 int MicrosoftRandom(long* Seed)
00017 {
00018 *Seed = ((*Seed) * 214013 + 2531011);
00019 return ((*Seed) >> 16) & 0x7fff;
00020 }
00021
00022 MicrosoftFreecellGameBoard::MicrosoftFreecellGameBoard(bool Display10AsT) : AFreecellGameBoard(Display10AsT)
00023 {
00024 }
00025
00026 MicrosoftFreecellGameBoard::~MicrosoftFreecellGameBoard()
00027 {
00028 }
00029
00030 void MicrosoftFreecellGameBoard::Shuffle(int Seed)
00031 {
00032 int i, j,
00033 pos = 0,
00034 wLeft = GetNumberOfCardsInDeck();
00035 char* TempDeck = new char[GetNumberOfCardsInDeck()];
00036
00037
00038 for(i=0;i<13;i++)
00039 {
00040 for(j=0;j<4;j++)
00041 {
00042 TempDeck[pos] = m_Deck[i+j*13];
00043 pos++;
00044 }
00045 }
00046
00047 for (i = 0; i < GetNumberOfCardsInDeck(); i++)
00048 {
00049 j = MicrosoftRandom((long*)&Seed) % wLeft;
00050 m_Deck[i] = TempDeck[j];
00051 TempDeck[j] = TempDeck[--wLeft];
00052 }
00053
00054 delete [] TempDeck;
00055 }
00056
00057 void MicrosoftFreecellGameBoard::Deal(char* GameBoard)
00058 {
00059 char Output[9][30];
00060 char CardString[5];
00061 int i;
00062
00063 for (i=0;i<GetNumberOfCardsInDeck();i++)
00064 Output[(i%8)+1][i/8] = m_Deck[i];
00065
00066 for (i = 0; i < 8; i++)
00067 Output[i][0] = '\0';
00068
00069 for (i = 0; i < GetNumberOfCardsInDeck(); i++)
00070 strcat(Output[i%8], CardToString(CardString, m_Deck[i], (i<GetNumberOfCardsInDeck()-8)));
00071
00072 for (i = 0; i < 8; i++)
00073 {
00074 strcat(Output[i], "\n");
00075 strcat(GameBoard, Output[i]);
00076 }
00077
00078 }
00079
00080 int MicrosoftFreecellGameBoard::GetGameBoardSize()
00081 {
00082 return 160;
00083 }
00084
00085
00086 GnomeFreecellGameBoard::GnomeFreecellGameBoard(bool Display10AsT) : MicrosoftFreecellGameBoard(Display10AsT)
00087 {
00088 }
00089
00090 GnomeFreecellGameBoard::~GnomeFreecellGameBoard()
00091 {
00092 }
00093
00094 void GnomeFreecellGameBoard::Shuffle(int Seed)
00095 {
00096 char* TempDeck = new char[GetNumberOfCardsInDeck()];
00097 int Index, i, j, pos = 0;
00098 int j_pos[4] = {13,26,0,-39};
00099
00100 for (i = 0; i < GetNumberOfCardsInDeck(); i++)
00101 {
00102 Index = MicrosoftRandom((long*)&Seed) % (i+1);
00103 for (j = i; j > Index; j--)
00104 m_Deck[j] = m_Deck[j-1];
00105 m_Deck[Index] = 51 - i;
00106 }
00107
00108 for (i = 0; i < GetNumberOfCardsInDeck(); i++)
00109 {
00110 Index = MicrosoftRandom((long*)&Seed) % (i+1);
00111 for (j = i; j > Index; j--)
00112 TempDeck[j] = TempDeck[j-1];
00113 TempDeck[Index] = m_Deck[51-i];
00114 }
00115
00116
00117 for (i = 0; i < GetNumberOfCardsInDeck(); i++)
00118 m_Deck[i] = MakeCard((TempDeck[51-i]%13)+1, (TempDeck[51-i])/13);
00119
00120 delete [] TempDeck;
00121 }
00122
00123 AisleRiotGameBoard::AisleRiotGameBoard(bool Display10AsT) : AFreecellGameBoard(Display10AsT)
00124 {
00125 }
00126
00127 AisleRiotGameBoard::AisleRiotGameBoard() : AFreecellGameBoard()
00128 {
00129 }
00130
00131 AisleRiotGameBoard::~AisleRiotGameBoard()
00132 {
00133 }
00134
00135 void AisleRiotGameBoard::Shuffle(int Seed)
00136 {
00137 int i, j;
00138 char TempCard;
00139
00140 for(i=0 ; i<GetNumberOfCardsInDeck() ; i++)
00141 {
00142 j = i + (MicrosoftRandom((long*)&Seed)%(GetNumberOfCardsInDeck()-i));
00143 TempCard = m_Deck[j];
00144 m_Deck[j] = m_Deck[i];
00145 m_Deck[i] = TempCard;
00146 }
00147 }
00148
00149 AisleRiotFreecellGameBoard::AisleRiotFreecellGameBoard(bool Display10AsT) : AisleRiotGameBoard(Display10AsT)
00150 {
00151 }
00152
00153 AisleRiotFreecellGameBoard::~AisleRiotFreecellGameBoard()
00154 {
00155 }
00156
00157 void AisleRiotFreecellGameBoard::Deal(char* GameBoard)
00158 {
00159 char Output[8][30];
00160 char CardString[5];
00161 int i;
00162
00163 for (i = 0; i < 8; i++)
00164 Output[i][0] = '\0';
00165
00166 for (i = 0; i < GetNumberOfCardsInDeck(); i++)
00167 strcat(Output[i%8], CardToString(CardString, m_Deck[i], (i<GetNumberOfCardsInDeck()-8)));
00168
00169 for (i = 0; i < 8; i++)
00170 {
00171 strcat(Output[i], "\n");
00172 strcat(GameBoard, Output[i]);
00173 }
00174 }
00175
00176 int AisleRiotFreecellGameBoard::GetGameBoardSize()
00177 {
00178 return 160;
00179 }
00180
00181 AisleRiotKlondikeGameBoard::AisleRiotKlondikeGameBoard(bool Display10AsT) : AisleRiotGameBoard(Display10AsT)
00182 {
00183 }
00184
00185 AisleRiotKlondikeGameBoard::~AisleRiotKlondikeGameBoard()
00186 {
00187 }
00188
00189 void AisleRiotKlondikeGameBoard::Deal(char* GameBoard)
00190 {
00191 char Output[8][30];
00192 char CardString[5];
00193 int CardNumber = 0,
00194 i, j;
00195
00196 for(i = 0 ; i < 7 ; i++)
00197 Output[i][0] = '\0';
00198
00199 CardNumber = 0;
00200 for(i = 0 ; i < 7 ; i++)
00201 {
00202 for(j = i ; j < 7 ; j++)
00203 {
00204 strcat(Output[j], CardToString(CardString, m_Deck[CardNumber], (j != i), (j != i)));
00205 CardNumber++;
00206 }
00207 }
00208
00209 strcpy(GameBoard, "Talon: ");
00210 for(; CardNumber < GetNumberOfCardsInDeck(); CardNumber++)
00211 strcat(GameBoard, CardToString(CardString, m_Deck[CardNumber], (CardNumber != GetNumberOfCardsInDeck()-1)));
00212 strcat(GameBoard, "\n");
00213
00214 for (i = 0; i < 7; i++)
00215 {
00216 strcat(Output[i], "\n");
00217 strcat(GameBoard, Output[i]);
00218 }
00219 }
00220
00221 int AisleRiotKlondikeGameBoard::GetGameBoardSize()
00222 {
00223 return 209;
00224 }
00225
00226
00227 AisleRiotEightOffGameBoard::AisleRiotEightOffGameBoard(bool Display10AsT) : AisleRiotGameBoard(Display10AsT)
00228 {
00229 }
00230
00231 AisleRiotEightOffGameBoard::~AisleRiotEightOffGameBoard()
00232 {
00233 }
00234
00235 void AisleRiotEightOffGameBoard::Deal(char* GameBoard)
00236 {
00237 char Output[8][30];
00238 char CardString[5], Freecells[30];
00239 int i;
00240
00241
00242 for (i = 0; i < 8; i++)
00243 Output[i][0] = '\0';
00244
00245 for (i = 0; i < 48; i++)
00246 strcat(Output[i % 8], CardToString(CardString, m_Deck[i], (i<48-8)));
00247
00248 strcpy(Freecells, "FC: ");
00249 for ( ; i < GetNumberOfCardsInDeck() ; i++)
00250 strcat(Freecells, CardToString(CardString, m_Deck[i], (i != GetNumberOfCardsInDeck()-1)));
00251
00252 strcat(Freecells, "\n");
00253 strcpy(GameBoard, Freecells);
00254
00255 for (i = 0; i < 8; i++)
00256 {
00257 strcat(Output[i], "\n");
00258 strcat(GameBoard, Output[i]);
00259 }
00260 }
00261
00262 int AisleRiotEightOffGameBoard::GetGameBoardSize()
00263 {
00264 return 164;
00265 }
00266
00267 AisleRiotSeahavenTowersGameBoard::AisleRiotSeahavenTowersGameBoard(bool Display10AsT) : AisleRiotGameBoard(Display10AsT)
00268 {
00269 }
00270
00271 AisleRiotSeahavenTowersGameBoard::~AisleRiotSeahavenTowersGameBoard()
00272 {
00273 }
00274
00275 void AisleRiotSeahavenTowersGameBoard::Deal(char* GameBoard)
00276 {
00277 char Output[10][30];
00278 char CardString[5], Freecells[30];
00279 int i;
00280
00281 for( i = 0 ; i < 10 ; i++)
00282 Output[i][0] = '\0';
00283
00284 for( i = 0 ; i < 50 ; i++)
00285 strcat(Output[i % 10], CardToString(CardString, m_Deck[i], (i<50-10)));
00286
00287 strcpy(Freecells, "FC: - ");
00288
00289 for ( ; i < GetNumberOfCardsInDeck() ; i++)
00290 strcat(Freecells, CardToString(CardString, m_Deck[i], (i != GetNumberOfCardsInDeck()-1)));
00291
00292 strcat(Freecells, "\n");
00293 strcpy(GameBoard, Freecells);
00294
00295 for( i = 0 ; i < 10 ; i++)
00296 {
00297 strcat(Output[i], "\n");
00298 strcat(GameBoard, Output[i]);
00299 }
00300 }
00301
00302 int AisleRiotSeahavenTowersGameBoard::GetGameBoardSize()
00303 {
00304 return 166;
00305 }
00306
00307 AisleRiotBeleagueredCastleGameBoard::AisleRiotBeleagueredCastleGameBoard(bool Display10AsT)
00308 {
00309 m_Deck = new char[GetNumberOfCardsInDeck()];
00310 m_Display10AsT = Display10AsT;
00311
00312
00313 int CardNumber = 0;
00314 for(int Suit=0;Suit<4;Suit++)
00315 {
00316 for(int Value = 2; Value<=13; Value++)
00317 {
00318 m_Deck[CardNumber] = MakeCard(Value, Suit);
00319 CardNumber++;
00320 }
00321 }
00322
00323 }
00324
00325 AisleRiotBeleagueredCastleGameBoard::~AisleRiotBeleagueredCastleGameBoard()
00326 {
00327 }
00328
00330 #define IndexProgToPysol(i) ((((i)%2) == 1)*4 + ((i/2)%4))
00331
00332 void AisleRiotBeleagueredCastleGameBoard::Deal(char* GameBoard)
00333 {
00334 char Output[8][100];
00335 char CardString[5];
00336 int i;
00337
00338 for (i = 0; i < 8; i++)
00339 Output[i][0] = '\0';
00340
00341 for (i = 0; i < GetNumberOfCardsInDeck(); i++)
00342 strcat(Output[IndexProgToPysol(i % 8)], CardToString(CardString, m_Deck[i], (i<GetNumberOfCardsInDeck()-8)));
00343
00344 strcpy(GameBoard, "Foundations: H-A C-A D-A S-A\n");
00345
00346 for (i = 0; i < 8; i++)
00347 {
00348 strcat(Output[i], "\n");
00349 strcat(GameBoard, Output[i]);
00350 }
00351 }
00352
00353 #undef IndexProgToPysol
00354
00355 int AisleRiotBeleagueredCastleGameBoard::GetGameBoardSize()
00356 {
00357 return 177;
00358 }
00359
00360 int AisleRiotBeleagueredCastleGameBoard::GetNumberOfCardsInDeck()
00361 {
00362 return 48;
00363 }