Console Golf Solitaire

This is golf solitaire that runs as a text based console program. I choose to do it this way to be creative and unqic.It should work with most 32-bit versions of windows including windows 10.

ScreenShots:

The menu
The single deck game
  1. unit golfsol1;
  2. //GolfSolitaire() is the main function
  3. interface
  4. uses graphics,windows,classes,sysutils,shellapi;
  5. const
  6. SCORES_SHOW_ONLY=126;
  7. SCORES_INIT=127;
  8. CurrentVersion=$01000000;
  9. procedure GolfSolitaire(params:tstringlist);
  10. implementation
  11. type TRandom=function(range:integer):integer;stdcall;
  12. TCard=record
  13. face,suit,deck,notused:byte;
  14. end;
  15. TGolfScore=record
  16. Name:shortstring;
  17. gametype:byte;
  18. score:shortint;
  19. end;
  20. TGolfGame=record
  21. gamenum:integer;
  22. decks:byte;
  23. cardcount:array[-1..9]of byte;
  24. drawpile:array[1..40]of pointer;
  25. discardpile:array[1..104]of pointer;
  26. end;
  27. PGolfScore=^TGolfScore;
  28. TGetConsoleWindow=Function:HWND;stdcall;
  29. var rand:hmodule=0;
  30. suits:array[1..4]of longint;
  31. drandom:TRandom;
  32. GetConsoleWindow:TGetConsoleWindow;//for compatiblity with older windows
  33. carddeck:array[1..4,1..14]of byte;
  34. tableua:array[-1..9]of tlist;
  35. hout:thandle;
  36. gameover,inGame:boolean;
  37. defattrib: word;
  38. currentscore:shortint;
  39. scores:array[0..9]of tgolfscore;
  40. hk:hkey;
  41. gamenum,intour:integer;
  42. lost,win,jokersused,aceking,decks,showdiscard,oldestver:dword;
  43. drawpile_bonus_points:Shortint;
  44. function AllUsedJokers:boolean;
  45. begin
  46. result:=(carddeck[1,14]=jokersused);
  47. end;
  48. procedure SaveGame;
  49. var sav:tgolfgame;
  50. i:integer;
  51. begin
  52. sav.gamenum:=gamenum;
  53. sav.decks:=decks;
  54. for i:=-1to 9do sav.cardcount[i]:=tableua[i].count;
  55. for i:=1to tableua[-1].count do
  56. sav.drawpile[i]:=tableua[-1][i-1];
  57. for i:=1to tableua[0].count do
  58. sav.discardpile[i]:=tableua[0][i-1];
  59. regsetvalueex(hk,'SavedGame',0,reg_binary,@sav,sizeof(sav));
  60. end;
  61. function allused:boolean;
  62. var i,j:integer;
  63. begin
  64. result:=allusedjokers;
  65. for i:=1to 4do
  66. for j:=1to 13do
  67. result:=result and(carddeck[i,j]>=decks);
  68. end;
  69. function drawcard:pointer;
  70. var car:tcard;
  71. label shuffle;
  72. begin
  73. car.face:=16;
  74. car.suit:=5;
  75. result:=pointer(car);
  76. if allused then exit;
  77. shuffle:if jokersused>0then car.face:=drandom(14)+1 else car.face:=drandom(13)+1;
  78. car.suit:=drandom(4)+1;
  79. if(car.face=14) and (car.suit>1) then goto shuffle;
  80. if carddeck[car.suit,car.face]=decks then goto shuffle;
  81. inc(carddeck[car.suit,car.face]);
  82. car.deck:=carddeck[car.suit,car.face];
  83. result:=pointer(car);
  84. end;
  85. procedure clearconsole;
  86. var co:coord;
  87. written:dword;
  88. begin
  89. co.x:=0;
  90. co.y:=0;
  91. setconsolecursorposition(hout,co);
  92. fillconsoleoutputcharacter(hout,#32,$ffff,co,written);
  93. setconsolecursorposition(hout,co);
  94. end;
  95. procedure Randominit(gamenum:integer);
  96. var i,j:integer;
  97. begin
  98. if decks=1then
  99. drawpile_bonus_points:=-(16+JokersUsed);
  100. if decks=2then
  101. drawpile_bonus_points:=-(40+jokersused);
  102. zeromemory(@carddeck,sizeof(carddeck));
  103. if rand<>0then
  104. freelibrary(rand);
  105. zeromemory(@carddeck,sizeof(carddeck));
  106. rand:=LoadLibrary('random32.dll');
  107. @drandom:=getprocaddress(rand,'MyRandom');
  108. if not assigned(drandom)then begin writeln('Could'#39't load random32.dll');readln;
  109. regclosekey(hk);exitprocess(0);end;
  110. for i:=0to gamenum do drandom(gamenum);
  111. setconsoletitle(pchar('Golf Solitaire #'+inttostr(gamenum)));
  112. if decks=1then
  113. for i:=1to 7do begin tableua[i].clear;
  114. for j:=1to 5do tableua[i].add(drawcard);
  115. end;
  116. if decks=2then
  117. for i:=1to 9do begin tableua[i].clear;
  118. for j:=1to 7do tableua[i].add(drawcard);
  119. end;
  120. tableua[0].clear;
  121. tableua[-1].clear;
  122. tableua[0].add(drawcard);
  123. while not allused do tableua[-1].add(drawcard);
  124. end;
  125. const background_white=background_red or background_green or background_blue or
  126. background_intensity;
  127. char_heart=#3;
  128. char_diamond=#4;
  129. char_club=#5;
  130. char_spade=#6;
  131. function cardtostring(card:tcard):string;
  132. var attrib:word;
  133. begin
  134. if lobyte(hiword(suits[card.suit]))=ord('R')then attrib:=foreground_red or foreground_intensity or
  135. background_white else
  136. attrib:=background_white;
  137. if card.suit=0then attrib:=0;
  138. setconsoletextattribute(hout, attrib);
  139. case card.face of
  140. 0,16:result:=#32;
  141. 1:result:='A';
  142. 10:result:='T';
  143. 11:result:='J';
  144. 12:result:='Q';
  145. 13:result:='K';
  146. 14:begin result:='??';exit;end;//Joker
  147. else result:=inttostr(card.face);end;
  148. case card.suit of
  149. 1,2,3,4:result:=result+chr(hibyte(hiword(suits[card.suit])));
  150. else result:=result+#32;
  151. end;
  152. end;
  153. function sortscores(Item1, Item2: pointer): Integer;
  154. begin
  155. if pgolfscore(item1).score<pgolfscore(item2).score then result:=-1;
  156. if pgolfscore(item1).score=pgolfscore(item2).score then result:=0;
  157. if pgolfscore(item1).score>pgolfscore(item2).score then result:=1;
  158. end;
  159. function ScoreStr(score:PGolfScore):string;
  160. begin
  161. result:=inttostr(score.score);
  162. if score.score=scores_init then result:='N/A';
  163. end;
  164. function gametypetostr(gt:byte):string;
  165. begin
  166. result:='';
  167. if gt and 1=1then result:='AceKing ';
  168. if gt and 2=2then result:=result+'2-decks';
  169. end;
  170. procedure ShowScores(score:shortint);
  171. var cbscores:dword;
  172. I:integer;
  173. thisscore:TGolfScore;
  174. scorea:array[0..9]of tgolfscore;
  175. sortedscores:tlist;
  176. begin
  177. setconsoletextattribute(hout,defattrib);
  178. sortedscores:=tlist.Create;
  179. thisscore.gametype:=0;
  180. cbscores:=0;
  181. if(aceking=1)then thisscore.gametype:=1;
  182. if(decks=2)then thisscore.gametype:=thisscore.gametype or 2;
  183. if score<scores_show_only then begin write('Enter your name:');readln(thisscore.name);
  184. thisscore.score:=score;end;
  185. regqueryvalueex(hk,'Scores',nil,nil,nil,@cbscores);
  186. if cbscores=sizeof(scores)then
  187. regqueryvalueex(hk,'Scores',nil,nil,@scores,@cbscores);
  188. for i:=0to 9do sortedscores.Add(@scores[i]);
  189. if score<126then sortedscores.Add(@thisscore);
  190. sortedscores.Sort(sortscores);
  191. writeln('Place,Score,Name,GameType');
  192. for i:=0to 9do begin write(i+1,'. ',scorestr(sortedscores[i]),' ',pgolfscore(
  193. sortedscores[i]).name,' ',gametypetostr(pgolfscore(sortedscores[i]).gametype));
  194. if sortedscores[i]=@thisscore then write('<--');writeln;copymemory(@scorea[i],
  195. sortedscores[i],sizeof(tgolfscore));
  196. end;
  197. copymemory(@scores,@scorea,sizeof(scorea));
  198. regsetvalueex(hk,'Scores',0,reg_binary,@scores,sizeof(scores));
  199. sortedscores.Free;
  200. writeln('Wins: ',win,' Lost: ',lost,' Games Played: ',win+lost);
  201. write('Press enter to return...');readln;
  202. clearconsole;
  203. end;
  204. procedure loadgame;
  205. var sav:tgolfgame;
  206. i,j,colcount:integer;
  207. cb:dword;
  208. Begin
  209. cb:=sizeof(sav);
  210. RegQueryValueEx(hk,'SavedGame',nil,nil,@sav,@cb);
  211. decks:=sav.decks;
  212. if decks=1 then colcount:=5 else colcount:=7;
  213. gamenum:=sav.gamenum;
  214. randominit(gamenum);
  215. for i:=1to 9do
  216. if tableua[i].count>0then for j:=1to colcount-sav.cardcount[i] do tableua[i].remove(
  217. tableua[i].last);
  218. tableua[0].clear;tableua[-1].clear;
  219. for i:=1 to sav.cardcount[-1] do
  220. tableua[-1].add(sav.drawpile[i]);
  221. for i:=1to sav.cardcount[0]do tableua[0].add(sav.discardpile[i]);
  222. end;
  223. procedure youwinproc;
  224. var
  225. conrect:trect;
  226. sortedscores:tlist;
  227. ywbmp:graphics.tbitmap;
  228. concan:tcanvas;
  229. begin
  230. ingame:=false;
  231. GetWindowRect(getconsolewindow,conrect);
  232. writeln('ÉÍÍÍÍÍÍÍÍÍÍ»');
  233. writeln('º You win! º');
  234. writeln('ÈÍÍÍÍÍÍÍÍÍͼ');
  235. gameover:=true;
  236. @getconsolewindow:=GetProcAddress(getmodulehandle('kernel32.dll'),
  237. 'GetConsoleWindow');
  238. if assigned(getconsolewindow)then
  239. if getconsolewindow<>0then begin
  240. ywbmp:=graphics.tbitmap.create;
  241. ywbmp.Handle:=loadbitmap(hinstance,'YOUWON');
  242. Concan:=tcanvas.Create;
  243. concan.Handle:=GetWindowDC(getconsolewindow);
  244. concan.Draw((conrect.Right-ywbmp.width)div 2,(conrect.Bottom-ywbmp.height)div 2,
  245. ywbmp);
  246. releasedc(getconsolewindow,concan.handle);
  247. concan.Free;
  248. ywbmp.FreeImage;
  249. ywbmp.Free;
  250. end;
  251. showscores(drawpile_bonus_points);
  252. inc(win);
  253. regdeletevalue(hk,'SavedGame');
  254. regsetvalueex(hk,'Win',0,reg_dword,@win,4);
  255. end;
  256. {$RESOURCE GOLFSOL32.RES}
  257. function quit(typ:dword):Bool;stdcall;
  258. var dwGame:dword;
  259. begin
  260. result:=true;
  261. dwGame:=gamenum;
  262. if ingame then savegame;
  263. regsetvalueex(hk,'Win',0,reg_dword,@win,4);
  264. regsetvalueex(hk,'Lost',0,reg_dword,@lost,4);
  265. regclosekey(hk);
  266. exitprocess(0);
  267. end;
  268. function ismove(pile1,pile2:tlist):boolean;
  269. var p1,p2:pointer;
  270. c1,c2:tcard;
  271. begin
  272. result:=false;
  273. if(pile1.Count*pile2.Count=0)then exit;
  274. p1:=pile1.last;
  275. p2:=pile2.last;
  276. copymemory(@c1,@p1,4);
  277. copymemory(@c2,@p2,4);
  278. result:=(abs(c1.face-c2.face)=1)or(c1.face=14)or(c2.face=14);
  279. if(((c1.face=1)and(c2.face=13))or((c1.face=13)and(c2.face=1)))and(aceking=1)then
  280. result:=true;
  281. end;
  282. function AnyMoreMoves:byte;
  283. var i:integer;
  284. begin
  285. result:=0;
  286. for i:=1to 9 do if ismove(tableua[0],tableua[i])then inc(result);
  287. end;
  288. procedure ShowRules;
  289. begin
  290. clearconsole;
  291. writeln('ÉÍÍÍÍÍÍÍÍÍÍ͹Golf RulesÌÍÍÍÍÍÍÍÍÍÍ»');
  292. writeln('ºThe rules for golf solitaire are º');
  293. writeln('ºvery simple. The whole idea of º');
  294. writeln('ºgame is to get rid of all cards º');
  295. writeln('ºin the seven columns(1 deck) or º');
  296. writeln('ºnine columns(2 decks). As in º');
  297. writeln('ºregular golf you want to get the º');
  298. writeln('ºlowest points. When the game endsº');
  299. writeln('ºwhatever cards are left count as º');
  300. writeln('ºone point per card. If you go outº');
  301. writeln('ºthe number of cards left will º');
  302. writeln('ºbecome a negative points. You º');
  303. writeln('ºwill try to move the cards from º');
  304. writeln('ºthe columns to the discard pile. º');
  305. writeln('ºThey must be one card bigger or º');
  306. writeln('ºone card smaller.Example: a 5 canº');
  307. writeln('ºbe moved to the discard pile onlyº');
  308. writeln('ºif the top card is a 6 or a 4,theº');
  309. writeln('ºsuit doesnt matter. You can choseº');
  310. writeln('ºa column by entering the number 1º');
  311. writeln('ºthough 9 and then pressng enter. º');
  312. writeln('ºWhen there are no more moves you º');
  313. writeln('ºcan type in 0 and hit enter or º');
  314. writeln('ºtype in 10 and hit enter to go toº');
  315. writeln('ºmenu. º');
  316. writeln('ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ');
  317. writeln('Press enter to return...');
  318. readln;
  319. intour:=2;
  320. end;
  321. procedure Tour;
  322. begin
  323. clearconsole;
  324. writeln('ÉÍÍÍÍÍÍÍÍÍ͹Golf TourÌÍÍÍÍÍÍÍÍÍÍÍÍ»');
  325. writeln('ºTo know how to use this game you º');
  326. writeln('ºwill be entering in numbers to º');
  327. writeln('ºtell the game your moves & what º');
  328. writeln('ºyou want to do. The columns are º');
  329. writeln('ºnumbered and so is the draw pile.º');
  330. writeln('ºTo draw you enter in 0 and press º');
  331. writeln('ºenter. Next we will look at the º');
  332. writeln('ºrules. º');
  333. writeln('ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ');
  334. writeln('Press enter to continue...');
  335. readln;
  336. intour:=1;
  337. end;
  338. procedure GolfSolitaire(params:tstringlist);
  339. var i,j,choice:integer;
  340. topcard:tcard;
  341. pc:pointer;
  342. cb,sgame:dword;
  343. label gamepmt,gameend,menu,trytour;
  344. begin
  345. hout:=getstdhandle(std_output_handle);
  346. defattrib:=foreground_intensity or foreground_red or foreground_blue or
  347. foreground_green;
  348. decks:=1;
  349. randomize;
  350. ingame:=false;
  351. setconsoleoutputcp(437);
  352. oldestver:=0;
  353. for i:=0to 9do begin scores[i].Name:='N/A';scores[i].score:=scores_init;end;
  354. SetConsoleCtrlHandler(@quit,true);
  355. regcreatekey(hkey_current_user,'Software\Justin\GolfSolitaire',hk);
  356. intour:=0;
  357. suits[1]:=makelong(ord('C'),makeword(ord('B'),ord(char_club)));
  358. suits[2]:=makelong(ord('S'),makeword(ord('B'),ord(char_spade)));
  359. suits[3]:=makelong(ord('H'),makeword(ord('R'),ord(char_heart)));
  360. suits[4]:=makelong(ord('D'),makeword(ord('R'),ord(char_diamond)));
  361. cb:=sizeof(suits);
  362. regqueryvalueex(hk,'Suit',nil,nil,@suits,@cb);
  363. regsetvalueex(hk,'Suit',0,reg_binary,@suits,sizeof(suits));
  364. cb:=4;regqueryvalueex(hk,'Decks',nil,nil,@decks,@cb);
  365. if(decks=0)or(decks>2)then decks:=1;
  366. showdiscard:=0;
  367. cb:=4;
  368. lost:=0;
  369. win:=0;
  370. regqueryvalueex(hk,'Lost',nil,nil,@lost,@cb);
  371. cb:=4;
  372. gameover:=true;
  373. regqueryvalueex(hk,'Win',nil,nil,@win,@cb);
  374. cb:=4;
  375. aceking:=0;jokersused:=0;sgame:=0;
  376. //regqueryvalueex(hk,'JokersUsed',nil,nil,@jokersused,@cb);
  377. //Jokers for some reason freeze up the game being delt.
  378. regqueryvalueex(hk,'LastGame',nil,nil,@sgame,@cb);
  379. cb:=4;
  380. //if jokersused>2then jokersused:=0;
  381. regqueryvalueex(hk,'AceKing',nil,nil,@aceking,@cb);
  382. cb:=4;
  383. if aceking>1then aceking:=0;
  384. regqueryvalueex(hk,'ShowDiscard',nil,nil,@showdiscard,@cb);
  385. if showdiscard>1then showdiscard:=0;
  386. for i:=-1 to 9do tableua[i]:=tlist.create;
  387. if regqueryvalueex(hk,'OldestVersion',nil,nil,nil,nil)<>error_success then
  388. begin
  389. trytour:
  390. write('Would you like to take a tour? type in 1 for Yes or 0 for No:');
  391. readln(choice);
  392. case choice of
  393. 1:tour;
  394. 0:goto menu;
  395. else goto trytour;
  396. end;
  397. oldestver:=currentversion;
  398. regsetvalueex(hk,'OldestVersion',0,reg_dword,@oldestver,4);
  399. if intour=1 then goto menu;
  400. end;
  401. menu:clearconsole;
  402. setconsoletextattribute(hout,defattrib);
  403. writeln('ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»');
  404. writeln('ºWelcome to Golf Solitaire º');
  405. writeln('ºWhat would you like to do? º');
  406. writeln('º1. Start a new game º');
  407. writeln('º2. Enter in a game number º');
  408. writeln('º3. View top ten º');
  409. cb:=4;
  410. writeln('º4. See game rules º');
  411. writeln('º5. Change rules and settings º');
  412. if ingame then
  413. writeln('º6. Return to game º');
  414. if regqueryvalueex(hk,'SavedGame',nil,nil,nil,nil)=error_success then
  415. writeln('º7. Load Saved Game º');
  416. writeln('ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ');
  417. if intour=1 then
  418. writeln('To see rules type 4 and press enter');
  419. write('Choice Number:');readln(choice);
  420. case choice of
  421. 4:begin showrules;goto menu;end;
  422. 1:begin
  423. gamenum:=random(maxint)+1; randominit(gamenum);end;
  424. 2:begin write('Enter game#:');readln(gamenum);randominit(gamenum);end;
  425. 3:begin showscores(scores_show_only);goto menu;end;
  426. 5:begin writeln('Current Settings:');
  427. write('Aces can be played on kings: ');if aceking=1then writeln('Yes')else
  428. writeln('No');//writeln('Jokers used: ',jokersused);
  429. writeln('Number of card decks:',decks);
  430. write('Show all cards in the discard pile:');
  431. if showdiscard=1then writeln('Yes')else writeln('No');
  432. writeln('2=DontChange 1=Yes 0=No Any Other number returns to menu');
  433. Write('Play Kings on Aces? Number Choice:');readln(aceking);
  434. if aceking>1then goto menu;
  435. {tryjoker:
  436. write('Number of jokers to use. 0 though 2 are valid numbers:');
  437. readln(jokersused);
  438. if(JokersUsed>2)then begin Writeln('Too many jokers.');goto tryjoker;end;
  439. }
  440. write('Show all cards in the discard pile?(0=No 1=yes)');readln(showdiscard);
  441. regsetvalueex(hk,'ShowDiscard',0,reg_dword,@showdiscard,4);
  442. //regsetvalueex(hk,'JokersUsed',0,reg_dword,@jokersused,4);
  443. regsetvalueex(HK,'AceKing',0,reg_dword,@aceking,4);
  444. write('Enter number of decks to use(1 or 2):');readln(decks);
  445. regsetvalueex(hk,'Decks',0,reg_dword,@decks,4);
  446. goto menu;
  447. end;
  448. 6:if ingame then goto gamepmt else goto menu;
  449. 7:if RegQueryValueex(hk,'SavedGame',nil,nil,nil,nil)=error_success then
  450. loadgame else goto menu;
  451. else goto menu;
  452. end;
  453. gameover:=false;
  454. drawpile_bonus_points:=-tableua[-1].count;
  455. gamepmt:
  456. clearconsole;
  457. setconsoletextattribute(hout,defattrib);
  458. ingame:=true;
  459. write('Game#: ',gamenum,' Cards left:');
  460. j:=0;
  461. for i:=1to 9do j:=j+tableua[i].count;
  462. write(j,' Draws left:',tableua[-1].count,' Type in 10 for menu');
  463. writeln;
  464. writeln('[1][2][3][4][5][6][7][8][9]');
  465. if decks=1 then
  466. for i:=0to 4do begin write(' ');
  467. for j:=1to 9do begin if tableua[j].count>i then write(cardtostring(tcard(tableua[j][i])))
  468. else write(' ');write(' ');end;
  469. writeln;
  470. end;
  471. if decks=2 then
  472. for i:=0to 6do begin write(' ');
  473. for j:=1to 9do begin if tableua[j].count>i then write(cardtostring(tcard(tableua[j][i])))
  474. else write(' ');write(' ');end;
  475. writeln;
  476. end;
  477. setconsoletextattribute(hout,defattrib);
  478. pc:=tableua[0].last;
  479. copymemory(@topcard,@pc,4);
  480. write('Draw[0]: ');
  481. if showdiscard=0then
  482. write(cardtostring(topcard))
  483. else for i:=0to tableua[0].count-1do begin pc:=tableua[0][i];copymemory(@topcard,
  484. @pc,4);write(cardtostring(topcard));end;
  485. writeln;
  486. setconsoletextattribute(hout,defattrib);
  487. write('Choice:');
  488. readln(choice);
  489. case choice of
  490. 1,2,3,4,5,6,7,8,9:if ismove(tableua[0],tableua[choice])then
  491. begin tableua[0].add(tableua[choice].last);tableua[choice].remove(
  492. tableua[choice].last);if(tableua[-1].count=0) and(anymoremoves=0) then goto gameend;
  493. end;
  494. 0:begin if((tableua[-1].count=0) and(anymoremoves=0)) then
  495. goto gameend;tableua[0].add(tableua[-1].last);inc(drawpile_bonus_points);
  496. tableua[-1].remove(tableua[-1].last);
  497. end;
  498. 10:goto menu;
  499. end;
  500. if(tableua[1].count+tableua[2].count+tableua[3].count+tableua[4].count+
  501. tableua[5].count+tableua[6].count+tableua[7].count+tableua[8].count+
  502. tableua[9].count=0)then begin
  503. youwinproc;
  504. goto menu;
  505. end;
  506. goto gamepmt;
  507. gameend:
  508. regdeletevalue(hk,'SavedGame');
  509. Writeln('Sorry, no more moves');
  510. writeln('Tableua points: ',tableua[1].count+tableua[2].count+tableua[3].count+
  511. tableua[4].count+tableua[5].count+tableua[6].count+tableua[7].count+
  512. tableua[8].count+tableua[9].count);
  513. gameover:=true;
  514. inc(lost);
  515. ingame:=false;
  516. regsetvalueex(hk,'Lost',0,reg_dword,@lost,4);
  517. showscores(tableua[1].count+tableua[2].count+tableua[3].count+tableua[4].count+
  518. tableua[5].count+tableua[6].count+tableua[7].count);
  519. //writeln('Press enter to return...');readln;
  520. goto menu;
  521. end;
  522. end.
unit golfsol1;
//GolfSolitaire() is the main function
interface
uses graphics,windows,classes,sysutils,shellapi;
const
SCORES_SHOW_ONLY=126;
SCORES_INIT=127;
CurrentVersion=$01000000;
procedure GolfSolitaire(params:tstringlist);
implementation
type TRandom=function(range:integer):integer;stdcall;
TCard=record
face,suit,deck,notused:byte;
end;
TGolfScore=record
Name:shortstring;
gametype:byte;
score:shortint;
end;
TGolfGame=record
gamenum:integer;
decks:byte;
cardcount:array[-1..9]of byte;
drawpile:array[1..40]of pointer;
discardpile:array[1..104]of pointer;
end;
PGolfScore=^TGolfScore;
TGetConsoleWindow=Function:HWND;stdcall;
var rand:hmodule=0;
suits:array[1..4]of longint;
drandom:TRandom;
GetConsoleWindow:TGetConsoleWindow;//for compatiblity with older windows
carddeck:array[1..4,1..14]of byte;
tableua:array[-1..9]of tlist;
hout:thandle;
gameover,inGame:boolean;
defattrib: word;
currentscore:shortint;
scores:array[0..9]of tgolfscore;
hk:hkey;
gamenum,intour:integer;
lost,win,jokersused,aceking,decks,showdiscard,oldestver:dword;
drawpile_bonus_points:Shortint;


function AllUsedJokers:boolean;
begin
result:=(carddeck[1,14]=jokersused);
end;

procedure SaveGame;
var sav:tgolfgame;
i:integer;
begin
sav.gamenum:=gamenum;
sav.decks:=decks;
for i:=-1to 9do sav.cardcount[i]:=tableua[i].count;
for i:=1to tableua[-1].count do
sav.drawpile[i]:=tableua[-1][i-1];
for i:=1to tableua[0].count do
sav.discardpile[i]:=tableua[0][i-1];
regsetvalueex(hk,'SavedGame',0,reg_binary,@sav,sizeof(sav));
end;

function allused:boolean;
var i,j:integer;
begin
result:=allusedjokers;
for i:=1to 4do
for j:=1to 13do
result:=result and(carddeck[i,j]>=decks);
end;

function drawcard:pointer;
var car:tcard;
label shuffle;
begin
car.face:=16;
car.suit:=5;
result:=pointer(car);
if allused then exit;
shuffle:if jokersused>0then car.face:=drandom(14)+1 else car.face:=drandom(13)+1;
car.suit:=drandom(4)+1;
if(car.face=14) and (car.suit>1) then goto shuffle;
if carddeck[car.suit,car.face]=decks then goto shuffle;
inc(carddeck[car.suit,car.face]);
car.deck:=carddeck[car.suit,car.face];
result:=pointer(car);
end;

procedure clearconsole;
var co:coord;
written:dword;
begin
co.x:=0;
co.y:=0;
setconsolecursorposition(hout,co);
fillconsoleoutputcharacter(hout,#32,$ffff,co,written);
setconsolecursorposition(hout,co);
end;

procedure Randominit(gamenum:integer);
var i,j:integer;
begin
if decks=1then
drawpile_bonus_points:=-(16+JokersUsed);
if decks=2then
drawpile_bonus_points:=-(40+jokersused);
zeromemory(@carddeck,sizeof(carddeck));
if rand<>0then
freelibrary(rand);
zeromemory(@carddeck,sizeof(carddeck));
rand:=LoadLibrary('random32.dll');
@drandom:=getprocaddress(rand,'MyRandom');
if not assigned(drandom)then begin writeln('Could'#39't load random32.dll');readln;
regclosekey(hk);exitprocess(0);end;
for i:=0to gamenum do drandom(gamenum);
setconsoletitle(pchar('Golf Solitaire #'+inttostr(gamenum)));
if decks=1then
for i:=1to 7do begin tableua[i].clear;
for j:=1to 5do tableua[i].add(drawcard);
end;
if decks=2then
for i:=1to 9do begin tableua[i].clear;
for j:=1to 7do tableua[i].add(drawcard);
end;
tableua[0].clear;
tableua[-1].clear;
tableua[0].add(drawcard);
while not allused do tableua[-1].add(drawcard);
end;
const background_white=background_red or background_green or background_blue or
background_intensity;
char_heart=#3;
char_diamond=#4;
char_club=#5;
char_spade=#6;
function cardtostring(card:tcard):string;
var attrib:word;
begin
if lobyte(hiword(suits[card.suit]))=ord('R')then attrib:=foreground_red or foreground_intensity or
background_white else
attrib:=background_white;
if card.suit=0then attrib:=0;
setconsoletextattribute(hout, attrib);
case card.face of
0,16:result:=#32;
1:result:='A';
10:result:='T';
11:result:='J';
12:result:='Q';
13:result:='K';
14:begin result:='??';exit;end;//Joker
else result:=inttostr(card.face);end;
case card.suit of
 1,2,3,4:result:=result+chr(hibyte(hiword(suits[card.suit])));
else result:=result+#32;
end;
end;

function sortscores(Item1, Item2: pointer): Integer;
begin
if pgolfscore(item1).score<pgolfscore(item2).score then result:=-1;
if pgolfscore(item1).score=pgolfscore(item2).score then result:=0;
if pgolfscore(item1).score>pgolfscore(item2).score then result:=1;
end;

function ScoreStr(score:PGolfScore):string;
begin
result:=inttostr(score.score);
if score.score=scores_init then result:='N/A';
end;

function gametypetostr(gt:byte):string;
begin
result:='';
if gt and 1=1then result:='AceKing ';
if gt and 2=2then result:=result+'2-decks';
end;

procedure ShowScores(score:shortint);
var cbscores:dword;
I:integer;
thisscore:TGolfScore;
scorea:array[0..9]of tgolfscore;
sortedscores:tlist;
begin
setconsoletextattribute(hout,defattrib);
sortedscores:=tlist.Create;
thisscore.gametype:=0;
cbscores:=0;
if(aceking=1)then thisscore.gametype:=1;
if(decks=2)then thisscore.gametype:=thisscore.gametype or 2;
if score<scores_show_only then begin write('Enter your name:');readln(thisscore.name);
thisscore.score:=score;end;
regqueryvalueex(hk,'Scores',nil,nil,nil,@cbscores);
if cbscores=sizeof(scores)then
regqueryvalueex(hk,'Scores',nil,nil,@scores,@cbscores);
for i:=0to 9do sortedscores.Add(@scores[i]);
if score<126then sortedscores.Add(@thisscore);
sortedscores.Sort(sortscores);
writeln('Place,Score,Name,GameType');
for i:=0to 9do begin write(i+1,'. ',scorestr(sortedscores[i]),' ',pgolfscore(
sortedscores[i]).name,' ',gametypetostr(pgolfscore(sortedscores[i]).gametype));
if sortedscores[i]=@thisscore then write('<--');writeln;copymemory(@scorea[i],
sortedscores[i],sizeof(tgolfscore));
end;
copymemory(@scores,@scorea,sizeof(scorea));
regsetvalueex(hk,'Scores',0,reg_binary,@scores,sizeof(scores));
sortedscores.Free;
writeln('Wins: ',win,' Lost: ',lost,' Games Played: ',win+lost);
write('Press enter to return...');readln;
clearconsole;
end;

procedure loadgame;
var sav:tgolfgame;
i,j,colcount:integer;
cb:dword;
Begin
cb:=sizeof(sav);
RegQueryValueEx(hk,'SavedGame',nil,nil,@sav,@cb);
decks:=sav.decks;
if decks=1 then colcount:=5 else colcount:=7;
gamenum:=sav.gamenum;
randominit(gamenum);
for i:=1to 9do
if tableua[i].count>0then for j:=1to colcount-sav.cardcount[i] do tableua[i].remove(
tableua[i].last);
tableua[0].clear;tableua[-1].clear;
for i:=1 to sav.cardcount[-1] do
tableua[-1].add(sav.drawpile[i]);
for i:=1to sav.cardcount[0]do tableua[0].add(sav.discardpile[i]);
end;

procedure youwinproc;
var
conrect:trect;
sortedscores:tlist;
ywbmp:graphics.tbitmap;
concan:tcanvas;
begin
ingame:=false;
GetWindowRect(getconsolewindow,conrect);
writeln('ÉÍÍÍÍÍÍÍÍÍÍ»');
writeln('º You win! º');
writeln('ÈÍÍÍÍÍÍÍÍÍͼ');
gameover:=true;
@getconsolewindow:=GetProcAddress(getmodulehandle('kernel32.dll'),
'GetConsoleWindow');
if assigned(getconsolewindow)then
if getconsolewindow<>0then begin
ywbmp:=graphics.tbitmap.create;
ywbmp.Handle:=loadbitmap(hinstance,'YOUWON');
Concan:=tcanvas.Create;
concan.Handle:=GetWindowDC(getconsolewindow);
concan.Draw((conrect.Right-ywbmp.width)div 2,(conrect.Bottom-ywbmp.height)div 2,
ywbmp);
releasedc(getconsolewindow,concan.handle);
concan.Free;
ywbmp.FreeImage;
ywbmp.Free;
end;
showscores(drawpile_bonus_points);
inc(win);
regdeletevalue(hk,'SavedGame');
regsetvalueex(hk,'Win',0,reg_dword,@win,4);
end;
{$RESOURCE GOLFSOL32.RES}
function quit(typ:dword):Bool;stdcall;
var dwGame:dword;
begin
result:=true;
dwGame:=gamenum;
if ingame then savegame;
regsetvalueex(hk,'Win',0,reg_dword,@win,4);
regsetvalueex(hk,'Lost',0,reg_dword,@lost,4);
regclosekey(hk);
exitprocess(0);
end;

function ismove(pile1,pile2:tlist):boolean;
var p1,p2:pointer;
c1,c2:tcard;
begin
result:=false;
if(pile1.Count*pile2.Count=0)then exit;
p1:=pile1.last;
p2:=pile2.last;
copymemory(@c1,@p1,4);
copymemory(@c2,@p2,4);
result:=(abs(c1.face-c2.face)=1)or(c1.face=14)or(c2.face=14);
if(((c1.face=1)and(c2.face=13))or((c1.face=13)and(c2.face=1)))and(aceking=1)then
result:=true;
end;
function AnyMoreMoves:byte;
var i:integer;
begin
result:=0;
for i:=1to 9 do if ismove(tableua[0],tableua[i])then inc(result);
end;

procedure ShowRules;
begin
clearconsole;
writeln('ÉÍÍÍÍÍÍÍÍÍÍ͹Golf RulesÌÍÍÍÍÍÍÍÍÍÍ»');
writeln('ºThe rules for golf solitaire are º');
writeln('ºvery simple. The whole idea of   º');
writeln('ºgame is to get rid of all cards  º');
writeln('ºin the seven columns(1 deck) or  º');
writeln('ºnine columns(2 decks). As in     º');
writeln('ºregular golf you want to get the º');
writeln('ºlowest points. When the game endsº');
writeln('ºwhatever cards are left count as º');
writeln('ºone point per card. If you go outº');
writeln('ºthe number of cards left will    º');
writeln('ºbecome a negative points. You    º');
writeln('ºwill try to move the cards from  º');
writeln('ºthe columns to the discard pile. º');
writeln('ºThey must be one card bigger or  º');
writeln('ºone card smaller.Example: a 5 canº');
writeln('ºbe moved to the discard pile onlyº');
writeln('ºif the top card is a 6 or a 4,theº');
writeln('ºsuit doesnt matter. You can choseº');
writeln('ºa column by entering the number 1º');
writeln('ºthough 9 and then pressng enter. º');
writeln('ºWhen there are no more moves you º');
writeln('ºcan type in 0 and hit enter or   º');
writeln('ºtype in 10 and hit enter to go toº');
writeln('ºmenu.                            º');
writeln('ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ');
writeln('Press enter to return...');
readln;
intour:=2;
end;

procedure Tour;
begin
clearconsole;
writeln('ÉÍÍÍÍÍÍÍÍÍ͹Golf TourÌÍÍÍÍÍÍÍÍÍÍÍÍ»');
writeln('ºTo know how to use this game you º');
writeln('ºwill be entering in numbers to   º');
writeln('ºtell the game your moves & what  º');
writeln('ºyou want to do. The columns are  º');
writeln('ºnumbered and so is the draw pile.º');
writeln('ºTo draw you enter in 0 and press º');
writeln('ºenter. Next we will look at the  º');
writeln('ºrules.                           º');
writeln('ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ');
writeln('Press enter to continue...');
readln;
intour:=1;
end;

procedure GolfSolitaire(params:tstringlist);
var i,j,choice:integer;
topcard:tcard;
pc:pointer;
cb,sgame:dword;
label gamepmt,gameend,menu,trytour;
begin
hout:=getstdhandle(std_output_handle);
defattrib:=foreground_intensity or foreground_red or foreground_blue or
foreground_green;
decks:=1;
randomize;
ingame:=false;
setconsoleoutputcp(437);
oldestver:=0;
for i:=0to 9do begin scores[i].Name:='N/A';scores[i].score:=scores_init;end;
SetConsoleCtrlHandler(@quit,true);
regcreatekey(hkey_current_user,'Software\Justin\GolfSolitaire',hk);
intour:=0;
suits[1]:=makelong(ord('C'),makeword(ord('B'),ord(char_club)));
suits[2]:=makelong(ord('S'),makeword(ord('B'),ord(char_spade)));
suits[3]:=makelong(ord('H'),makeword(ord('R'),ord(char_heart)));
suits[4]:=makelong(ord('D'),makeword(ord('R'),ord(char_diamond)));
cb:=sizeof(suits);
regqueryvalueex(hk,'Suit',nil,nil,@suits,@cb);
regsetvalueex(hk,'Suit',0,reg_binary,@suits,sizeof(suits));
cb:=4;regqueryvalueex(hk,'Decks',nil,nil,@decks,@cb);
if(decks=0)or(decks>2)then decks:=1;
showdiscard:=0;
cb:=4;
lost:=0;
win:=0;
regqueryvalueex(hk,'Lost',nil,nil,@lost,@cb);
cb:=4;
gameover:=true;
regqueryvalueex(hk,'Win',nil,nil,@win,@cb);
cb:=4;
aceking:=0;jokersused:=0;sgame:=0;
//regqueryvalueex(hk,'JokersUsed',nil,nil,@jokersused,@cb);
//Jokers for some reason freeze up the game being delt.
regqueryvalueex(hk,'LastGame',nil,nil,@sgame,@cb);
cb:=4;
//if jokersused>2then jokersused:=0;
regqueryvalueex(hk,'AceKing',nil,nil,@aceking,@cb);
cb:=4;
if aceking>1then aceking:=0;
regqueryvalueex(hk,'ShowDiscard',nil,nil,@showdiscard,@cb);
if showdiscard>1then showdiscard:=0;
for i:=-1 to 9do tableua[i]:=tlist.create;
if regqueryvalueex(hk,'OldestVersion',nil,nil,nil,nil)<>error_success then
begin
trytour:
write('Would you like to take a tour? type in 1 for Yes or 0 for No:');
readln(choice);
case choice of
1:tour;
0:goto menu;
else goto trytour;
end;
oldestver:=currentversion;
regsetvalueex(hk,'OldestVersion',0,reg_dword,@oldestver,4);
if intour=1 then goto menu;
end;
menu:clearconsole;
setconsoletextattribute(hout,defattrib);
writeln('ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»');
writeln('ºWelcome to Golf Solitaire         º');
writeln('ºWhat would you like to do?        º');
writeln('º1. Start a new game               º');
writeln('º2. Enter in a game number         º');
writeln('º3. View top ten                   º');
cb:=4;
writeln('º4. See game rules                 º');
writeln('º5. Change rules and settings      º');
if ingame then
writeln('º6. Return to game                 º');
if regqueryvalueex(hk,'SavedGame',nil,nil,nil,nil)=error_success then
writeln('º7. Load Saved Game                º');
writeln('ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ');
if intour=1 then
writeln('To see rules type 4 and press enter');
write('Choice Number:');readln(choice);
case choice of
4:begin showrules;goto menu;end;
1:begin
gamenum:=random(maxint)+1; randominit(gamenum);end;
2:begin write('Enter game#:');readln(gamenum);randominit(gamenum);end;
3:begin showscores(scores_show_only);goto menu;end;
5:begin writeln('Current Settings:');
write('Aces can be played on kings: ');if aceking=1then writeln('Yes')else
writeln('No');//writeln('Jokers used: ',jokersused);
writeln('Number of card decks:',decks);
write('Show all cards in the discard pile:');
if showdiscard=1then writeln('Yes')else writeln('No');
writeln('2=DontChange 1=Yes 0=No Any Other number returns to menu');
Write('Play Kings on Aces? Number Choice:');readln(aceking);
if aceking>1then goto menu;
{tryjoker:
write('Number of jokers to use. 0 though 2 are valid numbers:');
readln(jokersused);
if(JokersUsed>2)then begin Writeln('Too many jokers.');goto tryjoker;end;
}
write('Show all cards in the discard pile?(0=No 1=yes)');readln(showdiscard);
regsetvalueex(hk,'ShowDiscard',0,reg_dword,@showdiscard,4);
//regsetvalueex(hk,'JokersUsed',0,reg_dword,@jokersused,4);
regsetvalueex(HK,'AceKing',0,reg_dword,@aceking,4);
write('Enter number of decks to use(1 or 2):');readln(decks);
regsetvalueex(hk,'Decks',0,reg_dword,@decks,4);
goto menu;
end;
6:if ingame then goto gamepmt else goto menu;
7:if RegQueryValueex(hk,'SavedGame',nil,nil,nil,nil)=error_success then
 loadgame else goto menu;
else goto menu;
end;
gameover:=false;
drawpile_bonus_points:=-tableua[-1].count;
gamepmt:
clearconsole;
setconsoletextattribute(hout,defattrib);
ingame:=true;
write('Game#: ',gamenum,' Cards left:');
j:=0;
for i:=1to 9do j:=j+tableua[i].count;
write(j,' Draws left:',tableua[-1].count,' Type in 10 for menu');
writeln;
writeln('[1][2][3][4][5][6][7][8][9]');
if decks=1 then
for i:=0to 4do begin write(' ');
for j:=1to 9do begin if tableua[j].count>i then write(cardtostring(tcard(tableua[j][i])))
else write('  ');write(' ');end;
writeln;
end;
if decks=2 then
for i:=0to 6do begin write(' ');
for j:=1to 9do begin if tableua[j].count>i then write(cardtostring(tcard(tableua[j][i])))
else write('  ');write(' ');end;
writeln;
end;
setconsoletextattribute(hout,defattrib);
pc:=tableua[0].last;
copymemory(@topcard,@pc,4);
write('Draw[0]: ');
if showdiscard=0then
write(cardtostring(topcard))
else for i:=0to tableua[0].count-1do begin pc:=tableua[0][i];copymemory(@topcard,
@pc,4);write(cardtostring(topcard));end;
writeln;
setconsoletextattribute(hout,defattrib);
write('Choice:');
readln(choice);
case choice of
1,2,3,4,5,6,7,8,9:if ismove(tableua[0],tableua[choice])then
begin tableua[0].add(tableua[choice].last);tableua[choice].remove(
tableua[choice].last);if(tableua[-1].count=0) and(anymoremoves=0) then goto gameend;
end;
0:begin if((tableua[-1].count=0) and(anymoremoves=0)) then
goto gameend;tableua[0].add(tableua[-1].last);inc(drawpile_bonus_points);
tableua[-1].remove(tableua[-1].last);
end;
10:goto menu;
end;
if(tableua[1].count+tableua[2].count+tableua[3].count+tableua[4].count+
tableua[5].count+tableua[6].count+tableua[7].count+tableua[8].count+
tableua[9].count=0)then begin
 youwinproc;
 goto menu;
end;
goto gamepmt;
gameend:
regdeletevalue(hk,'SavedGame');
Writeln('Sorry, no more moves');
writeln('Tableua points: ',tableua[1].count+tableua[2].count+tableua[3].count+
tableua[4].count+tableua[5].count+tableua[6].count+tableua[7].count+
tableua[8].count+tableua[9].count);
gameover:=true;
inc(lost);
ingame:=false;
regsetvalueex(hk,'Lost',0,reg_dword,@lost,4);
showscores(tableua[1].count+tableua[2].count+tableua[3].count+tableua[4].count+
tableua[5].count+tableua[6].count+tableua[7].count);
//writeln('Press enter to return...');readln;
goto menu;
end;
end.
Trash
 
 
Error
Unable to connect to backend.
HTTP error 0

All programs are virus free. Some antivirus software might say its "suspicious" or a "Potentionaly Unwanted Program". Some of them rate them on what there code looks like no matter if theres a definition in the virus database. If any of them are detected any Antivirus I will zip the software with the password "justin" j is lowercase

Published by Justin Roeder

I am an electronics engineer and computer programmer that has autism. I learned by myself

delphijustin Industries is an Autism Supported Business
Social Media Auto Publish Powered By : XYZScripts.com
All in one
Start
Amazon.com OH Columbus
Your cart is empty.
There are 135 days, 8 hours, 28 minutes and 37 seconds left until Halloween

You can use the keyboard arrows to navigate between the component buttons
",e=e.removeChild(e.firstChild)):"string"==typeof o.is?e=l.createElement(a,{is:o.is}):(e=l.createElement(a),"select"===a&&(l=e,o.multiple?l.multiple=!0:o.size&&(l.size=o.size))):e=l.createElementNS(e,a),e[Ni]=t,e[Pi]=o,Pl(e,t,!1,!1),t.stateNode=e,l=Ae(a,o),a){case"iframe":case"object":case"embed":Te("load",e),u=o;break;case"video":case"audio":for(u=0;u<$a.length;u++)Te($a[u],e);u=o;break;case"source":Te("error",e),u=o;break;case"img":case"image":case"link":Te("error",e),Te("load",e),u=o;break;case"form":Te("reset",e),Te("submit",e),u=o;break;case"details":Te("toggle",e),u=o;break;case"input":A(e,o),u=M(e,o),Te("invalid",e),Ie(n,"onChange");break;case"option":u=B(e,o);break;case"select":e._wrapperState={wasMultiple:!!o.multiple},u=Uo({},o,{value:void 0}),Te("invalid",e),Ie(n,"onChange");break;case"textarea":V(e,o),u=H(e,o),Te("invalid",e),Ie(n,"onChange");break;default:u=o}Me(a,u);var s=u;for(i in s)if(s.hasOwnProperty(i)){var c=s[i];"style"===i?ze(e,c):"dangerouslySetInnerHTML"===i?(c=c?c.__html:void 0,null!=c&&Aa(e,c)):"children"===i?"string"==typeof c?("textarea"!==a||""!==c)&&X(e,c):"number"==typeof c&&X(e,""+c):"suppressContentEditableWarning"!==i&&"suppressHydrationWarning"!==i&&"autoFocus"!==i&&(ea.hasOwnProperty(i)?null!=c&&Ie(n,i):null!=c&&x(e,i,c,l))}switch(a){case"input":L(e),j(e,o,!1);break;case"textarea":L(e),$(e);break;case"option":null!=o.value&&e.setAttribute("value",""+P(o.value));break;case"select":e.multiple=!!o.multiple,n=o.value,null!=n?q(e,!!o.multiple,n,!1):null!=o.defaultValue&&q(e,!!o.multiple,o.defaultValue,!0);break;default:"function"==typeof u.onClick&&(e.onclick=Fe)}Ve(a,o)&&(t.effectTag|=4)}null!==t.ref&&(t.effectTag|=128)}return null;case 6:if(e&&null!=t.stateNode)Ll(e,t,e.memoizedProps,o);else{if("string"!=typeof o&&null===t.stateNode)throw Error(r(166));n=yn(yu.current),yn(bu.current),Jn(t)?(n=t.stateNode,o=t.memoizedProps,n[Ni]=t,n.nodeValue!==o&&(t.effectTag|=4)):(n=(9===n.nodeType?n:n.ownerDocument).createTextNode(o),n[Ni]=t,t.stateNode=n)}return null;case 13:return zt(vu),o=t.memoizedState,0!==(64&t.effectTag)?(t.expirationTime=n,t):(n=null!==o,o=!1,null===e?void 0!==t.memoizedProps.fallback&&Jn(t):(a=e.memoizedState,o=null!==a,n||null===a||(a=e.child.sibling,null!==a&&(i=t.firstEffect,null!==i?(t.firstEffect=a,a.nextEffect=i):(t.firstEffect=t.lastEffect=a,a.nextEffect=null),a.effectTag=8))),n&&!o&&0!==(2&t.mode)&&(null===e&&!0!==t.memoizedProps.unstable_avoidThisFallback||0!==(1&vu.current)?rs===Qu&&(rs=Yu):(rs!==Qu&&rs!==Yu||(rs=Gu),0!==us&&null!==es&&(To(es,ns),Co(es,us)))),(n||o)&&(t.effectTag|=4),null);case 4:return wn(),Ol(t),null;case 10:return Zt(t),null;case 17:return It(t.type)&&Ft(),null;case 19:if(zt(vu),o=t.memoizedState,null===o)return null;if(a=0!==(64&t.effectTag),i=o.rendering,null===i){if(a)mr(o,!1);else if(rs!==Qu||null!==e&&0!==(64&e.effectTag))for(i=t.child;null!==i;){if(e=_n(i),null!==e){for(t.effectTag|=64,mr(o,!1),a=e.updateQueue,null!==a&&(t.updateQueue=a,t.effectTag|=4),null===o.lastEffect&&(t.firstEffect=null),t.lastEffect=o.lastEffect,o=t.child;null!==o;)a=o,i=n,a.effectTag&=2,a.nextEffect=null,a.firstEffect=null,a.lastEffect=null,e=a.alternate,null===e?(a.childExpirationTime=0,a.expirationTime=i,a.child=null,a.memoizedProps=null,a.memoizedState=null,a.updateQueue=null,a.dependencies=null):(a.childExpirationTime=e.childExpirationTime,a.expirationTime=e.expirationTime,a.child=e.child,a.memoizedProps=e.memoizedProps,a.memoizedState=e.memoizedState,a.updateQueue=e.updateQueue,i=e.dependencies,a.dependencies=null===i?null:{expirationTime:i.expirationTime,firstContext:i.firstContext,responders:i.responders}),o=o.sibling;return Mt(vu,1&vu.current|2),t.child}i=i.sibling}}else{if(!a)if(e=_n(i),null!==e){if(t.effectTag|=64,a=!0,n=e.updateQueue,null!==n&&(t.updateQueue=n,t.effectTag|=4),mr(o,!0),null===o.tail&&"hidden"===o.tailMode&&!i.alternate)return t=t.lastEffect=o.lastEffect,null!==t&&(t.nextEffect=null),null}else 2*ru()-o.renderingStartTime>o.tailExpiration&&1t)&&vs.set(e,t)))}}function Ur(e,t){e.expirationTimee?n:e,2>=e&&t!==e?0:e}function qr(e){if(0!==e.lastExpiredTime)e.callbackExpirationTime=1073741823,e.callbackPriority=99,e.callbackNode=$t(Vr.bind(null,e));else{var t=Br(e),n=e.callbackNode;if(0===t)null!==n&&(e.callbackNode=null,e.callbackExpirationTime=0,e.callbackPriority=90);else{var r=Fr();if(1073741823===t?r=99:1===t||2===t?r=95:(r=10*(1073741821-t)-10*(1073741821-r),r=0>=r?99:250>=r?98:5250>=r?97:95),null!==n){var o=e.callbackPriority;if(e.callbackExpirationTime===t&&o>=r)return;n!==Yl&&Bl(n)}e.callbackExpirationTime=t,e.callbackPriority=r,t=1073741823===t?$t(Vr.bind(null,e)):Wt(r,Hr.bind(null,e),{timeout:10*(1073741821-t)-ru()}),e.callbackNode=t}}}function Hr(e,t){if(ks=0,t)return t=Fr(),No(e,t),qr(e),null;var n=Br(e);if(0!==n){if(t=e.callbackNode,(Ju&(Wu|$u))!==Hu)throw Error(r(327));if(lo(),e===es&&n===ns||Kr(e,n),null!==ts){var o=Ju;Ju|=Wu;for(var a=Yr();;)try{eo();break}catch(t){Xr(e,t)}if(Gt(),Ju=o,Bu.current=a,rs===Ku)throw t=os,Kr(e,n),To(e,n),qr(e),t;if(null===ts)switch(a=e.finishedWork=e.current.alternate,e.finishedExpirationTime=n,o=rs,es=null,o){case Qu:case Ku:throw Error(r(345));case Xu:No(e,2=n){e.lastPingedTime=n,Kr(e,n);break}}if(i=Br(e),0!==i&&i!==n)break;if(0!==o&&o!==n){e.lastPingedTime=o;break}e.timeoutHandle=Si(oo.bind(null,e),a);break}oo(e);break;case Gu:if(To(e,n),o=e.lastSuspendedTime,n===o&&(e.nextKnownPendingLevel=ro(a)),ss&&(a=e.lastPingedTime,0===a||a>=n)){e.lastPingedTime=n,Kr(e,n);break}if(a=Br(e),0!==a&&a!==n)break;if(0!==o&&o!==n){e.lastPingedTime=o;break}if(1073741823!==is?o=10*(1073741821-is)-ru():1073741823===as?o=0:(o=10*(1073741821-as)-5e3,a=ru(),n=10*(1073741821-n)-a,o=a-o,0>o&&(o=0),o=(120>o?120:480>o?480:1080>o?1080:1920>o?1920:3e3>o?3e3:4320>o?4320:1960*Uu(o/1960))-o,n=o?o=0:(a=0|l.busyDelayMs,i=ru()-(10*(1073741821-i)-(0|l.timeoutMs||5e3)),o=i<=a?0:a+o-i),10 component higher in the tree to provide a loading indicator or placeholder to display."+N(i))}rs!==Zu&&(rs=Xu),l=yr(l,i),f=a;do{switch(f.tag){case 3:u=l,f.effectTag|=4096,f.expirationTime=t;var w=Ar(f,u,t);ln(f,w); break e;case 1:u=l;var E=f.type,k=f.stateNode;if(0===(64&f.effectTag)&&("function"==typeof E.getDerivedStateFromError||null!==k&&"function"==typeof k.componentDidCatch&&(null===ms||!ms.has(k)))){f.effectTag|=4096,f.expirationTime=t;var _=Ir(f,u,t);ln(f,_);break e}}f=f.return}while(null!==f)}ts=no(ts)}catch(e){t=e;continue}break}}function Yr(){var e=Bu.current;return Bu.current=Cu,null===e?Cu:e}function Gr(e,t){eus&&(us=e)}function Jr(){for(;null!==ts;)ts=to(ts)}function eo(){for(;null!==ts&&!Gl();)ts=to(ts)}function to(e){var t=Fu(e.alternate,e,ns);return e.memoizedProps=e.pendingProps,null===t&&(t=no(e)),qu.current=null,t}function no(e){ts=e;do{var t=ts.alternate;if(e=ts.return,0===(2048&ts.effectTag)){if(t=br(t,ts,ns),1===ns||1!==ts.childExpirationTime){for(var n=0,r=ts.child;null!==r;){var o=r.expirationTime,a=r.childExpirationTime;o>n&&(n=o),a>n&&(n=a),r=r.sibling}ts.childExpirationTime=n}if(null!==t)return t;null!==e&&0===(2048&e.effectTag)&&(null===e.firstEffect&&(e.firstEffect=ts.firstEffect),null!==ts.lastEffect&&(null!==e.lastEffect&&(e.lastEffect.nextEffect=ts.firstEffect),e.lastEffect=ts.lastEffect),1e?t:e}function oo(e){var t=qt();return Vt(99,ao.bind(null,e,t)),null}function ao(e,t){do lo();while(null!==gs);if((Ju&(Wu|$u))!==Hu)throw Error(r(327));var n=e.finishedWork,o=e.finishedExpirationTime;if(null===n)return null;if(e.finishedWork=null,e.finishedExpirationTime=0,n===e.current)throw Error(r(177));e.callbackNode=null,e.callbackExpirationTime=0,e.callbackPriority=90,e.nextKnownPendingLevel=0;var a=ro(n);if(e.firstPendingTime=a,o<=e.lastSuspendedTime?e.firstSuspendedTime=e.lastSuspendedTime=e.nextKnownPendingLevel=0:o<=e.firstSuspendedTime&&(e.firstSuspendedTime=o-1),o<=e.lastPingedTime&&(e.lastPingedTime=0),o<=e.lastExpiredTime&&(e.lastExpiredTime=0),e===es&&(ts=es=null,ns=0),1u&&(c=u,u=l,l=c),c=Ue(w,l),f=Ue(w,u),c&&f&&(1!==k.rangeCount||k.anchorNode!==c.node||k.anchorOffset!==c.offset||k.focusNode!==f.node||k.focusOffset!==f.offset)&&(E=E.createRange(),E.setStart(c.node,c.offset),k.removeAllRanges(),l>u?(k.addRange(E),k.extend(f.node,f.offset)):(E.setEnd(f.node,f.offset),k.addRange(E)))))),E=[];for(k=w;k=k.parentNode;)1===k.nodeType&&E.push({element:k,left:k.scrollLeft,top:k.scrollTop});for("function"==typeof w.focus&&w.focus(),w=0;w=t&&e<=t}function To(e,t){var n=e.firstSuspendedTime,r=e.lastSuspendedTime;nt||0===n)&&(e.lastSuspendedTime=t),t<=e.lastPingedTime&&(e.lastPingedTime=0),t<=e.lastExpiredTime&&(e.lastExpiredTime=0)}function Co(e,t){t>e.firstPendingTime&&(e.firstPendingTime=t);var n=e.firstSuspendedTime;0!==n&&(t>=n?e.firstSuspendedTime=e.lastSuspendedTime=e.nextKnownPendingLevel=0:t>=e.lastSuspendedTime&&(e.lastSuspendedTime=t+1),t>e.nextKnownPendingLevel&&(e.nextKnownPendingLevel=t))}function No(e,t){var n=e.lastExpiredTime;(0===n||n>t)&&(e.lastExpiredTime=t)}function Po(e,t,n,o){var a=t.current,i=Fr(),l=su.suspense;i=jr(i,a,l);e:if(n){n=n._reactInternalFiber;t:{if(J(n)!==n||1!==n.tag)throw Error(r(170));var u=n;do{switch(u.tag){case 3:u=u.stateNode.context;break t;case 1:if(It(u.type)){u=u.stateNode.__reactInternalMemoizedMergedChildContext;break t}}u=u.return}while(null!==u);throw Error(r(171))}if(1===n.tag){var s=n.type;if(It(s)){n=Dt(n,s,u);break e}}n=u}else n=Al;return null===t.context?t.context=n:t.pendingContext=n,t=on(i,l),t.payload={element:e},o=void 0===o?null:o,null!==o&&(t.callback=o),an(a,t),Dr(a,i),i}function Oo(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function Ro(e,t){e=e.memoizedState,null!==e&&null!==e.dehydrated&&e.retryTime