الكود
<body><b><font size="7"><SCRIPT>//if IE4/NS6, apply styleif (document.all||document.getElementById){document.write('<style>.tictac{')document.write('width:50px;height:50px;')document.write('}</style>')}var sqr1var sqr2var sqr3var sqr4var sqr5var sqr6var sqr7var sqr8var sqr9var sqr1T = 0var sqr2T = 0var sqr3T = 0var sqr4T = 0var sqr5T = 0var sqr6T = 0var sqr7T = 0var sqr8T = 0var sqr9T = 0var moveCount = 0var turn = 0var mode = 1function vari(){sqr1 = document.tic.sqr1.valuesqr2 = document.tic.sqr2.valuesqr3 = document.tic.sqr3.valuesqr4 = document.tic.sqr4.valuesqr5 = document.tic.sqr5.valuesqr6 = document.tic.sqr6.valuesqr7 = document.tic.sqr7.valuesqr8 = document.tic.sqr8.valuesqr9 = document.tic.sqr9.value}function check(){if(sqr1 == " X " && sqr2 == " X " && sqr3 == " X "){alert(" فزت !")reset()}else if(sqr4 == " X " && sqr5 == " X " && sqr6 == " X "){alert(" فزت !")reset()}else if(sqr7 == " X " && sqr8 == " X " && sqr9 == " X "){alert(" فزت !")reset()}else if(sqr1 == " X " && sqr5 == " X " && sqr9 == " X "){alert(" فزت !")reset()}else if(sqr1 == " X " && sqr4 == " X " && sqr7 == " X "){alert("You Win!")reset()}else if(sqr2 == " X " && sqr5 == " X " && sqr8 == " X "){alert("You Win!")reset()}else if(sqr3 == " X " && sqr6 == " X " && sqr9 == " X "){alert("You Win!")reset()}else if(sqr1 == " X " && sqr5 == " X " && sqr9 == " X "){alert("You Win!")reset()}else if(sqr3 == " X " && sqr5 == " X " && sqr7 == " X "){alert("You Win!")reset()}else{winCheck()check2()drawCheck()}}function check2(){vari()drawCheck()if(sqr1 == " O " && sqr2 == " O " && sqr3 == " O "){alert("لقد خسرت !")reset()}else if(sqr4 == " O " && sqr5 == " O " && sqr6 == " O "){alert("لقد خسرت !")reset()}else if(sqr7 == " O " && sqr8 == " O " && sqr9 == " O "){alert("You Lose!")reset()}else if(sqr1 == " O " && sqr5 == " O " && sqr9 == " O "){alert("You Lose!")reset()}else if(sqr1 == " O " && sqr4 == " O " && sqr7 == " O "){alert("You Lose!")reset()}else if(sqr2 == " O " && sqr5 == " O " && sqr8 == " O "){alert("You Lose!")reset()}else if(sqr3 == " O " && sqr6 == " O " && sqr9 == " O "){alert("You Lose!")reset()}else if(sqr1 == " O " && sqr5 == " O " && sqr9 == " O "){alert("You Lose!")reset()}else if(sqr3 == " O " && sqr5 == " O " && sqr7 == " O "){alert("You Lose!")reset()}}function player1Check(){if(sqr1 == " X " && sqr2 == " X " && sqr3 == " X "){alert("Player 1 wins!")reset()}else if(sqr4 == " X " && sqr5 == " X " && sqr6 == " X "){alert("Player 1 wins!")reset()}else if(sqr7 == " X " && sqr8 == " X " && sqr9 == " X "){alert("Player 1 wins!")reset()}else if(sqr1 == " X " && sqr5 == " X " && sqr9 == " X "){alert("Player 1 wins!")reset()}else if(sqr1 == " X " && sqr4 == " X " && sqr7 == " X "){alert("Player 1 wins!")reset()}else if(sqr2 == " X " && sqr5 == " X " && sqr8 == " X "){alert("Player 1 wins!")reset()}else if(sqr3 == " X " && sqr6 == " X " && sqr9 == " X "){alert("Player 1 wins!")reset()}else if(sqr1 == " X " && sqr5 == " X " && sqr9 == " X "){alert("Player 1 wins!")reset()}else if(sqr3 == " X " && sqr5 == " X " && sqr7 == " X "){alert("Player 1 wins!")reset()}else{player2Check()drawCheck()}}function player2Check(){vari()drawCheck()if(sqr1 == " O " && sqr2 == " O " && sqr3 == " O "){alert("Player 2 wins!")reset()}else if(sqr4 == " O " && sqr5 == " O " && sqr6 == " O "){alert("Player 2 wins!")reset()}else if(sqr7 == " O " && sqr8 == " O " && sqr9 == " O "){alert("Player 2 wins!")reset()}else if(sqr1 == " O " && sqr5 == " O " && sqr9 == " O "){alert("Player 2 wins!")reset()}else if(sqr1 == " O " && sqr4 == " O " && sqr7 == " O "){alert("Player 2 wins!")reset()}else if(sqr2 == " O " && sqr5 == " O " && sqr8 == " O "){alert("Player 2 wins!")reset()}else if(sqr3 == " O " && sqr6 == " O " && sqr9 == " O "){alert("Player 2 wins!")reset()}else if(sqr1 == " O " && sqr5 == " O " && sqr9 == " O "){alert("Player 2 wins!")reset()}else if(sqr3 == " O " && sqr5 == " O " && sqr7 == " O "){alert("Player 2 wins!")reset()}}function drawCheck(){vari()moveCount = sqr1T + sqr2T + sqr3T + sqr4T + sqr5T + sqr6T + sqr7T + sqr8T + sqr9Tif(moveCount == 9){reset()alert(" تعادل ")}}function winCheck(){check2()if(sqr1 == " O " && sqr2 == " O " && sqr3T == 0 && turn == 1){document.tic.sqr3.value = " O "sqr3T = 1;turn = 0;}else if(sqr2 == " O " && sqr3 == " O " && sqr1T == 0 && turn == 1){document.tic.sqr1.value = " O "sqr1T = 1;turn = 0;}else if(sqr4 == " O " && sqr5 == " O " && sqr6T == 0 && turn == 1){document.tic.sqr6.value = " O "sqr6T = 1;turn = 0;}else if(sqr5 == " O " && sqr6 == " O " && sqr4T == 0 && turn == 1){document.tic.sqr4.value = " O "sqr4T = 1;turn = 0;}else if(sqr7 == " O " && sqr8 == " O " && sqr9T == 0 && turn == 1){document.tic.sqr9.value = " O "sqr9T = 1;turn = 0;}else if(sqr8 == " O " && sqr9 == " O " && sqr7T == 0 && turn == 1){document.tic.sqr7.value = " O "sqr7T = 1;turn = 0;}else if(sqr1 == " O " && sqr5 == " O " && sqr9T == 0 && turn == 1){document.tic.sqr9.value = " O "sqr9T = 1;turn = 0;}else if(sqr5 == " O " && sqr9 == " O " && sqr1T == 0 && turn == 1){document.tic.sqr1.value = " O "sqr1T = 1;turn = 0;}else if(sqr3 == " O " && sqr5 == " O " && sqr7T == 0 && turn == 1){document.tic.sqr7.value = " O "sqr7T = 1;turn = 0;}else if(sqr7 == " O " && sqr5 == " O " && sqr3T == 0 && turn == 1){document.tic.sqr3.value = " O "sqr3T = 1;turn = 0;}else if(sqr1 == " O " && sqr3 == " O " && sqr2T == 0 && turn == 1){document.tic.sqr2.value = " O "sqr2T = 1;turn = 0;}else if(sqr4 == " O " && sqr6 == " O " && sqr5T == 0 && turn == 1){document.tic.sqr5.value = " O "sqr5T = 1;turn = 0;}else if(sqr7 == " O " && sqr9 == " O " && sqr8T == 0 && turn == 1){document.tic.sqr8.value = " O "sqr8T = 1;turn = 0;}else if(sqr1 == " O " && sqr7 == " O " && sqr4T == 0 && turn == 1){document.tic.sqr4.value = " O "sqr4T = 1;turn = 0;}else if(sqr2 == " O " && sqr8 == " O " && sqr5T == 0 && turn == 1){document.tic.sqr5.value = " O "sqr5T = 1;turn = 0;}else if(sqr3 == " O " && sqr9 == " O " && sqr6T == 0 && turn == 1){document.tic.sqr6.value = " O "sqr6T = 1;turn = 0;}else if(sqr1 == " O " && sqr5 == " O " && sqr9T == 0 && turn == 1){document.tic.sqr9.value = " O "sqr9T = 1;turn = 0;}else if(sqr4 == " O " && sqr7 == " O " && sqr1T == 0 && turn == 1){document.tic.sqr1.value = " O "sqr1T = 1;turn = 0;}else if(sqr5 == " O " && sqr8 == " O " && sqr2T == 0 && turn == 1){document.tic.sqr2.value = " O "sqr2T = 1;turn = 0;}else if(sqr6 == " O " && sqr9 == " O " && sqr3T == 0 && turn == 1){document.tic.sqr3.value = " O "sqr3T = 1;turn = 0;}else if(sqr1 == " O " && sqr4 == " O " && sqr7T == 0 && turn == 1){document.tic.sqr7.value = " O "sqr7T = 1;turn = 0;}else if(sqr2 == " O " && sqr5 == " O " && sqr8T == 0 && turn == 1){document.tic.sqr8.value = " O "sqr8T = 1;turn = 0;}else if(sqr3 == " O " && sqr6 == " O " && sqr9T == 0 && turn == 1){document.tic.sqr9.value = " O "sqr9T = 1;turn = 0;}else if(sqr1 == " O " && sqr9 == " O " && sqr5T == 0 && turn == 1){document.tic.sqr5.value = " O "sqr5T = 1;turn = 0;}else if(sqr3 == " O " && sqr7 == " O " && sqr5T == 0 && turn == 1){document.tic.sqr5.value = " O "sqr5T = 1;turn = 0;}else{computer()}check2()}function computer(){check2()if(sqr1 == " X " && sqr2 == " X " && sqr3T == 0 && turn == 1){document.tic.sqr3.value = " O "sqr3T = 1;turn = 0;}else if(sqr2 == " X " && sqr3 == " X " && sqr1T == 0 && turn == 1){document.tic.sqr1.value = " O "sqr1T = 1;turn = 0;}else if(sqr4 == " X " && sqr5 == " X " && sqr6T == 0 && turn == 1){document.tic.sqr6.value = " O "sqr6T = 1;turn = 0;}else if(sqr5 == " X " && sqr6 == " X " && sqr4T == 0 && turn == 1){document.tic.sqr4.value = " O "sqr4T = 1;turn = 0;}else if(sqr7 == " X " && sqr8 == " X " && sqr9T == 0 && turn == 1){document.tic.sqr9.value = " O "sqr9T = 1;turn = 0;}else if(sqr8 == " X " && sqr9 == " X " && sqr7T == 0 && turn == 1){document.tic.sqr7.value = " O "sqr7T = 1;turn = 0;}else if(sqr1 == " X " && sqr5 == " X " && sqr9T == 0 && turn == 1){document.tic.sqr9.value = " O "sqr9T = 1;turn = 0;}else if(sqr5 == " X " && sqr9 == " X " && sqr1T == 0 && turn == 1){document.tic.sqr1.value = " O "sqr1T = 1;turn = 0;}else if(sqr3 == " X " && sqr5 == " X " && sqr7T == 0 && turn == 1){document.tic.sqr7.value = " O "sqr7T = 1;turn = 0;}else if(sqr7 == " X " && sqr5 == " X " && sqr3T == 0 && turn == 1){document.tic.sqr3.value = " O "sqr3T = 1;turn = 0;}else if(sqr1 == " X " && sqr3 == " X " && sqr2T == 0 && turn == 1){document.tic.sqr2.value = " O "sqr2T = 1;turn = 0;}else if(sqr4 == " X " && sqr6 == " X " && sqr5T == 0 && turn == 1){document.tic.sqr5.value = " O "sqr5T = 1;turn = 0;}else if(sqr7 == " X " && sqr9 == " X " && sqr8T == 0 && turn == 1){document.tic.sqr8.value = " O "sqr8T = 1;turn = 0;}else if(sqr1 == " X " && sqr7 == " X " && sqr4T == 0 && turn == 1){document.tic.sqr4.value = " O "sqr4T = 1;turn = 0;}else if(sqr2 == " X " && sqr8 == " X " && sqr5T == 0 && turn == 1){document.tic.sqr5.value = " O "sqr5T = 1;turn = 0;}else if(sqr3 == " X " && sqr9 == " X " && sqr6T == 0 && turn == 1){document.tic.sqr6.value = " O "sqr6T = 1;turn = 0;}else if(sqr1 == " X " && sqr5 == " X " && sqr9T == 0 && turn == 1){document.tic.sqr9.value = " O "sqr9T = 1;turn = 0;}else if(sqr4 == " X " && sqr7 == " X " && sqr1T == 0 && turn == 1){document.tic.sqr1.value = " O "sqr1T = 1;turn = 0;}else if(sqr5 == " X " && sqr8 == " X " && sqr2T == 0 && turn == 1){document.tic.sqr2.value = " O "sqr2T = 1;turn = 0;}else if(sqr6 == " X " && sqr9 == " X " && sqr3T == 0 && turn == 1){document.tic.sqr3.value = " O "sqr3T = 1;turn = 0;}else if(sqr1 == " X " && sqr4 == " X " && sqr7T == 0 && turn == 1){document.tic.sqr7.value = " O "sqr7T = 1;turn = 0;}else if(sqr2 == " X " && sqr5 == " X " && sqr8T == 0 && turn == 1){document.tic.sqr8.value = " O "sqr8T = 1;turn = 0;}else if(sqr3 == " X " && sqr6 == " X " && sqr9T == 0 && turn == 1){document.tic.sqr9.value = " O "sqr9T = 1;turn = 0;}else if(sqr1 == " X " && sqr9 == " X " && sqr5T == 0 && turn == 1){document.tic.sqr5.value = " O "sqr5T = 1;turn = 0;}else if(sqr3 == " X " && sqr7 == " X " && sqr5T == 0 && turn == 1){document.tic.sqr5.value = " O "sqr5T = 1;turn = 0;}else{AI()}check2()}function AI(){vari()if(document.tic.sqr5.value == " " && turn == 1){document.tic.sqr5.value = " O "turn = 0sqr5T = 1}else if(document.tic.sqr1.value == " " && turn == 1){document.tic.sqr1.value = " O "turn = 0sqr1T = 1}else if(document.tic.sqr9.value == " " && turn == 1){document.tic.sqr9.value = " O "turn = 0sqr9T = 1}else if(document.tic.sqr6.value == " " && turn == 1){document.tic.sqr6.value = " O "turn = 0sqr6T = 1}else if(document.tic.sqr2.value == " " && turn == 1){document.tic.sqr2.value = " O "turn = 0sqr2T = 1}else if(document.tic.sqr8.value == " " && turn == 1){document.tic.sqr8.value = " O "turn = 0sqr8T = 1}else if(document.tic.sqr3.value == " " && turn == 1){document.tic.sqr3.value = " O "turn = 0sqr3T = 1}else if(document.tic.sqr7.value == " " && turn == 1){document.tic.sqr7.value = " O "turn = 0sqr7T = 1}else if(document.tic.sqr4.value == " " && turn == 1){document.tic.sqr4.value = " O "turn = 0sqr4T = 1}check2()}function reset(){document.tic.sqr1.value = " "document.tic.sqr2.value = " "document.tic.sqr3.value = " "document.tic.sqr4.value = " "document.tic.sqr5.value = " "document.tic.sqr6.value = " "document.tic.sqr7.value = " "document.tic.sqr8.value = " "document.tic.sqr9.value = " "sqr1T = 0sqr2T = 0sqr3T = 0sqr4T = 0sqr5T = 0sqr6T = 0sqr7T = 0sqr8T = 0sqr9T = 0vari()turn = 0moveCount = 0}function resetter(){reset()}</SCRIPT></font></b><FORM NAME="tic" method="post"><p align="center"><font size="7"><INPUT TYPE="button" NAME="sqr1" class="tictac" value=" " onClick="if(document.tic.sqr1.value == ' ' && turn == 0 && mode == 1) {document.tic.sqr1.value = ' X '; sqr1T = 1; turn = 1; vari(); check();} else if(document.tic.sqr1.value == ' ' && turn == 1 && mode == 2) {document.tic.sqr1.value = ' X '; sqr1T = 1; turn = 0; vari(); player1Check()} else if(document.tic.sqr1.value == ' ' && turn == 0 && mode == 2) {document.tic.sqr1.value = ' O '; sqr1T = 1; turn = 1; vari(); player1Check()} drawCheck()" style="font-weight: 700"><b></b><INPUT TYPE="button" NAME="sqr2" class="tictac" value=" " onClick="if(document.tic.sqr2.value == ' ' && turn == 0 && mode == 1) {document.tic.sqr2.value = ' X '; sqr2T = 1; turn = 1; vari(); check();} else if(document.tic.sqr2.value == ' ' && turn == 1 && mode == 2) {document.tic.sqr2.value = ' X '; sqr2T = 1; turn = 0; vari(); player1Check()} else if(document.tic.sqr2.value == ' ' && turn == 0 && mode == 2) {document.tic.sqr2.value = ' O '; sqr2T = 1; turn = 1; vari(); player1Check()} drawCheck()" style="font-weight: 700"><b></b><INPUT TYPE="button" NAME="sqr3" class="tictac" value=" " onClick="if(document.tic.sqr3.value == ' ' && turn == 0 && mode == 1) {document.tic.sqr3.value = ' X '; sqr3T = 1; turn = 1; vari(); check();} else if(document.tic.sqr3.value == ' ' && turn == 1 && mode == 2) {document.tic.sqr3.value = ' X '; sqr3T = 1; turn = 0; vari(); player1Check()} else if(document.tic.sqr3.value == ' ' && turn == 0 && mode == 2) {document.tic.sqr3.value = ' O '; sqr3T = 1; turn = 1; vari(); player1Check()} drawCheck()" style="font-weight: 700"><b><br /></b><INPUT TYPE="button" NAME="sqr4" class="tictac" value=" " onClick="if(document.tic.sqr4.value == ' ' && turn == 0 && mode == 1) {document.tic.sqr4.value = ' X '; sqr4T = 1; turn = 1; vari(); check();} else if(document.tic.sqr4.value == ' ' && turn == 1 && mode == 2) {document.tic.sqr4.value = ' X '; sqr4T = 1; turn = 0; vari(); player1Check()} else if(document.tic.sqr4.value == ' ' && turn == 0 && mode == 2) {document.tic.sqr4.value = ' O '; sqr4T = 1; turn = 1; vari(); player1Check()} drawCheck()" style="font-weight: 700"><b></b><INPUT TYPE="button" NAME="sqr5" class="tictac" value=" " onClick="if(document.tic.sqr5.value == ' ' && turn == 0 && mode == 1) {document.tic.sqr5.value = ' X '; sqr5T = 1; turn = 1; vari(); check();} else if(document.tic.sqr5.value == ' ' && turn == 1 && mode == 2) {document.tic.sqr5.value = ' X '; sqr5T = 1; turn = 0; vari(); player1Check()} else if(document.tic.sqr5.value == ' ' && turn == 0 && mode == 2) {document.tic.sqr5.value = ' O '; sqr5T = 1; turn = 1; vari(); player1Check()} drawCheck()" style="font-weight: 700"><b></b><INPUT TYPE="button" NAME="sqr6" class="tictac" value=" " onClick="if(document.tic.sqr6.value == ' ' && turn == 0 && mode == 1) {document.tic.sqr6.value = ' X '; sqr6T = 1; turn = 1; vari(); check();} else if(document.tic.sqr6.value == ' ' && turn == 1 && mode == 2) {document.tic.sqr6.value = ' X '; sqr6T = 1; turn = 0; vari(); player1Check()} else if(document.tic.sqr6.value == ' ' && turn == 0 && mode == 2) {document.tic.sqr6.value = ' O '; sqr6T = 1; turn = 1; vari(); player1Check()} drawCheck()" style="font-weight: 700"><b><br /></b><INPUT TYPE="button" NAME="sqr7" class="tictac" value=" " onClick="if(document.tic.sqr7.value == ' ' && turn == 0 && mode == 1) {document.tic.sqr7.value = ' X '; sqr7T = 1; turn = 1; vari(); check();} else if(document.tic.sqr7.value == ' ' && turn == 1 && mode == 2) {document.tic.sqr7.value = ' X '; sqr7T = 1; turn = 0; vari(); player1Check()} else if(document.tic.sqr7.value == ' ' && turn == 0 && mode == 2) {document.tic.sqr7.value = ' O '; sqr7T = 1; turn = 1; vari(); player1Check()} drawCheck()" style="font-weight: 700"><b></b><INPUT TYPE="button" NAME="sqr8" class="tictac" value=" " onClick="if(document.tic.sqr8.value == ' ' && turn == 0 && mode == 1) {document.tic.sqr8.value = ' X '; sqr8T = 1; turn = 1; vari(); check();} else if(document.tic.sqr8.value == ' ' && turn == 1 && mode == 2) {document.tic.sqr8.value = ' X '; sqr8T = 1; turn = 0; vari(); player1Check()} else if(document.tic.sqr8.value == ' ' && turn == 0 && mode == 2) {document.tic.sqr8.value = ' O '; sqr8T = 1; turn = 1; vari(); player1Check()} drawCheck()" style="font-weight: 700"><b></b><INPUT TYPE="button" NAME="sqr9" class="tictac" value=" " onClick="if(document.tic.sqr9.value == ' ' && turn == 0 && mode == 1) {document.tic.sqr9.value = ' X '; sqr9T = 1; turn = 1; vari(); check();} else if(document.tic.sqr9.value == ' ' && turn == 1 && mode == 2) {document.tic.sqr9.value = ' X '; sqr9T = 1; turn = 0; vari(); player1Check()} else if(document.tic.sqr9.value == ' ' && turn == 0 && mode == 2) {document.tic.sqr9.value = ' O '; sqr9T = 1; turn = 1; vari(); player1Check()} drawCheck()" style="font-weight: 700"><b></b></font></p></form>
ليست هناك تعليقات: