forked from devsam/core
warning 수정
This commit is contained in:
+215
-215
@@ -1,215 +1,215 @@
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
|
||||
$type = Util::getReq('type', 'int', 9);
|
||||
|
||||
//로그인 검사
|
||||
$session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
increaseRefresh("장수일람", 2);
|
||||
|
||||
$me = $db->queryFirstRow('SELECT con,turntime FROM general WHERE owner = %i', $userID);
|
||||
|
||||
$con = checkLimit($me['con']);
|
||||
if ($con >= 2) {
|
||||
printLimitMsg($me['turntime']);
|
||||
exit();
|
||||
}
|
||||
|
||||
if ($type <= 0 || $type > 15) {
|
||||
$type = 9;
|
||||
}
|
||||
|
||||
$ownerNameList = [];
|
||||
if($gameStor->isunited){
|
||||
foreach(RootDB::db()->queryAllLists('SELECT no, name FROM member') as [$ownerID, $ownerName]){
|
||||
$ownerNameList[$ownerID] = $ownerName;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=1024" />
|
||||
<title><?=UniqueConst::$serverName?>: 장수일람</title>
|
||||
<?=WebUtil::printCSS('../e_lib/bootstrap.min.css')?>
|
||||
<?=WebUtil::printCSS('../d_shared/common.css')?>
|
||||
<?=WebUtil::printCSS('css/common.css')?>
|
||||
<?=WebUtil::printJS('../e_lib/jquery-3.3.1.min.js')?>
|
||||
<?=WebUtil::printJS('../e_lib/bootstrap.bundle.min.js')?>
|
||||
<?=WebUtil::printJS('../d_shared/common_path.js')?>
|
||||
<?=WebUtil::printJS('js/common.js')?>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<table align=center width=1000 class='tb_layout bg0'>
|
||||
<tr><td>장 수 일 람<br><?=closeButton()?></td></tr>
|
||||
<tr><td><form name=form1 method=post>정렬순서 :
|
||||
<select id='viewType' name='type' size=1>
|
||||
<option value=1>국가</option>
|
||||
<option value=2>통솔</option>
|
||||
<option value=3>무력</option>
|
||||
<option value=4>지력</option>
|
||||
<option value=5>명성</option>
|
||||
<option value=6>계급</option>
|
||||
<option value=7>관직</option>
|
||||
<option value=8>삭턴</option>
|
||||
<option value=9>벌점</option>
|
||||
<option value=10>Lv</option>
|
||||
<option value=11>성격</option>
|
||||
<option value=12>내특</option>
|
||||
<option value=13>전특</option>
|
||||
<option value=14>연령</option>
|
||||
<option value=15>NPC</option>
|
||||
</select>
|
||||
<input type=submit value='정렬하기'></form>
|
||||
</td></tr>
|
||||
</table>
|
||||
<?php
|
||||
$nationname = [];
|
||||
$nationlevel = [];
|
||||
$nationname[0] = "-";
|
||||
foreach (getAllNationStaticInfo() as $nation) {
|
||||
$nationname[$nation['nation']] = $nation['name'];
|
||||
$nationlevel[$nation['nation']] = $nation['level'];
|
||||
}
|
||||
|
||||
|
||||
[$orderKey, $orderDesc] = [
|
||||
1=>['nation', false],
|
||||
2=>['leadership', true],
|
||||
3=>['strength', true],
|
||||
4=>['intel', true],
|
||||
5=>['experience', true],
|
||||
6=>['dedication', true],
|
||||
7=>['officer_level', true],
|
||||
8=>['killturn', false],
|
||||
9=>['connect', true],
|
||||
10=>['experience', true],
|
||||
11=>['personal', true],
|
||||
12=>['special', true],
|
||||
13=>['special2', true],
|
||||
14=>['age', true],
|
||||
15=>['npc', true],
|
||||
][$type];
|
||||
|
||||
$generalList = $db->query('SELECT owner,no,picture,imgsvr,npc,age,nation,special,special2,personal,name,injury,leadership,strength,intel,experience,dedication,officer_level,killturn,connect from general order by %b %l', $orderKey, $orderDesc?'desc':'');
|
||||
|
||||
echo"
|
||||
<table align=center width=1000 class='tb_layout bg0'>
|
||||
<tr>
|
||||
<td width=64 align=center id=bg1>얼 굴</td>
|
||||
<td width=140 align=center id=bg1>이 름</td>
|
||||
<td width=45 align=center id=bg1>연령</td>
|
||||
<td width=45 align=center id=bg1>성격</td>
|
||||
<td width=80 align=center id=bg1>특기</td>
|
||||
<td width=45 align=center id=bg1>레 벨</td>
|
||||
<td width=140 align=center id=bg1>국 가</td>
|
||||
<td width=55 align=center id=bg1>명 성</td>
|
||||
<td width=55 align=center id=bg1>계 급</td>
|
||||
<td width=75 align=center id=bg1>관 직</td>
|
||||
<td width=45 align=center id=bg1>통솔</td>
|
||||
<td width=45 align=center id=bg1>무력</td>
|
||||
<td width=45 align=center id=bg1>지력</td>
|
||||
<td width=45 align=center id=bg1>삭턴</td>
|
||||
<td width=70 align=center id=bg1>벌점</td>
|
||||
</tr>";
|
||||
foreach($generalList as $general){
|
||||
$nation = $nationname[$general['nation']];
|
||||
|
||||
$lbonus = calcLeadershipBonus($general['officer_level'], $nationlevel[$general['nation']]??0);
|
||||
if ($lbonus > 0) {
|
||||
$lbonusText = "<font color=cyan>+{$lbonus}</font>";
|
||||
} else {
|
||||
$lbonusText = "";
|
||||
}
|
||||
|
||||
if ($general['injury'] > 0) {
|
||||
$leadership = intdiv($general['leadership'] * (100 - $general['injury']), 100);
|
||||
$strength = intdiv($general['strength'] * (100 - $general['injury']), 100);
|
||||
$intel = intdiv($general['intel'] * (100 - $general['injury']), 100);
|
||||
$leadership = "<font color=red>{$leadership}</font>{$lbonusText}";
|
||||
$strength = "<font color=red>{$strength}</font>";
|
||||
$intel = "<font color=red>{$intel}</font>";
|
||||
} else {
|
||||
$leadership = "{$general['leadership']}{$lbonusText}";
|
||||
$strength = "{$general['strength']}";
|
||||
$intel = "{$general['intel']}";
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($general['npc'] >= 2) {
|
||||
$name = "<font color=cyan>{$general['name']}</font>";
|
||||
} elseif ($general['npc'] == 1) {
|
||||
$name = "<font color=skyblue>{$general['name']}</font>";
|
||||
} else {
|
||||
$name = "{$general['name']}";
|
||||
}
|
||||
|
||||
if(key_exists($general['owner'], $ownerNameList)){
|
||||
$name = $name.'<br><small>('.$ownerNameList[$general['owner']].')</small>';
|
||||
}
|
||||
|
||||
$general['connect'] = Util::round($general['connect'], -1);
|
||||
|
||||
$imageTemp = GetImageURL($general['imgsvr']);
|
||||
echo "
|
||||
<tr data-general-id='{$general['no']}'
|
||||
data-general-wounded='{$general['injury']}'
|
||||
data-general-leadership='{$general['leadership']}'
|
||||
data-general-leadership-bonus='{$lbonus}'
|
||||
data-general-strength='{$general['strength']}'
|
||||
data-general-intel='{$general['intel']}'
|
||||
data-is-npc='".($general['npc']>=2?'true':'false')."'
|
||||
>
|
||||
<td align=center><img class='generalIcon' width='64' height='64' src='{$imageTemp}/{$general['picture']}'></img></td>
|
||||
<td align=center>$name</td>
|
||||
<td align=center>{$general['age']}세</td>
|
||||
<td align=center>".displayCharInfo($general['personal'])."</td>
|
||||
<td align=center>".displaySpecialDomesticInfo($general['special'])." / ".displaySpecialWarInfo($general['special2'])."</td>
|
||||
<td align=center>Lv ".getExpLevel($general['experience'])."</td>
|
||||
<td align=center>{$nation}</td>
|
||||
<td align=center>".getHonor($general['experience'])."</td>
|
||||
<td align=center>".getDed($general['dedication'])."</td>
|
||||
<td align=center>";
|
||||
echo getOfficerLevelText($general['officer_level']);
|
||||
echo "</td>
|
||||
<td align=center>$leadership</td>
|
||||
<td align=center>$strength</td>
|
||||
<td align=center>$intel</td>
|
||||
<td align=center>{$general['killturn']}</td>
|
||||
<td align=center>{$general['connect']}";
|
||||
echo "<br>【".getConnect($general['connect'])."】</td>
|
||||
</tr>";
|
||||
}
|
||||
echo "
|
||||
</table>
|
||||
";
|
||||
|
||||
?>
|
||||
|
||||
<table align=center width=1000 class='tb_layout bg0'>
|
||||
<tr><td><?=closeButton()?></td></tr>
|
||||
<tr><td><?=banner()?></td></tr>
|
||||
</table>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$("#viewType").val("<?=$type?>").attr("selected", "selected");
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
<?php
|
||||
namespace sammo;
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
|
||||
$type = Util::getReq('type', 'int', 9);
|
||||
|
||||
//로그인 검사
|
||||
$session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
|
||||
increaseRefresh("장수일람", 2);
|
||||
|
||||
$me = $db->queryFirstRow('SELECT con,turntime FROM general WHERE owner = %i', $userID);
|
||||
|
||||
$con = checkLimit($me['con']);
|
||||
if ($con >= 2) {
|
||||
printLimitMsg($me['turntime']);
|
||||
exit();
|
||||
}
|
||||
|
||||
if ($type <= 0 || $type > 15) {
|
||||
$type = 9;
|
||||
}
|
||||
|
||||
$ownerNameList = [];
|
||||
if($gameStor->isunited){
|
||||
foreach(RootDB::db()->queryAllLists('SELECT no, name FROM member') as [$ownerID, $ownerName]){
|
||||
$ownerNameList[$ownerID] = $ownerName;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=1024" />
|
||||
<title><?=UniqueConst::$serverName?>: 장수일람</title>
|
||||
<?=WebUtil::printCSS('../e_lib/bootstrap.min.css')?>
|
||||
<?=WebUtil::printCSS('../d_shared/common.css')?>
|
||||
<?=WebUtil::printCSS('css/common.css')?>
|
||||
<?=WebUtil::printJS('../e_lib/jquery-3.3.1.min.js')?>
|
||||
<?=WebUtil::printJS('../e_lib/bootstrap.bundle.min.js')?>
|
||||
<?=WebUtil::printJS('../d_shared/common_path.js')?>
|
||||
<?=WebUtil::printJS('js/common.js')?>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<table align=center width=1000 class='tb_layout bg0'>
|
||||
<tr><td>장 수 일 람<br><?=closeButton()?></td></tr>
|
||||
<tr><td><form name=form1 method=post>정렬순서 :
|
||||
<select id='viewType' name='type' size=1>
|
||||
<option value=1>국가</option>
|
||||
<option value=2>통솔</option>
|
||||
<option value=3>무력</option>
|
||||
<option value=4>지력</option>
|
||||
<option value=5>명성</option>
|
||||
<option value=6>계급</option>
|
||||
<option value=7>관직</option>
|
||||
<option value=8>삭턴</option>
|
||||
<option value=9>벌점</option>
|
||||
<option value=10>Lv</option>
|
||||
<option value=11>성격</option>
|
||||
<option value=12>내특</option>
|
||||
<option value=13>전특</option>
|
||||
<option value=14>연령</option>
|
||||
<option value=15>NPC</option>
|
||||
</select>
|
||||
<input type=submit value='정렬하기'></form>
|
||||
</td></tr>
|
||||
</table>
|
||||
<?php
|
||||
$nationname = [];
|
||||
$nationlevel = [];
|
||||
$nationname[0] = "-";
|
||||
foreach (getAllNationStaticInfo() as $nation) {
|
||||
$nationname[$nation['nation']] = $nation['name'];
|
||||
$nationlevel[$nation['nation']] = $nation['level'];
|
||||
}
|
||||
|
||||
|
||||
[$orderKey, $orderDesc] = [
|
||||
1=>['nation', false],
|
||||
2=>['leadership', true],
|
||||
3=>['strength', true],
|
||||
4=>['intel', true],
|
||||
5=>['experience', true],
|
||||
6=>['dedication', true],
|
||||
7=>['officer_level', true],
|
||||
8=>['killturn', false],
|
||||
9=>['connect', true],
|
||||
10=>['experience', true],
|
||||
11=>['personal', true],
|
||||
12=>['special', true],
|
||||
13=>['special2', true],
|
||||
14=>['age', true],
|
||||
15=>['npc', true],
|
||||
][$type];
|
||||
|
||||
$generalList = $db->query('SELECT owner,no,picture,imgsvr,npc,age,nation,special,special2,personal,name,injury,leadership,strength,intel,experience,dedication,officer_level,killturn,connect from general order by %b %l', $orderKey, $orderDesc?'desc':'');
|
||||
|
||||
echo"
|
||||
<table align=center width=1000 class='tb_layout bg0'>
|
||||
<tr>
|
||||
<td width=64 align=center id=bg1>얼 굴</td>
|
||||
<td width=140 align=center id=bg1>이 름</td>
|
||||
<td width=45 align=center id=bg1>연령</td>
|
||||
<td width=45 align=center id=bg1>성격</td>
|
||||
<td width=80 align=center id=bg1>특기</td>
|
||||
<td width=45 align=center id=bg1>레 벨</td>
|
||||
<td width=140 align=center id=bg1>국 가</td>
|
||||
<td width=55 align=center id=bg1>명 성</td>
|
||||
<td width=55 align=center id=bg1>계 급</td>
|
||||
<td width=75 align=center id=bg1>관 직</td>
|
||||
<td width=45 align=center id=bg1>통솔</td>
|
||||
<td width=45 align=center id=bg1>무력</td>
|
||||
<td width=45 align=center id=bg1>지력</td>
|
||||
<td width=45 align=center id=bg1>삭턴</td>
|
||||
<td width=70 align=center id=bg1>벌점</td>
|
||||
</tr>";
|
||||
foreach($generalList as $general){
|
||||
$nation = $nationname[$general['nation']];
|
||||
|
||||
$lbonus = calcLeadershipBonus($general['officer_level'], $nationlevel[$general['nation']]??0);
|
||||
if ($lbonus > 0) {
|
||||
$lbonusText = "<font color=cyan>+{$lbonus}</font>";
|
||||
} else {
|
||||
$lbonusText = "";
|
||||
}
|
||||
|
||||
if ($general['injury'] > 0) {
|
||||
$leadership = intdiv($general['leadership'] * (100 - $general['injury']), 100);
|
||||
$strength = intdiv($general['strength'] * (100 - $general['injury']), 100);
|
||||
$intel = intdiv($general['intel'] * (100 - $general['injury']), 100);
|
||||
$leadership = "<font color=red>{$leadership}</font>{$lbonusText}";
|
||||
$strength = "<font color=red>{$strength}</font>";
|
||||
$intel = "<font color=red>{$intel}</font>";
|
||||
} else {
|
||||
$leadership = "{$general['leadership']}{$lbonusText}";
|
||||
$strength = "{$general['strength']}";
|
||||
$intel = "{$general['intel']}";
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($general['npc'] >= 2) {
|
||||
$name = "<font color=cyan>{$general['name']}</font>";
|
||||
} elseif ($general['npc'] == 1) {
|
||||
$name = "<font color=skyblue>{$general['name']}</font>";
|
||||
} else {
|
||||
$name = "{$general['name']}";
|
||||
}
|
||||
|
||||
if(key_exists($general['owner'], $ownerNameList)){
|
||||
$name = $name.'<br><small>('.$ownerNameList[$general['owner']].')</small>';
|
||||
}
|
||||
|
||||
$general['connect'] = Util::round($general['connect'], -1);
|
||||
|
||||
$imageTemp = GetImageURL($general['imgsvr']);
|
||||
echo "
|
||||
<tr data-general-id='{$general['no']}'
|
||||
data-general-wounded='{$general['injury']}'
|
||||
data-general-leadership='{$general['leadership']}'
|
||||
data-general-leadership-bonus='{$lbonus}'
|
||||
data-general-strength='{$general['strength']}'
|
||||
data-general-intel='{$general['intel']}'
|
||||
data-is-npc='".($general['npc']>=2?'true':'false')."'
|
||||
>
|
||||
<td align=center><img class='generalIcon' width='64' height='64' src='{$imageTemp}/{$general['picture']}'></img></td>
|
||||
<td align=center>$name</td>
|
||||
<td align=center>{$general['age']}세</td>
|
||||
<td align=center>".displayCharInfo($general['personal'])."</td>
|
||||
<td align=center>".displaySpecialDomesticInfo($general['special'])." / ".displaySpecialWarInfo($general['special2'])."</td>
|
||||
<td align=center>Lv ".getExpLevel($general['experience'])."</td>
|
||||
<td align=center>{$nation}</td>
|
||||
<td align=center>".getHonor($general['experience'])."</td>
|
||||
<td align=center>".getDed($general['dedication'])."</td>
|
||||
<td align=center>";
|
||||
echo getOfficerLevelText($general['officer_level']);
|
||||
echo "</td>
|
||||
<td align=center>$leadership</td>
|
||||
<td align=center>$strength</td>
|
||||
<td align=center>$intel</td>
|
||||
<td align=center>{$general['killturn']}</td>
|
||||
<td align=center>{$general['connect']}";
|
||||
echo "<br>【".getConnect($general['connect'])."】</td>
|
||||
</tr>";
|
||||
}
|
||||
echo "
|
||||
</table>
|
||||
";
|
||||
|
||||
?>
|
||||
|
||||
<table align=center width=1000 class='tb_layout bg0'>
|
||||
<tr><td><?=closeButton()?></td></tr>
|
||||
<tr><td><?=banner()?></td></tr>
|
||||
</table>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$("#viewType").val("<?=$type?>").attr("selected", "selected");
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
@@ -1,300 +1,292 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\General;
|
||||
|
||||
use\sammo\{
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
LastTurn,
|
||||
GameUnitConst,
|
||||
Command
|
||||
};
|
||||
|
||||
use function\sammo\{
|
||||
getDomesticExpLevelBonus,
|
||||
CriticalRatioDomestic,
|
||||
CriticalScoreEx,
|
||||
tryUniqueItemLottery,
|
||||
getAllNationStaticInfo
|
||||
};
|
||||
|
||||
use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
|
||||
|
||||
class che_인재탐색 extends Command\GeneralCommand
|
||||
{
|
||||
static protected $actionName = '인재탐색';
|
||||
|
||||
protected function argTest(): bool
|
||||
{
|
||||
$this->arg = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init()
|
||||
{
|
||||
|
||||
$general = $this->generalObj;
|
||||
|
||||
$this->setNation();
|
||||
$env = $this->env;
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::ReqGeneralGold($reqGold),
|
||||
ConstraintHelper::ReqGeneralRice($reqRice),
|
||||
];
|
||||
}
|
||||
|
||||
public function getCommandDetailTitle(): string
|
||||
{
|
||||
$db = DB::db();
|
||||
$env = $this->env;
|
||||
|
||||
$maxGenCnt = $env['maxgeneral'];
|
||||
$totalGenCnt = $db->queryFirstField('SELECT count(no) FROM general WHERE npc <= 2');
|
||||
$totalNpcCnt = $db->queryFirstField('SELECT count(`no`) FROM general WHERE 3 <= npc AND npc <= 4');
|
||||
|
||||
$name = $this->getName();
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$foundProp = $this->calcFoundProp($maxGenCnt, $totalGenCnt, $totalNpcCnt);
|
||||
$foundPropText = number_format($foundProp * 100, 1);
|
||||
|
||||
$title = "{$name}(랜덤경험";
|
||||
if ($reqGold > 0) {
|
||||
$title .= ", 자금{$reqGold}";
|
||||
}
|
||||
if ($reqRice > 0) {
|
||||
$title .= ", 군량{$reqRice}";
|
||||
}
|
||||
|
||||
$title .= ", 확률 {$foundPropText}%)";
|
||||
return $title;
|
||||
}
|
||||
|
||||
public function getCost(): array
|
||||
{
|
||||
return [$this->env['develcost'], 0];
|
||||
}
|
||||
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function calcFoundProp(int $maxGenCnt, int $totalGenCnt, int $totalNpcCnt): float
|
||||
{
|
||||
|
||||
|
||||
$currCnt = Util::toInt($totalGenCnt + $totalNpcCnt / 2);
|
||||
$remainSlot = $maxGenCnt - $currCnt;
|
||||
if ($remainSlot < 0) {
|
||||
$remainSlot = 0;
|
||||
}
|
||||
|
||||
$foundPropMain = pow($remainSlot / $maxGenCnt, 6);
|
||||
$foundPropSmall = 1 / ($totalNpcCnt / 3 + 1);
|
||||
$foundPropBig = 1 / $maxGenCnt;
|
||||
|
||||
if ($totalNpcCnt < 50) {
|
||||
$foundProp = max($foundPropMain, $foundPropSmall);
|
||||
} else {
|
||||
$foundProp = max($foundPropMain, $foundPropBig);
|
||||
}
|
||||
return $foundProp;
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
$env = $this->env;
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
|
||||
$general = $this->generalObj;
|
||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||
|
||||
$nationID = $general->getNationID();
|
||||
|
||||
$nationCnt = count(getAllNationStaticInfo());
|
||||
|
||||
$totalGenCnt = $db->queryFirstField('SELECT count(no) FROM general WHERE npc <= 2');
|
||||
$totalNpcCnt = $db->queryFirstField('SELECT count(`no`) FROM general WHERE 3 <= npc AND npc <= 4');
|
||||
|
||||
$genCnt = $db->queryFirstField('SELECT count(no) FROM general WHERE nation=%i AND npc < 2', $nationID);
|
||||
$npcCnt = $db->queryFirstField('SELECT count(no) FROM general WHERE nation=%i AND 3 <= npc AND npc <= 4', $nationID);
|
||||
|
||||
$currCnt = Util::toInt($totalGenCnt + $totalNpcCnt / 2);
|
||||
$avgCnt = $currCnt / $nationCnt;
|
||||
|
||||
$foundNpc = Util::randBool($this->calcFoundProp($env['maxgeneral'], $totalGenCnt, $totalNpcCnt));
|
||||
|
||||
$logger = $general->getLogger();
|
||||
|
||||
if (!$foundNpc) {
|
||||
$logger->pushGeneralActionLog("인재를 찾을 수 없었습니다. <1>$date</>");
|
||||
|
||||
$incStat = Util::choiceRandomUsingWeight([
|
||||
'leadership_exp' => $general->getLeadership(false, false, false, false),
|
||||
'strength_exp' => $general->getStrength(false, false, false, false),
|
||||
'intel_exp' => $general->getIntel(false, false, false, false)
|
||||
]);
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$exp = 100;
|
||||
$ded = 70;
|
||||
|
||||
$general->increaseVarWithLimit('gold', -$reqGold, 0);
|
||||
$general->increaseVarWithLimit('rice', -$reqRice, 0);
|
||||
$general->addExperience($exp);
|
||||
$general->addDedication($ded);
|
||||
$general->increaseVar($incStat, 1);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
$general->applyDB($db);
|
||||
return true;
|
||||
}
|
||||
//인간적으로 너무 길어서 끊었다!
|
||||
|
||||
$exp = 200;
|
||||
$ded = 300;
|
||||
|
||||
$pickTypeList = ['무' => 6, '지' => 6, '무지' => 3];
|
||||
|
||||
$pickType = Util::choiceRandomUsingWeight($pickTypeList);
|
||||
|
||||
$totalStat = GameConst::$defaultStatNPCTotal;
|
||||
$minStat = GameConst::$defaultStatNPCMin;
|
||||
$mainStat = GameConst::$defaultStatNPCMax - Util::randRangeInt(0, GameConst::$defaultStatNPCMin);
|
||||
$otherStat = $minStat + Util::randRangeInt(0, Util::toInt(GameConst::$defaultStatNPCMin/2));
|
||||
$subStat = $totalStat - $mainStat - $otherStat;
|
||||
if ($subStat < $minStat) {
|
||||
$subStat = $otherStat;
|
||||
$otherStat = $minStat;
|
||||
$mainStat = $totalStat - $subStat - $otherStat;
|
||||
if ($mainStat) {
|
||||
throw new \LogicException('기본 스탯 설정값이 잘못되어 있음');
|
||||
}
|
||||
}
|
||||
|
||||
$avgGen = $db->queryFirstRow(
|
||||
'SELECT avg(dedication) as ded,avg(experience) as exp,
|
||||
avg(dex1+dex2+dex3+dex4) as dex_t, avg(age) as age, avg(dex5) as dex5
|
||||
from general where npc < 5',
|
||||
$nationID
|
||||
);
|
||||
$dexTotal = $avgGen['dex_t'];
|
||||
|
||||
if ($pickType == '무') {
|
||||
$leadership = $subStat;
|
||||
$strength = $mainStat;
|
||||
$intel = $otherStat;
|
||||
$dexVal = Util::choiceRandom([
|
||||
[$dexTotal * 5 / 8, $dexTotal / 8, $dexTotal / 8, $dexTotal / 8],
|
||||
[$dexTotal / 8, $dexTotal * 5 / 8, $dexTotal / 8, $dexTotal / 8],
|
||||
[$dexTotal / 8, $dexTotal / 8, $dexTotal * 5 / 8, $dexTotal / 8],
|
||||
]);
|
||||
} else if ($pickType == '지') {
|
||||
$leadership = $subStat;
|
||||
$strength = $otherStat;
|
||||
$intel = $mainStat;
|
||||
$dexVal = [$dexTotal / 8, $dexTotal / 8, $dexTotal * 5 / 8, $dexTotal / 8];
|
||||
} else {
|
||||
$leadership = $otherStat;
|
||||
$strength = $subStat;
|
||||
$intel = $mainStat;
|
||||
$dexVal = [$dexTotal / 4, $dexTotal / 4, $dexTotal / 4, $dexTotal / 4];
|
||||
}
|
||||
|
||||
$leadership = Util::round($leadership);
|
||||
$strength = Util::round($strength);
|
||||
$intel = Util::round($intel);
|
||||
|
||||
$scoutType = "발견";
|
||||
$scoutLevel = 0;
|
||||
$scoutNation = 0;
|
||||
|
||||
$age = Util::randRangeInt(20, 25);
|
||||
$birthYear = $env['year'] - $age;
|
||||
$deathYear = $env['year'] + Util::randRangeInt(10, 50);
|
||||
|
||||
$cityID = Util::choiceRandom(array_keys(\sammo\CityConst::all()));
|
||||
$newNPC = new \sammo\Scenario\NPC(
|
||||
Util::randRangeInt(1, 150),
|
||||
\sammo\getRandGenName(),
|
||||
null,
|
||||
$scoutNation,
|
||||
$cityID,
|
||||
$leadership,
|
||||
$strength,
|
||||
$intel,
|
||||
$scoutLevel,
|
||||
$birthYear,
|
||||
$deathYear,
|
||||
null,
|
||||
null
|
||||
);
|
||||
$newNPC->npc = 3;
|
||||
$newNPC->setMoney(1000, 1000);
|
||||
$newNPC->setExpDed($avgGen['exp'], $avgGen['ded']);
|
||||
$newNPC->setSpecYear(
|
||||
Util::round((GameConst::$retirementYear - $age) / 12) + $age,
|
||||
Util::round((GameConst::$retirementYear - $age) / 6) + $age
|
||||
);
|
||||
$newNPC->setDex(
|
||||
$dexVal[0],
|
||||
$dexVal[1],
|
||||
$dexVal[2],
|
||||
$dexVal[3],
|
||||
$avgGen['dex5']
|
||||
);
|
||||
|
||||
$newNPC->build($this->env);
|
||||
$npcName = $newNPC->realName;
|
||||
$josaRa = JosaUtil::pick($npcName, '라');
|
||||
|
||||
$generalName = $general->getName();
|
||||
$josaYi = JosaUtil::pick($generalName, '이');
|
||||
|
||||
$logger->pushGeneralActionLog("<Y>$npcName</>{$josaRa}는 <C>인재</>를 {$scoutType}하였습니다! <1>$date</>");
|
||||
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} <Y>$npcName</>{$josaRa}는 <C>인재</>를 {$scoutType}하였습니다!");
|
||||
$logger->pushGeneralHistoryLog("<Y>$npcName</>{$josaRa}는 <C>인재</>를 {$scoutType}");
|
||||
|
||||
$incStat = Util::choiceRandomUsingWeight([
|
||||
'leadership_exp' => $general->getLeadership(false, false, false, false),
|
||||
'strength_exp' => $general->getStrength(false, false, false, false),
|
||||
'intel_exp' => $general->getIntel(false, false, false, false)
|
||||
]);
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$exp = 200;
|
||||
$ded = 300;
|
||||
|
||||
$general->increaseVarWithLimit('gold', -$reqGold, 0);
|
||||
$general->increaseVarWithLimit('rice', -$reqRice, 0);
|
||||
$general->addExperience($exp);
|
||||
$general->addDedication($ded);
|
||||
$general->increaseVar($incStat, 3);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
$general->applyDB($db);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
<?php
|
||||
|
||||
namespace sammo\Command\General;
|
||||
|
||||
use\sammo\{
|
||||
DB,
|
||||
Util,
|
||||
JosaUtil,
|
||||
General,
|
||||
ActionLogger,
|
||||
GameConst,
|
||||
LastTurn,
|
||||
GameUnitConst,
|
||||
Command
|
||||
};
|
||||
|
||||
use function\sammo\{
|
||||
getDomesticExpLevelBonus,
|
||||
CriticalRatioDomestic,
|
||||
CriticalScoreEx,
|
||||
tryUniqueItemLottery,
|
||||
getAllNationStaticInfo
|
||||
};
|
||||
|
||||
use \sammo\Constraint\Constraint;
|
||||
use \sammo\Constraint\ConstraintHelper;
|
||||
|
||||
|
||||
class che_인재탐색 extends Command\GeneralCommand
|
||||
{
|
||||
static protected $actionName = '인재탐색';
|
||||
|
||||
protected function argTest(): bool
|
||||
{
|
||||
$this->arg = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function init()
|
||||
{
|
||||
|
||||
$general = $this->generalObj;
|
||||
|
||||
$this->setNation();
|
||||
$env = $this->env;
|
||||
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$this->fullConditionConstraints = [
|
||||
ConstraintHelper::ReqGeneralGold($reqGold),
|
||||
ConstraintHelper::ReqGeneralRice($reqRice),
|
||||
];
|
||||
}
|
||||
|
||||
public function getCommandDetailTitle(): string
|
||||
{
|
||||
$db = DB::db();
|
||||
$env = $this->env;
|
||||
|
||||
$maxGenCnt = $env['maxgeneral'];
|
||||
$totalGenCnt = $db->queryFirstField('SELECT count(no) FROM general WHERE npc <= 2');
|
||||
$totalNpcCnt = $db->queryFirstField('SELECT count(`no`) FROM general WHERE 3 <= npc AND npc <= 4');
|
||||
|
||||
$name = $this->getName();
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$foundProp = $this->calcFoundProp($maxGenCnt, $totalGenCnt, $totalNpcCnt);
|
||||
$foundPropText = number_format($foundProp * 100, 1);
|
||||
|
||||
$title = "{$name}(랜덤경험";
|
||||
if ($reqGold > 0) {
|
||||
$title .= ", 자금{$reqGold}";
|
||||
}
|
||||
if ($reqRice > 0) {
|
||||
$title .= ", 군량{$reqRice}";
|
||||
}
|
||||
|
||||
$title .= ", 확률 {$foundPropText}%)";
|
||||
return $title;
|
||||
}
|
||||
|
||||
public function getCost(): array
|
||||
{
|
||||
return [$this->env['develcost'], 0];
|
||||
}
|
||||
|
||||
public function getPreReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getPostReqTurn(): int
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function calcFoundProp(int $maxGenCnt, int $totalGenCnt, int $totalNpcCnt): float
|
||||
{
|
||||
|
||||
|
||||
$currCnt = Util::toInt($totalGenCnt + $totalNpcCnt / 2);
|
||||
$remainSlot = $maxGenCnt - $currCnt;
|
||||
if ($remainSlot < 0) {
|
||||
$remainSlot = 0;
|
||||
}
|
||||
|
||||
$foundPropMain = pow($remainSlot / $maxGenCnt, 6);
|
||||
$foundPropSmall = 1 / ($totalNpcCnt / 3 + 1);
|
||||
$foundPropBig = 1 / $maxGenCnt;
|
||||
|
||||
if ($totalNpcCnt < 50) {
|
||||
$foundProp = max($foundPropMain, $foundPropSmall);
|
||||
} else {
|
||||
$foundProp = max($foundPropMain, $foundPropBig);
|
||||
}
|
||||
return $foundProp;
|
||||
}
|
||||
|
||||
public function run(): bool
|
||||
{
|
||||
if (!$this->hasFullConditionMet()) {
|
||||
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
$env = $this->env;
|
||||
$relYear = $env['year'] - $env['startyear'];
|
||||
|
||||
$general = $this->generalObj;
|
||||
$date = $general->getTurnTime($general::TURNTIME_HM);
|
||||
|
||||
$nationID = $general->getNationID();
|
||||
|
||||
$totalGenCnt = $db->queryFirstField('SELECT count(no) FROM general WHERE npc <= 2');
|
||||
$totalNpcCnt = $db->queryFirstField('SELECT count(`no`) FROM general WHERE 3 <= npc AND npc <= 4');
|
||||
|
||||
$foundNpc = Util::randBool($this->calcFoundProp($env['maxgeneral'], $totalGenCnt, $totalNpcCnt));
|
||||
|
||||
$logger = $general->getLogger();
|
||||
|
||||
if (!$foundNpc) {
|
||||
$logger->pushGeneralActionLog("인재를 찾을 수 없었습니다. <1>$date</>");
|
||||
|
||||
$incStat = Util::choiceRandomUsingWeight([
|
||||
'leadership_exp' => $general->getLeadership(false, false, false, false),
|
||||
'strength_exp' => $general->getStrength(false, false, false, false),
|
||||
'intel_exp' => $general->getIntel(false, false, false, false)
|
||||
]);
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$exp = 100;
|
||||
$ded = 70;
|
||||
|
||||
$general->increaseVarWithLimit('gold', -$reqGold, 0);
|
||||
$general->increaseVarWithLimit('rice', -$reqRice, 0);
|
||||
$general->addExperience($exp);
|
||||
$general->addDedication($ded);
|
||||
$general->increaseVar($incStat, 1);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
$general->applyDB($db);
|
||||
return true;
|
||||
}
|
||||
//인간적으로 너무 길어서 끊었다!
|
||||
|
||||
$exp = 200;
|
||||
$ded = 300;
|
||||
|
||||
$pickTypeList = ['무' => 6, '지' => 6, '무지' => 3];
|
||||
|
||||
$pickType = Util::choiceRandomUsingWeight($pickTypeList);
|
||||
|
||||
$totalStat = GameConst::$defaultStatNPCTotal;
|
||||
$minStat = GameConst::$defaultStatNPCMin;
|
||||
$mainStat = GameConst::$defaultStatNPCMax - Util::randRangeInt(0, GameConst::$defaultStatNPCMin);
|
||||
$otherStat = $minStat + Util::randRangeInt(0, Util::toInt(GameConst::$defaultStatNPCMin/2));
|
||||
$subStat = $totalStat - $mainStat - $otherStat;
|
||||
if ($subStat < $minStat) {
|
||||
$subStat = $otherStat;
|
||||
$otherStat = $minStat;
|
||||
$mainStat = $totalStat - $subStat - $otherStat;
|
||||
if ($mainStat) {
|
||||
throw new \LogicException('기본 스탯 설정값이 잘못되어 있음');
|
||||
}
|
||||
}
|
||||
|
||||
$avgGen = $db->queryFirstRow(
|
||||
'SELECT avg(dedication) as ded,avg(experience) as exp,
|
||||
avg(dex1+dex2+dex3+dex4) as dex_t, avg(age) as age, avg(dex5) as dex5
|
||||
from general where npc < 5',
|
||||
$nationID
|
||||
);
|
||||
$dexTotal = $avgGen['dex_t'];
|
||||
|
||||
if ($pickType == '무') {
|
||||
$leadership = $subStat;
|
||||
$strength = $mainStat;
|
||||
$intel = $otherStat;
|
||||
$dexVal = Util::choiceRandom([
|
||||
[$dexTotal * 5 / 8, $dexTotal / 8, $dexTotal / 8, $dexTotal / 8],
|
||||
[$dexTotal / 8, $dexTotal * 5 / 8, $dexTotal / 8, $dexTotal / 8],
|
||||
[$dexTotal / 8, $dexTotal / 8, $dexTotal * 5 / 8, $dexTotal / 8],
|
||||
]);
|
||||
} else if ($pickType == '지') {
|
||||
$leadership = $subStat;
|
||||
$strength = $otherStat;
|
||||
$intel = $mainStat;
|
||||
$dexVal = [$dexTotal / 8, $dexTotal / 8, $dexTotal * 5 / 8, $dexTotal / 8];
|
||||
} else {
|
||||
$leadership = $otherStat;
|
||||
$strength = $subStat;
|
||||
$intel = $mainStat;
|
||||
$dexVal = [$dexTotal / 4, $dexTotal / 4, $dexTotal / 4, $dexTotal / 4];
|
||||
}
|
||||
|
||||
$leadership = Util::round($leadership);
|
||||
$strength = Util::round($strength);
|
||||
$intel = Util::round($intel);
|
||||
|
||||
$scoutType = "발견";
|
||||
$scoutLevel = 0;
|
||||
$scoutNation = 0;
|
||||
|
||||
$age = Util::randRangeInt(20, 25);
|
||||
$birthYear = $env['year'] - $age;
|
||||
$deathYear = $env['year'] + Util::randRangeInt(10, 50);
|
||||
|
||||
$cityID = Util::choiceRandom(array_keys(\sammo\CityConst::all()));
|
||||
$newNPC = new \sammo\Scenario\NPC(
|
||||
Util::randRangeInt(1, 150),
|
||||
\sammo\getRandGenName(),
|
||||
null,
|
||||
$scoutNation,
|
||||
$cityID,
|
||||
$leadership,
|
||||
$strength,
|
||||
$intel,
|
||||
$scoutLevel,
|
||||
$birthYear,
|
||||
$deathYear,
|
||||
null,
|
||||
null
|
||||
);
|
||||
$newNPC->npc = 3;
|
||||
$newNPC->setMoney(1000, 1000);
|
||||
$newNPC->setExpDed($avgGen['exp'], $avgGen['ded']);
|
||||
$newNPC->setSpecYear(
|
||||
Util::round((GameConst::$retirementYear - $age) / 12) + $age,
|
||||
Util::round((GameConst::$retirementYear - $age) / 6) + $age
|
||||
);
|
||||
$newNPC->setDex(
|
||||
$dexVal[0],
|
||||
$dexVal[1],
|
||||
$dexVal[2],
|
||||
$dexVal[3],
|
||||
$avgGen['dex5']
|
||||
);
|
||||
|
||||
$newNPC->build($this->env);
|
||||
$npcName = $newNPC->realName;
|
||||
$josaRa = JosaUtil::pick($npcName, '라');
|
||||
|
||||
$generalName = $general->getName();
|
||||
$josaYi = JosaUtil::pick($generalName, '이');
|
||||
|
||||
$logger->pushGeneralActionLog("<Y>$npcName</>{$josaRa}는 <C>인재</>를 {$scoutType}하였습니다! <1>$date</>");
|
||||
$logger->pushGlobalActionLog("<Y>{$generalName}</>{$josaYi} <Y>$npcName</>{$josaRa}는 <C>인재</>를 {$scoutType}하였습니다!");
|
||||
$logger->pushGeneralHistoryLog("<Y>$npcName</>{$josaRa}는 <C>인재</>를 {$scoutType}");
|
||||
|
||||
$incStat = Util::choiceRandomUsingWeight([
|
||||
'leadership_exp' => $general->getLeadership(false, false, false, false),
|
||||
'strength_exp' => $general->getStrength(false, false, false, false),
|
||||
'intel_exp' => $general->getIntel(false, false, false, false)
|
||||
]);
|
||||
[$reqGold, $reqRice] = $this->getCost();
|
||||
|
||||
$exp = 200;
|
||||
$ded = 300;
|
||||
|
||||
$general->increaseVarWithLimit('gold', -$reqGold, 0);
|
||||
$general->increaseVarWithLimit('rice', -$reqRice, 0);
|
||||
$general->addExperience($exp);
|
||||
$general->addDedication($ded);
|
||||
$general->increaseVar($incStat, 3);
|
||||
$this->setResultTurn(new LastTurn(static::getName(), $this->arg));
|
||||
$general->checkStatChange();
|
||||
tryUniqueItemLottery($general);
|
||||
$general->applyDB($db);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -534,7 +534,7 @@ class GeneralAI
|
||||
if(!key_exists($userGeneral->getCityID(), $this->nationCities)){
|
||||
continue;
|
||||
}
|
||||
$city = $this->supplyCities[$userGeneral->getCityID()];
|
||||
$city = $this->nationCities[$userGeneral->getCityID()];
|
||||
$troopLeaderID = $userGeneral->getVar('troop');
|
||||
if(!$troopLeaderID || !key_exists($troopLeaderID, $this->troopLeaders)){
|
||||
continue;
|
||||
@@ -2778,7 +2778,7 @@ class GeneralAI
|
||||
if($city['city'] === $candidate['city']){
|
||||
continue;
|
||||
}
|
||||
$realDevelRate = 0;
|
||||
$realDevelRate = 0.0001; //하단의 나눗셈
|
||||
|
||||
foreach($this->calcCityDevelRate($candidate) as $develKey => [$develVal, $develType]){
|
||||
if(!($this->genType & $develType)){
|
||||
|
||||
Reference in New Issue
Block a user