Fixed checkWin method and README
parent
3c33261f38
commit
1d74dc8f31
78
4GEWINNT.php
78
4GEWINNT.php
|
|
@ -147,39 +147,47 @@ function placechip($col){
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkwin($row, $col){
|
function checkwin($row, $col){
|
||||||
return $_SESSION["board"][$row][$col] === $_SESSION["currentplayer"]
|
for ($row = 0; $row <= 5; $row++) {
|
||||||
&& $_SESSION["board"][$row + 1][$col] === $_SESSION["currentplayer"]
|
for ($col = 0; $col <= 6; $col++) {
|
||||||
&& $_SESSION["board"][$row + 2][$col] === $_SESSION["currentplayer"]
|
if (
|
||||||
&& $_SESSION["board"][$row + 3][$col] === $_SESSION["currentplayer"] ||
|
$row <= 2 &&
|
||||||
$_SESSION["board"][$row][$col] === $_SESSION["currentplayer"]
|
$_SESSION["board"][$row][$col] === $_SESSION["currentplayer"] &&
|
||||||
&& $_SESSION["board"][$row - 1][$col] === $_SESSION["currentplayer"]
|
$_SESSION["board"][$row + 1][$col] === $_SESSION["currentplayer"] &&
|
||||||
&& $_SESSION["board"][$row - 2][$col] === $_SESSION["currentplayer"]
|
$_SESSION["board"][$row + 2][$col] === $_SESSION["currentplayer"] &&
|
||||||
&& $_SESSION["board"][$row - 3][$col] === $_SESSION["currentplayer"] ||
|
$_SESSION["board"][$row + 3][$col] === $_SESSION["currentplayer"]
|
||||||
$_SESSION["board"][$row][$col] === $_SESSION["currentplayer"]
|
) {
|
||||||
&& $_SESSION["board"][$row][$col + 1] === $_SESSION["currentplayer"]
|
return true;
|
||||||
&& $_SESSION["board"][$row][$col + 2] === $_SESSION["currentplayer"]
|
} else if (
|
||||||
&& $_SESSION["board"][$row][$col + 3] === $_SESSION["currentplayer"] ||
|
$col <= 3 &&
|
||||||
$_SESSION["board"][$row][$col] === $_SESSION["currentplayer"]
|
$_SESSION["board"][$row][$col] === $_SESSION["currentplayer"] &&
|
||||||
&& $_SESSION["board"][$row][$col - 1] === $_SESSION["currentplayer"]
|
$_SESSION["board"][$row][$col + 1] === $_SESSION["currentplayer"] &&
|
||||||
&& $_SESSION["board"][$row][$col - 2] === $_SESSION["currentplayer"]
|
$_SESSION["board"][$row][$col + 2] === $_SESSION["currentplayer"] &&
|
||||||
&& $_SESSION["board"][$row][$col - 3] === $_SESSION["currentplayer"] ||
|
$_SESSION["board"][$row][$col + 3] === $_SESSION["currentplayer"]
|
||||||
$_SESSION["board"][$row][$col] === $_SESSION["currentplayer"]
|
) {
|
||||||
&& $_SESSION["board"][$row + 1][$col + 1] === $_SESSION["currentplayer"]
|
return true;
|
||||||
&& $_SESSION["board"][$row + 2][$col + 2] === $_SESSION["currentplayer"]
|
} else if (
|
||||||
&& $_SESSION["board"][$row + 3][$col + 3] === $_SESSION["currentplayer"] ||
|
$row <= 2 &&
|
||||||
$_SESSION["board"][$row][$col] === $_SESSION["currentplayer"]
|
$col <= 3 &&
|
||||||
&& $_SESSION["board"][$row - 1][$col - 1] === $_SESSION["currentplayer"]
|
$_SESSION["board"][$row][$col] === $_SESSION["currentplayer"] &&
|
||||||
&& $_SESSION["board"][$row - 2][$col - 2] === $_SESSION["currentplayer"]
|
$_SESSION["board"][$row + 1][$col + 1] === $_SESSION["currentplayer"] &&
|
||||||
&& $_SESSION["board"][$row - 3][$col - 3] === $_SESSION["currentplayer"] ||
|
$_SESSION["board"][$row + 2][$col + 2] === $_SESSION["currentplayer"] &&
|
||||||
$_SESSION["board"][$row][$col] === $_SESSION["currentplayer"]
|
$_SESSION["board"][$row + 3][$col + 3] === $_SESSION["currentplayer"]
|
||||||
&& $_SESSION["board"][$row + 1][$col - 1] === $_SESSION["currentplayer"]
|
) {
|
||||||
&& $_SESSION["board"][$row + 2][$col - 2] === $_SESSION["currentplayer"]
|
return true;
|
||||||
&& $_SESSION["board"][$row + 3][$col - 3] === $_SESSION["currentplayer"] ||
|
} else if (
|
||||||
$_SESSION["board"][$row][$col] === $_SESSION["currentplayer"]
|
$row <= 2 &&
|
||||||
&& $_SESSION["board"][$row - 1][$col + 1] === $_SESSION["currentplayer"]
|
$col <= 3 &&
|
||||||
&& $_SESSION["board"][$row - 2][$col + 2] === $_SESSION["currentplayer"]
|
$_SESSION["board"][$row][$col + 3] === $_SESSION["currentplayer"] &&
|
||||||
&& $_SESSION["board"][$row - 3][$col + 3] === $_SESSION["currentplayer"] ? true : false;
|
$_SESSION["board"][$row + 1][$col + 2] === $_SESSION["currentplayer"] &&
|
||||||
|
$_SESSION["board"][$row + 2][$col + 1] === $_SESSION["currentplayer"] &&
|
||||||
|
$_SESSION["board"][$row + 3][$col] === $_SESSION["currentplayer"]
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function swapplayer(){
|
function swapplayer(){
|
||||||
|
|
@ -207,7 +215,7 @@ function botturn(){
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>4-GEWINNT</title>
|
<title>4GEWINNT</title>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
all: initial;
|
all: initial;
|
||||||
|
|
@ -272,7 +280,7 @@ function botturn(){
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>4-GEWINNT</h1>
|
<h1>4GEWINNT</h1>
|
||||||
<div id="board">
|
<div id="board">
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<?php
|
<?php
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue