<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가

function chk_xp_num($point, $xp_point, $max_level, $xp_rate='0') {

	$info = array();

	if(!$xp_rate) $xp_rate = 0;

	if(!$point || $point < 0 || !is_numeric($point)) $point = 0;

	if(!$point || $point < $xp_point) {
		$level = 1;
		$max_xp = $xp_point;
		$min_xp = 0;
	} else {
		$min_xp = $xp_point;
		for ($i=2; $i <= $max_level; $i++) {
			$xp_plus = $xp_point + $xp_point * ($i - 1) * $xp_rate;
			$max_xp = $min_xp + $xp_plus;
			if($point < $max_xp) {
				$level = $i;
				break;
			}
			$min_xp = $max_xp;
		}

		if(($i - 1) == $max_level) {
			$level = $max_level;
			$min_xp = $point;
			$max_xp = $point;
		}
	}

	$info = array($level, $point, $min_xp, $max_xp);
	
	return $info;
}

?>