-
Notifications
You must be signed in to change notification settings - Fork 4
/
CYATHZEE.PAS
661 lines (639 loc) · 18.4 KB
/
CYATHZEE.PAS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
{ @author: Sylvain Maltais (support@gladir.com)
@created: 2024
@website(https://www.gladir.com/7iles)
@abstract(Target: Turbo Pascal 7, Free Pascal 3.2)
}
Program CYahtzee; { COCO-YATHZEE.PAS }
Uses Crt;
Const
NUM_DICE=5;
Var
Finish,PlayNow:Boolean;
ScoreBoard:Array[1..6,0..12] of Integer;
BonusBoard:Array[1..6]of Integer;
TotalBoard:Array[1..6]of Integer;
Dices:Array[0..NUM_DICE] of Integer;
Total,Bonus,Rounds,I,J,H:Integer;
Err:Word;
Input:String;
K:Char;
Function StrToUpper(S:String):String;
Var
I:Byte;
Begin
For I:=1 to Length(S)do Begin
If S[I] in['a'..'z']Then S[I]:=Chr(Ord(S[I])-32);
End;
StrToUpper:=S;
End;
Function ExtractWord(Pos:Integer;S:String):String;
Var
I:Integer;
CurrPos:Integer;
CurrStr:String;
Begin
ExtractWord:='';
CurrStr:='';
CurrPos:=1;
For I:=1 to Length(S)do Begin
If S[I]=' 'Then Begin
If(CurrPos=Pos)Then Begin
ExtractWord:=CurrStr;
Exit;
End;
Inc(CurrPos);
CurrStr:='';
End
Else
CurrStr:=CurrStr+S[I];
End;
If(CurrPos=Pos)Then Begin
ExtractWord:=CurrStr;
End;
End;
Function Dupl(C:String;Num:Integer):String;
Var
I:Integer;
S:String;
Begin
S:='';
For I:=1 to Num do S:=S+C;
Dupl:=S;
End;
Function PadLeft(S:String;Space:Byte):String;Begin
While Length(S)<Space do S:=' '+S;
PadLeft:=S;
End;
Function PadRight(S:String;Space:Byte):String;
Var
I:Byte;
Begin
If Length(S)<Space Then For I:=Length(S)+1 to Space do S:=S+' ';
PadRight:=S;
End;
Function PadRight_(S:String;Space:Byte;Chr:Char):String;
Var
I:Byte;
Begin
If Length(S)<Space Then For I:=Length(S)+1 to Space do S:=S+Chr;
PadRight_:=S;
End;
Function Compare(a,b:Integer):Integer;Begin
Compare:= a-b;
End;
Procedure QuickSort(Var FList:Array of Integer;L,R:Integer);
Var
I,J,P:LongInt;
T:Integer;
Begin
Repeat
I:=L;
J:=R;
P:=(L+R) div 2;
Repeat
While Compare(FList[P],FList[i])>0 do I:=I+1;
While Compare(FList[P],FList[J])<0 do J:=J-1;
If I <= J Then Begin
T:=FList[I];
Flist[I]:=FList[J];
FList[J]:=T;
If P=I Then P:=J Else
If P=J Then P:=I;
I:=I+1;
J:=J-1;
End;
Until I>J;
If L<J Then QuickSort(FList,L,J);
L:=I;
Until I>=R;
End;
Function RandomDice:Integer;Begin
RandomDice:=Random(6)+1;
End;
Function CalculateUpper(Choice:Integer):Boolean;
Var
Points,i:Integer;
Begin
Points:=0;
If ScoreBoard[H,choice-1] >= 0 Then Begin
CalculateUpper:=False;
Exit;
End;
For I:=0 to NUM_DICE-1 do Begin
If Dices[i]=Choice Then Points:=Points+Choice;
End;
ScoreBoard[H,Choice-1]:=Points;
CalculateUpper:=True;
End;
Function Check_of_a_kind(Number:Integer;Var Dices:Array of Integer):Boolean;
Var
Index,Points,Count,I,J:Integer;
Begin
Index:=0;
Points:=0;
Count:=0;
If Number=3 Then Index:=6 Else
If Number=4 Then Index:=7
Else Index:=11;
If ScoreBoard[H,Index]>=0 Then Begin
Check_of_a_kind:=False;
Exit;
End;
For I:=1 to 6 do Begin
For J:=0 to NUM_DICE-1 do Begin
If Dices[J]=I Then Inc(count);
End;
If Count>=Number Then Begin
For J:=0 to NUM_DICE-1 do Points:=Points+Dices[j];
If Number=5 Then Points:=50;
ScoreBoard[H,Index]:=Points;
Check_of_a_kind:=True;
Exit;
End;
Count:=0;
End;
ScoreBoard[H,Index]:=0;
Check_of_a_kind:=True;
End;
Function Check_full_house(Var Dices:Array of Integer):Boolean;
Var
Points,I,Count1,Count2:Integer;
Begin
Points:=0;
Count1:=0;
Count2:=0;
If ScoreBoard[H,8]>=0 then Begin
Check_full_house:=False;
Exit;
End;
QuickSort(dices, 0,NUM_DICE);
For I:=0 to 2 do Begin
If Dices[0]=Dices[I]Then Inc(Count1);
End;
For I:=NUM_DICE-1 downto 3 do Begin
If Dices[NUM_DICE-1]=Dices[I]Then Inc(Count2);
End;
If Count1+Count2=5 Then Points:=25;
ScoreBoard[H,8]:=Points;
Check_full_house:=True;
End;
Function Check_straight(Choice:Integer;Var Dices:Array of Integer):Boolean;
Var
Points,I,J,Straight,RepeatFlag,Index,Length:Integer;
Begin
Points:=0;
If Choice=4 Then Begin
Index:=9;
Length:=3;
End
Else
Begin
Index:=10;
Length:=4;
End;
If ScoreBoard[H,Index]>=0 Then Begin
Check_Straight:=False;
Exit;
End;
QuickSort(Dices,0,NUM_DICE);
For I:=0 to 2 do Begin
Straight:=1;
RepeatFlag:=0;
For J:=0 to Length-1 do Begin
If(Dices[j]-Dices[j+1])<>-1 Then Begin
If(Dices[j]=Dices[j+1])and(RepeatFlag=0)Then Begin
RepeatFlag := 1;
Continue;
End
Else
Begin
Straight:=0;
Break;
End;
End;
End;
If Straight<>0 Then Begin
If Choice=4 Then Points:=30
Else Points:=40;
End;
End;
ScoreBoard[H,Index]:=Points;
Check_straight:=True;
End;
Procedure ShowDice(X,Y,Dice:Integer);
Var
OldX,OldY:Integer;
Begin
OldX:=WhereX;
OldY:=WhereY;
TextBackground(7);
TextColor(0);
Case Dice of
1:Begin
GotoXY(X,Y);
Write(' ',' ',' ');
GotoXY(X,Y+1);
Write(' ',' ',#254,' ',' ');
GotoXY(X,Y+2);
Write(' ',' ',' ');
End;
2:Begin
GotoXY(X,Y);
Write(' ',#254,' ',' ');
GotoXY(X,Y+1);
Write(' ',' ',' ');
GotoXY(X,Y+2);
Write(' ',' ',#254,' ');
End;
3:Begin
GotoXY(X,Y);
Write(' ',#254,' ',' ');
GotoXY(X,Y+1);
Write(' ',' ',#254,' ',' ');
GotoXY(X,Y+2);
Write(' ',' ',#254,' ');
End;
4:Begin
GotoXY(X,Y);
Write(' ',#254,' ',#254,' ');
GotoXY(X,Y+1);
Write(' ',' ',' ');
GotoXY(X,Y+2);
Write(' ',#254,' ',#254,' ');
End;
5:Begin
GotoXY(X,Y);
Write(' ',#254,' ',#254,' ');
GotoXY(X,Y+1);
Write(' ',' ',#254,' ',' ');
GotoXY(X,Y+2);
Write(' ',#254,' ',#254,' ');
End;
6:Begin
GotoXY(X,Y);
Write(' ',#254,' ',#254,' ');
GotoXY(X,Y+1);
Write(' ',#254,' ',#254,' ');
GotoXY(X,Y+2);
Write(' ',#254,' ',#254,' ');
End;
End;
TextBackground(Cyan);
TextColor(7);
GotoXY(OldX,OldY);
End;
Procedure PrintScores(Rounds:Integer);
Var
I,J,Total,Bonus:Integer;
Begin
ClrScr;
TextBackground(Cyan);
TextColor(7);
GotoXY(32,1);
WriteLn('C O C O - Y A H T Z E E');
Total:=0;
Bonus:=0;
For I:=0 to 12 do Begin
If ScoreBoard[H,I]>0 Then Total:=Total+ScoreBoard[H,I];
End;
If ScoreBoard[H,0]+ScoreBoard[H,1]+ScoreBoard[H,2]+
ScoreBoard[H,3]+ScoreBoard[H,4]+ScoreBoard[H,5]>=63 Then Bonus:=35
Else Bonus:=0;
BonusBoard[H]:=Bonus;
GotoXY(60,2);
Write('TOUR : ',Rounds+1);
GotoXY(60,3);
Write('PARTIE : ',H);
GotoXY(1,2);
WriteLn(' ',Dupl(' ',30),#218,Dupl(#196,2),#194,Dupl(#196,2),#194,
Dupl(#196,2),#194,Dupl(#196,2),#194,Dupl(#196,2),#194,
Dupl(#196,2),#191);
WriteLn(' ',PadRight('SECTION SUPERIEUR',30),#179,'1 ',#179,'2 ',#179,
'3 ',#179,'4 ',#179,'5 ',#179,'6 ',#179);
WriteLn(' ',Dupl(' ',30),#179,Dupl('-',2),#179,Dupl('-',2),#179,
Dupl('-',2),#179,Dupl('-',2),#179,Dupl('-',2),#179,
Dupl('-',2),#179);
Write(' ',PadRight_('Les as ',29,'.'),'1',#179);
For J:=1 to 6 do Begin
If ScoreBoard[J,0]>=0 Then Write(ScoreBoard[J,0]:2)
Else Write(' ':2);
If J<6 Then Write(#179);
End;
WriteLn(#179,'1');
Write(' ',PadRight_('Les deux',29,'.'),'2',#179);
For J:=1 to 6 do Begin
If ScoreBoard[J,1]>=0 Then Write(ScoreBoard[J,1]:2)
Else Write(' ':2);
If J<6 Then Write(#179);
End;
WriteLn(#179,'2');
Write(' ',PadRight_('Les trois',29,'.'),'3',#179);
For J:=1 to 6 do Begin
If ScoreBoard[J,2]>=0 Then Write(ScoreBoard[J,2]:2)
Else Write(' ':2);
If J<6 Then Write(#179);
End;
WriteLn(#179,'3');
Write(' ',PadRight_('Les quatres',29,'.'),'4',#179);
For J:=1 to 6 do Begin
If ScoreBoard[J,3]>=0 Then Write(ScoreBoard[J,3]:2)
Else Write(' ':2);
If J<6 Then Write(#179);
End;
WriteLn(#179,'4');
Write(' ',PadRight_('Les cinq',29,'.'),'5',#179);
For J:=1 to 6 do Begin
If ScoreBoard[J,4]>=0 Then Write(ScoreBoard[J,4]:2)
Else Write(' ':2);
If J<6 Then Write(#179);
End;
WriteLn(#179,'5');
Write(' ',PadRight_('Les six',29,'.'),'6',#179);
For J:=1 to 6 do Begin
If ScoreBoard[J,5]>=0 Then Write(ScoreBoard[J,5]:2)
Else Write(' ':2);
If J<6 Then Write(#179);
End;
WriteLn(#179,'6');
Write(' ',PadRight('Section sup‚rieure de prime',30),#179);
For J:=1 to 6 do Begin
If BonusBoard[J]>=0 Then Write(Bonus:2)
Else Write(0:2);
Write(#179);
End;
WriteLn(' ');
WriteLn(' ',Dupl(' ',30),#179,Dupl('-',2),#179,Dupl('-',2),#179,
Dupl('-',2),#179,Dupl('-',2),#179,Dupl('-',2),#179,
Dupl('-',2),#179);
WriteLn(' ',PadRight('SECTION INFERIEUR',30),#179,'1 ',#179,'2 ',#179,
'3 ',#179,'4 ',#179,'5 ',#179,'6 ',#179);
WriteLn(' ',Dupl(' ',30),#179,Dupl('-',2),#179,Dupl('-',2),#179,
Dupl('-',2),#179,Dupl('-',2),#179,Dupl('-',2),#179,
Dupl('-',2),#179);
Write(' ',PadRight_('Brelan (3)',29,'.'),'7',#179);
For J:=1 to 6 do Begin
If ScoreBoard[J,6]>=0 Then Write(ScoreBoard[J,6]:2)
Else Write(' ':2);
If J<6 Then Write(#179);
End;
WriteLn(#179,'7');
Write(' ',PadRight_('Carr‚ (4)',29,'.'),'8',#179);
For J:=1 to 6 do Begin
If ScoreBoard[J,7]>=0 Then Write(ScoreBoard[J,7]:2)
Else Write(' ':2);
If J<6 Then Write(#179);
End;
WriteLn(#179,'8');
Write(' ',PadRight_('Petite suite',29,'.'),'9',#179);
For J:=1 to 6 do Begin
If ScoreBoard[J,8]>=0 Then Write(ScoreBoard[J,8]:2)
Else Write(' ':2);
If J<6 Then Write(#179);
End;
WriteLn(#179,'9');
Write(' ',PadRight_('Grande suite',29,'.'),'A',#179);
For J:=1 to 6 do Begin
If ScoreBoard[J,9]>=0 Then Write(ScoreBoard[J,9]:2)
Else Write(' ':2);
If J<6 Then Write(#179);
End;
WriteLn(#179,'A');
Write(' ',PadRight_('Full',29,'.'),'B',#179);
For J:=1 to 6 do Begin
If ScoreBoard[J,10]>=0 Then Write(ScoreBoard[J,10]:2)
Else Write(' ':2);
If J<6 Then Write(#179);
End;
WriteLn(#179,'B');
Write(' ',PadRight_('Yahtzee',29,'.'),'C',#179);
For J:=1 to 6 do Begin
If ScoreBoard[J,11]>=0 Then Write(ScoreBoard[J,11]:2)
Else Write(' ':2);
If J<6 Then Write(#179);
End;
WriteLn(#179,'C');
Write(' ',PadRight_('Chance',29,'.'),'D',#179);
For J:=1 to 6 do Begin
If ScoreBoard[J,12]>=0 Then Write(ScoreBoard[J,12]:2)
Else Write(' ':2);
If J<6 Then Write(#179);
End;
WriteLn(#179,'D');
WriteLn(' ',Dupl(' ',30),#179,Dupl('-',2),#179,Dupl('-',2),#179,
Dupl('-',2),#179,Dupl('-',2),#179,Dupl('-',2),#179,
Dupl('-',2),#179);
Write(' ',PadRight_('Total g‚n‚ral',30,'.'),#179);
TotalBoard[H]:=Total;
For J:=1 to 6 do Begin
If TotalBoard[J]>=0 Then Write(TotalBoard[J]:2)
Else Write(' ':2);
If J<6 Then Write(#179);
End;
WriteLn(#179);
WriteLn(' ',Dupl(' ',30),#192,Dupl(#196,2),#193,Dupl(#196,2),#193,
Dupl(#196,2),#193,Dupl(#196,2),#193,Dupl(#196,2),#193,
Dupl(#196,2),#217);
End;
Var
Num_of_reroll,Index,Selection,Choice:Integer;
Token:String;
BEGIN
{$IFDEF FPC}
{$IFDEF WINDOWS}
SetUseACP(False);
{$ENDIF}
{$ENDIF}
If(ParamStr(1)='/?')or(ParamStr(1)='--help')or(ParamStr(1)='-h')or
(ParamStr(1)='/h')or(ParamStr(1)='/H')Then Begin
WriteLn('YATHZEE : Cette commande permet de lancer le jeu ',
'Yathzee (jeu de d‚s).');
WriteLn;
WriteLn('Syntaxe : YATHZEE [/PLAY]');
WriteLn;
WriteLn(' /PLAY Permet de jouer imm‚diatement');
End
Else
Begin
Finish:=False;
If(StrToUpper(ParamStr(1))='/PLAY')Then PlayNow:=True;
Repeat
If(PlayNow)Then Begin
K:='2';
End
Else
Begin
ClrScr;
TextColor(LightBlue);
WriteLn(' ':40,'COCO-');
WriteLn(' ':12,' ');
WriteLn(' ':12,'ÛÛ Û Û ');
WriteLn(' ':12,'ÛÛ Û Û Û Û ');
WriteLn(' ':12,' Û Û Û Û Û ');
WriteLn(' ':12,' Û Û Û ÛÛ ');
WriteLn(' ':12,' Û Û ÛÛÛÛÛ Û ');
WriteLn(' ':12,' Û ÛÛ ÛÛÛÛ Û Û ÛÛÛ ÛÛÛÛÛ ÛÛÛÛ ÛÛÛÛ ');
WriteLn(' ':12,' Û Û Û Û Û ÛÛ ÛÛ Û Û Û Û Û Û Û ');
WriteLn(' ':12,' ÛÛ Û Û Û Û Û Û Û ÛÛÛ Û ÛÛ Û ÛÛ ');
WriteLn(' ':12,' ÛÛÛ Û Û Û ÛÛ Û Û Û ÛÛ Û ÛÛ ');
WriteLn(' ':12,' Û Û ÛÛÛ Û Û Û ÛÛ ÛÛÛÛÛÛ ÛÛÛ Û');
WriteLn(' ':12,' ÛÛ ÛÛÛÛ Û ÛÛÛ Û Û Û Û ÛÛÛÛÛÛ ÛÛÛÛÛÛ ');
WriteLn(' ':12,' Û Û Û Û ');
WriteLn(' ':12,' ÛÛ ÛÛÛ ');
WriteLn(' ':12,' ');
WriteLn(' ':12,' ');
TextColor(7);
WriteLn;
WriteLn(' ':30,Dupl(#196,20));
WriteLn;
WriteLn(' ':30,'1 - Instructions');
WriteLn;
WriteLn(' ':30,'2 - Jouer … COCO-YATHZEE');
WriteLn;
WriteLn(' ':30,'3 - Quitter');
WriteLn;
WriteLn(' ':30,Dupl(#196,20));
WriteLn;
Write('Entrez votre choix : ');
K:=UpCase(ReadKey);
If K=#0 Then ReadKey;
WriteLn(K);
End;
Case K of
'1':Begin
{ Instruction }
ClrScr;
GotoXY(32,1);
TextColor(Yellow);
WriteLn('C O C O - Y A H T Z E E');
TextColor(White);
WriteLn;
WriteLn('Explications de la feuille de pointage :');
WriteLn;
WriteLn('Partie sup‚rieure');
WriteLn;
TextColor(7);
WriteLn(' As : Total de tous les d‚s de valeur 1 (exemple 1-2-2-4-6 = 1 points ');
WriteLn(' ou 1-1-1-3-5 = 3 points).');
WriteLn(' Deux : Total de tous les d‚s … 2 valeurs (exemple 2-1-5-3-5 = 2 points ');
WriteLn(' ou 2-2-2-2-4 = 8 points).');
WriteLn(' Trois : Total de tous les d‚s … 3 valeurs (exemple 3-1-1-4-5 = 3 points ');
WriteLn(' ou 3-3-3-2-4 = 9 points).');
WriteLn(' Quatre : Total de tous les d‚s … 4 valeurs (exemple 4-1-3-2-5 = 4 points ');
WriteLn(' ou 4-4-3-2-5 = 8 points).');
WriteLn(' Cinq : Total de tous les d‚s … 5 valeurs (exemple 5-1-3-2-6 = 5 points ou ');
WriteLn(' 5-5-5-2-1 = 15 points).');
WriteLn(' Six : Total de tous les d‚s … 6 valeurs (exemple 6-1-2-3-4 = 6 points ou ');
WriteLn(' 6-6-6-6-1 = 24 points).');
WriteLn(' [automatique] Bonus As-Six : gagnez un bonus de 35 si vous obtenez au moins ');
WriteLn(' 63 au total dans le reste de la section sup‚rieure.');
TextColor(White);
WriteLn('Partie inf‚rieure');
TextColor(7);
WriteLn;
WriteLn(' Brelan : Gagnez des points ‚gaux … la somme des valeurs des d‚s si vous en ');
WriteLn(' poss‚dez au moins 3 de mˆme valeur (exemple 1-1-1-2-2 = 7 points ');
WriteLn(' ou 5-5-5-2-2 = 19 points).');
WriteLn(' Carr‚ : Gagnez des points ‚gaux … la somme des valeurs des d‚s si vous en ');
WriteLn(' poss‚dez au moins 4 de mˆme valeur (exemple 1-1-1-1-2 = 6 points ou ');
WriteLn(' 5-5-5-5-2 = 22 points).');
WriteLn(' Full : Gagnez 25 points si vous obtenez 2 d''une valeur et 3 d''une autre ');
WriteLn(' valeur (exemple 1-1-2-2-2 ou 3-3-5-5-5 ou 6-6-2-2-2).');
WriteLn(' Petite suite : Gagnez 30 points si vous obtenez une suite de 4 (exemple ');
WriteLn(' 1-2-3-4-* ou 2-3-4-5-* ou 3-4-5-6-*)');
WriteLn(' Grande suite : Gagnez 40 points si vous obtenez une s‚rie de 5 (exemple ');
WriteLn(' 1-2-3-4-5 ou 2-3-4-5-6)');
WriteLn(' Yahtzee :Gagnez 50 points si vous obtenez 5 de mˆme valeur (exemple 1-1-1-1-1 ');
WriteLn(' ou 2-2-2-2-2)');
WriteLn(' Chance : Gagnez des points ‚gaux … la somme des valeurs des d‚s (exemple ');
WriteLn(' 1-1-1-1-1 = 5 points ou 1-2-3-4-5 = 15 points ou 5-5-5-6-6 = ');
WriteLn(' 27 points)');
WriteLn('[automatique] Bonus Yahtzee : gagnez un bonus de 100 pour chaque Yahtzee lanc‚ ');
WriteLn(' aprŠs avoir d‚j… marqu‚ un Yahtzee de 50 points');
WriteLn('[automatique] Total : votre score total calcul‚ … la fin de la partie');
WriteLn;
Write('Presse une touche pour retourner au menu');
If ReadKey=#0 Then ReadKey;
End;
'P','2':Begin
TextBackground(Cyan);
Randomize;
Rounds:=0;
For J:=1 to 6 do Begin
BonusBoard[J]:=-1;
TotalBoard[J]:=-1;
For I:=0 to 12 do ScoreBoard[J,I]:=-1;
End;
H:=1;
PrintScores(Rounds);
For H:=1 to 6 do While Rounds<>13 do Begin
For I:=0 to NUM_DICE-1 do Dices[i]:=RandomDice;
For I:=0 to NUM_DICE-1 do Begin
GotoXY(58,I*4+6);
Write(I+1);
ShowDice(60,I*4+5,Dices[I]);
End;
GotoXY(1,25);
Num_of_reroll:=0;
For I:=0 to 1 do Begin
Write('Quel d‚s relancer (1 … 5) ? ');
ReadLn(Input);
If(Input='0')or(Input='Q')or(Input='QUIT')Then Begin
Halt;
End;
Token:=ExtractWord(1,Input);
While Token<>'' do Begin
Val(Token,Index,Err);
Dec(Index);
If Index=-1 Then Break;
If Index>4 Then Break;
Inc(Num_Of_Reroll);
Dices[Index]:=RandomDice;
Token:=ExtractWord(2,Input);
Input:='';
End;
If Num_of_reroll=0 Then Break;
GotoXY(1,25);
If I=0 Then Write('Votre deuxiŠme lanc‚ :')
Else Write('Votre troisiŠme lanc‚ :');
ClrEol;
For J:=0 to NUM_DICE-1 do ShowDice(60,I*4+5,Dices[J]);
End;
GotoXY(1,25);
Write('S‚lection (1 … 9 ou A … D) ? ');
Case UpCase(ReadKey)of
'1':CalculateUpper(1);
'2':CalculateUpper(2);
'3':CalculateUpper(3);
'4':CalculateUpper(4);
'5':CalculateUpper(5);
'6':CalculateUpper(6);
'7':Check_of_a_kind(3,Dices);
'8':Check_of_a_kind(4,Dices);
'9':Check_full_house(Dices);
'A':Check_straight(4,Dices);
'B':Check_straight(5,Dices);
'C':Check_of_a_kind(5,Dices);
'D':Begin
If ScoreBoard[H,12]>=0 Then Break
Else
Begin
ScoreBoard[H,12]:=0;
For I:=0 to NUM_DICE-1 do ScoreBoard[H,12]:=ScoreBoard[H,12]+Dices[i];
End;
End;
'Q':Halt;
End;
Total:=0;
For I:=0 to 12 do Begin
If ScoreBoard[H,I]>0 Then Total:=Total+ScoreBoard[H,I];
End;
PrintScores(Rounds);
Inc(Rounds);
End;
End;
'3','Q',#27:Finish:=True;
End;
Until Finish;
ClrScr;
End;
END.