/** * @param DB $db * @param int|null $id * @param int $width * @param int $height * @param int $line */ function __construct(DB $db, array $users, $id = null, $width = 3, $height = 3, $line = 3) { $this->db = $db; if (!empty($id)) { $game = unserialize($this->db->openGame($id)); if (!empty($game)) { $this->id = $id; $this->users = $game['users']; $this->line = $game['game']['line']; $this->grid = new Grid($game['game']['width'], $game['game']['height']); } else { print "Такой игры не обнаружено"; exit; } } else { foreach ($users as $user) { $this->users[] = new User($user); } $this->line = $line; $this->grid = new Grid($width, $height); } $this->grid->drawGrid($this->users); $u = $this->getCurrentGamer(); print "\nХод " . $this->getCurrentGamer()->name . "\n"; }