<?php

class RemoteControl
{
    public static function CheckStatus()
    {
        var_dump($_SESSION['ActivePlayer']);
        $Status = App::$DBs[$_SESSION['user_db']]->select('StatusSpot')->from('Character')->where('Name', $_SESSION['ActivePlayer'])->get()->result_array();

if ($_SERVER['REMOTE_ADDR'] == "46.201.197.23") {
    var_dump($Status);
}
        $Status = $Status[0]['StatusSpot'];
        if ($Status == 0){
            return false;
        }
        else if($Status == 1){
            return true;
        }
    }
    public static function GoToSpot()
    {
        if (!static::CheckStatus()){
            Messages::Add('Возрат не нужен');
            return false;
        }
        $Config = App::$Configs->mod_RemoteControl;
        //if (ValuteManager::CheckFive($Config['GoToSpot']['Price']['Valutes'][0],$Config['GoToSpot']['Price']['Valutes'][1],$Config['GoToSpot']['Price']['Valutes'][2],$Config['GoToSpot']['Price']['Valutes'][3],$Config['GoToSpot']['Price']['Valutes'][4])) {
            if (App::$DBs[$_SESSION['user_db']]->set('StatusSpot', 2)->where('Name', $_SESSION['ActivePlayer'])->update('Character')) {
                //ValuteManager::TakeFive($Config['GoToSpot']['Price']['Valutes'][0],$Config['GoToSpot']['Price']['Valutes'][1],$Config['GoToSpot']['Price']['Valutes'][2],$Config['GoToSpot']['Price']['Valutes'][3],$Config['GoToSpot']['Price']['Valutes'][4]);
                   $Status = App::$DBs[$_SESSION['user_db']]->select('StatusSpot')->from('Character')->where('Name', $_SESSION['ActivePlayer'])->get()->result_array();

                if ($_SERVER['REMOTE_ADDR'] == "46.201.197.23") {
                    var_dump($Status);
                }
                Messages::Add('success_go_to_spot');
                Logs::WriteLog("Module: [GoToSpot], Account [{$_SESSION['login']}]. Success", 'Modules.log');
                return true;
            }
        //}
        Messages::Add('fail_go_to_spot');
        Logs::WriteLog("Module: [GoToSpot], Account [{$_SESSION['login']}]. Fail in sql query", 'Modules.log');
        return false;
    }
}