Bon à moi
(c'est très optimisable, notamment la distribution des cartes qui est très lente et qui peut être remplacée par 3 lignes de code (certain se rappellent peut-être du défi 'mélanger une liste' il y a plus de 20 mois))
poker()
Prgm
¨ Poker 1.0
¨ Programmå par
¨ Christophe Molon-Noblot
¨ 10-11/05/2000
Local hname,hchange,winstr,handname,keeplist,cardlist,vallist,cololist,uselist,monney,hand,ˆ,ˆ1,ˆ2,a,a1,a2,b1,b2,cc1,cc2,d1,d2,e1,e2,win,winlist,plist,doubleli,numlist,chand,vhand,n1,n2,t
100»monney
setFold(vars)»rep1
newList(52)»vallist
newList(52)»cololist
newList(52)»uselist
newList(5)»hand
newList(5)»hchange
newList(5)»handname
newList(5)»hname
ClrIO
Disp "******** Poker ********"
Disp ""
Disp " Programmå par"
Disp "Christophe Molon-Noblot"
Disp ""
Disp "Tirage en cours¡"
For ˆ1,0,3
For ˆ,1,13
ˆ»vallist[ˆ+13*ˆ1]
ˆ1+1»cololist[ˆ+13*ˆ1]
EndFor
EndFor
Lbl debut
Fill 0,uselist
Fill 0,hand
Fill 1,hchange
{"?","?","?","?","?"}»keeplist
{" "," "," "," "," "}»winlist
For ˆ,1,5
rand(52)»a
If uselist[a]=0 Then
a»hand[ˆ]
1»uselist[a]
Else
ˆ-1»ˆ
EndIf
EndFor
monney-5»monney
ClrIO
Lbl writeout
For ˆ,1,5
keeplist[ˆ]&" "&{"2","3","4","5","6","7","8","9","10","Valet","Dame","Roi","As"}[vallist[hand[ˆ]]]&" de "&{"Coeurs","Carreaux","Träfles","Piques"}[cololist[hand[ˆ]]]»handname[ˆ]
Disp handname[ˆ]
{"2","3","4","5","6","7","8","9","10","Valet","Dame","Roi","As"}[vallist[hand[ˆ]]]&{"Coe","Car","Trä","Piq"}[cololist[hand[ˆ]]]»hname[ˆ]
EndFor
Disp "Garder/Changer/Ok:F1-F7"
Lbl toolb
ToolBar
Title hname[1],c1
Title hname[2],c2
Title hname[3],c3
Title hname[4],c4
Title hname[5],c5
Title "$"&string(monney)
Item "Paire de figures ou as¡$5",c0
Item "2 paires¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡$10",c0
Item "tierce¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡$15l",c0
Item "suite¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡$20",c0
Item "quinte¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡$25",c0
Item "full¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡$40",c0
Item "carrå¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡$125",c0
Item "suite quintåe¡¡¡¡¡¡¡¡¡¡$250",c0
Item "suite royale quintåe¡¡¡$2000",c0
Title "OK",cok
EndTBar
Lbl c0:Goto toolb
Lbl c1
If hchange[1]=0 Then
1»hchange[1]
"?"»keeplist[1]
Else
0»hchange[1]
"?"»keeplist[1]
EndIf
ClrIO
Goto writeout
Lbl c2
If hchange[2]=0 Then
1»hchange[2]
"?"»keeplist[2]
Else
0»hchange[2]
"?"»keeplist[2]
EndIf
ClrIO
Goto writeout
Lbl c3
If hchange[3]=0 Then
1»hchange[3]
"?"»keeplist[3]
Else
0»hchange[3]
"?"»keeplist[3]
EndIf
ClrIO
Goto writeout
Lbl c4
If hchange[4]=0 Then
1»hchange[4]
"?"»keeplist[4]
Else
0»hchange[4]
"?"»keeplist[4]
EndIf
ClrIO
Goto writeout
Lbl c5
If hchange[5]=0 Then
1»hchange[5]
"?"»keeplist[5]
Else
0»hchange[5]
"?"»keeplist[5]
EndIf
ClrIO
Goto writeout
Lbl cok
For ˆ,1,5
If hchange[ˆ]=1 Then
rand(52)»a
"ü"»keeplist[ˆ]
If uselist[a]=0 Then
0»uselist[hand[ˆ]]
a»hand[ˆ]
1»uselist[a]
Else
ˆ-1»ˆ
EndIf
EndIf
EndFor
0»win
"Perdu ! "»winstr
{0,0,0,0,0}»plist
{0,0}»doubleli
vallist[hand[1]]»a1
vallist[hand[2]]»b1
vallist[hand[3]]»cc1
vallist[hand[4]]»d1
vallist[hand[5]]»e1
{a1,b1,cc1,d1,e1}»vhand
cololist[hand[1]]»a2
cololist[hand[2]]»b2
cololist[hand[3]]»cc2
cololist[hand[4]]»d2
cololist[hand[5]]»e2
{a2,b2,cc2,d2,e2}»chand
0»t
{0,0}»numlist
For ˆ1,1,5
For ˆ2,1,5
If #({"a","b","cc","d","e"}[ˆ1]&"1")=#({"a","b","cc","d","e"}[ˆ2]&"1") and ˆ1?ˆ2 Then
1»plist[ˆ1]:1»plist[ˆ2]
If doubleli[1]=0 Then
#({"a","b","cc","d","e"}[ˆ1]&"1")»doubleli[1]
Else
If doubleli[2]=0 and #({"a","b","cc","d","e"}[ˆ1]&"1")?doubleli[1]:#({"a","b","cc","d","e"}[ˆ1]&"1")»doubleli[2]
EndIf
EndIf
EndFor
EndFor
0»n1
0»n2
For ˆ,1,5
If plist[ˆ]=1 Then
"*"»winlist[ˆ]
If vhand[ˆ]=doubleli[1]:n1+1»n1
If vhand[ˆ]=doubleli[2]:n2+1»n2
EndIf
EndFor
If n1=2 and n2=0 and doubleli[1]<10:{" "," "," "," "," "}»winlist
If n1=0 and n2=2 and doubleli[2]<10:{" "," "," "," "," "}»winlist
If n1=2 and n2=0 and doubleli[1]>9:5»win
If n2=2 and n1=0 and doubleli[2]>10:5»win
If n1=2 and n2=2:10»win
If n1=3 and n2=0:15»win
If n2=3 and n1=0:15»win
If n1+n2=5:40»win
If n1=4 or n2=4:125»win
SortA vhand
vhand[1]»a1
vhand[2]»b1
vhand[3]»cc1
vhand[4]»d1
vhand[5]»e1
If a2=b2 and a2=cc2 and a2=d2 and a2=e2 Then
25»win
{"*","*","*","*","*"}»winlist
EndIf
If e1=a1+4 and d1=a1+3 and cc1=a1+2 and b1=a1+1 Then
{"*","*","*","*","*"}»winlist
If win=25:250»win
If win=0:20»win
If vhand[1]=9 Then
If win=250:2000»win
EndIf
EndIf
monney+win»monney
If win=5:"Gagnå: Paire (+$5)"»winstr
If win=15:"Gagnå: Tierce (+$15)"»winstr
If win=125:"Gagnå: Carrå (+$125)"»winstr
If win=10:"Gagnå: 2 Paires (+$10)"»winstr
If win=40:"Gagnå: Full (+$40)"»winstr
If win=25:"Gagnå: Quinte (+$25)"»winstr
If win=2000:"Gagnå: Quinte (+$2000)"»winstr
If win=250:"Gagnå: Suite Quintåe (+$250)"»winstr
If win=20:"Gagnå: Suite (+$20)"»winstr
ClrIO
For ˆ,1,5
keeplist[ˆ]&winlist[ˆ]&" "&{"2","3","4","5","6","7","8","9","10","Valet","Dame","Roi","As"}[vallist[hand[ˆ]]]&" de "&{"Coeurs","Carreaux","Träfles","Piques"}[cololist[hand[ˆ]]]»handname[ˆ]
Disp handname[ˆ]
EndFor
Disp winstr
Lbl tool2
ToolBar
Title "Nouveau tirage",suite
Title "$"&string(monney),c11
Title "Quitter",fin
EndTBar
Lbl c11:Goto tool2
Lbl suite
If monney<1 Then
Dialog
Title "'Tophe's Poker"
Text ""
Text " Perdu !"
Text " Rejouer ?"
EndDlog
If ok=0:Goto fin
EndIf
Goto debut
Lbl fin
setFold(#rep1)
EndPrgm