<?php
require __DIR__.'/_bootstrap.php';

use Zoo\Database;
use Zoo\Auth\PlayerAuthService;
use Zoo\Reward\DailyCheckinService;
use Zoo\Wallet\WalletQuery;

try{
    $db=Database::connect();
    $player=(new PlayerAuthService($db))->authenticate([]);
    $uid=(int)$player['user_id'];

    $svc=new DailyCheckinService($db);

    json_out([
      'ok'=>true,
      'status'=>$svc->status($uid),
      'recent'=>$svc->recent($uid,7),
      'wallet'=>(new WalletQuery($db))->get($uid)
    ]);
}catch(Throwable $e){
    json_out(['ok'=>false,'error'=>$e->getMessage()],422);
}
