00001
00002
00003
00004
00005
00006
00007
00008
00009 #include <string.h>
00010 #include <stdio.h>
00011 #include "PysolGameBoards.h"
00012
00013 double PysolRandom64(integer64* Seed)
00014 {
00015 (*Seed) = ((*Seed)*INT64_CONSTANT(6364136223846793005) + INT64_CONSTANT(1)) & INT64_CONSTANT(0xffffffffffffffff);
00016 return (((*Seed) >> 21) & INT64_CONSTANT(0x7fffffff)) / 2147483648.0;
00017 }
00018
00019 int PysolRandom64Int(integer64* Seed, int LowerBound, int UpperBound)
00020 {
00021 return (LowerBound + (int)(PysolRandom64(Seed) * (UpperBound+1-LowerBound)));
00022 }
00023
00024 APysolFreecellGameBoard::APysolFreecellGameBoard(bool Display10AsT) : AFreecellGameBoard(Display10AsT)
00025 {
00026 }
00027
00028 APysolFreecellGameBoard::APysolFreecellGameBoard() : AFreecellGameBoard()
00029 {
00030 }
00031
00032 APysolFreecellGameBoard::~APysolFreecellGameBoard()
00033 {
00034 }
00035
00036 void APysolFreecellGameBoard::Shuffle(int Seed)
00037 {
00038 int j, n = GetNumberOfCardsInDeck()-1;
00039 char* TempDeck = new char[GetNumberOfCardsInDeck()];
00040 char TempCard;
00041
00042
00043
00044 for (int i=0;i<GetNumberOfCardsInDeck();i++)
00045 TempDeck[i] = MakeCard((i%13)+1, i/13);
00046
00047
00048 integer64 Seed64 = Seed;
00049
00050 while (n > 0)
00051 {
00052 j = PysolRandom64Int(&Seed64, 0, n);
00053 TempCard = TempDeck[n];
00054 TempDeck[n] = TempDeck[j];
00055 TempDeck[j] = TempCard;
00056 n--;
00057 }
00058
00059 for(j=0;j<GetNumberOfCardsInDeck();j++)
00060 m_Deck[j] = TempDeck[GetNumberOfCardsInDeck()-j-1];
00061
00062 delete [] TempDeck;
00063 }
00064
00065 char* APysolFreecellGameBoard::CardToString(char* String, char Card, bool AppendWhiteSpace, bool FlipCondition)
00066 {
00067 if (FlipCondition)
00068 strcpy(String, "<");
00069 else
00070 String[0] = NULL;
00071
00072 switch(GetValue(Card))
00073 {
00074 case 1:
00075 strcat(String, "A");
00076 break;
00077 case 2:
00078 case 3:
00079 case 4:
00080 case 5:
00081 case 6:
00082 case 7:
00083 case 8:
00084 case 9:
00085 String[FlipCondition ? 1 : 0] = GetValue(Card) + '0';
00086 String[FlipCondition ? 2 : 1] = NULL;
00087 break;
00088 case 10:
00089 if (m_Display10AsT)
00090 strcat(String, "T");
00091 else
00092 strcat(String, "10");
00093 break;
00094 case 11:
00095 strcat(String, "J");
00096 break;
00097 case 12:
00098 strcat(String, "Q");
00099 break;
00100 case 13:
00101 strcat(String, "K");
00102 break;
00103 default:
00104 strcat(String, "***");
00105 }
00106
00107 switch (GetSuit(Card))
00108 {
00109 case 0:
00110 strcat(String, "C");
00111 break;
00112 case 1:
00113 strcat(String, "S");
00114 break;
00115 case 2:
00116 strcat(String, "H");
00117 break;
00118 case 3:
00119 strcat(String, "D");
00120 break;
00121 default:
00122 strcat(String, "$$$");
00123 }
00124
00125 if (FlipCondition)
00126 strcat(String, ">");
00127
00128 if (AppendWhiteSpace)
00129 strcat(String, " ");
00130
00131 return String;
00132 }
00133
00134
00135 PysolFreecellGameBoard::PysolFreecellGameBoard(bool Display10AsT) : APysolFreecellGameBoard(Display10AsT)
00136 {
00137 }
00138
00139 PysolFreecellGameBoard::~PysolFreecellGameBoard()
00140 {
00141 }
00142
00143 void PysolFreecellGameBoard::Deal(char* GameBoard)
00144 {
00145 char Output[8][30];
00146 char CardString[5];
00147 int i;
00148
00149 for (i = 0; i < 8; i++)
00150 Output[i][0] = '\0';
00151
00152 for (i = 0; i < GetNumberOfCardsInDeck(); i++)
00153 strcat(Output[i%8], CardToString(CardString, m_Deck[i], (i<GetNumberOfCardsInDeck()-8)));
00154
00155 for (i = 0; i < 8; i++)
00156 {
00157 strcat(Output[i], "\n");
00158 strcat(GameBoard, Output[i]);
00159 }
00160 }
00161
00162 int PysolFreecellGameBoard::GetGameBoardSize()
00163 {
00164 return 160;
00165 }
00166
00167 PysolDerKatzenschwantzGameBoard::PysolDerKatzenschwantzGameBoard(bool Display10AsT)
00168 {
00169 m_Deck = new char[GetNumberOfCardsInDeck()];
00170 m_Display10AsT = Display10AsT;
00171
00172 int CardNumber = 0;
00173 for (int i=0;i<2;i++)
00174 {
00175 for (int Suit = 0; Suit<4; Suit++)
00176 {
00177 for (int Value = 1; Value<=13;Value++)
00178 {
00179 m_Deck[CardNumber] = MakeCard(Value, Suit);
00180 CardNumber++;
00181 }
00182 }
00183 }
00184 }
00185
00186 PysolDerKatzenschwantzGameBoard::~PysolDerKatzenschwantzGameBoard()
00187 {
00188 }
00189
00190 void PysolDerKatzenschwantzGameBoard::Deal(char* GameBoard)
00191 {
00192 GameBoard[0] = NULL;
00193 char CardString[5];
00194
00195 for (int i = 0; i < GetNumberOfCardsInDeck(); i++)
00196 {
00197 if (GetValue(m_Deck[i]) == 13)
00198 strcat(GameBoard, "\n");
00199
00200 strcat(GameBoard, CardToString(CardString, m_Deck[i], true));
00201 }
00202 }
00203
00204 int PysolDerKatzenschwantzGameBoard::GetGameBoardSize()
00205 {
00206 return 328;
00207 }
00208
00209 int PysolDerKatzenschwantzGameBoard::GetNumberOfCardsInDeck()
00210 {
00211 return 104;
00212 }
00213
00214 PysolDieSchlangeGameBoard::PysolDieSchlangeGameBoard(bool Display10AsT) : PysolDerKatzenschwantzGameBoard(Display10AsT)
00215 {
00216 }
00217
00218 PysolDieSchlangeGameBoard::~PysolDieSchlangeGameBoard()
00219 {
00220 }
00221
00222 void PysolDieSchlangeGameBoard::Deal(char* GameBoard)
00223 {
00224 char CardString[5];
00225
00226 strcpy(GameBoard, "Foundations: H-A S-A D-A C-A H-A S-A D-A C-A\n");
00227 for (int i = 0; i < GetNumberOfCardsInDeck(); i++)
00228 {
00229 if (GetValue(m_Deck[i]) == 13)
00230 strcat(GameBoard, "\n");
00231
00232 if (GetValue(m_Deck[i]) != 1)
00233 strcat(GameBoard, CardToString(CardString, m_Deck[i], true));
00234 }
00235 }
00236
00237 int PysolDieSchlangeGameBoard::GetGameBoardSize()
00238 {
00239 return 349;
00240 }
00241
00242 PysolForecellGameBoard::PysolForecellGameBoard(bool Display10AsT) : APysolFreecellGameBoard(Display10AsT)
00243 {
00244 }
00245
00246 PysolForecellGameBoard::~PysolForecellGameBoard()
00247 {
00248 }
00249
00250 void PysolForecellGameBoard::Deal(char* GameBoard)
00251 {
00252 char Output[8][30];
00253 char CardString[5], Freecells[30];
00254 int i;
00255
00256
00257 for (i = 0; i < 8; i++)
00258 Output[i][0] = '\0';
00259
00260 for (i = 0; i < 48; i++)
00261 strcat(Output[i % 8], CardToString(CardString, m_Deck[i], (i<48-8)));
00262
00263 strcpy(Freecells, "FC: ");
00264 for ( ; i < GetNumberOfCardsInDeck() ; i++)
00265 strcat(Freecells, CardToString(CardString, m_Deck[i], (i != GetNumberOfCardsInDeck()-1)));
00266
00267 strcat(Freecells, "\n");
00268 strcpy(GameBoard, Freecells);
00269
00270 for (i = 0; i < 8; i++)
00271 {
00272 strcat(Output[i], "\n");
00273 strcat(GameBoard, Output[i]);
00274 }
00275 }
00276
00277 int PysolForecellGameBoard::GetGameBoardSize()
00278 {
00279 return 164;
00280 }
00281
00282 PysolEightOffGameBoard::PysolEightOffGameBoard(bool Display10AsT) : APysolFreecellGameBoard(Display10AsT)
00283 {
00284 }
00285
00286 PysolEightOffGameBoard::~PysolEightOffGameBoard()
00287 {
00288 }
00289
00290 void PysolEightOffGameBoard::Deal(char* GameBoard)
00291 {
00292 char Output[8][30];
00293 char CardString[5], Freecells[30];
00294 int i;
00295
00296
00297 for (i = 0; i < 8; i++)
00298 Output[i][0] = '\0';
00299
00300 for (i = 0; i < 48; i++)
00301 strcat(Output[i % 8], CardToString(CardString, m_Deck[i], (i<48-8)));
00302
00303 strcpy(Freecells, "FC: ");
00304 for ( ; i < GetNumberOfCardsInDeck() ; i++)
00305 {
00306 strcat(Freecells, CardToString(CardString, m_Deck[i], true));
00307 strcat(Freecells, "- ");
00308 }
00309
00310 strcat(Freecells, "\n");
00311 strcpy(GameBoard, Freecells);
00312
00313 for (i = 0; i < 8; i++)
00314 {
00315 strcat(Output[i], "\n");
00316 strcat(GameBoard, Output[i]);
00317 }
00318 }
00319
00320 int PysolEightOffGameBoard::GetGameBoardSize()
00321 {
00322 return 173;
00323 }
00324
00325 PysolSeahavenTowersGameBoard::PysolSeahavenTowersGameBoard(bool Display10AsT) : APysolFreecellGameBoard(Display10AsT)
00326 {
00327 }
00328
00329 PysolSeahavenTowersGameBoard::~PysolSeahavenTowersGameBoard()
00330 {
00331 }
00332
00333 void PysolSeahavenTowersGameBoard::Deal(char* GameBoard)
00334 {
00335 char Output[10][30];
00336 char CardString[5], Freecells[30];
00337 int i;
00338
00339 for( i = 0 ; i < 10 ; i++)
00340 Output[i][0] = '\0';
00341
00342 for( i = 0 ; i < 50 ; i++)
00343 strcat(Output[i % 10], CardToString(CardString, m_Deck[i], (i<50-10)));
00344
00345 strcpy(Freecells, "FC: - ");
00346
00347 for ( ; i < GetNumberOfCardsInDeck(); i++)
00348 strcat(Freecells, CardToString(CardString, m_Deck[i], (i != GetNumberOfCardsInDeck()-1)));
00349
00350 strcat(Freecells, "\n");
00351 strcpy(GameBoard, Freecells);
00352
00353 for( i = 0 ; i < 10 ; i++)
00354 {
00355 strcat(Output[i], "\n");
00356 strcat(GameBoard, Output[i]);
00357 }
00358 }
00359
00360 int PysolSeahavenTowersGameBoard::GetGameBoardSize()
00361 {
00362 return 166;
00363 }
00364
00365 PysolBakersDozenGameBoard::PysolBakersDozenGameBoard(bool Display10AsT) : APysolFreecellGameBoard(Display10AsT)
00366 {
00367 }
00368
00369 PysolBakersDozenGameBoard::~PysolBakersDozenGameBoard()
00370 {
00371 }
00372
00373 void PysolBakersDozenGameBoard::Deal(char* GameBoard)
00374 {
00375 int KingsCount, i;
00376 char TempCard,
00377 Output[13][30],
00378 CardString[5];
00379
00380 for (i = 0; i < 13; i++)
00381 {
00382 KingsCount = 0;
00383
00384 for (int j = 0; j<4; j++)
00385 {
00386 if (GetValue(m_Deck[j*13+i]) == 13)
00387 {
00388
00389 TempCard = m_Deck[KingsCount*13+i];
00390 m_Deck[KingsCount*13+i] = m_Deck[j*13+i];
00391 m_Deck[j*13+i] = TempCard;
00392 KingsCount++;
00393 }
00394 }
00395 }
00396
00397 for (i=0;i<13;i++)
00398 Output[i][0] = NULL;
00399
00400 for (i = GetNumberOfCardsInDeck()-1; i >=0 ;i--)
00401 strcat(Output[i%13], CardToString(CardString, m_Deck[i], (i>12)));
00402
00403 for (i=12;i>=0;i--)
00404 {
00405 strcat(Output[i], "\n");
00406 strcat(GameBoard, Output[i]);
00407 }
00408 }
00409
00410 int PysolBakersDozenGameBoard::GetGameBoardSize()
00411 {
00412 return 160;
00413 }
00414
00415 PysolGypsyGameBoard::PysolGypsyGameBoard(bool Display10AsT) : PysolDerKatzenschwantzGameBoard(Display10AsT)
00416 {
00417 }
00418
00419 PysolGypsyGameBoard::~PysolGypsyGameBoard()
00420 {
00421 }
00422
00423 void PysolGypsyGameBoard::Deal(char* GameBoard)
00424 {
00425 int i;
00426 char Output[8][30],
00427 CardString[6];
00428
00429 for (i = 0; i < 8; i++)
00430 Output[i][0] = '\0';
00431
00432 for (i = 0; i<24; i++)
00433 strcat(Output[i%8], CardToString(CardString, m_Deck[i], true, i<16));
00434
00435 strcpy(GameBoard, "Talon: ");
00436 for (;i<8*13;i++)
00437 strcat(GameBoard, CardToString(CardString, m_Deck[i], true));
00438
00439 strcat(GameBoard, "\n");
00440 for (i=0;i<8;i++)
00441 {
00442 strcat(Output[i], "\n");
00443 strcat(GameBoard, Output[i]);
00444 }
00445 }
00446
00447 int PysolGypsyGameBoard::GetGameBoardSize()
00448 {
00449 return 368;
00450 }
00451
00452 PysolKlondikeGameBoard::PysolKlondikeGameBoard(bool Display10AsT) : APysolFreecellGameBoard(Display10AsT)
00453 {
00454 }
00455
00456 PysolKlondikeGameBoard::~PysolKlondikeGameBoard()
00457 {
00458 }
00459
00460 void PysolKlondikeGameBoard::Deal(char* GameBoard)
00461 {
00462 int CardNumber = 0,
00463 i, j;
00464 char Output[7][35],
00465 CardString[6];
00466
00467 for (i = 0; i < 7; i++)
00468 Output[i][0] = '\0';
00469
00470 for (i=1;i<7;i++)
00471 {
00472 for (j = 0 ; j < 7-i;j++)
00473 {
00474 strcat(Output[j], CardToString(CardString, m_Deck[CardNumber], true, true));
00475 CardNumber++;
00476 }
00477 }
00478
00479 for (i = 0;i<7;i++)
00480 {
00481 strcat(Output[i], CardToString(CardString, m_Deck[CardNumber], false));
00482 CardNumber++;
00483 }
00484
00485 strcpy(GameBoard, "Talon: ");
00486 while (CardNumber < 52)
00487 {
00488 strcat(GameBoard, CardToString(CardString, m_Deck[CardNumber], true));
00489 CardNumber++;
00490 }
00491
00492
00493 strcat(GameBoard, "\n");
00494 for (i=6;i>=0;i--)
00495 {
00496 strcat(Output[i], "\n");
00497 strcat(GameBoard, Output[i]);
00498 }
00499 }
00500
00501 int PysolKlondikeGameBoard::GetGameBoardSize()
00502 {
00503 return 210;
00504 }
00505
00506 PysolWhiteheadGameBoard::PysolWhiteheadGameBoard(bool Display10AsT) : APysolFreecellGameBoard(Display10AsT)
00507 {
00508 }
00509
00510 PysolWhiteheadGameBoard::~PysolWhiteheadGameBoard()
00511 {
00512 }
00513
00514 void PysolWhiteheadGameBoard::Deal(char* GameBoard)
00515 {
00516 int CardNumber = 0,
00517 i, j;
00518 char Output[7][35],
00519 CardString[6];
00520
00521 for (i = 0; i < 7; i++)
00522 Output[i][0] = '\0';
00523
00524 for (i=1;i<7;i++)
00525 {
00526 for (j = 0 ; j < 7-i;j++)
00527 {
00528 strcat(Output[j], CardToString(CardString, m_Deck[CardNumber], true));
00529 CardNumber++;
00530 }
00531 }
00532
00533 for (i = 0;i<7;i++)
00534 {
00535 strcat(Output[i], CardToString(CardString, m_Deck[CardNumber], false));
00536 CardNumber++;
00537 }
00538
00539 strcpy(GameBoard, "Talon: ");
00540 while (CardNumber < 52)
00541 {
00542 strcat(GameBoard, CardToString(CardString, m_Deck[CardNumber], true));
00543 CardNumber++;
00544 }
00545
00546
00547 strcat(GameBoard, "\n");
00548 for (i=6;i>=0;i--)
00549 {
00550 strcat(Output[i], "\n");
00551 strcat(GameBoard, Output[i]);
00552 }
00553 }
00554
00555 int PysolWhiteheadGameBoard::GetGameBoardSize()
00556 {
00557 return 168;
00558 }
00559
00560 PysolSmallHarpGameBoard::PysolSmallHarpGameBoard(bool Display10AsT) : APysolFreecellGameBoard(Display10AsT)
00561 {
00562 }
00563
00564 PysolSmallHarpGameBoard::~PysolSmallHarpGameBoard()
00565 {
00566 }
00567
00568 void PysolSmallHarpGameBoard::Deal(char* GameBoard)
00569 {
00570 int CardNumber = 0,
00571 i, j;
00572 char Output[7][35],
00573 CardString[6];
00574
00575 for (i = 0; i < 7; i++)
00576 Output[i][0] = '\0';
00577
00578 for (i=1;i<7;i++)
00579 {
00580 for (j = 0 ; j < 7-i;j++)
00581 {
00582 strcat(Output[j], CardToString(CardString, m_Deck[CardNumber], true, true));
00583 CardNumber++;
00584 }
00585 }
00586
00587 for (i = 0;i<7;i++)
00588 {
00589 strcat(Output[i], CardToString(CardString, m_Deck[CardNumber], false));
00590 CardNumber++;
00591 }
00592
00593 strcpy(GameBoard, "Talon: ");
00594 while (CardNumber < 52)
00595 {
00596 strcat(GameBoard, CardToString(CardString, m_Deck[CardNumber], true));
00597 CardNumber++;
00598 }
00599
00600 strcat(GameBoard, "\n");
00601 for (i=0;i<7;i++)
00602 {
00603 strcat(Output[i], "\n");
00604 strcat(GameBoard, Output[i]);
00605 }
00606 }
00607
00608 int PysolSmallHarpGameBoard::GetGameBoardSize()
00609 {
00610 return 210;
00611 }
00612
00613 PysolSimpleSimonGameBoard::PysolSimpleSimonGameBoard(bool Display10AsT) : APysolFreecellGameBoard(Display10AsT)
00614 {
00615 }
00616
00617 PysolSimpleSimonGameBoard::~PysolSimpleSimonGameBoard()
00618 {
00619 }
00620
00621 void PysolSimpleSimonGameBoard::Deal(char* GameBoard)
00622 {
00623 int CardNumber = 0,
00624 i, j;
00625 char Output[10][30],
00626 CardString[6];
00627
00628 for (i = 0; i < 10; i++)
00629 Output[i][0] = '\0';
00630
00631 for (i = 9; i > 2;i--)
00632 {
00633 for (j = 0; j < i;j++)
00634 {
00635 strcat(Output[j], CardToString(CardString, m_Deck[CardNumber], true));
00636 CardNumber++;
00637 }
00638 }
00639
00640 for (i = 0; i < 10;i++)
00641 {
00642 strcat(Output[i], CardToString(CardString, m_Deck[CardNumber], false));
00643 CardNumber++;
00644 }
00645
00646 for (i=0;i<10;i++)
00647 {
00648 strcat(Output[i], "\n");
00649 strcat(GameBoard, Output[i]);
00650 }
00651
00652 }
00653
00654 int PysolSimpleSimonGameBoard::GetGameBoardSize()
00655 {
00656 return 160;
00657 }
00658
00659 PysolYukonGameBoard::PysolYukonGameBoard(bool Display10AsT) : APysolFreecellGameBoard(Display10AsT)
00660 {
00661 }
00662
00663 PysolYukonGameBoard::~PysolYukonGameBoard()
00664 {
00665 }
00666
00667 void PysolYukonGameBoard::Deal(char* GameBoard)
00668 {
00669 int CardNumber = 0,
00670 i, j;
00671 char Output[7][50],
00672 CardString[6];
00673
00674 for (i = 0; i < 7; i++)
00675 Output[i][0] = '\0';
00676
00677 for (i = 1; i < 7; i++)
00678 {
00679 for (j = i; j < 7;j++)
00680 {
00681 strcat(Output[j], CardToString(CardString, m_Deck[CardNumber], true, true));
00682 CardNumber++;
00683 }
00684 }
00685
00686 for (i = 0; i < 4;i++)
00687 {
00688 for (j = 1; j < 7; j++)
00689 {
00690 strcat(Output[j], CardToString(CardString, m_Deck[CardNumber], true, false));
00691 CardNumber++;
00692 }
00693 }
00694
00695 for (i = 0; i < 7;i++)
00696 {
00697 strcat(Output[i], CardToString(CardString, m_Deck[CardNumber], true, false));
00698 CardNumber++;
00699 }
00700
00701 for (i=0;i<7;i++)
00702 {
00703 strcat(Output[i], "\n");
00704 strcat(GameBoard, Output[i]);
00705 }
00706
00707 }
00708
00709 int PysolYukonGameBoard::GetGameBoardSize()
00710 {
00711 return 209;
00712 }
00713
00714 PysolBeleagueredCastleGameBoard::PysolBeleagueredCastleGameBoard(bool Display10AsT) : APysolFreecellGameBoard(Display10AsT)
00715 {
00716 }
00717
00718 PysolBeleagueredCastleGameBoard::~PysolBeleagueredCastleGameBoard()
00719 {
00720 }
00721
00722 void PysolBeleagueredCastleGameBoard::Deal(char* GameBoard)
00723 {
00724 char Output[8][30];
00725 char CardString[5];
00726 int i, j;
00727
00728 for (i = 0; i < 8; i++)
00729 Output[i][0] = '\0';
00730
00731
00732 for (i = 0; i < GetNumberOfCardsInDeck(); i++)
00733 {
00734 if (GetValue(m_Deck[i]) == 1)
00735 {
00736 for (j = i; j < GetNumberOfCardsInDeck()-1; j++)
00737 {
00738 m_Deck[j] = m_Deck[j+1];
00739 }
00740 i--;
00741 }
00742 }
00743
00744
00745 memset(&m_Deck[48], 0, 4);
00746
00747 for (i = 0; i < 48; i++)
00748 strcat(Output[i % 8], CardToString(CardString, m_Deck[i], (i<GetNumberOfCardsInDeck()-8)));
00749
00750
00751 strcpy(GameBoard, "Foundations: H-A C-A D-A S-A\n");
00752
00753 for (i = 0; i < 8; i++)
00754 {
00755 strcat(Output[i], "\n");
00756 strcat(GameBoard, Output[i]);
00757 }
00758 }
00759
00760 int PysolBeleagueredCastleGameBoard::GetGameBoardSize()
00761 {
00762 return 181;
00763 }
00764
00765 PysolCitadelGameBoard::PysolCitadelGameBoard(bool Display10AsT) : APysolFreecellGameBoard(Display10AsT)
00766 {
00767 }
00768
00769 PysolCitadelGameBoard::~PysolCitadelGameBoard()
00770 {
00771 }
00772
00773 void PysolCitadelGameBoard::Deal(char* GameBoard)
00774 {
00775 char Output[8][30], CardString[5], Foundations[4];
00776 char FoundationSuit[4] = {2, 0 ,3, 1};
00777 int Length, i, j;
00778
00779 for (i = 0; i < 8; i++)
00780 Output[i][0] = '\0';
00781
00782
00783 for (i = 0; i < GetNumberOfCardsInDeck(); i++)
00784 {
00785 if (GetValue(m_Deck[i]) == 1)
00786 {
00787 for (j = i; j < GetNumberOfCardsInDeck()-1; j++)
00788 {
00789 m_Deck[j] = m_Deck[j+1];
00790 }
00791 i--;
00792 }
00793 }
00794
00795
00796 memset(&m_Deck[48], 0, 4);
00797
00798
00799 memset(Foundations, 1, 4);
00800
00801 for (i = 0; i < 48; i++)
00802 {
00803 if (GetValue(m_Deck[i]) == Foundations[GetSuit(m_Deck[i])]+1)
00804 {
00805 Foundations[GetSuit(m_Deck[i])]++;
00806 }
00807 else
00808 {
00809 strcat(Output[i % 8], CardToString(CardString, m_Deck[i], (i<GetNumberOfCardsInDeck()-8)));
00810 }
00811 }
00812
00813
00814 strcpy(GameBoard, "Foundations: ");
00815 for (i = 0; i<sizeof(FoundationSuit);i++)
00816 {
00817 switch(FoundationSuit[i])
00818 {
00819 case 0:
00820 strcat(GameBoard, "C-");
00821 break;
00822 case 1:
00823 strcat(GameBoard, "S-");
00824 break;
00825 case 2:
00826 strcat(GameBoard, "H-");
00827 break;
00828 case 3:
00829 strcat(GameBoard, "D-");
00830 break;
00831 }
00832
00833 switch(Foundations[FoundationSuit[i]])
00834 {
00835 case 1:
00836 strcat(GameBoard, "A");
00837 break;
00838 case 2:
00839 case 3:
00840 case 4:
00841 case 5:
00842 case 6:
00843 case 7:
00844 case 8:
00845 case 9:
00846 Length = strlen(GameBoard);
00847 GameBoard[Length] = Foundations[FoundationSuit[i]] + '0';
00848 GameBoard[Length+1] = NULL;
00849 break;
00850 case 10:
00851 if (m_Display10AsT)
00852 strcat(GameBoard, "T");
00853 else
00854 strcat(GameBoard, "10");
00855 break;
00856 case 11:
00857 strcat(GameBoard, "J");
00858 break;
00859 case 12:
00860 strcat(GameBoard, "Q");
00861 break;
00862 case 13:
00863 strcat(GameBoard, "K");
00864 break;
00865 default:
00866 strcat(GameBoard, "***");
00867 }
00868
00869 if (FoundationSuit[i] != 1)
00870 strcat(GameBoard, " ");
00871 }
00872
00873 strcat(GameBoard, "\n");
00874 for (i = 0; i < 8; i++)
00875 {
00876 strcat(Output[i], "\n");
00877 strcat(GameBoard, Output[i]);
00878 }
00879 }
00880
00881 int PysolCitadelGameBoard::GetGameBoardSize()
00882 {
00883 return 181;
00884 }
00885
00886 PysolFanGameBoard::PysolFanGameBoard(bool Display10AsT) : APysolFreecellGameBoard(Display10AsT)
00887 {
00888 }
00889
00890 PysolFanGameBoard::~PysolFanGameBoard()
00891 {
00892 }
00893
00894 void PysolFanGameBoard::Deal(char* GameBoard)
00895 {
00896 char Output[18][15];
00897 char CardString[5];
00898 int i;
00899
00900 for (i = 0; i < 18; i++)
00901 Output[i][0] = '\0';
00902
00903 for (i = 0; i<GetNumberOfCardsInDeck()-1;i++)
00904 strcat(Output[i%17], CardToString(CardString, m_Deck[i], i < 2*17));
00905
00906 strcpy(Output[17], CardToString(CardString, m_Deck[GetNumberOfCardsInDeck()-1], false));
00907
00908 GameBoard[0] = NULL;
00909 for (i = 0; i < 18; i++)
00910 {
00911 strcat(Output[i], "\n");
00912 strcat(GameBoard, Output[i]);
00913 }
00914
00915 }
00916
00917 int PysolFanGameBoard::GetGameBoardSize()
00918 {
00919 return 160;
00920 }