<< Click to Display Table of Contents >> Baralho.php |
![]() ![]() ![]() |
<?php
class Baralho {
private $deck = [];
public function __construct() {
$this->deck = [];
for ($naipe = Carta::Ouros; $naipe <= Carta::Paus; $naipe++) {
for ($valor = Carta::A; $valor <= Carta::K; $valor++) {
array_push($this->deck, new Carta($naipe, $valor));
}
}
}
public function GetCarta($posicao): Carta {
return $this->deck[$posicao];
}
public function __toString() {
$ret = "";
foreach ($this->deck as $carta) {
$ret = $ret . $carta . "<br/>";
}
return $ret;
}
public function Misturar(): void {
shuffle($this->deck);
}
}