fix(misc): phan

This commit is contained in:
2021-10-12 01:30:37 +09:00
parent 3998d10bba
commit a18500dd9b
12 changed files with 858 additions and 867 deletions
+32 -26
View File
@@ -15,20 +15,34 @@ return [
// Note that the **only** effect of choosing `'5.6'` is to infer
// that functions removed in php 7.0 exist.
// (See `backward_compatibility_checks` for additional options)
"target_php_version" => '7.4',
"target_php_version" => '8.0',
'backward_compatibility_checks ' => true,
'minimum_severity'=>\Phan\Issue::SEVERITY_CRITICAL,
'minimum_severity' => \Phan\Issue::SEVERITY_NORMAL,
'file_list' => [
'f_config/config.php',
'hwe/_119_b.php',
'hwe/_119.php',
'hwe/a_bestGeneral.php',
'hwe/a_emperior.php',
'hwe/_admin1.php',
'hwe/_admin1_submit.php',
'hwe/_admin2.php',
'hwe/_admin2_submit.php',
'hwe/_admin4.php',
'hwe/_admin4_submit.php',
'hwe/_admin5.php',
'hwe/_admin5_submit.php',
'hwe/_admin7.php',
'hwe/_admin8.php',
'hwe/_admin_force_rehall.php',
'hwe/a_emperior_detail.php',
'hwe/a_emperior.php',
'hwe/a_genList.php',
'hwe/a_hallOfFame.php',
'hwe/a_history.php',
'hwe/a_kingdomList.php',
'hwe/a_npcList.php',
'hwe/api.php',
'hwe/a_status.php',
'hwe/a_traffic.php',
'hwe/a_vote.php',
@@ -41,13 +55,11 @@ return [
'hwe/b_dipcenter.php',
'hwe/b_diplomacy.php',
'hwe/b_genList.php',
'hwe/v_inheritPoint.php',
'hwe/b_myBossInfo.php',
'hwe/b_myCityInfo.php',
'hwe/b_myGenInfo.php',
'hwe/b_myKingdomInfo.php',
'hwe/b_myPage.php',
'hwe/b_npc_control.php',
'hwe/b_processing.php',
'hwe/b_tournament.php',
'hwe/b_troop.php',
@@ -55,7 +67,6 @@ return [
'hwe/c_dipcenter.php',
'hwe/c_tournament.php',
'hwe/c_vote.php',
'hwe/func.php',
'hwe/func_auction.php',
'hwe/func_command.php',
'hwe/func_converter.php',
@@ -64,16 +75,15 @@ return [
'hwe/func_legacy.php',
'hwe/func_map.php',
'hwe/func_message.php',
'hwe/func.php',
'hwe/func_process.php',
'hwe/func_string.php',
'hwe/func_template.php',
'hwe/func_time_event.php',
'hwe/func_tournament.php',
'hwe/index.php',
'hwe/install.php',
'hwe/install_db.php',
'hwe/join.php',
'hwe/join_post.php',
'hwe/install.php',
'hwe/j_adjust_icon.php',
'hwe/j_autoreset.php',
'hwe/j_basic_info.php',
@@ -92,8 +102,8 @@ return [
'hwe/j_general_log_old.php',
'hwe/j_general_set_permission.php',
'hwe/j_general_turn.php',
'hwe/j_getChiefTurn.php',
'hwe/j_get_basic_general_list.php',
'hwe/j_getChiefTurn.php',
'hwe/j_get_city_list.php',
'hwe/j_get_general_list.php',
'hwe/j_get_nation_general_list.php',
@@ -101,11 +111,12 @@ return [
'hwe/j_get_select_npc_token.php',
'hwe/j_get_select_pool.php',
'hwe/j_image_upload.php',
'hwe/j_install.php',
'hwe/j_install_db.php',
'hwe/j_install.php',
'hwe/j_load_scenarios.php',
'hwe/j_map.php',
'hwe/j_map_history.php',
'hwe/j_map.php',
'hwe/j_map_recent.php',
'hwe/j_msg_contact_list.php',
'hwe/j_msg_decide_opt.php',
'hwe/j_msg_delete.php',
@@ -123,26 +134,20 @@ return [
'hwe/j_set_npc_control.php',
'hwe/j_simulate_battle.php',
'hwe/j_troop.php',
'hwe/j_update_picked_general.php',
'hwe/j_vacation.php',
'hwe/lib.php',
'hwe/process_war.php',
'hwe/proc.php',
'hwe/readme.php',
'hwe/recent_map.php',
'hwe/select_general_from_pool.php',
'hwe/select_npc.php',
'hwe/t_board.php',
'hwe/t_diplomacy.php',
'hwe/_119.php',
'hwe/_119_b.php',
'hwe/_admin1.php',
'hwe/_admin1_submit.php',
'hwe/_admin2.php',
'hwe/_admin2_submit.php',
'hwe/_admin4.php',
'hwe/_admin4_submit.php',
'hwe/_admin5.php',
'hwe/_admin5_submit.php',
'hwe/_admin7.php',
'hwe/_admin8.php',
'hwe/_admin_force_rehall.php',
'hwe/v_board.php',
'hwe/v_inheritPoint.php',
'hwe/v_join.php',
'hwe/v_NPCControl.php',
],
// A list of directories that should be parsed for class and
@@ -179,6 +184,7 @@ return [
'suppress_issue_types' => [
'PhanUnreferencedUseNormal',
'PhanTypeArraySuspiciousNullable',
],
// A list of plugin files to execute.
+1
View File
@@ -342,6 +342,7 @@ switch ($btn) {
}
break;
case "랜덤턴":
$turnterm = $gameStor->turnterm;
foreach ($genlist as $generalID) {
$turntime = getRandTurn($turnterm);
$db->update('general', [
@@ -17,6 +17,7 @@ class BuySpecificUnique extends \sammo\BaseAPI
{
public function validateArgs(): ?string
{
$availableItems = [];
foreach (GameConst::$allItems as $items) {
foreach ($items as $itemKey => $amount) {
if ($amount == 0) {
@@ -62,10 +62,10 @@ class ResetTurnTime extends \sammo\BaseAPI
$userLogger = new UserLogger($userID);
if($afterTurn >= 0){
$userLogger->push(sprintf("{$reqPoint} 포인트로 턴 시간을 바꾼 결과 %02d:%02d 뒤로 밀림", intdiv($afterTurn, 60), $afterTurn%60), "inheritPoint");
$userLogger->push(sprintf("{$reqPoint} 포인트로 턴 시간을 바꾼 결과 %02d:%02d 뒤로 밀림", intdiv(Util::toInt($afterTurn), 60), $afterTurn%60), "inheritPoint");
}
else{
$userLogger->push(sprintf("{$reqPoint} 포인트로 턴 시간을 바꾼 결과 %02d:%02d 앞으로 당김", intdiv(-$afterTurn, 60), (-$afterTurn)%60), "inheritPoint");
$userLogger->push(sprintf("{$reqPoint} 포인트로 턴 시간을 바꾼 결과 %02d:%02d 앞으로 당김", intdiv(Util::toInt(-$afterTurn), 60), (-$afterTurn)%60), "inheritPoint");
}
$userLogger->flush();
+3 -3
View File
@@ -3,9 +3,9 @@ namespace sammo;
class CityHelper{
//Just Helper
private static $list = null;
private static $listInv = null;
private static $listByNation = null;
private static ?array $list = null;
private static ?array $listInv = null;
private static ?array $listByNation = null;
private function __construct(){
@@ -218,7 +218,7 @@ class che_물자원조 extends Command\NationCommand{
}
$josaRoSrc = JosaUtil::pick($nationName, '로');
$destNationLogger = new ActionLogger(0, $destChiefID, $year, $month);
$destNationLogger = new ActionLogger(0, $destNationID, $year, $month);
$destNationLogger->pushNationalHistoryLog("<D><b>{$nationName}</b></>{$josaRoSrc}부터 금<C>{$goldAmountText}</> 쌀<C>{$riceAmountText}</>을 지원 받음");
$destNationStor = KVStorage::getStorage(DB::db(), $destNationID, 'nation_env');
+118 -136
View File
@@ -93,8 +93,7 @@ class GeneralAI
$city = $db->queryFirstRow('SELECT * FROM city WHERE city = %i', $general->getCityID());
$general->setRawCity($city);
$this->city = $city;
}
else{
} else {
$this->city = $general->getRawCity();
}
@@ -184,7 +183,6 @@ class GeneralAI
$genType |= self::t통솔장;
}
return $genType;
}
protected function calcDiplomacyState()
@@ -219,8 +217,7 @@ class GeneralAI
} else if ($warState == 1 && $warTerm < 5) {
$onWarReady += 1;
$warTargetNation[$warNationID] = 1;
}
else{
} else {
$onWarYet += 1;
}
}
@@ -251,7 +248,8 @@ class GeneralAI
}
}
protected function calcWarRoute(){
protected function calcWarRoute()
{
if ($this->warRoute !== null) {
return;
}
@@ -570,8 +568,7 @@ class GeneralAI
$generalID = $general->getID();
if ($turnList[$generalID] instanceof Command\General\che_징병) {
return true;
}
else{
} else {
return false;
}
});
@@ -1222,7 +1219,7 @@ class GeneralAI
}
$crewtype = $targetUserGeneral->getCrewTypeObj();
$reqMoney = $crewtype->costWithTech($this->nation['tech'], $targetUserGeneral->getLeadership(false)) * 100 * 3 * 1.1;
$reqMoney = $crewtype->costWithTech($this->nation['tech'], Util::toInt($targetUserGeneral->getLeadership(false))) * 100 * 3 * 1.1;
if ($this->env['year'] > $this->env['startyear'] + 3) {
$reqMoney = max($reqMoney, $reqHumanMinRes);
}
@@ -1244,7 +1241,8 @@ class GeneralAI
$payAmount = Util::valueFit($payAmount, 100, $this->maxResourceActionAmount);
$candidateArgs[] = [[
$candidateArgs[] = [
[
'destGeneralID' => $targetUserGeneral->getID(),
'isGold' => $resName == 'gold',
'amount' => $payAmount
@@ -1259,7 +1257,10 @@ class GeneralAI
}
$cmd = buildNationCommandClass(
'che_포상', $this->general, $this->env, $lastTurn,
'che_포상',
$this->general,
$this->env,
$lastTurn,
Util::choiceRandomUsingWeightPair($candidateArgs)
);
if (!$cmd->hasFullConditionMet()) {
@@ -1315,20 +1316,18 @@ class GeneralAI
if (key_exists($targetUserGeneral->getID(), $this->userWarGenerals)) {
$isWarGeneral = true;
}
else{
} else {
$isWarGeneral = false;
}
if ($isWarGeneral) {
$reqHumanMinRes = $reqHumanMinWarRes;
}
else{
} else {
$reqHumanMinRes = $reqHumanMinDevelRes;
}
$crewtype = $targetUserGeneral->getCrewTypeObj();
$reqMoney = $crewtype->costWithTech($this->nation['tech'], $targetUserGeneral->getLeadership(false)) * 100 * 6 * 1.1;
$reqMoney = $crewtype->costWithTech($this->nation['tech'], Util::toInt($targetUserGeneral->getLeadership(false))) * 100 * 6 * 1.1;
if ($this->env['year'] > $this->env['startyear'] + 3) {
$reqMoney = max($reqMoney, $reqHumanMinRes);
}
@@ -1351,7 +1350,8 @@ class GeneralAI
$payAmount = Util::valueFit($payAmount, 100, $this->maxResourceActionAmount);
$candidateArgs[] = [[
$candidateArgs[] = [
[
'destGeneralID' => $targetUserGeneral->getID(),
'isGold' => $resName == 'gold',
'amount' => $payAmount
@@ -1366,7 +1366,10 @@ class GeneralAI
}
$cmd = buildNationCommandClass(
'che_포상', $this->general, $this->env, $lastTurn,
'che_포상',
$this->general,
$this->env,
$lastTurn,
Util::choiceRandomUsingWeightPair($candidateArgs)
);
if (!$cmd->hasFullConditionMet()) {
@@ -1417,7 +1420,7 @@ class GeneralAI
}
$crewtype = $targetNPCGeneral->getCrewTypeObj();
$reqMoney = $crewtype->costWithTech($this->nation['tech'], $targetNPCGeneral->getLeadership(false)) * 100 * 1.5;
$reqMoney = $crewtype->costWithTech($this->nation['tech'], Util::toInt($targetNPCGeneral->getLeadership(false))) * 100 * 1.5;
if ($this->env['year'] > $this->env['startyear'] + 5) {
$reqMoney = max($reqMoney, $reqNPCMinWarRes);
}
@@ -1440,7 +1443,8 @@ class GeneralAI
$payAmount = Util::valueFit($payAmount, 100, $this->maxResourceActionAmount);
$candidateArgs[] = [[
$candidateArgs[] = [
[
'destGeneralID' => $targetNPCGeneral->getID(),
'isGold' => $resName == 'gold',
'amount' => $payAmount
@@ -1455,7 +1459,10 @@ class GeneralAI
}
$cmd = buildNationCommandClass(
'che_포상', $this->general, $this->env, $lastTurn,
'che_포상',
$this->general,
$this->env,
$lastTurn,
Util::choiceRandomUsingWeightPair($candidateArgs)
);
if (!$cmd->hasFullConditionMet()) {
@@ -1509,7 +1516,7 @@ class GeneralAI
}
$crewtype = $targetNPCGeneral->getCrewTypeObj();
$reqMoney = $crewtype->costWithTech($nation['tech'], $targetNPCGeneral->getLeadership(false)) * 100 * 3 * 1.1;
$reqMoney = $crewtype->costWithTech($nation['tech'], Util::toInt($targetNPCGeneral->getLeadership(false))) * 100 * 3 * 1.1;
if ($this->env['year'] > $this->env['startyear'] + 5) {
$reqMoney = max($reqMoney, $reqNPCMinWarRes);
}
@@ -1526,7 +1533,8 @@ class GeneralAI
continue;
}
$candidateArgs[] = [[
$candidateArgs[] = [
[
'destGeneralID' => $targetNPCGeneral->getID(),
'isGold' => $resName == 'gold',
'amount' => Util::valueFit($payAmount, 100, $this->maxResourceActionAmount)
@@ -1556,7 +1564,8 @@ class GeneralAI
$payAmount = Util::valueFit($payAmount, 100, $this->maxResourceActionAmount);
$candidateArgs[] = [[
$candidateArgs[] = [
[
'destGeneralID' => $targetNPCGeneral->getID(),
'isGold' => $resName == 'gold',
'amount' => $payAmount
@@ -1564,7 +1573,6 @@ class GeneralAI
max(count($npcWarGenerals), count($npcCivilGenerals)) - $idx
];
}
}
if (!$candidateArgs) {
@@ -1572,7 +1580,10 @@ class GeneralAI
}
$cmd = buildNationCommandClass(
'che_포상', $this->general, $this->env, $lastTurn,
'che_포상',
$this->general,
$this->env,
$lastTurn,
Util::choiceRandomUsingWeightPair($candidateArgs)
);
if (!$cmd->hasFullConditionMet()) {
@@ -1626,7 +1637,8 @@ class GeneralAI
break;
}
$candidateArgs[] = [[
$candidateArgs[] = [
[
'destGeneralID' => $targetNPCGeneral->getID(),
'isGold' => $resName == 'gold',
'amount' => $takeAmount
@@ -1644,8 +1656,7 @@ class GeneralAI
if ($resVal >= $reqNationResVal) {
$willTakeSmallAmount = true;
}
else{
} else {
$willTakeSmallAmount = false;
}
@@ -1661,17 +1672,14 @@ class GeneralAI
if ($targetNPCGeneral->getVar($resName) <= $reqNPCMinWarRes * 2) {
break;
}
}
else if($targetNPCGeneral->getVar($resName) <= $reqNPCMinWarRes){
} else if ($targetNPCGeneral->getVar($resName) <= $reqNPCMinWarRes) {
break;
}
if (!$willTakeSmallAmount) {
$takeAmount = $targetNPCGeneral->getVar($resName) - $reqNPCMinWarRes;
$takeAmount = Util::valueFit(sqrt($takeAmount * $reqResValDelta), 0, $takeAmount);
}
else{
} else {
$maxTakeAmount = $targetNPCGeneral->getVar($resName) - $reqNPCMinWarRes;
$minTakeAmount = $targetNPCGeneral->getVar($resName) - $reqNPCMinWarRes * 2;
$takeAmount = Util::valueFit(sqrt($minTakeAmount * $reqResValDelta), 0, $maxTakeAmount);
@@ -1686,7 +1694,8 @@ class GeneralAI
}
$takeAmount = Util::valueFit($takeAmount, 100, $this->maxResourceActionAmount);
$candidateArgs[] = [[
$candidateArgs[] = [
[
'destGeneralID' => $targetNPCGeneral->getID(),
'isGold' => $resName == 'gold',
'amount' => $takeAmount
@@ -1694,7 +1703,6 @@ class GeneralAI
$takeAmount
];
}
}
if (!$candidateArgs) {
@@ -1702,7 +1710,10 @@ class GeneralAI
}
$cmd = buildNationCommandClass(
'che_몰수', $this->general, $this->env, $lastTurn,
'che_몰수',
$this->general,
$this->env,
$lastTurn,
Util::choiceRandomUsingWeightPair($candidateArgs)
);
if (!$cmd->hasFullConditionMet()) {
@@ -1896,11 +1907,9 @@ class GeneralAI
if (!key_exists($destNationID, $lowTargetNations)) {
$nations[$destNationID] = 1 / sqrt($destNationPower + 1);
}
else{
} else {
$warNations[$destNationID] = 1 / sqrt($destNationPower + 1);
}
}
if (!$nations) {
if (!$warNations) {
@@ -2098,8 +2107,7 @@ class GeneralAI
if ($cmd->hasFullConditionMet()) {
$cmdList[] = [$cmd, $leadership / Util::valueFit($develRate['pop'], 0.001)];
}
}
else if ($develRate['pop'] < 0.99) {
} else if ($develRate['pop'] < 0.99) {
$cmd = buildGeneralCommandClass('che_정착장려', $general, $env);
if ($cmd->hasFullConditionMet()) {
$cmdList[] = [$cmd, $leadership / Util::valueFit($develRate['pop'] / 4, 0.001)];
@@ -2125,8 +2133,7 @@ class GeneralAI
if ($cmd->hasFullConditionMet()) {
$cmdList[] = [$cmd, $strength / Util::valueFit($develRate['secu'] / 0.8, 0.001, 1)];
}
}
else if($develRate['secu'] < 1){
} else if ($develRate['secu'] < 1) {
$cmd = buildGeneralCommandClass('che_치안강화', $general, $env);
if ($cmd->hasFullConditionMet()) {
$cmdList[] = [$cmd, $strength / 2 / Util::valueFit($develRate['secu'], 0.001)];
@@ -2243,8 +2250,7 @@ class GeneralAI
if ($cmd->hasFullConditionMet()) {
if (in_array($city['front'], [1, 3])) {
$cmdList[] = [$cmd, $leadership / Util::valueFit($develRate['pop'], 0.001)];
}
else{
} else {
$cmdList[] = [$cmd, $leadership / Util::valueFit($develRate['pop'], 0.001) / 2];
}
}
@@ -2290,8 +2296,7 @@ class GeneralAI
if ($cmd->hasFullConditionMet()) {
if (in_array($city['front'], [1, 3])) {
$cmdList[] = [$cmd, ($isSpringSummer ? 1.2 : 0.8) * $intel / 4 / Util::valueFit($develRate['agri'], 0.001, 1)];
}
else{
} else {
$cmdList[] = [$cmd, ($isSpringSummer ? 1.2 : 0.8) * $intel / 2 / Util::valueFit($develRate['agri'], 0.001, 1)];
}
}
@@ -2301,8 +2306,7 @@ class GeneralAI
if ($cmd->hasFullConditionMet()) {
if (in_array($city['front'], [1, 3])) {
$cmdList[] = [$cmd, ($isSpringSummer ? 0.8 : 1.2) * $intel / 4 / Util::valueFit($develRate['comm'], 0.001, 1)];
}
else{
} else {
$cmdList[] = [$cmd, ($isSpringSummer ? 0.8 : 1.2) * $intel / 2 / Util::valueFit($develRate['comm'], 0.001, 1)];
}
}
@@ -2346,8 +2350,7 @@ class GeneralAI
'crewType' => $crewType->id,
'amount' => $this->fullLeadership * 100
]);
}
else{
} else {
$costCmd = buildGeneralCommandClass('che_징병', $general, $this->env, [
'crewType' => $crewType->id,
'amount' => $this->fullLeadership * 100
@@ -2357,7 +2360,7 @@ class GeneralAI
$goldCost = $costCmd->getCost()[0];
$riceCost = $crewType->riceWithTech(
$this->nation['tech'],
$this->fullLeadership*100
Util::toInt($this->fullLeadership * 100)
);
if (($relGold + $relRice) * 1.5 <= $goldCost + $riceCost) {
@@ -2366,19 +2369,13 @@ class GeneralAI
$tryBuying = false;
if ($this->generalPolicy->can상인무시) {
if($relRice * 1.5 < $relGold && $relRice < $riceCost * 2)
{
if ($relRice * 1.5 < $relGold && $relRice < $riceCost * 2) {
$tryBuying = true;
} else if ($relRice * 2 < $relGold) {
$tryBuying = true;
}
else if($relRice * 2 < $relGold)
{
$tryBuying = true;
}
}
else{
if($relRice * 2 < $relGold && $relRice < $riceCost * 3)
{
} else {
if ($relRice * 2 < $relGold && $relRice < $riceCost * 3) {
$tryBuying = true;
}
}
@@ -2387,7 +2384,10 @@ class GeneralAI
//1:1
$amount = Util::valueFit(Util::toInt(($relGold - $relRice) / (1 + $deathRate)), 100, GameConst::$maxResourceActionAmount);
if ($amount >= $this->nationPolicy->minimumResourceActionAmount) {
$cmd = buildGeneralCommandClass('che_군량매매', $general, $this->env,
$cmd = buildGeneralCommandClass(
'che_군량매매',
$general,
$this->env,
[
'buyRice' => true,
'amount' => $amount
@@ -2401,19 +2401,13 @@ class GeneralAI
$trySelling = false;
if ($this->generalPolicy->can상인무시) {
if($relGold * 1.5 < $relRice && $relGold < $goldCost * 2)
{
if ($relGold * 1.5 < $relRice && $relGold < $goldCost * 2) {
$trySelling = true;
} else if ($relGold * 2 < $relRice) {
$trySelling = true;
}
else if($relGold * 2 < $relRice)
{
$trySelling = true;
}
}
else{
if($relGold * 2 < $relRice && $relGold < $goldCost * 3)
{
} else {
if ($relGold * 2 < $relRice && $relGold < $goldCost * 3) {
$trySelling = true;
}
}
@@ -2421,7 +2415,10 @@ class GeneralAI
if ($trySelling) {
$amount = Util::valueFit(Util::toInt(($relRice - $relGold) / (1 + $deathRate)), 100, GameConst::$maxResourceActionAmount);
if ($amount >= $this->nationPolicy->minimumResourceActionAmount) {
$cmd = buildGeneralCommandClass('che_군량매매', $general, $this->env,
$cmd = buildGeneralCommandClass(
'che_군량매매',
$general,
$this->env,
[
'buyRice' => false,
'amount' => $amount
@@ -2467,10 +2464,10 @@ class GeneralAI
$maxPop = $city['pop_max'] - $this->nationPolicy->minNPCRecruitCityPopulation;
if (($city['pop'] / $city['pop_max'] < $this->nationPolicy->safeRecruitCityPopulationRatio) &&
(Util::randF($remainPop/$maxPop))){
(Util::randF($remainPop / $maxPop))
) {
return null;
}
}
$nationID = $general->getNationID();
@@ -2485,8 +2482,7 @@ class GeneralAI
if ($armType) {
if (!($genType & self::t지장) && $armType == GameUnitConst::T_WIZARD) {
$armType = null;
}
else if(!($genType & self::t무장) && in_array($armType, [GameUnitConst::T_FOOTMAN, GameUnitConst::T_ARCHER, GameUnitConst::T_CAVALRY])){
} else if (!($genType & self::t무장) && in_array($armType, [GameUnitConst::T_FOOTMAN, GameUnitConst::T_ARCHER, GameUnitConst::T_CAVALRY])) {
$armType = null;
}
}
@@ -2535,7 +2531,7 @@ class GeneralAI
if ($types) {
$type = Util::choiceRandomUsingWeight($types);
} else {
throw new MustNotBeReachedException('에러:'.var_dump([$general->getName(), $general->getAuxVar('armType'), $armType, $cities, $regions, $relYear, $tech], true));
throw new MustNotBeReachedException('에러:' . print_r([$general->getName(), $general->getAuxVar('armType'), $armType, $cities, $regions, $relYear, $tech], true));
}
if ($this->generalPolicy->can고급병종) {
@@ -2543,8 +2539,7 @@ class GeneralAI
if ($currCrewType->isValid($cities, $regions, $relYear, $tech)) {
if ($currCrewType->reqTech >= 2000) {
$type = $currCrewType->id;
}
else if($currCrewType->armType != $armType && $currCrewType->reqTech >= 1000){
} else if ($currCrewType->armType != $armType && $currCrewType->reqTech >= 1000) {
//굳이 뽑은 이유가 있겠지
$type = $currCrewType->id;
}
@@ -2566,8 +2561,8 @@ class GeneralAI
$riceCost = $crewType->riceWithTech(
$this->nation['tech'],
$this->fullLeadership*100 *
$general->getRankVar('killcrew')/max($general->getRankVar('deathcrew'),1)*1.2
Util::toInt($this->fullLeadership * 100 *
$general->getRankVar('killcrew') / max($general->getRankVar('deathcrew'), 1) * 1.2)
);
$cmd = buildGeneralCommandClass('che_징병', $general, $env, [
@@ -2582,8 +2577,7 @@ class GeneralAI
'crewType' => $type,
'amount' => $crew
]);
}
else if($gold < $cost && $gold * 2 >= $cost){
} else if ($gold < $cost && $gold * 2 >= $cost) {
$crew *= 0.5;
$riceCost *= 0.5;
$crew = Util::round($crew - 49, -2);
@@ -2752,8 +2746,7 @@ class GeneralAI
if ($this->genType & self::t통솔장) {
$reqRes = $reqNPCWar;
}
else{
} else {
$reqRes = $reqNPCDevel;
if ($genRes >= $reqNPCWar && $reqNPCWar > $reqNPCDevel + 1000) {
$amount = $genRes - $reqNPCDevel;
@@ -2783,8 +2776,7 @@ class GeneralAI
'isGold' => 'rice',
'amount' => $genRes
], $genRes];
}
else{
} else {
$args[] = [[
'isGold' => 'rice',
'amount' => $genRes / 2
@@ -2850,8 +2842,7 @@ class GeneralAI
if ($city['pop'] >= $minRecruitPop) {
return null;
}
}
else{
} else {
if ($city['pop'] / $city['pop_max'] >= $this->nationPolicy->safeRecruitCityPopulationRatio) {
if ($city['pop'] >= $this->nationPolicy->minNPCRecruitCityPopulation && $city['pop'] >= $minRecruitPop) {
LogText("{$this->general->getName()}, {$this->general->getID()} 후방워프 불가: 인구 충분", [$city['pop'] / $city['pop_max'], $this->nationPolicy->safeRecruitCityPopulationRatio]);
@@ -2900,8 +2891,7 @@ class GeneralAI
}
if (key_exists($cityID, $this->frontCities)) {
$recruitableCityList[$cityID] = $pop_ratio / 2;
}
else{
} else {
$recruitableCityList[$cityID] = $pop_ratio;
}
}
@@ -3345,7 +3335,8 @@ class GeneralAI
return $cmd;
}
protected function categorizeNationCities():void{
protected function categorizeNationCities(): void
{
if ($this->nationCities !== null) {
return;
@@ -3377,8 +3368,7 @@ class GeneralAI
}
if ($nationCity['front']) {
$frontCities[$cityID] = $nationCity;
}
else{
} else {
$backupCities[$cityID] = $nationCity;
}
@@ -3392,7 +3382,8 @@ class GeneralAI
}
protected function categorizeNationGeneral():void{
protected function categorizeNationGeneral(): void
{
if ($this->userGenerals !== null) {
return;
}
@@ -3436,8 +3427,7 @@ class GeneralAI
if ($officerLevel > 4) {
$chiefGenerals[$officerLevel] = $nationGeneral;
}
else if($officerLevel > 2){
} else if ($officerLevel > 2) {
$nationCities[$officerCity]['important'] += 1;
}
@@ -3453,29 +3443,24 @@ class GeneralAI
if ($npcType == 5) {
//부대장임
$troopLeaders[$generalID] = $nationGeneral;
}
else if($nationGeneral->getVar('troop') === $generalID && $nationGeneral->getReservedTurn(0, $this->env)->getName() === 'che_집합'){
} else if ($nationGeneral->getVar('troop') === $generalID && $nationGeneral->getReservedTurn(0, $this->env)->getName() === 'che_집합') {
//비 NPC부대장임
$troopLeaders[$generalID] = $nationGeneral;
}
else if($nationGeneral->getVar('killturn') < 5){
} else if ($nationGeneral->getVar('killturn') < 5) {
//삭턴이 몇 안남은 장수는 '내정장 npc'로 처리
$npcCivilGenerals[$generalID] = $nationGeneral;
}
else if($npcType < 2) {
} else if ($npcType < 2) {
$userGenerals[$generalID] = $nationGeneral;
if ($nationGeneral->calcRecentWarTurn($this->env['turnterm']) <= $lastWar + 12) {
$userWarGenerals[$generalID] = $nationGeneral;
}
else if(
} else if (
$this->dipState !== self::d평화 &&
$nationGeneral->getVar('crew') >= $this->nationPolicy->minWarCrew
) {
$userWarGenerals[$generalID] = $nationGeneral;
//TODO: 훈련,사기 나중에 되돌릴 것
//TODO: 징,모병턴 기준으로 계산하는 코드를 추가할 것
}
else{
} else {
$userCivilGenerals[$generalID] = $nationGeneral;
}
} else if ($nationGeneral->getLeadership(false) >= $this->nationPolicy->minNPCWarLeadership) {
@@ -3497,7 +3482,8 @@ class GeneralAI
}
public function chooseNationTurn(NationCommand $reservedCommand): NationCommand{
public function chooseNationTurn(NationCommand $reservedCommand): NationCommand
{
//TODO: NationTurn과 InstantNationTurn 구분 필요
$lastTurn = $reservedCommand->getLastTurn();
$general = $this->general;
@@ -3523,8 +3509,7 @@ class GeneralAI
$this->chooseTexRate();
$this->chooseRiceBillRate();
}
}
else if(in_array($month, [3, 6, 9, 12])){
} else if (in_array($month, [3, 6, 9, 12])) {
$this->chooseNonLordPromotion();
}
}
@@ -3564,7 +3549,8 @@ class GeneralAI
return $cmd;
}
public function chooseInstantNationTurn(NationCommand $reservedCommand): ?NationCommand{
public function chooseInstantNationTurn(NationCommand $reservedCommand): ?NationCommand
{
if ($reservedCommand->hasFullConditionMet()) {
return $reservedCommand;
}
@@ -3585,7 +3571,8 @@ class GeneralAI
return buildNationCommandClass(null, $this->general, $this->env, $this->general->getLastTurn());
}
public function chooseGeneralTurn(GeneralCommand $reservedCommand): GeneralCommand{
public function chooseGeneralTurn(GeneralCommand $reservedCommand): GeneralCommand
{
$general = $this->general;
$npcType = $general->getNPCType();
$nationID = $general->getNationID();
@@ -3747,7 +3734,8 @@ class GeneralAI
return $this->devRate;
}
protected function chooseNonLordPromotion(){
protected function chooseNonLordPromotion()
{
//빈자리는 아무나 채움
$db = DB::db();
@@ -3772,17 +3760,13 @@ class GeneralAI
/** @var General */
if ($this->npcWarGenerals) {
$randGeneral = Util::choiceRandom($this->npcWarGenerals);
}
else if($this->npcCivilGenerals){
} else if ($this->npcCivilGenerals) {
$randGeneral = Util::choiceRandom($this->npcCivilGenerals);
}
else if($this->userWarGenerals){
} else if ($this->userWarGenerals) {
$randGeneral = Util::choiceRandom($this->userWarGenerals);
}
else if($this->userCivilGenerals){
} else if ($this->userCivilGenerals) {
$randGeneral = Util::choiceRandom($this->userCivilGenerals);
}
else{
} else {
break;
}
@@ -3799,8 +3783,7 @@ class GeneralAI
if ($randGeneral->getStrength(false, false, false, false) < GameConst::$chiefStatMin) {
continue;
}
}
else{
} else {
if ($randGeneral->getIntel(false, false, false, false) < GameConst::$chiefStatMin) {
continue;
}
@@ -3829,7 +3812,8 @@ class GeneralAI
}
}
protected function calcCityDevelRate(array $city){
protected function calcCityDevelRate(array $city)
{
return [
'trust' => [$city['trust'] / 100, self::t통솔장],
'pop' => [$city['pop'] / $city['pop_max'], self::t통솔장],
@@ -3841,7 +3825,8 @@ class GeneralAI
];
}
protected function choosePromotion(){
protected function choosePromotion()
{
$db = DB::db();
$nation = $this->nation;
@@ -3928,8 +3913,7 @@ class GeneralAI
if (!key_exists($chiefLevel, $this->chiefGenerals) && !key_exists($chiefLevel, $nextChiefs)) {
$newChiefProb = 1;
}
else{
} else {
$newChiefProb = Util::randF(0.1);
}
@@ -3951,11 +3935,9 @@ class GeneralAI
}
if ($chiefLevel == 11) {
}
else if($chiefLevel % 2 == 0 && $general->getStrength(false, false, false, false) < GameConst::$chiefStatMin){
} else if ($chiefLevel % 2 == 0 && $general->getStrength(false, false, false, false) < GameConst::$chiefStatMin) {
continue;
}
else if($chiefLevel % 2 == 1 && $general->getIntel(false, false, false, false) < GameConst::$chiefStatMin){
} else if ($chiefLevel % 2 == 1 && $general->getIntel(false, false, false, false) < GameConst::$chiefStatMin) {
continue;
}
+2 -2
View File
@@ -71,7 +71,7 @@ class APIHelper
[$lastModified, $etag] = $cacheResult;
if ($lastModified !== null) {
header("Last-Modified: " . gmdate("D, d M Y H:i:s", TimeUtil::DateTimeToSeconds($lastModified, true)) . " GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s", Util::toInt(TimeUtil::DateTimeToSeconds($lastModified, true))) . " GMT");
}
if ($etag !== null) {
header("Etag: $etag");
@@ -97,7 +97,7 @@ class APIHelper
} catch (\Exception $e) {
Json::dieWithReason($e->getMessage());
} catch (mixed $e) {
Json::dieWithReason($e);
Json::dieWithReason(strval($e));
}
}
}
+1
View File
@@ -39,6 +39,7 @@ class Json
return json_decode($value);
}
/** @return never */
public static function die($value, $flag = self::NO_CACHE)
{
//NOTE: REST 형식에 맞게, ok(), fail()로 쪼개는게 낫지 않을까 생각해봄.
+1 -1
View File
@@ -618,7 +618,7 @@ class Util extends \utilphp\util
*
* @param array $items 선택하고자 하는 배열
*
* @return int|float|string|object 선택된 value값.
* @return int|float|string|array|object 선택된 value값.
*/
public static function choiceRandom(array $items)
{