From b3fb20df580f73c030cd7cf3dc794e645f5cee67 Mon Sep 17 00:00:00 2001 From: hide_d Date: Sat, 4 May 2019 18:33:09 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9E=A5=EC=88=98=EC=9D=BC=EB=9E=8C=20API=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func_converter.php | 17 +++--- hwe/func_process.php | 19 ++++--- hwe/j_get_general_list.php | 108 +++++++++++++++++++++++++++++++++++++ hwe/select_npc.php | 11 +++- 4 files changed, 141 insertions(+), 14 deletions(-) create mode 100644 hwe/j_get_general_list.php diff --git a/hwe/func_converter.php b/hwe/func_converter.php index f780cd9a..695bcb1a 100644 --- a/hwe/func_converter.php +++ b/hwe/func_converter.php @@ -174,13 +174,10 @@ function getGenSpecial($type) { return $call; } -function getSpecialInfo(?int $type):?string{ - if($type === null){ - return null; - } - +function getSpecialTextList():array{ + //앞칸은 '설명을 위해' '그냥' 적어둠 - $infoText = [ + return [ 0 => ['-', null], 1 => ['경작', '[내정] 농지 개간 : 기본 보정 +10%, 성공률 +10%p, 비용 -20%'], 2 => ['상재', '[내정] 상업 투자 : 기본 보정 +10%, 성공률 +10%p, 비용 -20%'], @@ -219,6 +216,14 @@ function getSpecialInfo(?int $type):?string{ 74 => ['격노', '[전투] 상대방 필살 및 회피 시도시 일정 확률로 격노(필살) 발동, 공격 시 일정 확률로 진노(1페이즈 추가)'], 75 => ['척사', '[전투] 지역·도시 병종 상대로 대미지 +10%, 아군 피해 -10%'] ]; +} + +function getSpecialInfo(?int $type):?string{ + if($type === null){ + return null; + } + + $infoText = getSpecialTextList(); return $infoText[$type][1]??null; } diff --git a/hwe/func_process.php b/hwe/func_process.php index 20e4f07f..6f197759 100644 --- a/hwe/func_process.php +++ b/hwe/func_process.php @@ -159,6 +159,17 @@ function CriticalRatioDomestic(&$general, $type) { ); } +function calcLeadershipBonus($generalLevel, $nationLevel):int{ + if($generalLevel == 12) { + $lbonus = $nationLevel * 2; + } elseif($generalLevel >= 5) { + $lbonus = $nationLevel; + } else { + $lbonus = 0; + } + return $lbonus; +} + /** * 수뇌직 통솔 보너스 계산 * @@ -168,13 +179,7 @@ function CriticalRatioDomestic(&$general, $type) { * @return int 계산된 $general['lbonus'] 값 */ function setLeadershipBonus(&$general, $nationLevel){ - if($general['level'] == 12) { - $lbonus = $nationLevel * 2; - } elseif($general['level'] >= 5) { - $lbonus = $nationLevel; - } else { - $lbonus = 0; - } + $lbonus = calcLeadershipBonus($general['level'], $nationLevel); $general['lbonus'] = $lbonus; return $lbonus; } diff --git a/hwe/j_get_general_list.php b/hwe/j_get_general_list.php new file mode 100644 index 00000000..76a3ac9d --- /dev/null +++ b/hwe/j_get_general_list.php @@ -0,0 +1,108 @@ +isGameLoggedIn()){ + increaseRefresh("장수일람", 2); + + $me = $db->queryFirstRow('SELECT con, turntime FROM general WHERE owner=%i', $userID); + $con = checkLimit($me['con']); + if ($con >= 2) { + Json::die([ + 'result'=>false, + 'reason'=>'접속 제한중입니다. 1턴 이내에 너무 많은 갱신을 하셨습니다.' + ]); + } +} +else{ + $availableNextCall = $session->availableNextCallGetGeneralList??'2000-01-01 00:00:00'; + $now = new \DateTimeImmutable(); + + if($now <= new \DateTimeImmutable($availableNextCall) && $session->userGrade < 5){ + Json::die([ + 'result'=>false, + 'reason'=>"장수 리스트는 10초에 한번 갱신 가능합니다.\n다음 시간 : ".$availableNextCall + ]); + } + + $availableNextCall = $now->add(new \DateInterval('PT1S'))->format('Y-m-d H:i:s'); + $session->availableNextCallGetGeneralList = $availableNextCall; +} + +$session->setReadOnly(); + +$rawGeneralList = $db->queryAllLists('SELECT owner,no,picture,imgsvr,npc,age,nation,special,special2,personal,name,name2,injury,leader,power,intel,experience,dedication,level,killturn,connect from general'); + +$ownerNameList = []; +if($gameStor->isunited){ + foreach(RootDB::db()->queryAllLists('SELECT no, name FROM member') as [$ownerID, $ownerName]){ + $ownerNameList[$ownerID] = $ownerName; + } +} + +$generalList = []; +foreach($rawGeneralList as $rawGeneral){ + [$owner,$no,$picture,$imgsvr,$npc,$age,$nation,$special,$special2,$personal,$name,$name2,$injury,$leader,$power,$intel,$experience,$dedication,$level,$killturn,$connect] = $rawGeneral; + + if(key_exists($owner, $ownerNameList)){ + $name2 = $ownerNameList[$owner]; + } + + $nationArr = getNationStaticInfo($nation); + $lbonus = calcLeadershipBonus($level, $nationArr['level']); + + $generalList[] = [ + $no, + $picture, + $imgsvr, + $npc, + $age, + $nationArr['name'], + SpecCall($special), + SpecCall($special2), + getGenChar($personal), + $name, + $name2, + $leader, + $lbonus, + $power, + $intel, + getHonor($experience), + getDed($dedication), + getLevel($level, $nationArr['level']), + $killturn, + $connect + ]; +} + +$result = [ + 'result'=>'true', + 'list'=>$generalList, +]; + +if($withToken){ + $result['list'][] ='aserasdrgtlkjsdrgltjsrdt1!!!!!!!!!!!!!!!!!!'; + $now = (new \DateTimeImmutable())->format('Y-m-d H:i:s'); + $tokens = []; + foreach($db->query('SELECT * FROM select_npc_token WHERE `valid_until`>=%s', $now) as $token){ + $validUntil = $token['valid_until']; + + foreach(Json::decode($token['pick_result']) as $pickResult){ + $tokens[$pickResult['no']]=$pickResult['keepCnt']; + } + } + $result['token'] = $tokens; +} + +Json::die($result); diff --git a/hwe/select_npc.php b/hwe/select_npc.php index 979bbf62..fef164d7 100644 --- a/hwe/select_npc.php +++ b/hwe/select_npc.php @@ -50,7 +50,16 @@ foreach (SpecialityConst::WAR as $id=>$values) { $specialAll['-'] = '없음'; echo Json::encode($specialAll); ?> -; +; +var characterInfo = +[$name, $info]){ + $characterAll[$name] = $info; +} +echo Json::encode($characterAll); +?> +;