-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate.php
More file actions
15 lines (14 loc) · 801 Bytes
/
validate.php
File metadata and controls
15 lines (14 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
//Função para verificar se tem 3 posições iguais ao mesmo tempo no tabuleiro.
function validate(array $board, string $player): bool
{
return
($board[0] === $player && $board[1] === $player && $board[2] === $player) ||
($board[3] === $player && $board[4] === $player && $board[5] === $player) ||
($board[6] === $player && $board[7] === $player && $board[8] === $player) ||
($board[0] === $player && $board[3] === $player && $board[6] === $player) ||
($board[1] === $player && $board[4] === $player && $board[7] === $player) ||
($board[2] === $player && $board[5] === $player && $board[8] === $player) ||
($board[0] === $player && $board[4] === $player && $board[8] === $player) ||
($board[2] === $player && $board[4] === $player && $board[6] === $player);
}