-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from bhamidou/develop
Develop
- Loading branch information
Showing
10 changed files
with
174 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,10 @@ | |
"mesg", | ||
"otro", | ||
"soporte" | ||
], | ||
"cSpell.ignoreWords": [ | ||
"buscaminas", | ||
"lado", | ||
"nada" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
<?php | ||
|
||
class Constantes{ | ||
class Constantes { | ||
static $host = "localhost"; | ||
static $user = "root"; | ||
static $pass = "1234"; | ||
static $database = "buscaminas"; | ||
static $port = "3333"; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
require __DIR__.'../Conexion.php'; | ||
|
||
class ConexionUsuario{ | ||
public function checkLogin($email,$pass){ | ||
$con = new Conexion(); | ||
$con->conectar(); | ||
|
||
$consulta = "SELECT * FROM USUARIO WHERE email = ? AND pass = ? "; | ||
|
||
$stmt = mysqli_prepare(Conexion::$conexion, $consulta); | ||
|
||
$parsePw = md5($pass); | ||
|
||
mysqli_stmt_bind_param($stmt, "ss", $email, $parsePw); | ||
|
||
mysqli_stmt_execute($stmt); | ||
$resultados = mysqli_stmt_get_result($stmt); | ||
|
||
$rtn = []; | ||
|
||
while ($fila = mysqli_fetch_row($resultados)) { | ||
$rtn[] = [$fila[1],$fila[2]]; | ||
} | ||
|
||
$check = false; | ||
if($email == !empty($rtn[0][0]) && $pass == !empty($rtn[0][1])){ | ||
$check = true; | ||
} | ||
|
||
$con->desconectar(); | ||
|
||
return $check; | ||
} | ||
|
||
public function updatePassword($id, $newPw){ | ||
$con = new Conexion(); | ||
$con->conectar(); | ||
|
||
$consulta = "UPDATE USUARIO SET pass = ? WHERE id = ? "; | ||
|
||
$stmt = mysqli_prepare(Conexion::$conexion, $consulta); | ||
|
||
$hashPw = md5($newPw); | ||
|
||
mysqli_stmt_bind_param($stmt, "si", $hashPw, $id); | ||
|
||
mysqli_stmt_execute($stmt); | ||
|
||
$con->desconectar(); | ||
|
||
} | ||
|
||
function createUser($email, $pass, $nombre){ | ||
$con = new Conexion(); | ||
$con->conectar(); | ||
|
||
$consulta = "INSERT INTO USUARIO (email, pass, nombre) VALUES (?, ?, ?)"; | ||
|
||
$stmt = mysqli_prepare(Conexion::$conexion, $consulta); | ||
|
||
$hashPw = md5($pass); | ||
|
||
mysqli_stmt_bind_param($stmt, "sss", $email, $hashPw, $nombre); | ||
|
||
mysqli_stmt_execute($stmt); | ||
|
||
$con->desconectar(); | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,7 @@ | ||
<?php | ||
|
||
require_once 'Constantes.php'; | ||
require_once 'Conexion.php'; | ||
class Partida { | ||
|
||
class Partida{ | ||
|
||
private $tablero; | ||
|
||
public function darManotazo($pos){ | ||
/** | ||
* 0-> nada | ||
* 1 -> al lado | ||
* 2 -> le has | ||
*/ | ||
$code = 0; | ||
if( $this->tablero[$pos] == '*'){ | ||
$code = 2; | ||
}else if($this->tablero[$pos-1] == '*' || $this->tablero[$pos+1] == '*'){ | ||
$code = 1; | ||
} | ||
|
||
return $code; | ||
} | ||
|
||
public function crearTablero($size, $numMinas){ | ||
|
||
$rtnVec = array_fill(0,$size,'-'); | ||
|
||
while($numMinas>=0){ | ||
$randPos = rand(0,($size-1)) ; | ||
$rtnVec[$randPos] = '*'; | ||
$numMinas--; | ||
} | ||
|
||
$this->tablero =$rtnVec; | ||
} | ||
|
||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
// require_once __DIR__.'/Conexion/Conexion.php'; | ||
require_once __DIR__.'/Conexion/ConexionUsuario.php'; | ||
|
||
class Usuario{ | ||
|
||
|
||
private $id; | ||
private $email; | ||
private $pass; | ||
private $nombre; | ||
private $tablero; | ||
private $estadoPartida; | ||
|
||
public function __construct($id,$email, $pass) { | ||
$this->id = $id; | ||
$this->email= $email; | ||
$this->pass = $pass; | ||
} | ||
|
||
public function darManotazo($pos){ | ||
/** | ||
* 0-> nada | ||
* 1 -> al lado | ||
* 2 -> le has dado | ||
*/ | ||
$code = 0; | ||
if( $this->tablero[$pos] == '*'){ | ||
$code = 2; | ||
}elseif($this->tablero[$pos-1] == '*' || $this->tablero[$pos+1] == '*'){ | ||
$code = 1; | ||
} | ||
|
||
return $code; | ||
} | ||
|
||
public function crearTablero($size, $numMinas){ | ||
|
||
$rtnVec = array_fill(0,$size,'-'); | ||
|
||
while($numMinas>=0){ | ||
$randPos = rand(0,($size-1)) ; | ||
$rtnVec[$randPos] = '*'; | ||
$numMinas--; | ||
} | ||
|
||
$this->tablero =$rtnVec; | ||
} | ||
|
||
public function changePassword($newPw){ | ||
$conexionUsuario = new ConexionUsuario(); | ||
|
||
$conexionUsuario->updatePassword(1, $newPw); | ||
} | ||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters