Merge branch 'devel' into siegetank

This commit is contained in:
2019-05-05 15:59:10 +09:00
7 changed files with 373 additions and 22 deletions
+11 -6
View File
@@ -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;
}
+12 -7
View File
@@ -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;
}
+109
View File
@@ -0,0 +1,109 @@
<?php
namespace sammo;
include "lib.php";
include "func.php";
//로그인 검사
$session = Session::requireLogin();
$userID = Session::getUserID();
$db = DB::db();
$withToken = Util::getReq('with_token', 'bool', false);
$gameStor = KVStorage::getStorage($db, 'game_env');
if($session->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('PT10S'))->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'],
getGenSpecial($special),
getGenSpecial($special2),
getGenChar($personal),
$name,
$name2,
$injury,
$leader,
$lbonus,
$power,
$intel,
getExpLevel($experience),
getHonor($experience),
getDed($dedication),
getLevel($level, $nationArr['level']),
$killturn,
$connect
];
}
$result = [
'result'=>'true',
'list'=>$generalList,
];
if($withToken){
$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);
+3 -1
View File
@@ -90,9 +90,11 @@ if($token && !$refresh){
$candidates = [];
$weight = [];
foreach($db->query('SELECT `no`, `name`, leader, power, intel, imgsvr, picture, special, special2 FROM general WHERE npc=2') as $general){
foreach($db->query('SELECT `no`, `name`, leader, power, nation, personal, intel, imgsvr, picture, special, special2 FROM general WHERE npc=2') as $general){
$general['special'] = \sammo\SpecialityConst::DOMESTIC[$general['special']][0]??'-';
$general['special2'] = \sammo\SpecialityConst::WAR[$general['special2']][0]??'-';
$general['personal'] = getGenChar($general['personal']);
$general['nation'] = getNationStaticInfo($general['nation'])['name'];
$candidates[$general['no']] = $general + ['keepCnt'=>KEEP_CNT];
$allStat = $general['leader'] + $general['power'] + $general['intel'];
$weight[$general['no']] = pow($allStat, 1.5);
+194 -2
View File
@@ -3,8 +3,10 @@ var templateGeneralCard =
<h4 class="bg1 with_border"><%name%></h4>\
<h4><img src="<%iconPath%>" height=64 width=64></h4>\
<p><%leader%> / <%power%> / <%intel%><br>\
<%nation%><br>\
<%personalText%><br>\
<%specialText%> / <%special2Text%></p>\
<button type="subject" class="with_skin with_border select_btn" value="<%no%>" name="pick">빙의하기</button>\
<button type="subject" class="with_skin with_border select_btn" data-name="<%name%>" value="<%no%>" name="pick">빙의하기</button>\
<label><input <%keepCnt?"":disabled="disabled"%> type="checkbox" value="<%no%>" name="keep[]" class="keep_select">보관(<%keepCnt%>회)</label>\
</div>';
@@ -16,9 +18,32 @@ var templateSpecial =
</span>\
';
var templateGeneralRow =
'<tr>\
<td><img class="generalIcon" width="64" height="64" src="<%iconPath%>"></td>\
<td style="<%userCSS%>"><%name%><%nameAux%></td>\
<td><%age%>세</td>\
<td><%personalWithTooltip%></td>\
<td><%specialDomesticWithTooltip%> / <%speicalWarWithTooltip%></td>\
<td>Lv <%explevel%></td>\
<td><%nation%></td>\
<td><%experience%></td>\
<td><%dedication%></td>\
<td><%level%></td>\
<td><%total%></td>\
<td><%leader%></td>\
<td><%power%></td>\
<td><%intel%></td>\
<td><%killturn%></td>\
</tr>';
function pickGeneral(){
$btn = $(this);
if (!confirm('빙의할까요? : {0}'.format($btn.data('name')))) {
return false;
}
$.post({
url:'j_select_npc.php',
dataType:'json',
@@ -112,10 +137,19 @@ function printGenerals(value){
else{
cardData.special2Text = cardData.special2;
}
if(cardData.personal in characterInfo){
cardData.personalText = TemplateEngine(templateSpecial, {
text:cardData.personal,
info:characterInfo[cardData.personal]
});
}
else{
cardData.personalText = cardData.personal;
}
var $card = $(TemplateEngine(templateGeneralCard, cardData));
console.log($card);
$('.card_holder').append($card);
$card.find('.select_btn').click(pickGeneral);
@@ -131,7 +165,145 @@ function printGenerals(value){
updateOutdateTimer();
}
function printGeneralList(value){
var tokenList = value.token;
var generalList = $.map(value.list, function(general){
general = {
no:general[0],
picture:general[1],
imgsvr:general[2],
npc:general[3],
age:general[4],
nation:general[5],
special:general[6],
special2:general[7],
personal:general[8],
name:general[9],
name2:general[10],
injury:general[11],
leader:general[12],
lbonus:general[13],
power:general[14],
intel:general[15],
explevel:general[16],
experience:general[17],
dedication:general[18],
level:general[19],
killturn:general[20],
connect:general[21],
reserved:0
};
if(general.npc < 2){
general.reserved = 2;
}
if(general.no in tokenList){
general.reserved = 1;
}
general.userCSS = "";
general.nameAux = "";
if(general.reserved == 1){
general.userCSS = 'color:violet';
}
else if(general.npc >= 2){
general.userCSS = 'color:cyan';
}
else if(general.npc == 1){
general.userCSS = 'color:skyblue';
}
if(general.name2){
general.nameAux += '<br><small>({0})</small>'.format(general.name2);
}
if(general.reserved == 1){
general.nameAux += '<br><small>({0}회)</small>'.format(tokenList[general.no]);
}
general.total = general.leader + general.power + general.intel;
general.iconPath = getIconPath(general.imgsvr, general.picture);
general.specialDomesticWithTooltip = TemplateEngine(templateSpecial, {
text:general.special,
info:specialInfo[general.special]
});
general.speicalWarWithTooltip = TemplateEngine(templateSpecial, {
text:general.special2,
info:specialInfo[general.special2]
});
general.personalWithTooltip = TemplateEngine(templateSpecial, {
text:general.personal,
info:characterInfo[general.personal]
});
return general;
});
generalList.sort(function(lhs, rhs){
if(lhs.reserved > rhs.reserved){
return -1;
}
if(lhs.reserved < rhs.reserved){
return 1;
}
if(lhs.total != rhs.total){
return rhs.total - lhs.total;
}
if(lhs.leader != rhs.leader){
return rhs.leader - lhs.total;
}
if(lhs.name < rhs.name){
return -1;
}
if(lhs.name > rhs.name){
return 1;
}
return 0;
});
window.generalList = generalList;
_printGeneralList(true);
}
function _printGeneralList(clear){
var $generalTable = $('#general_list');
if(clear){
$generalTable.empty();
$generalTable.data('lastIdx', 0);
$('#row_print_more').show();
}
generalList = window.generalList;
var idxFrom = $generalTable.data('lastIdx');
var idxTo = Math.min(idxFrom + 50, generalList.length);
$generalTable.data('lastIdx', idxTo);
for(var idx = idxFrom; idx < idxFrom + 50; idx++){
var general = generalList[idx];
$generalTable.append(TemplateEngine(templateGeneralRow, general));
}
if(idxTo == generalList.length){
$('#row_print_more').hide();
}
$generalTable.find('.obj_tooltip').tooltip({
title:function(){
return $.trim($(this).find('.tooltiptext').html());
},
html:true
});
$('#tb_general_list').show();
}
$(function($){
window.generalList = [];
$.post('j_get_select_npc_token.php').then(function(value){
if(!value.result){
@@ -165,4 +337,24 @@ $('#btn_pick_more').click(function(){
});
});
$('#btn_load_general_list').click(function(){
$.post({
url:'j_get_general_list.php',
dataType:'json',
data:{
with_token:true
}
}).then(function(result){
if(!result.result){
alert(result.reason);
return false;
}
printGeneralList(result);
});
});
$('#btn_print_more').click(function(){
_printGeneralList();
})
});
+43 -5
View File
@@ -26,7 +26,7 @@ $nationList = $db->query('SELECT nation,`name`,color,scout,scoutmsg FROM nation
<title><?=UniqueConst::$serverName?>: NPC빙의</title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=1024" />
<meta name="viewport" content="style='width:1024" />
<?=WebUtil::printCSS('../e_lib/bootstrap.min.css')?>
<?=WebUtil::printCSS('../d_shared/common.css')?>
<?=WebUtil::printCSS('../css/config.css')?>
@@ -50,7 +50,16 @@ foreach (SpecialityConst::WAR as $id=>$values) {
$specialAll['-'] = '없음';
echo Json::encode($specialAll);
?>
;
;
var characterInfo =
<?php
$characterAll = [];
foreach(getCharacterList() as $id=>[$name, $info]){
$characterAll[$name] = $info;
}
echo Json::encode($characterAll);
?>
;
</script>
<?=WebUtil::printJS('../d_shared/common_path.js')?>
@@ -63,7 +72,7 @@ echo Json::encode($specialAll);
<?php
if ($gencount >= $maxgeneral) {
if ($gencount>= $maxgeneral) {
?>
<body>
@@ -93,9 +102,38 @@ history.go(-1);
<form class="card_holder">
</form>
</div>
<div class="with_border legacy_layout" style="text-align:center">
<button id="btn_pick_more" disabled="disabled" class="with_skin with_border">다른 장수 보기</button><br>
<div class="with_border legacy_layout" style="text-align:center; padding-top:20px; padding-bottom:20px;">
<button type="button" id="btn_pick_more" disabled="disabled" class="with_skin with_border">다른 장수 보기</button><button type="button" id="btn_load_general_list" class="with_skin with_border" style='margin-left:2ch;'>장수 목록 보기</button><br>
</div>
<table style='width:970px;table-layout: fixed;display:none; margin-bottom:20px;' class="tb_layout bg0" id='tb_general_list'>
<thead>
<tr class='bg1'>
<th style='width:64px;'>얼 굴</td>
<th style='width:140px;'>이 름</td>
<th style='width:40px;'>연령</td>
<th style='width:40px;'>성격</td>
<th style='width:80px;'>특기</td>
<th style='width:45px;'>레 벨</td>
<th style='width:140px;'>국 가</td>
<th style='width:50px;'>명 성</td>
<th style='width:50px;'>계 급</td>
<th style='width:75px;'>관 직</td>
<th style='width:60px;'>종능</td>
<th style='width:45px;'>통솔</td>
<th style='width:45px;'>무력</td>
<th style='width:45px;'>지력</td>
<th style='width:45px;'>삭턴</td>
</tr>
</thead>
<tbody id='general_list'>
</tbody>
<tfoot id='row_print_more' style='display:none;'>
<tr>
<td colspan="15"><button type="button" class="with_skin with_border" id="btn_print_more" style="width:100%;">장수 더 보기</button></td>
</tr>
</tfoot>
</table>
<div class="with_border legacy_layout"><?=backButton()?></div>
<div class="with_border legacy_layout"><?=banner()?></div>
</div>
+1 -1
View File
@@ -36,7 +36,7 @@ var serverCreateTemplate = "\
";
var serverLoginTemplate = "\
<td style='background:url(<%picture%>);background-size: 64px 64px;'></td>\
<td style='background:url(\"<%picture%>\");background-size: 64px 64px;'></td>\
<td><%name%></td>\
<td class='ignore_border'>\
<a href='<%serverPath%>/'><button class='general_login with_skin'>입장</button></a>\