<?php

namespace App\Jobs;

use App\Http\logic\api\ExtensionLogic;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis;

class GameCoun implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    // 1005=>TP、2030=>Rummy、2050=>Rummy两人、2060=>TPJoker玩法、2061=>TPAK玩法、2070=>Rummy10Card、2090=>Rummy两人十张
    // 2010=>百人TP、 2012=>百人AB  暂时忽略

    protected $GameIDs = [1005, 2030, 2050, 2060, 2061, 2070, 2090];

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * 任务尝试次数
     *
     * @var int
     */
    public $tries = 5;

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
       // Log::info('进来了');
//        $logic = new ExtensionLogic();
//        $redis = Redis::connection('test');
//        // 出栈
//        while (true) {
//            $brPop = $redis->brPop('gameCount', 0);
//
//            $ret = $brPop[1] ?? 0;
//            if (!empty($ret)) {
//                $ret = explode(',', $ret);
//                if (in_array($ret[1], $this->GameIDs)) {
//                    $UserID = $ret[0];
//                    $logic->invitation($UserID, 2);
//                }
//            }
//        }
    }
}
