Accueil > > > JEU DU MORPION INTELLIGENT: HUMAIN VERSUS PHP
JEU DU MORPION INTELLIGENT: HUMAIN VERSUS PHP
Information sur la source
Description
Jouez en ligne au jeu du morpion contre l'ordinateur. Personnalisez le niveau. Présence d'un mode invincible (corrigé 1 fois). Gestion des points. Mais surtout, amusez-vous bien !
Source
- <?php
-
- //======================================= http://altert.family.free.fr/ ========
-
- $BackGroundColor = "#F8F8F8";
- $ActiveCellColor = "yellow";
-
- //------------------------------------------------------------------------------
-
- function GetGet($Value,$DefaultValue) {
- //INFO: l'utilisation de HTMLSPECIALCHARS évite les trous de sécurité du type
- // http://localhost/morpion.php?game=100020010&level=2&serverpts=<script>alert("Salut");</script>&playerpts=0
- if (isset($_GET[$Value])) {
- if ($_GET[$Value]=='')
- return $DefaultValue;
- else
- return htmlspecialchars($_GET[$Value]);
- } else
- return $DefaultValue;
- }
-
- function HasChar($Text,$Char) {
- $HasC = false;
- for ($i=0 ; $i<strlen($Text) ; $i++)
- if ($Text[$i]==$Char) {
- $HasC = true;
- break;
- }
- return $HasC;
- }
-
- //------------------------------------------------------------------------------
-
- $DisallowLinks = false;
- $WinningPosition = -1;
- $ServerPoints = GetGet('serverpts',0);
- $PlayerPoints = GetGet('playerpts',0);
- $Grid = GetGet('game','000000000');
- $Level = GetGet('level','1'); //par défaut, le moteur est "Intermédiaire"
-
- //------------------------------------------------------------------------------
-
- function Full3($P1,$P2,$P3) {
- //Indique si 3 cases spécifiées sont occupées par le même signe
- global $Grid;
- return ($Grid[$P1]!='0' && $Grid[$P1]==$Grid[$P2] && $Grid[$P2]==$Grid[$P3]);
- }
-
- function CheckWin() {
- //0-1-2
- //3-4-5
- //6-7-8
- global $Grid;
- return ( Full3(0,3,6) || Full3(1,4,7) || Full3(2,5,8) || //Verticales
- Full3(0,1,2) || Full3(3,4,5) || Full3(6,7,8) || //Horizontales
- Full3(0,4,8) || Full3(2,4,6) ); //Diagonales
- }
-
- function EchoTab($Index) {
- global $Grid, $DisallowLinks, $Level, $ServerPoints, $PlayerPoints;
- if (!HasChar($Grid,'0')) {
- echo '<a class=link href="morpion.php?level='.$Level.'&serverpts='.$ServerPoints.'&playerpts='.$PlayerPoints.'">';
- if ($Grid[$Index]=='1')
- echo '<img src="croix.gif" alt="Cliquez pour recommencer">';
- else
- echo '<img src="cercle.gif" alt="Cliquez pour recommencer">';
- echo '</a>';
- } else {
- switch ($Grid[$Index]) {
- case '0':
- $CurGrid = $Grid;
- $CurGrid[$Index] = '1';
- if ($DisallowLinks)
- echo '<img src="blank.gif" border="0">';
- else
- echo '<a href="morpion.php?game='.$CurGrid.'&level='.$Level.'&serverpts='.$ServerPoints.'&playerpts='.$PlayerPoints.'"><img src="blank.gif" border="0"></a>';
- break;
- case '1':
- echo '<img src="croix.gif">';
- break;
- case '2':
- echo '<img src="cercle.gif">';
- break;
- }
- }
- }
-
- function GetCellColor($Cell,$EchoSth) {
- //0-1-2
- //3-4-5
- //6-7-8
- global $BackGroundColor, $ActiveCellColor, $WinningPosition;
-
- //Recherche de la condition de coloration
- switch ($Cell) {
- case 0: $CellBG = Full3(0,1,2) || Full3(0,3,6) || Full3(0,4,8); break;
- case 1: $CellBG = Full3(0,1,2) || Full3(1,4,7); break;
- case 2: $CellBG = Full3(0,1,2) || Full3(2,5,8) || Full3(2,4,6); break;
- case 3: $CellBG = Full3(3,4,5) || Full3(0,3,6); break;
- case 4: $CellBG = Full3(3,4,5) || Full3(1,4,7) || Full3(0,4,8) || Full3(2,4,6); break;
- case 5: $CellBG = Full3(3,4,5) || Full3(2,5,8); break;
- case 6: $CellBG = Full3(6,7,8) || Full3(0,3,6) || Full3(2,4,6); break;
- case 7: $CellBG = Full3(6,7,8) || Full3(1,4,7); break;
- case 8: $CellBG = Full3(6,7,8) || Full3(2,5,8) || Full3(0,4,8); break;
- }
-
- //Application de la couleur
- if ($CellBG) {
- $WinningPosition = $Cell;
- if ($EchoSth)
- echo $ActiveCellColor;
- } else
- if ($EchoSth)
- echo $BackGroundColor;
- }
-
- //------------------------------------------------------------------------------
-
- /*
- INFORMATIONS GENERALES
- Joueur '0' = personne
- Joueur '1' = internaute
- Joueur '2' = serveur
- */
-
- function Computing() {
- global $Grid, $Level;
- $Buffer = $Grid;
- $Choix = -1;
- $Symetrical = (($Level>=2) && ($Grid=='100010002' || $Grid=='200010001' || $Grid=='001010200' || $Grid=='002010100'));
-
- //Recherche d'une position immédiatement gagnante
- for ($i=0 ; $i<9 ; $i++) {
- $Grid = $Buffer;
- if ($Grid[$i]=='0') {
- $Grid[$i] = '2';
- if (CheckWin()) {
- $Choix = $i;
- break;
- }
- }
- }
-
- //Recherche d'une position qui contre l'adversaire
- if ($Choix==-1)
- for ($i=0 ; $i<9 ; $i++) {
- $Grid = $Buffer;
- if ($Grid[$i]=='0') {
- $Grid[$i] = '1';
- if (CheckWin()) {
- $Choix = $i;
- break;
- }
- }
- }
-
- //Recherche d'une position qui dispense 2 positions gagnantes
- if ($Choix==-1 && $Level>=1)
- for ($i=0 ; $i<9 ; $i++) {
- $Grid = $Buffer;
- if ($Grid[$i]=='0') {
- $Grid[$i] = '2';
- $Buffer2 = $Grid;
- $WinCount = 0;
- for ($j=0 ; $j<9 ; $j++) {
- $Grid = $Buffer2;
- if ($Grid[$j]=='0') {
- $Grid[$j] = '2';
- if (CheckWin())
- $WinCount++;
- }
- }
- if ($WinCount>=2) {
- $Choix = $i;
- break;
- }
- }
- }
- $Grid = $Buffer;
-
- //Recherche d'une position adverse qui force 2 positions gagnantes
- if ($Choix==-1 && $Grid!='100020001' && $Grid!='001020100' && !$Symetrical && $Level>=1)
- for ($i=0 ; $i<9 ; $i++) {
- $Grid = $Buffer;
- if ($Grid[$i]=='0') {
- $Grid[$i] = '1';
- $Buffer2 = $Grid;
- $WinCount = 0;
- for ($j=0 ; $j<9 ; $j++) {
- $Grid = $Buffer2;
- if ($Grid[$j]=='0') {
- $Grid[$j] = '1';
- if (CheckWin())
- $WinCount++;
- }
- }
- if ($WinCount>=2) {
- $Choix = $i;
- break;
- }
- }
- }
- $Grid = $Buffer;
-
- //Petit remède d'invincibilité complémentaire
- if ($Level>=1)
- $NoCorner = ($Grid=='100020001' || $Grid=='001020100');
- else
- $NoCorner = false;
-
-
- //Choix de la case centrale si disponible
- if ($Choix==-1 && $Grid[4]=='0')
- if ($Level>=1 || ($Level==0 && rand(0,5)!=4))
- $Choix = 4;
-
- //En mode de jeu le plus grand, il est interdit pour l'ordinateur de jouer sur les points cardinaux au second tour (sinon il perd à coup sûr)
- //D'après une situation particulière de symétrie, on exploite cette même interdiction mais pour des raisons différentes
- if (($Choix==-1 && $Level>=2 && $Grid=='000010000') || $Symetrical) {
- $_choice = -1;
- while ($_choice==-1)
- switch(rand(1,4)) {
- case 1: if ($Grid[6]=='0') $_choice=6; break;
- case 2: if ($Grid[8]=='0') $_choice=8; break;
- case 3: if ($Grid[0]=='0') $_choice=0; break;
- case 4: if ($Grid[2]=='0') $_choice=2; break;
- }
- $Choix = $_choice;
- }
-
- //Choix d'une case au pif...
- if ($Choix==-1) {
- $Case = rand(0,8);
- while ($Grid[$Case]!='0') {
- $Case++;
- if ($Case>8)
- $Case = 0;
- }
- //...on ne doit pas jouer pas au pif dans les coins quand c'est stratégiquement suicidaire
- if ($NoCorner) {
- if ($Case==0 || $Case==2 || $Case==6 || $Case==8)
- $Case++;
- if ($Case>8)
- $Case = 1;
- }
- $Choix = $Case;
- }
-
- //Restauration des données
- $Grid = $Buffer;
- return $Choix;
- }
-
- if (($Grid!='000000000' || isset($_GET['serverbegins'])) && !CheckWin() && HasChar($Grid,'0')) {
- $Index = Computing();
- if ($Index!= -1)
- $Grid[$Index]='2';
- else {
- echo '<b>Une erreur fatale est survenue.';
- echo '<br/><br/>Cliquez <a href="morpion.php">ici</a> pour faire une nouvelle partie.';
- return 0;
- }
- }
-
- //Traitement des points: pour pouvoir transmettre efficacement les scores, il est nécessaire
- //d'appeler 9 fois dans le vide la fonction GetCellColor. Cela permet d'initialiser correctement
- //la variable $WinningPosition et donc de rendre les scores transmissibles via la fonction
- //EchoTbl qui est chargée d'afficher les nouveaux scores.
- for ($i=0 ; $i<9 ; $i++)
- GetCellColor($i,false);
- if ($WinningPosition>=0 && $WinningPosition<9)
- switch ($Grid[$WinningPosition]) {
- case '1': $PlayerPoints++; break;
- case '2': $ServerPoints++; break;
- }
- ?>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>Le jeu du morpion</title>
- <style>
- A.link { color: #8080FF; text-decoration: none }
- A.link:hover { color: blue; text-decoration: underline overline }
- TD.gameboard { border: 2px solid maroon }
- IMG { border: 0 }
- </style>
- </head>
- <body bgcolor="<?php echo $BackGroundColor; ?>">
- <table width="35%" cellspacing="0" border="0" align="center">
- <tr>
- <td colspan="2" height="50px" align="center" style="border: 1px solid #996600">
- <?php
- if ($DisallowLinks=CheckWin())
- echo '<b><font face="Verdana" color="#996600">La partie est terminée !</font></b>';
- else
- if (!HasChar($Grid,'0')) {
- echo '<b><font face="Verdana" color="#996600">Match nul !</font></b>';
- $DisallowLinks=true;
- } else
- echo ' ';
- ?>
- </td>
- </tr>
-
- <tr>
- <td valign="center" width="35%" style="border-right: 1px solid navy">
- <font size="4" color="green"><b>Actions :</b></font>
- <br/>
- <?php
- if ($Grid=='000000000')
- echo '<br/><a class=link href="morpion.php?game='.$Grid.'&serverbegins&level='.$Level.'&serverpts='.$ServerPoints.'&playerpts='.$PlayerPoints.'">Laisser la main</a>';
- else
- echo '<br/> ';
- ?>
- <?php
- if ($ServerPoints!=0 || $PlayerPoints!=0)
- echo '<br/><a class=link href="morpion.php?game=000000000&level='.$Level.'">RAZ</a>';
- else
- echo '<br/> ';
- ?>
- <br/><a class=link href="morpion.php?level=<?php echo $Level.'&serverpts='.$ServerPoints.'&playerpts='.$PlayerPoints; ?>">Recommencer</a>
- </td>
-
- <td rowspan="2">
- <br/>
- <table width="156" border="3" cellspacing="3" align="center" style="border: none">
- <tr>
- <td bgcolor="<?php GetCellColor(0,true); ?>" class=gameboard style="border-top:none; border-left:none"><?php EchoTab(0); ?></td>
- <td bgcolor="<?php GetCellColor(1,true); ?>" class=gameboard style="border-top:none"><?php EchoTab(1); ?></td>
- <td bgcolor="<?php GetCellColor(2,true); ?>" class=gameboard style="border-top:none; border-right:none"><?php EchoTab(2); ?></td>
- </tr>
- <tr>
- <td bgcolor="<?php GetCellColor(3,true); ?>" class=gameboard style="border-left:none"><?php EchoTab(3); ?></td>
- <td bgcolor="<?php GetCellColor(4,true); ?>" class=gameboard><?php EchoTab(4); ?></td>
- <td bgcolor="<?php GetCellColor(5,true); ?>" class=gameboard style="border-right:none"><?php EchoTab(5); ?></td>
- </tr>
- <tr>
- <td bgcolor="<?php GetCellColor(6,true); ?>" class=gameboard style="border-bottom:none; border-left:none"><?php EchoTab(6); ?></td>
- <td bgcolor="<?php GetCellColor(7,true); ?>" class=gameboard style="border-bottom:none"><?php EchoTab(7); ?></td>
- <td bgcolor="<?php GetCellColor(8,true); ?>" class=gameboard style="border-bottom:none; border-right:none"><?php EchoTab(8); ?></td>
- </tr>
- </table>
- <br/>
- </td>
- </tr>
-
- <tr>
- <td valign="center" width="35%" style="border-right: 1px solid navy; border-top: 1px solid navy">
- <font size="4" color="green"><b>Options:</b></font>
- <br/>
- <?php
- function EchoLevelList($Lvl,$Caption) {
- global $Grid, $Level, $ServerPoints, $PlayerPoints;
- echo '<br/>';
- if ($Level==$Lvl)
- echo '<img src="tic.gif" align="absmiddle"> ';
- if ($Grid=='000000000')
- echo '<a class=link href="morpion.php?game='.$Grid.'&level='.$Lvl.'&serverpts='.$ServerPoints.'&playerpts='.$PlayerPoints.'">'.$Caption.'</a>';
- else
- echo $Caption;
- }
- EchoLevelList(0,'Faible');
- EchoLevelList(1,'Intermédiaire');
- EchoLevelList(2,'Invincible');
- ?>
- </td>
- </tr>
-
- <tr>
- <td colspan="2" align="center">
- <font size="2" color="navy">Serveur : <?php echo $ServerPoints; ?> <b>..::..</b> Joueur : <?php echo $PlayerPoints; ?></font>
- </td>
- </tr>
-
- <tr>
- <td colspan="2" align="center" style="border: 2px solid #996600">
- <font size="2" color="maroon">Jeu du morpion <b>©</b> septembre 2005</font>
- </td>
- </tr>
- </table>
- </body>
- </html>
<?php
//======================================= http://altert.family.free.fr/ ========
$BackGroundColor = "#F8F8F8";
$ActiveCellColor = "yellow";
//------------------------------------------------------------------------------
function GetGet($Value,$DefaultValue) {
//INFO: l'utilisation de HTMLSPECIALCHARS évite les trous de sécurité du type
// http://localhost/morpion.php?game=100020010&level=2&serverpts=<script>alert("Salut");</script>&playerpts=0
if (isset($_GET[$Value])) {
if ($_GET[$Value]=='')
return $DefaultValue;
else
return htmlspecialchars($_GET[$Value]);
} else
return $DefaultValue;
}
function HasChar($Text,$Char) {
$HasC = false;
for ($i=0 ; $i<strlen($Text) ; $i++)
if ($Text[$i]==$Char) {
$HasC = true;
break;
}
return $HasC;
}
//------------------------------------------------------------------------------
$DisallowLinks = false;
$WinningPosition = -1;
$ServerPoints = GetGet('serverpts',0);
$PlayerPoints = GetGet('playerpts',0);
$Grid = GetGet('game','000000000');
$Level = GetGet('level','1'); //par défaut, le moteur est "Intermédiaire"
//------------------------------------------------------------------------------
function Full3($P1,$P2,$P3) {
//Indique si 3 cases spécifiées sont occupées par le même signe
global $Grid;
return ($Grid[$P1]!='0' && $Grid[$P1]==$Grid[$P2] && $Grid[$P2]==$Grid[$P3]);
}
function CheckWin() {
//0-1-2
//3-4-5
//6-7-8
global $Grid;
return ( Full3(0,3,6) || Full3(1,4,7) || Full3(2,5,8) || //Verticales
Full3(0,1,2) || Full3(3,4,5) || Full3(6,7,8) || //Horizontales
Full3(0,4,8) || Full3(2,4,6) ); //Diagonales
}
function EchoTab($Index) {
global $Grid, $DisallowLinks, $Level, $ServerPoints, $PlayerPoints;
if (!HasChar($Grid,'0')) {
echo '<a class=link href="morpion.php?level='.$Level.'&serverpts='.$ServerPoints.'&playerpts='.$PlayerPoints.'">';
if ($Grid[$Index]=='1')
echo '<img src="croix.gif" alt="Cliquez pour recommencer">';
else
echo '<img src="cercle.gif" alt="Cliquez pour recommencer">';
echo '</a>';
} else {
switch ($Grid[$Index]) {
case '0':
$CurGrid = $Grid;
$CurGrid[$Index] = '1';
if ($DisallowLinks)
echo '<img src="blank.gif" border="0">';
else
echo '<a href="morpion.php?game='.$CurGrid.'&level='.$Level.'&serverpts='.$ServerPoints.'&playerpts='.$PlayerPoints.'"><img src="blank.gif" border="0"></a>';
break;
case '1':
echo '<img src="croix.gif">';
break;
case '2':
echo '<img src="cercle.gif">';
break;
}
}
}
function GetCellColor($Cell,$EchoSth) {
//0-1-2
//3-4-5
//6-7-8
global $BackGroundColor, $ActiveCellColor, $WinningPosition;
//Recherche de la condition de coloration
switch ($Cell) {
case 0: $CellBG = Full3(0,1,2) || Full3(0,3,6) || Full3(0,4,8); break;
case 1: $CellBG = Full3(0,1,2) || Full3(1,4,7); break;
case 2: $CellBG = Full3(0,1,2) || Full3(2,5,8) || Full3(2,4,6); break;
case 3: $CellBG = Full3(3,4,5) || Full3(0,3,6); break;
case 4: $CellBG = Full3(3,4,5) || Full3(1,4,7) || Full3(0,4,8) || Full3(2,4,6); break;
case 5: $CellBG = Full3(3,4,5) || Full3(2,5,8); break;
case 6: $CellBG = Full3(6,7,8) || Full3(0,3,6) || Full3(2,4,6); break;
case 7: $CellBG = Full3(6,7,8) || Full3(1,4,7); break;
case 8: $CellBG = Full3(6,7,8) || Full3(2,5,8) || Full3(0,4,8); break;
}
//Application de la couleur
if ($CellBG) {
$WinningPosition = $Cell;
if ($EchoSth)
echo $ActiveCellColor;
} else
if ($EchoSth)
echo $BackGroundColor;
}
//------------------------------------------------------------------------------
/*
INFORMATIONS GENERALES
Joueur '0' = personne
Joueur '1' = internaute
Joueur '2' = serveur
*/
function Computing() {
global $Grid, $Level;
$Buffer = $Grid;
$Choix = -1;
$Symetrical = (($Level>=2) && ($Grid=='100010002' || $Grid=='200010001' || $Grid=='001010200' || $Grid=='002010100'));
//Recherche d'une position immédiatement gagnante
for ($i=0 ; $i<9 ; $i++) {
$Grid = $Buffer;
if ($Grid[$i]=='0') {
$Grid[$i] = '2';
if (CheckWin()) {
$Choix = $i;
break;
}
}
}
//Recherche d'une position qui contre l'adversaire
if ($Choix==-1)
for ($i=0 ; $i<9 ; $i++) {
$Grid = $Buffer;
if ($Grid[$i]=='0') {
$Grid[$i] = '1';
if (CheckWin()) {
$Choix = $i;
break;
}
}
}
//Recherche d'une position qui dispense 2 positions gagnantes
if ($Choix==-1 && $Level>=1)
for ($i=0 ; $i<9 ; $i++) {
$Grid = $Buffer;
if ($Grid[$i]=='0') {
$Grid[$i] = '2';
$Buffer2 = $Grid;
$WinCount = 0;
for ($j=0 ; $j<9 ; $j++) {
$Grid = $Buffer2;
if ($Grid[$j]=='0') {
$Grid[$j] = '2';
if (CheckWin())
$WinCount++;
}
}
if ($WinCount>=2) {
$Choix = $i;
break;
}
}
}
$Grid = $Buffer;
//Recherche d'une position adverse qui force 2 positions gagnantes
if ($Choix==-1 && $Grid!='100020001' && $Grid!='001020100' && !$Symetrical && $Level>=1)
for ($i=0 ; $i<9 ; $i++) {
$Grid = $Buffer;
if ($Grid[$i]=='0') {
$Grid[$i] = '1';
$Buffer2 = $Grid;
$WinCount = 0;
for ($j=0 ; $j<9 ; $j++) {
$Grid = $Buffer2;
if ($Grid[$j]=='0') {
$Grid[$j] = '1';
if (CheckWin())
$WinCount++;
}
}
if ($WinCount>=2) {
$Choix = $i;
break;
}
}
}
$Grid = $Buffer;
//Petit remède d'invincibilité complémentaire
if ($Level>=1)
$NoCorner = ($Grid=='100020001' || $Grid=='001020100');
else
$NoCorner = false;
//Choix de la case centrale si disponible
if ($Choix==-1 && $Grid[4]=='0')
if ($Level>=1 || ($Level==0 && rand(0,5)!=4))
$Choix = 4;
//En mode de jeu le plus grand, il est interdit pour l'ordinateur de jouer sur les points cardinaux au second tour (sinon il perd à coup sûr)
//D'après une situation particulière de symétrie, on exploite cette même interdiction mais pour des raisons différentes
if (($Choix==-1 && $Level>=2 && $Grid=='000010000') || $Symetrical) {
$_choice = -1;
while ($_choice==-1)
switch(rand(1,4)) {
case 1: if ($Grid[6]=='0') $_choice=6; break;
case 2: if ($Grid[8]=='0') $_choice=8; break;
case 3: if ($Grid[0]=='0') $_choice=0; break;
case 4: if ($Grid[2]=='0') $_choice=2; break;
}
$Choix = $_choice;
}
//Choix d'une case au pif...
if ($Choix==-1) {
$Case = rand(0,8);
while ($Grid[$Case]!='0') {
$Case++;
if ($Case>8)
$Case = 0;
}
//...on ne doit pas jouer pas au pif dans les coins quand c'est stratégiquement suicidaire
if ($NoCorner) {
if ($Case==0 || $Case==2 || $Case==6 || $Case==8)
$Case++;
if ($Case>8)
$Case = 1;
}
$Choix = $Case;
}
//Restauration des données
$Grid = $Buffer;
return $Choix;
}
if (($Grid!='000000000' || isset($_GET['serverbegins'])) && !CheckWin() && HasChar($Grid,'0')) {
$Index = Computing();
if ($Index!= -1)
$Grid[$Index]='2';
else {
echo '<b>Une erreur fatale est survenue.';
echo '<br/><br/>Cliquez <a href="morpion.php">ici</a> pour faire une nouvelle partie.';
return 0;
}
}
//Traitement des points: pour pouvoir transmettre efficacement les scores, il est nécessaire
//d'appeler 9 fois dans le vide la fonction GetCellColor. Cela permet d'initialiser correctement
//la variable $WinningPosition et donc de rendre les scores transmissibles via la fonction
//EchoTbl qui est chargée d'afficher les nouveaux scores.
for ($i=0 ; $i<9 ; $i++)
GetCellColor($i,false);
if ($WinningPosition>=0 && $WinningPosition<9)
switch ($Grid[$WinningPosition]) {
case '1': $PlayerPoints++; break;
case '2': $ServerPoints++; break;
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Le jeu du morpion</title>
<style>
A.link { color: #8080FF; text-decoration: none }
A.link:hover { color: blue; text-decoration: underline overline }
TD.gameboard { border: 2px solid maroon }
IMG { border: 0 }
</style>
</head>
<body bgcolor="<?php echo $BackGroundColor; ?>">
<table width="35%" cellspacing="0" border="0" align="center">
<tr>
<td colspan="2" height="50px" align="center" style="border: 1px solid #996600">
<?php
if ($DisallowLinks=CheckWin())
echo '<b><font face="Verdana" color="#996600">La partie est terminée !</font></b>';
else
if (!HasChar($Grid,'0')) {
echo '<b><font face="Verdana" color="#996600">Match nul !</font></b>';
$DisallowLinks=true;
} else
echo ' ';
?>
</td>
</tr>
<tr>
<td valign="center" width="35%" style="border-right: 1px solid navy">
<font size="4" color="green"><b>Actions :</b></font>
<br/>
<?php
if ($Grid=='000000000')
echo '<br/><a class=link href="morpion.php?game='.$Grid.'&serverbegins&level='.$Level.'&serverpts='.$ServerPoints.'&playerpts='.$PlayerPoints.'">Laisser la main</a>';
else
echo '<br/> ';
?>
<?php
if ($ServerPoints!=0 || $PlayerPoints!=0)
echo '<br/><a class=link href="morpion.php?game=000000000&level='.$Level.'">RAZ</a>';
else
echo '<br/> ';
?>
<br/><a class=link href="morpion.php?level=<?php echo $Level.'&serverpts='.$ServerPoints.'&playerpts='.$PlayerPoints; ?>">Recommencer</a>
</td>
<td rowspan="2">
<br/>
<table width="156" border="3" cellspacing="3" align="center" style="border: none">
<tr>
<td bgcolor="<?php GetCellColor(0,true); ?>" class=gameboard style="border-top:none; border-left:none"><?php EchoTab(0); ?></td>
<td bgcolor="<?php GetCellColor(1,true); ?>" class=gameboard style="border-top:none"><?php EchoTab(1); ?></td>
<td bgcolor="<?php GetCellColor(2,true); ?>" class=gameboard style="border-top:none; border-right:none"><?php EchoTab(2); ?></td>
</tr>
<tr>
<td bgcolor="<?php GetCellColor(3,true); ?>" class=gameboard style="border-left:none"><?php EchoTab(3); ?></td>
<td bgcolor="<?php GetCellColor(4,true); ?>" class=gameboard><?php EchoTab(4); ?></td>
<td bgcolor="<?php GetCellColor(5,true); ?>" class=gameboard style="border-right:none"><?php EchoTab(5); ?></td>
</tr>
<tr>
<td bgcolor="<?php GetCellColor(6,true); ?>" class=gameboard style="border-bottom:none; border-left:none"><?php EchoTab(6); ?></td>
<td bgcolor="<?php GetCellColor(7,true); ?>" class=gameboard style="border-bottom:none"><?php EchoTab(7); ?></td>
<td bgcolor="<?php GetCellColor(8,true); ?>" class=gameboard style="border-bottom:none; border-right:none"><?php EchoTab(8); ?></td>
</tr>
</table>
<br/>
</td>
</tr>
<tr>
<td valign="center" width="35%" style="border-right: 1px solid navy; border-top: 1px solid navy">
<font size="4" color="green"><b>Options:</b></font>
<br/>
<?php
function EchoLevelList($Lvl,$Caption) {
global $Grid, $Level, $ServerPoints, $PlayerPoints;
echo '<br/>';
if ($Level==$Lvl)
echo '<img src="tic.gif" align="absmiddle"> ';
if ($Grid=='000000000')
echo '<a class=link href="morpion.php?game='.$Grid.'&level='.$Lvl.'&serverpts='.$ServerPoints.'&playerpts='.$PlayerPoints.'">'.$Caption.'</a>';
else
echo $Caption;
}
EchoLevelList(0,'Faible');
EchoLevelList(1,'Intermédiaire');
EchoLevelList(2,'Invincible');
?>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<font size="2" color="navy">Serveur : <?php echo $ServerPoints; ?> <b>..::..</b> Joueur : <?php echo $PlayerPoints; ?></font>
</td>
</tr>
<tr>
<td colspan="2" align="center" style="border: 2px solid #996600">
<font size="2" color="maroon">Jeu du morpion <b>©</b> septembre 2005</font>
</td>
</tr>
</table>
</body>
</html>
Conclusion
Vous pouvez toujours aller visiter http://altert.family.free.fr/
Historique
- 17 décembre 2005 14:38:09 :
- - correction mineure du mode invincible
- gestion des points
- coloration des victoires
- modification de quelques balises <abc> en <abc/>
- des trucs parci parlà (forcément)
Sources du même auteur
PROTÉGER LE TÉLÉCHARGEMENT DES FICHIERS ZIPPROTÉGER LE TÉLÉCHARGEMENT DES FICHIERS ZIP Tant que la session ne l'autorisera pas, il sera impossible de télécharger le fichier ZIP (quoi que l'internaute puisse en penser).
Ce code source ...
GÉRER DES FICHIERS DE CONFIGURATION INI [POO]GÉRER DES FICHIERS DE CONFIGURATION INI [POO] Encore une classe PHP opérationnelle et complète qui reprend les lignes essentielles de la classe TIniFile disponible en langage Delphi (cf inifiles.p...
GÉRER DES LISTES AVEC TSTRINGLIST [POO]GÉRER DES LISTES AVEC TSTRINGLIST [POO] Gestion de panier: ajouter, insérer, déplacer, supprimer, trier, repérer, vider, enregistrer dans un fichier, afficher dans le navigateur...
C'est ...
EXTENSIONS CHARGÉES SUR UN SERVEUREXTENSIONS CHARGÉES SUR UN SERVEUR Permet de voir tous les modules disponibles sur un serveur surtout si on ne connait pas la configuration de ce dernier : fonctions standard, zip, sess...
VISUALISER LE CONTENU D'UN FICHIER *.ZIPVISUALISER LE CONTENU D'UN FICHIER *.ZIPzip_open, zip_read, zip_entry_name, zip_entry_filesize, zip_entry_compressedsize, ratio, zip_entry_compressionmethod, zip_is_file, zip_close, function...
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
demande code source jeu de morpion [ par oubaha ]
bonsoir je suis nouveau adherent j'espére que vous m'admettriez. &nb
Tableau pour vue d'un jeu rpg [ par bob_07 ]
Bonjour, je suis actuellement en train de construir un jeu rpg en php. Pour la vue du joueur, je voulais créer un tableau qui affiche selon les c
jeu php [ par choosedeath ]
bonjour, je suis un jeune lycéen et j'ai un projet de jeu en php/msql de conquete spatiale (stratégie et commerce). le hic, c'est que je ne
Je cherche un code pour pouvoir changer de nick de jeu sur un trivia version tcl [ par PetiteLibellule ]
Jusqu'a maintenant sur une version mirc pour changer de nick de jeu en utilisant un trivia il suffisait de taper !nick et le nick de jeu desir
probleme t_string [ par smith62 ]
Bonjour tlm,Voila g un probleme Parse error: parse error, unexpected T_STRING in /secu/teamfr/teamdigitalk/digitalk/a-news/war/match_enregistrer.php o
Codeur php [ par Vanadium ]
Bonjour!!Je souhaiterais savoir si quelqu'un pourrait gracieusement m'aidé a la création d'un jeu online, mais je cherche quelqu'un voulant
Jeu de bourse [ par cnormand ]
Bonjour je suis webmaster de plusieurs sites et souhaiterai créer un site de bourse online fictif. Yaurait-il quelqu'un , ou qui veut s'ass
jeu de gestion de tennis [ par probordelais ]
Bonjour,Je fais un jeu de gestion d'un club de tennis en php. Le plus difficile est la gestion des matchs en temps réel. En fait, il me faudrai u
Problème de jeu de cadre [ par jeancharles26 ]
Bonjour,Voici mon souci :J'ai une page d'accueil avec un jeu de cadres. Le menu est dans le cadre vertical gauche et les pages apparaissent dans
Création d'un jeu de cartes en réseau [ par skmancuso ]
Bonjour,Je souhaiterais développer un jeu de carte en réseau du genre "dame de pique" sur mon site web.Malheureusement je ne suis pas tr
|
Derniers Blogs
TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010TECHDAYS PARIS 2010 : LA BI DANS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Vincent Bellet et Baptiste Giraudier La BI dans SharePoint 2010, Les nouveaux services d'application dans SP2010 et SQL Server Reporting services 2008 R2. La BI dans SharePoint est généralisée pour tous afin de permettre à tous les coll...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010TECHDAYS PARIS 2010 : PLAN DE MIGRATION VERS SHAREPOINT 2010 par ROMELARD Fabrice
Animé par: Arnault Nouvel et Antoine Dongois Le processus à prendre : Apprendre (découvrir la plateforme) Préparer (documenter l'historique et choisir la méthode de MAJ) Test (Test de MAJ) Implémenter (Effectuer la MAJ) Valid...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice TECHDAYS PARIS 2010 : LA PLEINIèRE DU SECOND JOURTECHDAYS PARIS 2010 : LA PLEINIèRE DU SECOND JOUR par ROMELARD Fabrice
Après un retour sur l'histoire des TechDays de Paris et le fait que ce soit le plus gros event MS au monde (du fait de sa gratuité), le président de MS France (Eric Boustoullier) a fait une présentation de la vision Microsoft pour les années à venir...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Forum
DEMANDE D'AIDEDEMANDE D'AIDE par palmerdt
Cliquez pour lire la suite par palmerdt
Logiciels
DB-MAIN (9.1.0)DB-MAIN (9.1.0)DB-MAIN is a data-modeling and data-architecture tool. It is designed to help developers and anal... Cliquez pour télécharger DB-MAIN Xilisoft DPG Convertisseur (5.1.37.0120)XILISOFT DPG CONVERTISSEUR (5.1.37.0120)Xilisoft DPG Convertisseur offre aux fans de Nintendo DS une bonne solution leur permettant de dé... Cliquez pour télécharger Xilisoft DPG Convertisseur GraphicsGale (2.01.01)GRAPHICSGALE (2.01.01)GraphicsGale est un logiciel de PixelArt avec de nombreuse fonctionnalités permettant de réalisé ... Cliquez pour télécharger GraphicsGale Architecte 3D (Platinum 2010)ARCHITECTE 3D (PLATINUM 2010)Architecte 3D Platinium vous permet de concevoir facilement les plans votre future maison, de l'é... Cliquez pour télécharger Architecte 3D TeamViewer 5 (TeamViewer 5)TEAMVIEWER 5 (TEAMVIEWER 5)Dépanner un ami,expliquer une manipulation devient un jeu d'enfant.
Prise en main d'un autre ord... Cliquez pour télécharger TeamViewer 5
|