<?php
require_once __DIR__ . '/../../_bootstrap.php';
require_once ROOT_PATH . '/includes/match_functions.php';
if ($_SERVER['REQUEST_METHOD'] !== 'GET') jsonResponse(['ok'=>false,'erro'=>'Método não permitido.'],405);
$u = afApiOuSessaoUsuario($pdo,'farm');
try {
    $p = afBuscarPartidaAtiva($pdo, (int)$u['id']);
    jsonResponse(['ok'=>true,'partida'=>$p ? afPartidaPublica($p,$pdo) : null]);
} catch (Throwable $e) {
    jsonResponse(['ok'=>false,'erro'=>$e->getMessage()],422);
}
