CODICE
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.0.0
Author: GreyWolf
Script Function: Classico gioco del tris.
#ce ----------------------------------------------------------------------------
#include <GUIConstants.au3>
$Form1 = GUICreate("Tris by GreyWolf",619, 517, 311, 260)
$Group1 = GUICtrlCreateGroup(":::::::::::::::::::::::::::::::::::::::::::::::::::::::TRIS:::::::::::::::::::::::::::::::::::::::::::::::::::::::::", 112, 80, 385, 385)
$Button1 = GUICtrlCreateButton("", 132, 112, 100, 100, 0)
$Button2 = GUICtrlCreateButton("", 248, 112, 100, 100, 0)
$Button3 = GUICtrlCreateButton("", 368, 112, 100, 100, 0)
$Button4 = GUICtrlCreateButton("", 132, 232, 100, 100, 0)
$Button5 = GUICtrlCreateButton("", 248, 232, 100, 100, 0)
$Button6 = GUICtrlCreateButton("", 368, 232, 100, 100, 0)
$Button7 = GUICtrlCreateButton("", 132, 344, 100, 100, 0)
$Button8 = GUICtrlCreateButton("", 248, 344, 100, 100, 0)
$Button9 = GUICtrlCreateButton("", 368, 344, 100, 100, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("Author", 16, 0, 137, 49)
$Label1 = GUICtrlCreateLabel(" Creathed by Greywolf ", 24, 16, 124, 25)
$Radio1 = GUICtrlCreateRadio(" X ", 184, 8, 113, 17)
$Radio2 = GUICtrlCreateRadio(" 0", 184, 24, 113, 17)
$Group3 = GUICtrlCreateGroup("Tu", 456, 8, 153, 57)
$Group4 = GUICtrlCreateGroup("Computer", 536, 8, 1, 57)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$punt1=0
$punt2=0
$Label2 = GUICtrlCreateLabel($punt1, 472, 24, 52, 33)
$Label3 = GUICtrlCreateLabel($punt2, 544, 24, 52, 33)
GUISetState(@SW_SHOW)
GUICtrlSetState($radio1, $GUI_CHECKED)
$umano="per.jpg"
$comp="zero.jpg"
Global $n,$1,$2,$3,$4,$5,$6,$7,$8,$9,$imm1,$imm2,$imm3,$imm4,$imm5,$imm5,$imm6,$imm7,$imm8,$imm9,$vittoriacomp,$vittoriaumano,$nmsg,$umano,$comp
Func simbolo()
Switch $nMsg
Case $radio1
$umano="per.jpg"
$comp="zero.jpg"
reset()
Case $radio2
$umano="zero.jpg"
$comp="per.jpg"
reset()
EndSwitch
EndFunc
While 1
$nMsg = GUIGetMsg()
simbolo()
Switch $nMsg
Case $button1
GUICtrlDelete($button1)
$imm1=GUICtrlCreatePic(@scriptdir & $umano,132, 112, 100, 100, 0)
$1=1
vittoria()
gioco()
Case $button2
GUICtrlDelete($button2)
$imm2=GUICtrlCreatePic(@scriptdir & $umano,248, 112, 100, 100, 0)
$2=1
vittoria()
gioco()
Case $button3
GUICtrlDelete($button3)
$imm3=GUICtrlCreatePic(@scriptdir & $umano,368, 112, 100, 100, 0)
$3=1
vittoria()
gioco()
Case $button4
GUICtrlDelete($button4)
$imm4=GUICtrlCreatePic(@scriptdir & $umano,132, 232, 100, 100, 0)
$4=1
vittoria()
gioco()
Case $button5
GUICtrlDelete($button5)
$imm5=GUICtrlCreatePic(@scriptdir & $umano,248, 232, 100, 100, 0)
$5=1
vittoria()
gioco()
Case $button6
GUICtrlDelete($button6)
$imm6=GUICtrlCreatePic(@scriptdir & $umano,368, 232, 100, 100, 0)
$6=1
vittoria()
gioco()
Case $button7
GUICtrlDelete($button7)
$imm7=GUICtrlCreatePic(@scriptdir & $umano,132, 344, 100, 100, 0)
$7=1
vittoria()
gioco()
Case $button8
GUICtrlDelete($button8)
$imm8=GUICtrlCreatePic(@scriptdir & $umano,248, 344, 100, 100, 0)
$8=1
vittoria()
gioco()
Case $button9
GUICtrlDelete($button9)
$imm9=GUICtrlCreatePic(@scriptdir & $umano,368, 344, 100, 100, 0)
$9=1
vittoria()
gioco()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func gioco()
While 1
logicacompvincere()
Switch $n
Case $n=1
If $1=0 Then
GUICtrlDelete($button1)
$imm1=GUICtrlCreatePic(@scriptdir & $comp,132, 112, 100, 100, 0)
$1=2
vittoria()
ExitLoop
Else
logicacompvincere()
EndIf
Case $n=2
If $2=0 Then
GUICtrlDelete($button2)
$imm2=GUICtrlCreatePic(@scriptdir & $comp,248, 112, 100, 100, 0)
$2=2
vittoria()
ExitLoop
Else
logicacompvincere()
EndIf
Case $n=3
If $3=0 Then
GUICtrlDelete($button3)
$imm3=GUICtrlCreatePic(@scriptdir & $comp,368, 112, 100, 100, 0)
$3=2
vittoria()
ExitLoop
Else
logicacompvincere()
EndIf
Case $n=4
If $4=0 Then
GUICtrlDelete($button4)
$imm4=GUICtrlCreatePic(@scriptdir & $comp,132, 232, 100, 100, 0)
$4=2
vittoria()
ExitLoop
Else
logicacompvincere()
EndIf
Case $n=5
If $5=0 Then
GUICtrlDelete($button5)
$imm5=GUICtrlCreatePic(@scriptdir & $comp,248, 232, 100, 100, 0)
$5=2
vittoria()
ExitLoop
Else
logicacompvincere()
EndIf
Case $n=6
If $6=0 Then
GUICtrlDelete($button6)
$imm6=GUICtrlCreatePic(@scriptdir & $comp,368, 232, 100, 100, 0)
$6=2
vittoria()
ExitLoop
Else
logicacompvincere()
endif
Case $n=7
If $7=0 Then
GUICtrlDelete($button7)
$imm7=GUICtrlCreatePic(@scriptdir & $comp,132, 344, 100, 100, 0)
$7=2
vittoria()
ExitLoop
Else
logicacompvincere()
endif
Case $n=8
If $8=0 Then
GUICtrlDelete($button8)
$imm8=GUICtrlCreatePic(@scriptdir & $comp,248, 344, 100, 100, 0)
$8=2
vittoria()
ExitLoop
Else
logicacompvincere()
EndIf
Case $n=9
If $9=0 Then
GUICtrlDelete($button9)
$imm9=GUICtrlCreatePic(@scriptdir & $comp,368, 344, 100, 100, 0)
$9=2
vittoria()
ExitLoop
Else
logicacompvincere()
EndIf
EndSwitch
if ($1<>0) and ($2<>0) and ($3<>0) and ($4<>0) and ($5<>0) and ($6<>0) and ($7<>0) and ($8<>0) and ($9<>0) Then
ExitLoop
Else
EndIf
WEnd
EndFunc
Func vittoria()
If $1=1 and $2=1 and $3=1 Then
MsgBox(0,"Tris","Hai Vinto")
$vittoriaumano=1
reset()
ElseIf $4=1 and $5=1 and $6=1 Then
MsgBox(0,"Tris","Hai Vinto")
$vittoriaumano=1
reset()
ElseIf $7=1 and $8=1 and $9=1 Then
MsgBox(0,"Tris","Hai Vinto")
$vittoriaumano=1
reset()
ElseIf $1=1 and $4=1 and $7=1 Then
MsgBox(0,"Tris","Hai Vinto")
$vittoriaumano=1
reset()
ElseIf $2=1 and $5=1 and $8=1 Then
MsgBox(0,"Tris","Hai Vinto")
$vittoriaumano=1
reset()
ElseIf $3=1 and $6=1 and $9=1 Then
MsgBox(0,"Tris","Hai Vinto")
$vittoriaumano=1
reset()
ElseIf $1=1 and $5=1 and $9=1 Then
MsgBox(0,"Tris","Hai Vinto")
$vittoriaumano=1
reset()
ElseIf $3=1 and $5=1 and $7=1 Then
MsgBox(0,"Tris","Hai Vinto")
$vittoriaumano=1
reset()
ElseIf $1=2 and $2=2 and $3=2 Then
MsgBox(0,"Tris","Hai Perso")
$vittoriacomp=1
reset()
ElseIf $4=2 and $5=2 and $6=2 Then
MsgBox(0,"Tris","Hai Perso")
$vittoriacomp=1
reset()
ElseIf $7=2 and $8=2 and $9=2 Then
MsgBox(0,"Tris","Hai Perso")
$vittoriacomp=1
reset()
ElseIf $1=2 and $4=2 and $7=2 Then
MsgBox(0,"Tris","Hai Perso")
$vittoriacomp=1
reset()
ElseIf $2=2 and $5=2 and $8=2 Then
MsgBox(0,"Tris","Hai Perso")
$vittoriacomp=1
reset()
ElseIf $3=2 and $6=2 and $9=2 Then
MsgBox(0,"Tris","Hai Perso")
$vittoriacomp=1
reset()
ElseIf $1=2 and $5=2 and $9=2 Then
MsgBox(0,"Tris","Hai Perso")
$vittoriacomp=1
reset()
ElseIf $3=2 and $5=2 and $7=2 Then
MsgBox(0,"Tris","Hai Perso")
$vittoriacomp=1
reset()
ElseIf ($1<>0) and ($2<>0) and ($3<>0) and ($4<>0) and ($5<>0) and ($6<>0) and ($7<>0) and ($8<>0) and ($9<>0) Then
MsgBox(0,"Tris","Pareggio")
reset()
EndIf
punteggio()
EndFunc
Func logicacompvincere()
If $1=2 And $2=2 And $3<>1 Then
$n=3
ElseIf $1=2 and $3=2 and $2<>1 Then
$n=2
ElseIf $2=2 and $3=2 and $1<>1 Then
$n=1
ElseIf $4=2 and $5=2 and $6<>1 Then
$n=6
ElseIf $4=2 and $6=2 and $5<>1 Then
$n=5
ElseIf $5=2 and $6=2 and $4<>1 Then
$n=4
ElseIf $7=2 and $8=2 and $9<>1 Then
$n=9
ElseIf $7=2 and $9=2 and $8<>1 Then
$n=8
ElseIf $8=2 and $9=2 and $7<>1 Then
$n=7
ElseIf $1=2 and $4=2 and $7<>1 Then
$n=7
ElseIf $1=2 and $7=2 and $4<>1 Then
$n=4
ElseIf $4=2 and $7=2 and $1<>1 Then
$n=1
ElseIf $2=2 and $5=2 and $8<>1 Then
$n=8
ElseIf $2=2 and $8=2 and $5<>1 Then
$n=5
ElseIf $5=2 and $8=2 and $2<>1 Then
$n=2
ElseIf $3=2 and $6=2 and $9<>1 Then
$n=9
ElseIf $3=2 and $9=2 and $6<>1 Then
$n=6
ElseIf $6=2 and $9=2 and $3<>1 Then
$n=3
ElseIf $1=2 and $5=2 and $9<>1 Then
$n=9
ElseIf $1=2 and $9=2 and $5<>1 Then
$n=5
ElseIf $5=2 and $9=2 and $1<>1 Then
$n=1
ElseIf $3=2 and $5=2 and $7<>1 Then
$n=7
ElseIf $3=2 and $7=2 and $5<>1 Then
$n=5
ElseIf $5=2 and $7=2 and $3<>1 Then
$n=3
ElseIf logicacompdifendere() Then
EndIf
EndFunc
Func logicacompdifendere()
If $1=1 and $2=1 and $3<>2 Then
$n=3
ElseIf $1=1 and $3=1 and $2<>2 Then
$n=2
ElseIf $2=1 and $3=1 and $1<>2 Then
$n=1
ElseIf $4=1 and $5=1 and $6<>2 Then
$n=6
ElseIf $4=1 and $6=1 and $5<>2 Then
$n=5
ElseIf $5=1 and $6=1 and $4<>2 Then
$n=4
ElseIf $7=1 and $8=1 and $9<>2 Then
$n=9
ElseIf $7=1 and $9=1 and $8<>2 Then
$n=8
ElseIf $8=1 and $9=1 and $7<>2 Then
$n=7
ElseIf $1=1 and $4=1 and $7<>2 Then
$n=7
ElseIf $1=1 and $7=1 and $4<>2 Then
$n=4
ElseIf $4=1 and $7=1 and $1<>2 Then
$n=1
ElseIf $2=1 and $5=1 and $8<>2 Then
$n=8
ElseIf $2=1 and $8=1 and $5<>2 Then
$n=5
ElseIf $5=1 and $8=1 and $2<>2 Then
$n=2
ElseIf $3=1 and $6=1 and $9<>2 Then
$n=9
ElseIf $3=1 and $9=1 and $6<>2 Then
$n=6
ElseIf $6=1 and $9=1 and $3<>2 Then
$n=3
ElseIf $1=1 and $5=1 and $9<>2 Then
$n=9
ElseIf $1=1 and $9=1 and $5<>2 Then
$n=5
ElseIf $5=1 and $9=1 and $1<>2 Then
$n=1
ElseIf $3=1 and $5=1 and $7<>2 Then
$n=7
ElseIf $3=1 and $7=1 and $5<>2 Then
$n=5
ElseIf $5=1 and $7=1 and $3<>2 Then
$n=3
Else
$n=Int(Random(1,10))
EndIf
EndFunc
Func Punteggio()
If $vittoriaumano=1 Then
$punt1=$punt1 + 1
ElseIf $vittoriacomp=1 Then
$punt2=$punt2 + 1
Else
EndIf
GUICtrlDelete($label2)
GUICtrlDelete($label3)
$Label2 = GUICtrlCreateLabel($punt1, 472, 24, 52, 33)
$Label3 = GUICtrlCreateLabel($punt2, 544, 24, 52, 33)
If $punt1=5 Then
MsgBox(0,"Tris","Complimenti hai vinto!!")
$punt1=0
$punt2=0
GUICtrlDelete($label2)
GUICtrlDelete($label3)
$Label2 = GUICtrlCreateLabel($punt1, 472, 24, 52, 33)
$Label3 = GUICtrlCreateLabel($punt2, 544, 24, 52, 33)
ElseIf $punt2=5 Then
MsgBox(0,"Tris","Il Computer ha vinto!!")
$punt1=0
$punt2=0
GUICtrlDelete($label2)
GUICtrlDelete($label3)
$Label2 = GUICtrlCreateLabel($punt1, 472, 24, 52, 33)
$Label3 = GUICtrlCreateLabel($punt2, 544, 24, 52, 33)
EndIf
$vittoriaumano=0
$vittoriacomp=0
EndFunc
Func reset()
GUICtrlDelete($button1)
GUICtrlDelete($button2)
GUICtrlDelete($button3)
GUICtrlDelete($button4)
GUICtrlDelete($button5)
GUICtrlDelete($button6)
GUICtrlDelete($button7)
GUICtrlDelete($button8)
GUICtrlDelete($button9)
GUICtrlDelete($imm1)
GUICtrlDelete($imm2)
GUICtrlDelete($imm3)
GUICtrlDelete($imm4)
GUICtrlDelete($imm5)
GUICtrlDelete($imm6)
GUICtrlDelete($imm7)
GUICtrlDelete($imm8)
GUICtrlDelete($imm9)
$Button1 = GUICtrlCreateButton("", 132, 112, 100, 100, 0)
$Button2 = GUICtrlCreateButton("", 248, 112, 100, 100, 0)
$Button3 = GUICtrlCreateButton("", 368, 112, 100, 100, 0)
$Button4 = GUICtrlCreateButton("", 132, 232, 100, 100, 0)
$Button5 = GUICtrlCreateButton("", 248, 232, 100, 100, 0)
$Button6 = GUICtrlCreateButton("", 368, 232, 100, 100, 0)
$Button7 = GUICtrlCreateButton("", 132, 344, 100, 100, 0)
$Button8 = GUICtrlCreateButton("", 248, 344, 100, 100, 0)
$Button9 = GUICtrlCreateButton("", 368, 344, 100, 100, 0)
$1=0
$2=0
$3=0
$4=0
$5=0
$6=0
$7=0
$8=0
$9=0
EndFunc