Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Ruolette - Roulette.pas

Roulette.pas

Caricato da: Phi
Scarica il programma completo

  1. program ROUETTE;
  2.  
  3. uses crt, dos;
  4. {$R rouletteres.res}
  5.  
  6. type
  7. slot = record
  8. v : real;
  9. s : boolean;
  10. end;
  11. salvataggi = array [1..8] of slot;
  12. const
  13. S = '';
  14.  
  15. procedure Text_N;
  16. begin
  17. textcolor (15);
  18. textbackground (0);
  19. end;
  20. procedure Text_1;
  21. begin
  22. textcolor (14);
  23. textbackground(1);
  24. end;
  25. procedure Text_3;
  26. begin
  27. textcolor (14);
  28. textbackground(4);
  29. end;
  30.  
  31. var
  32. Salv : File of salvataggi;
  33. sl : salvataggi;
  34. Ric: SearchRec;
  35. A, B, ESTR, Q, ss : byte;
  36. Psalv, P1, P2, P3 : boolean;
  37. BK : char;
  38. M, P : real;
  39. S1 : string;
  40.  
  41. function Y(A : byte) : byte;
  42. var
  43. M : byte;
  44. begin
  45. M := A mod 3;
  46. if M = 0 then
  47. A := (A div 3) + 1
  48. else
  49. A := (A div 3) + 2;
  50. Y := A
  51. end;
  52.  
  53. function X(A : byte): byte;
  54. begin
  55. if A > 0 then begin
  56. A := A mod 3;
  57. if A = 0 then A := 76
  58. else A := A * 3 + 67;
  59. end
  60. else A := 73;
  61. X := A
  62. end;
  63.  
  64. procedure SWR1(Color,I : byte);
  65. begin
  66. gotoxy(64,I);
  67. textcolor(Color);
  68. writeln (S);
  69. delay(85);
  70. end;
  71.  
  72. procedure SWR2(Color : byte);
  73. begin
  74. textcolor(Color);
  75. write(S);
  76. delay(70);
  77. end;
  78.  
  79. procedure SWR3(A : byte);
  80. begin
  81. if (A < 11) or ((A > 18) and (A < 29))  then begin
  82. if A mod 2 = 0 then textcolor(0)
  83. else textcolor(4);
  84. end
  85. else begin
  86. if A mod 2 = 0 then textcolor(4)
  87. else textcolor(0);
  88. end;
  89. gotoxy(X(A),Y(A));
  90. end;
  91.  
  92. procedure WR1;
  93. var
  94. I : byte;
  95. begin
  96. I := 0;
  97. repeat
  98. I := I + 1;
  99. SWR1(14,I);
  100. I := I + 1;
  101. SWR1(10,I);
  102. until I = 16;
  103. gotoxy (64,17);
  104. repeat
  105. SWR2(14);
  106. SWR2(10);
  107. I := I - 2
  108. until I = 0;
  109. SWR2(14);
  110. end;
  111.  
  112. procedure WR2;
  113. begin
  114. window(66,1,79,15);
  115. textbackground(2);
  116. textcolor(14);
  117. clrscr;
  118. writeln('  _    0');
  119. writeln;
  120. writeln('> W          <');
  121. writeln('  _');
  122. writeln('_            _');
  123. writeln('  X');
  124. writeln('  _');
  125. writeln('P            D');
  126. writeln('  Y');
  127. writeln('_ _          _');
  128. writeln;
  129. writeln('  Z');
  130. writeln('  _');
  131. writeln('    A  B  C');
  132. end;
  133.  
  134. procedure WR3;
  135. var I : byte;
  136. begin
  137. window(1,1,80,25);
  138. textcolor(4);
  139. gotoxy(79,12);
  140. write('');
  141. textcolor(0);
  142. gotoxy(66,12);
  143. write('');
  144. for  I := 1 to 36 do begin
  145. SWR3(I);
  146. write(I);
  147. end;
  148. end;
  149.  
  150. procedure WR5;
  151. begin
  152. window(66,22,79,24);
  153. Text_3;
  154. clrscr;
  155. gotoxy(2,2);
  156. writeln ('$ = ',M:5:2);
  157. window(66,18,79,20);
  158. clrscr;
  159. gotoxy(2,2);
  160. writeln('Estratto=',ESTR);
  161. end;
  162.  
  163. procedure WR4;
  164. var G, K : byte;
  165. begin
  166. case A of
  167. 2 : begin
  168. G := 68;
  169. case BK of
  170. 'W' : K := 3;
  171. 'X' : K := 6;
  172. 'Y' : K := 9;
  173. 'Z' : K := 12;
  174. end;
  175. end;
  176. 3 : begin
  177. K := 14;
  178. case BK of
  179. 'A' : G := 70;
  180. 'B' : G := 73;
  181. 'C' : G := 76;
  182. end;
  183. end;
  184. 4 : begin
  185. K := 8;
  186. if BK = 'P' then G := 66
  187. else G := 79;
  188. end;
  189. 5 : begin
  190. K := 3;
  191. if BK = '>' then G := 66
  192. else G := 79;
  193. end;
  194. else begin
  195. K := 12;
  196. if BK = 'N' then G := 66
  197. else G := 79;
  198. end;
  199. end;
  200. gotoxy(G,K);
  201. if A = 6 then write('')
  202. else begin
  203. textcolor(10);
  204. write (BK);
  205. textcolor(14);
  206. end;
  207. end;
  208.  
  209. procedure Clean;
  210. begin
  211. Text_N;
  212. window(64,1,64,17);
  213. clrscr;
  214. window(64,17,80,17);
  215. clrscr;
  216. window(4,6,54,20);
  217. clrscr;
  218. WR2;
  219. WR3;
  220. Text_1;
  221. end;
  222.  
  223. procedure LettFile;
  224. var I : byte;
  225. P : boolean;
  226. begin
  227. P := false;
  228. Assign (Salv, 'Salv.roulette');
  229. reset(Salv);
  230. read(Salv,sl);
  231. close(Salv);
  232. for I := 1 to 8 do if sl[I].s then P := true;
  233. if P then begin
  234. writeln ('Caricare il salvataggio(s\n)?');
  235. repeat
  236. readln(BK);
  237. until (BK = 'S') or (BK = 's') or (BK = 'N') or (BK = 'n');
  238. Findclose(Ric);
  239. if (BK = 'S') or (BK = 's') then begin
  240. Psalv := true;
  241. write ('Quale slot carichi?(');
  242. for I := 1 to 8 do if sl[I].s then write (I,'; ');
  243. writeln(')');
  244. repeat
  245. repeat
  246. readln(ss);
  247. until (ss>0) and (ss <9);
  248. until sl[ss].s;
  249. M := sl[ss].v
  250. end;
  251. end;
  252. end;
  253.  
  254. procedure ScriviFile;
  255. begin
  256. rewrite(Salv);
  257. write(Salv,sl);
  258. close(Salv);
  259. end;
  260.  
  261. BEGIN
  262. randomize;
  263. clrscr;
  264. FindFirst('Salv.roulette', anyfile, Ric);
  265. if Doserror = 0 then LettFile;
  266. clrscr;
  267. WR2;
  268. WR3;
  269. window(1,1,80,25);
  270. if not(Psalv) then M := 200;
  271. WR5;
  272. window(3,2,62,4);
  273. Text_1;
  274. clrscr;
  275. gotoxy(25,2);
  276. writeln('ROULETTE');
  277. repeat
  278. window(4,6,54,20);
  279. writeln('Puntare su:  1*  numero singolo    4*  pari\dispari');
  280. writeln('             2*  settore(W,X..)    5*  > 18 \ <= 18');
  281. writeln('             3*  colonna(A,B,C)    6*  neri \ rossi');
  282. window(5,9,6,9);
  283. repeat
  284. readln(A);
  285. until (A > 0) and (A < 7);
  286. window(4,6,54,20);
  287. case A of
  288. 1 : S1 := 'numero';
  289. 2 : S1 := 'settore';
  290. 3 : S1 := 'colonna';
  291. 4 : S1 := '"P" o "D"';
  292. 5 : S1 := '">" o "<"';
  293. else S1 := '"N" o "R"';
  294. end;
  295. gotoxy(1,6);
  296. writeln ('Puntare su ', S1);
  297. window(5,12,7,12);
  298. case A of
  299. 1 : begin
  300. repeat
  301. readln (B);
  302. until B < 37;
  303. P1 := true;
  304. end;
  305. 2 : begin
  306. repeat
  307. readln (BK);
  308. until (BK = 'W') or (BK = 'X') or (BK = 'Y') or (BK = 'Z');
  309. end;
  310. 3 : begin
  311. repeat
  312. readln (BK);
  313. until (BK = 'A') or (BK = 'B') or (BK = 'C');
  314. end;
  315. 4 : begin
  316. repeat
  317. readln (BK);
  318. until (BK = 'P') or (BK = 'D');
  319. end;
  320. 5 : begin
  321. repeat
  322. readln (BK);
  323. until (BK = '>') or (BK = '<');
  324. end;
  325. else begin
  326. repeat
  327. readln (BK);
  328. until (BK = 'N') or (BK = 'R');
  329. end;
  330. end;
  331. window(1,1,80,25);
  332. if P1 then begin
  333. gotoxy(X(B),Y(B));
  334. write(B);
  335. end
  336. else WR4;
  337. ESTR := random(36);
  338. gotoxy(5,14);
  339. write('Quanto punti ?');
  340. window(20,14,35,14);
  341. repeat
  342. clrscr;
  343. readln(P);
  344. until P <= M;
  345. window(1,1,80,25);
  346. gotoxy(7,16);
  347. writeln ('!!ESTRAZIONE.... !!');
  348. Text_N;
  349. case A of
  350. 1 : begin
  351. Q := 35;
  352. if B = ESTR then P3 := true;
  353. end;
  354. 2 : begin
  355. case BK of
  356. 'W' : Q := 10;
  357. 'X' : Q := 19;
  358. 'Y' : Q := 28;
  359. else Q := 37;
  360. end;
  361. if (ESTR < Q) and (ESTR > 0) and (ESTR > (Q-10)) then P3 := true;
  362. Q := 5;
  363. end;
  364. 3 : begin
  365. case BK of
  366. 'A' : Q := 1;
  367. 'B' : Q := 2;
  368. else Q := 0;
  369. end;
  370. if (ESTR > 0) and ((ESTR mod 3) = Q) then P3 := true;
  371. Q := 3;
  372. end;
  373. 4 : begin
  374. if BK = 'P' then Q := 0
  375. else Q := 1;
  376. if (ESTR > 0) and ((ESTR mod 2) = Q) then P3 := true;
  377. Q := 1;
  378. end;
  379. 5 : begin
  380. if (((ESTR < 19) and (BK = '<')) or ((ESTR > 18)and (BK = '>'))) and (ESTR > 0) then P3 := true;
  381. Q := 1;
  382. end;
  383. 6 : begin
  384. Q := 1;
  385. end;
  386. end;
  387. WR1;
  388. gotoxy(X(ESTR),Y(ESTR));
  389. Text_3;
  390. write(ESTR);
  391. Text_1;
  392. gotoxy(7,16);
  393. if P3 then begin
  394. write(space(7), '! HAI VINTO !', space(7));
  395. M := M + (P * Q);
  396. end
  397. else begin
  398. write(space(7), '! HAI PERSO !', space(7));
  399. M := M - P;
  400. end;
  401. WR5;
  402. Text_1;
  403. window(5,18,44,18);
  404. if Psalv then begin;
  405. sl[ss].v := M;
  406. sl[ss].s := true;
  407. ScriviFile;
  408. end;
  409. if M = 0 then begin
  410. P2 := true;
  411. textcolor(7);
  412. textbackground(4);
  413. writeln('!!! BANCAROTTA !!!');
  414. if Psalv then begin
  415. sl[ss].s := false;
  416. ScriviFile;
  417. end;
  418. end;
  419. readln;
  420. if not(P2) then begin
  421. write ('Proseguire il gioco(1) o salvare e uscire(2)?');
  422. window(6,19,7,19);
  423. repeat
  424. readln(BK);
  425. until (BK = '1') or (BK = '2');
  426. if (BK = '2') then begin
  427. clrscr;
  428. writeln('Su quale slot scrivi(1..8)?');
  429. window(7,20,8,20);
  430. repeat
  431. readln(ss);
  432. until (ss>0) and (ss <9);
  433. sl[ss].v := M;
  434. sl[ss].s := true;
  435. P2 := true;
  436. if not(Psalv) then assign(Salv,'Salv.roulette');
  437. ScriviFile;
  438. end;
  439. Text_1;
  440. Clean;
  441. end;
  442. P3 := false;
  443. until P2;
  444. Text_1;
  445. delay(300);
  446. clrscr;
  447. gotoxy(2,2);
  448. writeln('Bye');
  449. delay(500);
  450. END.