Skip to content

Commit

Permalink
fix and add setUser and setArrUser
Browse files Browse the repository at this point in the history
  • Loading branch information
bhamidou committed Oct 17, 2023
1 parent e149adb commit 11581d3
Showing 1 changed file with 37 additions and 72 deletions.
109 changes: 37 additions & 72 deletions Controller/Usuario.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,70 +6,36 @@

class Usuario
{
private $id;
private $email;
private $pass;
private $nombre;
private $tablero;
private $estadoPartida;
private $role;
public $id;
public $email;
public $pass;
public $nombre;
public $partidasJugadas;
public $partidasGanadas;
public $role;

public function __toString()
{
return 'id: '.$this->id.'email: '.$this->email.'pass: ' . $this->pass. 'nombre: ' . $this->nombre. 'tablero: ' . $this->tablero. 'estadoPartida: ' . $this->estadoPartida;
}

public function darManotazo($pos)
public function __toString()
{
/**
* 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;
return 'id: '.$this->id.'email: '.$this->email.'pass: ' . $this->pass. 'nombre: ' . $this->nombre. 'partidasJugadas: ' . $this->partidasJugadas. 'partidasGanadas: ' . $this->partidasGanadas;
}

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);

$mail = new Mail();
$mail->sendmail($this->email, $this->nombre, "Solicitud de nueva contraseña", $newPw);


public function setArrUser($arrValues){
$this->setId($arrValues["ID"]);
$this->setEmail($arrValues["email"]);
$this->setPass($arrValues["pass"]);
$this->setnombre($arrValues["nombre"]);
$this->setPartidasJugadas($arrValues["partidasJugadas"]);
$this->setPartidasGanadas($arrValues["partidasGanadas"]);
$this->setRole($arrValues["rol"]);
}

public function setUser($arrValues){

$this->setId($arrValues[1]);
$this->setEmail($arrValues[2]);
$this->setPass($arrValues[3]);
$this->setnombre($arrValues[4]);
$this->setEstadoPartida($arrValues[5]);
$this->setTablero($arrValues[6]);
$this->setRole($arrValues[7]);
$this->setEmail($arrValues["email"]);
$this->setPass($arrValues["pass"]);
$this->setnombre($arrValues["nombre"]);
$this->setRole($arrValues["rol"]);
}

public function getId()
Expand Down Expand Up @@ -112,27 +78,26 @@ public function setNombre($value)
$this->nombre = $value;
}

public function getEstadoPartida()
{
return $this->estadoPartida;
}

public function setEstadoPartida($value)
{
$this->estadoPartida = $value;
}
public function getTablero() {
return $this->tablero;
}

public function setTablero($value) {
$this->tablero = $value;
}
public function getRole() {
return $this->role;
}

public function setRole($value) {
$this->role = $value;
}
public function getPartidasJugadas() {
return $this->partidasJugadas;
}

public function setPartidasJugadas($value) {
$this->partidasJugadas = $value;
}

public function getPartidasGanadas() {
return $this->partidasGanadas;
}

public function setPartidasGanadas($value) {
$this->partidasGanadas = $value;
}
}

0 comments on commit 11581d3

Please sign in to comment.