테스트 사이트 - 개발 중인 베타 버전입니다

[나리야 전용] 경험치 계산이 제대로 안되서 특정% 로 시작할때 #수정1

간장게장같은남자
· 9개월 전 · 481

나리야 경험치 레벨 1 이상일때 $exp 가 이상하게 출력되는 버그를 임시방편으로 수정할 수 있는 방법입니다.

 

나리야에서 직전 레벨 경험치 필드 하나 생성해주면 될텐데 관리자님이 귀찮아 하시는 관계로..

글쓸곳도 마땅히 없고 아미나 사이트에 올리기에는 아닌거같고 우선 이용하시는분 계실까봐..
나리야 직전 레벨 경험치 업데이트를 바라며.. #1트


업체쪽에서 문의들어와서 급하게 수정하긴 했는데 잠결에 대충한 무식한 자료라 이해바랍니다. 

설정되는 레벨업 포인트 na[xp_point] 가 어디있는지 아무리 찾아도 안나오네요.


## 1. 테이블 생성

CREATE TABLE `exp_list` (
  `idx` int(11) NOT NULL,
  `min_exp` int(11) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

## 2. /nariya/extend/membership/exp.php 파일을 아래와 같이 수정

[code]

<?php
define('G5_IS_ADMIN', true);
include_once('./_common.php');

if ($is_admin != 'super')
    alert_close('최고관리자만 접근 가능합니다.');

$g5['title'] = '레벨업 경험치 시뮬레이터';
include_once(G5_PATH.'/head.sub.php');

if(!isset($opt) || !$opt) {
    $xp_point = isset($nariya['xp_point']) ? $nariya['xp_point'] : '';
    $xp_max = isset($nariya['xp_max']) ? $nariya['xp_max'] : '';
    $xp_rate = isset($nariya['xp_rate']) ? $nariya['xp_rate'] : '';
}

sql_query("truncate table exp_list");
sql_query("INSERT INTO `exp_list` (`idx`, `min_exp`) VALUES ('1', '0');");
?>

<div id="menu_frm" class="new_win" style="background:#fff;">
    <h1><?php echo $g5['title']; ?></h1>

    <div class="local_desc01">
        레벨업 경험치 = 기준 경험치 + 기준 경험치 * 직전 레벨 * 경험치 증가율(배)
    </div>

    <form id="expform" name="expform" method="post" style="padding:0 10px;">
    <input type="hidden" name="opt" value="exp">

    <div class="tbl_head01 tbl_wrap">
    <table>
    <thead>
    <tr>
        <th scope="col">최대 레벨</th>
        <th scope="col">기준 경험치</th>
        <th scope="col">경험치 증가율(배)</th>
    </tr>
    </thead>
    <tbody>
    <tr>
    <td><input type=text size=10 id="xp_max" name="xp_max" value="<?php echo $xp_max ?>" class="frm_input" required></td>
    <td><input type=text size=10 id="xp_point" name="xp_point" value="<?php echo $xp_point ?>" class="frm_input" required></td>
    <td><input type=text size=10 id="xp_rate" name="xp_rate" value="<?php echo $xp_rate ?>" class="frm_input" required></td>
    </tr>
    </tbody>
    </table>

    <br>

    <div class="btn_win02 btn_win">
        <input type="submit" value="시뮬레이션" class="btn_submit btn" accesskey="s">
        <button type="button" class="btn_02 btn" onclick="window.close();">창닫기</button>
    </div>

    <br>

    <div class="tbl_head01 tbl_wrap">
    <table>
    <thead>
    <tr>
        <th scope="col">레벨</th>
        <th scope="col">최소 경험치</th>
        <th scope="col">최대 경험치</th>
        <th scope="col">레벨업 경험치</th>
        <th scope="col">비고</th>
    </tr>
    </thead>
    <tbody>
    <tr>
    <td>1</td>
    <td>0</td>
    <td><?php echo number_format((int)$xp_point); ?></td>
    <td><?php echo number_format((int)$xp_point); ?></td>
    <td></td>
    </tr>
    <?php
        $min_xp = $xp_point;
        for ($i=2; $i <= $xp_max; $i++) {
            $xp_plus = $xp_point + $xp_point * ($i - 1) * $xp_rate;
            $max_xp = $min_xp + $xp_plus;
            sql_query("INSERT INTO `exp_list` (`idx`, `min_exp`) VALUES ('".$i."', '".$min_xp."');");
    ?>
        <tr>
        <td><?php echo $i; ?></td>
        <td><?php echo number_format((int)$min_xp); ?></td>
        <td><?php echo number_format((int)$max_xp); ?></td>
        <td><?php echo number_format((int)$xp_plus); ?></td>
        <td>&nbsp;</td>
        </tr>
    <?php $min_xp = $max_xp; } ?>
    </table>

    <br>

    <div class="btn_win02 btn_win">
        <input type="submit" value="시뮬레이션" class="btn_submit btn" accesskey="s">
        <button type="button" class="btn_02 btn" onclick="window.close();">창닫기</button>
    </div>

    <br>

    </form>
</div>

<?php 
include_once(G5_PATH.'/tail.sub.php');


[/code]

 

이러면 시뮬레이터 열때마다 디비가 비워지고 다시 생성됩니다.

 

 

## 3. 위젯 백분률 계산식 수정

 

/theme/테마명/widget/sidebar/user.php 또는 그래프가 있는 소스에 "멤버쉽 플러그인" 이라고 주석이 된 부분이 있을텐데 IS_NA_XP 아래 내용 2줄있는것을 아래와 같이 바꿔줍니다.

 

[code]

//2025-01-18 수정

$member['as_max'] = (isset($member['as_max']) && $member['as_max'] > 0) ? $member['as_max'] : 1;
$bfLevel = $member['as_level'];
$explist = sql_fetch("select * from exp_list where idx = ".$bfLevel);

$next_level_exp = (int)($member['as_max']-$explist['min_exp']);
$this_exp = (int)($member['as_exp']-$explist['min_exp']);

//일부값 ÷ 전체값 X 100
$per = (int)(($this_exp/$next_level_exp) * 100);


[/code]

 

능력자가 나타나주시거나 이거와 관련되어 해결된 게시물이 있으면 삭제하겠습니다.

쿼리가 하나 추가되어 방식은 무식하지만 필요하신분을 위해..

 

뭐 잘만 돌아가면 되는거 아니겠습니까

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

게시글 목록

번호 제목
23606
23598
23585
23579
23578
23564
23550
23549
23548
23529
23510
23507
23481
23471
23453
23452
23450
23436
23428
23404
23396
23389
23380
23369
23350
23337
23317
23307
23298
23290