update character and community feature
This commit is contained in:
parent
b347931acd
commit
b0b49777a0
6 changed files with 306 additions and 147 deletions
|
|
@ -1,14 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* item class
|
|
||||||
*/
|
|
||||||
require_once __DIR__ . "/item.class.php";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* status class
|
* status class
|
||||||
*/
|
*/
|
||||||
// require_once __DIR__ . "/status.class.php";
|
// require_once __DIR__ . "/status.class.php";
|
||||||
|
/**
|
||||||
|
* item class
|
||||||
|
*/
|
||||||
|
require_once __DIR__ . "/item.class.php";
|
||||||
class Character extends Module
|
class Character extends Module
|
||||||
{
|
{
|
||||||
protected $_rawdata;
|
protected $_rawdata;
|
||||||
|
|
@ -89,7 +87,6 @@ class Character extends Module
|
||||||
}
|
}
|
||||||
$columns = !empty($valid_columns) ? implode(", ", $valid_columns) : "*";
|
$columns = !empty($valid_columns) ? implode(", ", $valid_columns) : "*";
|
||||||
|
|
||||||
// condition 설정
|
|
||||||
$where_conditions = [];
|
$where_conditions = [];
|
||||||
foreach ($condition as $field => $value) {
|
foreach ($condition as $field => $value) {
|
||||||
if (in_array($field, $table_columns)) {
|
if (in_array($field, $table_columns)) {
|
||||||
|
|
@ -103,7 +100,6 @@ class Character extends Module
|
||||||
}
|
}
|
||||||
$where_clause = implode(" AND ", $where_conditions);
|
$where_clause = implode(" AND ", $where_conditions);
|
||||||
|
|
||||||
// 정렬 순서 설정
|
|
||||||
$order_parts = [];
|
$order_parts = [];
|
||||||
foreach ($req_order as $field => $direction) {
|
foreach ($req_order as $field => $direction) {
|
||||||
if (in_array($field, $table_columns)) {
|
if (in_array($field, $table_columns)) {
|
||||||
|
|
@ -116,11 +112,9 @@ class Character extends Module
|
||||||
$limit = "LIMIT {$limit}";
|
$limit = "LIMIT {$limit}";
|
||||||
}
|
}
|
||||||
|
|
||||||
// sql 생성
|
|
||||||
$sql = "SELECT {$columns} FROM {$g5["character_table"]} WHERE {$where_clause} ORDER BY {$order} {$limit}";
|
$sql = "SELECT {$columns} FROM {$g5["character_table"]} WHERE {$where_clause} ORDER BY {$order} {$limit}";
|
||||||
$result = sql_query($sql);
|
$result = sql_query($sql);
|
||||||
|
|
||||||
// 결과 생성
|
|
||||||
while ($row = sql_fetch_array($result)) {
|
while ($row = sql_fetch_array($result)) {
|
||||||
$characters[] = $row;
|
$characters[] = $row;
|
||||||
}
|
}
|
||||||
|
|
@ -128,6 +122,12 @@ class Character extends Module
|
||||||
return $characters;
|
return $characters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* update character (query)
|
||||||
|
* @param string|int $character_id
|
||||||
|
* @param object|array $data
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public static function update($character_id, $data)
|
public static function update($character_id, $data)
|
||||||
{
|
{
|
||||||
global $g5;
|
global $g5;
|
||||||
|
|
@ -147,6 +147,11 @@ class Character extends Module
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* insert character (query)
|
||||||
|
* @param object|array $data
|
||||||
|
* @return int|string|null
|
||||||
|
*/
|
||||||
public static function insert($data)
|
public static function insert($data)
|
||||||
{
|
{
|
||||||
global $g5;
|
global $g5;
|
||||||
|
|
@ -167,6 +172,11 @@ class Character extends Module
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* check character exists
|
||||||
|
* @param string|int $character_id
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public static function exists($character_id)
|
public static function exists($character_id)
|
||||||
{
|
{
|
||||||
global $g5;
|
global $g5;
|
||||||
|
|
@ -179,6 +189,11 @@ class Character extends Module
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delete character
|
||||||
|
* @param string|int $character_id
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public static function delete($character_id)
|
public static function delete($character_id)
|
||||||
{
|
{
|
||||||
global $g5;
|
global $g5;
|
||||||
|
|
@ -213,6 +228,231 @@ class Character extends Module
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get character exp
|
||||||
|
* @param string|int $character_id
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function getCharacterExp($character_id)
|
||||||
|
{
|
||||||
|
global $g5;
|
||||||
|
|
||||||
|
// 포인트합
|
||||||
|
$sql = " select sum(ex_point) as sum_ex_point
|
||||||
|
from {$g5['exp_table']}
|
||||||
|
where ch_id = '$character_id' ";
|
||||||
|
$row = sql_fetch($sql);
|
||||||
|
|
||||||
|
return $row['sum_ex_point'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get character all exp
|
||||||
|
* @param string|int $character_id
|
||||||
|
* @param string|int $amount
|
||||||
|
* @param string $content
|
||||||
|
* @param string $rel_action
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function addCharacterExp($character_id, $amount, $content = "", $rel_action = "")
|
||||||
|
{
|
||||||
|
global $g5;
|
||||||
|
|
||||||
|
if ($amount == 0 || $character_id == '') {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$ch = self::getCharacter($character_id);
|
||||||
|
if (!$ch['ch_id']) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$ch_exp = self::getCharacterExp($character_id);
|
||||||
|
|
||||||
|
$ex_ch_exp = $ch_exp + $amount;
|
||||||
|
$time = G5_TIME_YMDHIS;
|
||||||
|
$purify_content = addslashes($content);
|
||||||
|
|
||||||
|
$sql = "INSERT INTO {$g5['exp_table']} SET
|
||||||
|
ch_id = '{$character_id}',
|
||||||
|
ch_name = '{$ch['ch_name']}',
|
||||||
|
ex_datetime = '{$time}',
|
||||||
|
ex_content = '{$purify_content}',
|
||||||
|
ex_point = '{$amount}',
|
||||||
|
ex_ch_exp = '{$ex_ch_exp}',
|
||||||
|
ex_rel_action = '{$rel_action}' ";
|
||||||
|
sql_query($sql);
|
||||||
|
|
||||||
|
self::update($character_id, ["ch_exp" => intval($ex_ch_exp)]);
|
||||||
|
|
||||||
|
$rank_info = get_rank_exp($ex_ch_exp, $character_id);
|
||||||
|
|
||||||
|
if ($ch['ch_rank'] != $rank_info['rank']) {
|
||||||
|
$state_point = $ch['ch_point'] + $rank_info['add_point'];
|
||||||
|
self::update($character_id, ["ch_rank" => $rank_info['rank'], "ch_point" => $state_point]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get rank name
|
||||||
|
* @param string $rank
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function getRankName($rank)
|
||||||
|
{
|
||||||
|
global $g5;
|
||||||
|
|
||||||
|
$result = sql_fetch("SELECT lv_name FROM {$g5['level_table']} WHERE lv_id = '{$rank}'");
|
||||||
|
|
||||||
|
if ($result) {
|
||||||
|
$str = $result['lv_name'];
|
||||||
|
if (!$str) {
|
||||||
|
$str = '-';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$str = "-";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $str;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get rank id
|
||||||
|
* @param string $rank
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function getRankID($rank)
|
||||||
|
{
|
||||||
|
global $g5;
|
||||||
|
|
||||||
|
$result = sql_fetch("SELECT lv_id FROM {$g5['level_table']} WHERE lv_name = '{$rank}'");
|
||||||
|
|
||||||
|
if ($result) {
|
||||||
|
return $result['lv_id'];
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get rank by character exp
|
||||||
|
* @param string|int $exp_amount
|
||||||
|
* @param string|int $character_id
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getRank($exp_amount, $character_id)
|
||||||
|
{
|
||||||
|
global $g5;
|
||||||
|
|
||||||
|
$ch = self::getDetail($character_id, ["ch_rank"]);
|
||||||
|
|
||||||
|
$level = sql_fetch("SELECT t1.*,
|
||||||
|
(SELECT lv_id FROM {$g5['level_table']} WHERE lv_exp > t1.lv_exp ORDER BY lv_exp ASC LIMIT 1) as next_rank,
|
||||||
|
(SELECT lv_exp FROM {$g5['level_table']} WHERE lv_exp > t1.lv_exp ORDER BY lv_exp ASC LIMIT 1) as next_exp
|
||||||
|
FROM {$g5['level_table']} t1
|
||||||
|
WHERE t1.lv_exp <= {$exp_amount}
|
||||||
|
ORDER BY t1.lv_exp DESC
|
||||||
|
LIMIT 1
|
||||||
|
");
|
||||||
|
|
||||||
|
$ch_rank = sql_fetch("SELECT * FROM {$g5['level_table']} WHERE lv_id = '{$ch['ch_rank']}'");
|
||||||
|
|
||||||
|
$add_status = 0;
|
||||||
|
if ($ch_rank['lv_exp'] != $level['lv_exp']) {
|
||||||
|
$min_exp = min($ch_rank['lv_exp'], $level['lv_exp']);
|
||||||
|
$max_exp = max($ch_rank['lv_exp'], $level['lv_exp']);
|
||||||
|
|
||||||
|
$status_result = sql_fetch("SELECT SUM(lv_add_state) as status
|
||||||
|
FROM {$g5['level_table']}
|
||||||
|
WHERE lv_exp > {$min_exp} AND lv_exp <= {$max_exp}
|
||||||
|
");
|
||||||
|
$add_status = $status_result['status'];
|
||||||
|
|
||||||
|
if ($ch_rank['lv_exp'] > $level['lv_exp']) {
|
||||||
|
$add_status *= -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'rank' => $level['lv_id'],
|
||||||
|
'next_rank' => $level['next_rank'],
|
||||||
|
'add_point' => $add_status,
|
||||||
|
'rest_exp' => $level['next_exp'] ? $level['next_exp'] - $level['lv_exp'] : 0
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get side name
|
||||||
|
* @param string|int $side_id
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function getSideName($side_id)
|
||||||
|
{
|
||||||
|
global $g5;
|
||||||
|
|
||||||
|
$result = sql_fetch("SELECT si_name FROM {$g5['side_table']} WHERE si_id = '{$side_id}'");
|
||||||
|
|
||||||
|
return isset($result['si_name']) ? $result['si_name'] : "-";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get side icon
|
||||||
|
* @param string|int $side_id
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getSideIcon($side_id)
|
||||||
|
{
|
||||||
|
global $g5;
|
||||||
|
|
||||||
|
$result = sql_fetch("SELECT si_img, si_name FROM {$g5['side_table']} WHERE si_id = '{$side_id}'");
|
||||||
|
|
||||||
|
if (isset($result['si_img'])) {
|
||||||
|
$str = "<img src='" . $result['si_img'] . "' alt='" . $result['si_name'] . "' class='ui-side-icon'/>";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $str;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get class name
|
||||||
|
* @param string|int $class_id
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function getClassName($class_id)
|
||||||
|
{
|
||||||
|
global $g5;
|
||||||
|
|
||||||
|
$result = sql_fetch("SELECT cl_name FROM {$g5['class_table']} WHERE cl_id = '{$class_id}'");
|
||||||
|
|
||||||
|
return isset($result['cl_name']) ? $result["cl_name"] : "-";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get class icon
|
||||||
|
* @param string|int $class_id
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getClassIcon($class_id)
|
||||||
|
{
|
||||||
|
global $g5;
|
||||||
|
|
||||||
|
$result = sql_fetch("SELECT cl_img, cl_name FROM {$g5['class_table']} WHERE cl_id = '{$class_id}'");
|
||||||
|
|
||||||
|
if (isset($result['cl_img'])) {
|
||||||
|
return "<img src='" . $result['cl_img'] . "' alt='" . $result['cl_name'] . "' class='ui-class-icon'/>";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set member's main character
|
||||||
|
* @param string|int $member_id
|
||||||
|
* @param string|int $character_id
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public static function setMemberMainCharacter($member_id, $character_id = "")
|
public static function setMemberMainCharacter($member_id, $character_id = "")
|
||||||
{
|
{
|
||||||
global $g5;
|
global $g5;
|
||||||
|
|
@ -221,6 +461,11 @@ class Character extends Module
|
||||||
sql_query($sql);
|
sql_query($sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* character create on admin page
|
||||||
|
* @param object|array $data
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public static function createFromAdminPage($data)
|
public static function createFromAdminPage($data)
|
||||||
{
|
{
|
||||||
global $g5;
|
global $g5;
|
||||||
|
|
@ -231,6 +476,12 @@ class Character extends Module
|
||||||
return ['ch_id' => sql_insert_id()];
|
return ['ch_id' => sql_insert_id()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* character update on admin page
|
||||||
|
* @param string|int $character_id
|
||||||
|
* @param object|array $data
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public static function updateFromAdminPage($character_id, $data)
|
public static function updateFromAdminPage($character_id, $data)
|
||||||
{
|
{
|
||||||
global $g5;
|
global $g5;
|
||||||
|
|
@ -251,18 +502,35 @@ class Character extends Module
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* query with specific columns
|
||||||
|
* @param string $character_name
|
||||||
|
* @param object|array $req_columns
|
||||||
|
* @return array|bool|null
|
||||||
|
*/
|
||||||
public static function getDetailByName($character_name, $req_columns)
|
public static function getDetailByName($character_name, $req_columns)
|
||||||
{
|
{
|
||||||
$character_name = sql_real_escape_string($character_name);
|
$character_name = sql_real_escape_string($character_name);
|
||||||
return self::getDetailWithCondition($req_columns, ["ch_name" => $character_name]);
|
return self::getDetailWithCondition($req_columns, ["ch_name" => $character_name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* query with specific columns
|
||||||
|
* @param string|int $character_id
|
||||||
|
* @param object|array $req_columns
|
||||||
|
* @return array|bool|null
|
||||||
|
*/
|
||||||
public static function getDetail($character_id, $req_columns)
|
public static function getDetail($character_id, $req_columns)
|
||||||
{
|
{
|
||||||
$character_id = intval($character_id);
|
$character_id = intval($character_id);
|
||||||
return self::getDetailWithCondition($req_columns, ["ch_id" => $character_id]);
|
return self::getDetailWithCondition($req_columns, ["ch_id" => $character_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get character images
|
||||||
|
* @param string|int $character_id
|
||||||
|
* @return array|bool|null
|
||||||
|
*/
|
||||||
public static function getImages($character_id)
|
public static function getImages($character_id)
|
||||||
{
|
{
|
||||||
global $g5;
|
global $g5;
|
||||||
|
|
@ -279,7 +547,7 @@ class Character extends Module
|
||||||
/**
|
/**
|
||||||
* get character by character_id
|
* get character by character_id
|
||||||
* note?: this function may cause excessive load on the database.
|
* note?: this function may cause excessive load on the database.
|
||||||
* @param mixed $character_id
|
* @param string|int $character_id
|
||||||
* @return Character|array|object|null
|
* @return Character|array|object|null
|
||||||
*/
|
*/
|
||||||
public static function getCharacter($character_id)
|
public static function getCharacter($character_id)
|
||||||
|
|
@ -298,7 +566,7 @@ class Character extends Module
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get character by character_id (compatilbe name for avocado)
|
* get character by character_id (compatilbe name for avocado)
|
||||||
* @param mixed $character_id
|
* @param string|int $character_id
|
||||||
* @return Character|array|object|null
|
* @return Character|array|object|null
|
||||||
*/
|
*/
|
||||||
public static function get_character($character_id)
|
public static function get_character($character_id)
|
||||||
|
|
@ -308,7 +576,7 @@ class Character extends Module
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get character by name
|
* get character by name
|
||||||
* @param mixed $character_name
|
* @param string $character_name
|
||||||
* @return Character|null
|
* @return Character|null
|
||||||
*/
|
*/
|
||||||
public static function getCharacterByName($character_name)
|
public static function getCharacterByName($character_name)
|
||||||
|
|
@ -325,6 +593,11 @@ class Character extends Module
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get character by name (compatible name for avocado)
|
||||||
|
* @param mixed $character_name
|
||||||
|
* @return Character|null
|
||||||
|
*/
|
||||||
public static function get_character_by_name($character_name)
|
public static function get_character_by_name($character_name)
|
||||||
{
|
{
|
||||||
return self::getCharacterByName($character_name);
|
return self::getCharacterByName($character_name);
|
||||||
|
|
@ -566,6 +839,10 @@ class Character extends Module
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* search count reset (for community feature)
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public static function resetSearchCount()
|
public static function resetSearchCount()
|
||||||
{
|
{
|
||||||
global $g5, $character;
|
global $g5, $character;
|
||||||
|
|
|
||||||
|
|
@ -58,13 +58,6 @@ function del_html($str)
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
function help($help = "")
|
|
||||||
{
|
|
||||||
global $g5;
|
|
||||||
$str = '<span class="frm_info">' . str_replace("\n", "<br>", $help) . '</span>';
|
|
||||||
return $str;
|
|
||||||
}
|
|
||||||
|
|
||||||
function upload_file($srcfile, $destfile, $dir)
|
function upload_file($srcfile, $destfile, $dir)
|
||||||
{
|
{
|
||||||
if ($destfile == "")
|
if ($destfile == "")
|
||||||
|
|
|
||||||
|
|
@ -4,62 +4,10 @@ if (!defined('_GNUBOARD_'))
|
||||||
|
|
||||||
function insert_exp($ch_id, $exp, $content = '', $rel_action = '')
|
function insert_exp($ch_id, $exp, $content = '', $rel_action = '')
|
||||||
{
|
{
|
||||||
global $config;
|
return Character::addCharacterExp($ch_id, $exp, $content, $rel_action);
|
||||||
global $g5;
|
|
||||||
global $is_admin;
|
|
||||||
|
|
||||||
if ($exp == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if ($ch_id == '') {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
$ch = get_character($ch_id);
|
|
||||||
if (!$ch['ch_id']) {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 캐릭터 경험치
|
|
||||||
$ch_exp = get_exp_sum($ch_id);
|
|
||||||
|
|
||||||
// 경험치 건별 생성
|
|
||||||
$ex_ch_exp = $ch_exp + $exp;
|
|
||||||
|
|
||||||
$sql = " insert into {$g5['exp_table']}
|
|
||||||
set ch_id = '$ch_id',
|
|
||||||
ch_name = '{$ch['ch_name']}',
|
|
||||||
ex_datetime = '" . G5_TIME_YMDHIS . "',
|
|
||||||
ex_content = '" . addslashes($content) . "',
|
|
||||||
ex_point = '$exp',
|
|
||||||
ex_ch_exp = '$ex_ch_exp',
|
|
||||||
ex_rel_action = '$rel_action' ";
|
|
||||||
sql_query($sql);
|
|
||||||
|
|
||||||
// 경험치 UPDATE
|
|
||||||
Character::update($ch_id, ["ch_exp" => intval($ex_ch_exp)]);
|
|
||||||
|
|
||||||
$rank_info = get_rank_exp($ex_ch_exp, $ch_id);
|
|
||||||
|
|
||||||
// 기존 랭크에서 변동이 있을 경우에만 실행
|
|
||||||
if ($ch['ch_rank'] != $rank_info['rank']) {
|
|
||||||
$state_point = $ch['ch_point'] + $rank_info['add_point'];
|
|
||||||
// 스탯 포인트 변동 사항 및 랭크 변동사항 저장
|
|
||||||
Character::update($ch_id, ["ch_rank" => $rank_info['rank'], "ch_point" => $state_point]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 경험치 내역 합계
|
|
||||||
function get_exp_sum($ch_id)
|
function get_exp_sum($ch_id)
|
||||||
{
|
{
|
||||||
global $g5, $config;
|
return Character::getCharacterExp($ch_id);
|
||||||
|
|
||||||
// 포인트합
|
|
||||||
$sql = " select sum(ex_point) as sum_ex_point
|
|
||||||
from {$g5['exp_table']}
|
|
||||||
where ch_id = '$ch_id' ";
|
|
||||||
$row = sql_fetch($sql);
|
|
||||||
|
|
||||||
return $row['sum_ex_point'];
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,50 +4,15 @@ if (!defined('_GNUBOARD_'))
|
||||||
|
|
||||||
function get_rank_name($rank)
|
function get_rank_name($rank)
|
||||||
{
|
{
|
||||||
global $g5;
|
return Character::getRankName($rank);
|
||||||
$str = "";
|
|
||||||
$result = sql_fetch("SELECT lv_name FROM {$g5['level_table']} where lv_id = '{$rank}'");
|
|
||||||
$str = $result['lv_name'];
|
|
||||||
if (!$str) {
|
|
||||||
$str = '-';
|
|
||||||
}
|
|
||||||
return $str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_rank_id($rank)
|
function get_rank_id($rank)
|
||||||
{
|
{
|
||||||
global $g5;
|
return Character::getRankID($rank);
|
||||||
$str = "";
|
|
||||||
$result = sql_fetch("SELECT lv_id FROM {$g5['level_table']} where lv_name = '{$rank}'");
|
|
||||||
$str = $result['lv_id'];
|
|
||||||
return $str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_rank_exp($exp, $ch_id)
|
function get_rank_exp($exp, $ch_id)
|
||||||
{
|
{
|
||||||
global $g5;
|
return Character::getRank($exp, $ch_id);
|
||||||
$result = [];
|
|
||||||
|
|
||||||
$ch = Character::getDetail($ch_id, ["ch_rank"]);
|
|
||||||
|
|
||||||
$ch_rank = sql_fetch("SELECT * FROM {$g5['level_table']} where lv_id = '{$ch['ch_rank']}'");
|
|
||||||
|
|
||||||
$level = sql_fetch("SELECT * FROM {$g5['level_table']} where lv_exp <= {$exp} ORDER BY lv_exp DESC limit 0, 1");
|
|
||||||
$n_level = sql_fetch("SELECT * FROM {$g5['level_table']} where lv_exp >= {$level['lv_exp']} ORDER BY lv_exp ASC limit 0, 1");
|
|
||||||
|
|
||||||
if ($ch_rank['lv_exp'] < $level['lv_exp']) {
|
|
||||||
$add_status = sql_fetch("SELECT SUM(lv_add_state) as status FROM {$g5['level_table']} where lv_exp > '{$ch_rank['lv_exp']}' and lv_exp <= '{$level['lv_exp']}'");
|
|
||||||
$add_status = $add_status['status'];
|
|
||||||
|
|
||||||
} else if ($ch_rank['lv_exp'] > $level['lv_exp']) {
|
|
||||||
$add_status = sql_fetch("SELECT SUM(lv_add_state) as status FROM {$g5['level_table']} where lv_exp <= '{$ch_rank['lv_exp']}' and lv_exp > '{$level['lv_exp']}'");
|
|
||||||
$add_status = $add_status['status'] * -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
$result['rank'] = $level['lv_id'];
|
|
||||||
$result['next_rank'] = $n_level['lv_id'];
|
|
||||||
$result['add_point'] = $add_status;
|
|
||||||
$result['rest_exp'] = ($n_level ? $n_level['lv_exp'] - $level['lv_exp'] : 0);
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,52 +4,21 @@ if (!defined('_GNUBOARD_'))
|
||||||
|
|
||||||
function get_side_name($si_id)
|
function get_side_name($si_id)
|
||||||
{
|
{
|
||||||
global $g5;
|
return Character::getSideName($si_id);
|
||||||
$result = sql_fetch("select si_name from {$g5['side_table']} where si_id = '{$si_id}'");
|
|
||||||
|
|
||||||
$str = $result['si_name'];
|
|
||||||
if (!$str)
|
|
||||||
$str = '-';
|
|
||||||
|
|
||||||
return $str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_class_name($cl_id)
|
function get_class_name($cl_id)
|
||||||
{
|
{
|
||||||
global $g5;
|
return Character::getClassName($cl_id);
|
||||||
$result = sql_fetch("select cl_name from {$g5['class_table']} where cl_id = '{$cl_id}'");
|
|
||||||
|
|
||||||
$str = $result['cl_name'];
|
|
||||||
if (!$str)
|
|
||||||
$str = '-';
|
|
||||||
|
|
||||||
return $str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_side_icon($si_id)
|
function get_side_icon($si_id)
|
||||||
{
|
{
|
||||||
global $g5;
|
return Character::getSideIcon($si_id);
|
||||||
$str = "";
|
|
||||||
$side_url = G5_DATA_URL . "/side";
|
|
||||||
$result = sql_fetch("select si_img, si_name from {$g5['side_table']} where si_id = '{$si_id}'");
|
|
||||||
|
|
||||||
if ($result['si_img']) {
|
|
||||||
$str = "<img src='" . $result['si_img'] . "' alt='" . $result['si_name'] . "' class='ui-side-icon'/>";
|
|
||||||
}
|
|
||||||
|
|
||||||
return $str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_class_icon($cl_id)
|
function get_class_icon($cl_id)
|
||||||
{
|
{
|
||||||
global $g5;
|
return Character::getClassIcon($cl_id);
|
||||||
$str = "";
|
|
||||||
$class_url = G5_DATA_URL . "/class";
|
|
||||||
|
|
||||||
$result = sql_fetch("select cl_img, cl_name from {$g5['class_table']} where cl_id = '{$cl_id}'");
|
|
||||||
if ($result['cl_img']) {
|
|
||||||
$str = "<img src='" . $result['cl_img'] . "' alt='" . $result['cl_name'] . "' class='ui-class-icon'/>";
|
|
||||||
}
|
|
||||||
return $str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3538,3 +3538,10 @@ function get_random_token_string($length = 6)
|
||||||
|
|
||||||
return bin2hex($randomString);
|
return bin2hex($randomString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function help($help = "")
|
||||||
|
{
|
||||||
|
global $g5;
|
||||||
|
$str = '<span class="frm_info">' . str_replace("\n", "<br>", $help) . '</span>';
|
||||||
|
return $str;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue