<?php

namespace App\Http\Controllers;

use App\Models\GameRtp;
use Illuminate\Http\Request;

class GameRtpController extends Controller
{
    /**
     * Ambil RTP per game (READ ONLY)
     */
    public function get(Request $request)
    {
        $request->validate([
            'game_code' => 'required|string',
            'provider'  => 'required|string',
        ]);

        $rtp = GameRtp::where('game_code', $request->game_code)
            ->where('game_provider', $request->provider)
            ->where('expired_at', '>', now())
            ->first();

        return response()->json([
            'game_code' => $request->game_code,
            'provider'  => $request->provider,
            'rtp'       => $rtp ? $rtp->rtp . '%' : '--%',
            'status'    => $rtp ? 'ok' : 'expired'
        ]);
    }
}
