미채택 완료

레벨업 함수인데요 레벨이 1증가도 안하고 랜덤으로 증가하구요

Copy
function gainEXP($email,$gain){
    global $con;
    $query = "select * from t1_members where email='$email' limit 1";
    $result = mysqli_query ($con, $query);
    $rows = mysqli_fetch_array($result);

    //print_r2($rows);
    //echo $rows['exp'];    
    $Exp = 0;
    $MaxExp = 0;
    $Remain = 0;

    $Exp = (double)$rows['exp'];
    $MaxExp = (double)$rows['maxExp'];
    $Remain = (double)$rows['remain'];

    $Exp += (double)$gain;
    
    if($Exp >= $MaxExp){
        $Remain = $Exp - $MaxExp;  //remain 1레벨 총량
        LevelUp($email,$Remain);
    }
    
    $sql = "update t1_members set exp='$Exp', maxExp='$MaxExp', remain='$Remain' where email='$email'";
    //alert($sql);
    
    $row = mysqli_query($con,$sql);
    //mysqli_error();
    //die( "mysqli connect error : " . mysqli_error() );
}


function LevelUp($email, $remainingEXP){
    global $con;
    //alert($remainingEXP);

    $query = "select * from t1_members where email='$email' limit 1";
    $result = mysqli_query ($con,$query);
    $rows = mysqli_fetch_array($result);

    $Exp = 0;
    $MaxExp = 0;
    $Remain = 0;
    $Level = 0;
    
    $Exp = (double)$rows['exp'];
    $MaxExp = (double)$rows['maxExp'];
    $Remain = (double)$rows['remain'];
    $Level = (double)$rows['level'];
    if($Level===0){
        $Level=1;
    }    

    $Exp += (double)$remainingEXP;
    $Level++;
    $MaxExp = (double)(125 * $MaxExp)/100;

    $sql = "update t1_members set level ='$Level', exp='$Exp', maxExp='$MaxExp', remain='$Remain' where email='$email'";
    $row = mysqli_query($con, $sql);    
    gainEXP($email,0);
    //die( "mysqli connect error : " . mysqli_error() );
}

 

레벨업 함수인데요 레벨이 1증가도 안하고 랜덤으로 증가하구요

레벨업하면 다시 경험치가 0이 되어야 하는데 안되고 아주 과관이네요 이거 하면 할수록 멘붕오네요

캐싱되어서 웹사이트가 멍청이가 된걸까요?? php가 시대 흐름에 역행하는 기분은 머지 아 멘붕

 

레벨업 잘되는지 봐주실 고수님들 도와주세요  double 형 입니다.

|

답변 1개

클래스로 레벨관리해야 할까요??

답변을 작성하려면 로그인이 필요합니다.