diff --git a/hwe/_admin7.php b/hwe/_admin7.php
index a51290fc..b7589e2a 100644
--- a/hwe/_admin7.php
+++ b/hwe/_admin7.php
@@ -114,14 +114,14 @@ $generalObj = General::createGeneralObjFromDB($gen);
정렬순서 :
대상장수 :
diff --git a/hwe/b_battleCenter.php b/hwe/b_battleCenter.php
index 851bfbdd..ada1463d 100644
--- a/hwe/b_battleCenter.php
+++ b/hwe/b_battleCenter.php
@@ -54,17 +54,10 @@ increaseRefresh("감찰부", 2);
TurnExecutionHelper::executeAllCommand();
$gameStor->resetCache();
-$query = "select nation from general where no='$gen'";
-$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
-$general = MYDB_fetch_array($result);
+$testGeneralNationID = $db->queryFirstField('SELECT nation FROM general WHERE no = %i', $gen);
-$query = "select no,nation,officer_level,con,turntime,belong,permission,penalty from general where owner='{$userID}'";
-$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
-$me = MYDB_fetch_array($result);
-
-$query = "select secretlimit from nation where nation='{$me['nation']}'";
-$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), "");
-$nation = MYDB_fetch_array($result);
+$me = $db->queryFirstRow('SELECT no,nation,officer_level,con,turntime,belong,permission,penalty from general where owner=%i', $userID);
+$nationID = $me['nation'];
$con = checkLimit($me['con']);
if ($con >= 2) {
@@ -83,7 +76,7 @@ else if ($permission < 1) {
}
//잘못된 접근
-if ($general['nation'] != $me['nation']) {
+if ($testGeneralNationID != $nationID) {
$gen = 0;
}
@@ -94,24 +87,24 @@ if ($btn == '정렬하기') {
[$queryTypeText, $reqArgType, $comp] = $queryMap[$reqQueryType];
if($reqArgType===0){
- $generalBasicList = $db->query('SELECT no, name, npc, turntime FROM general');
+ $generalBasicList = $db->query('SELECT no, name, npc, turntime FROM general WHERE nation = %i', $nationID);
}
else if($reqArgType===1){
- $generalBasicList = $db->query('SELECT no, name, npc, turntime, %b FROM general', $reqQueryType);
+ $generalBasicList = $db->query('SELECT no, name, npc, turntime, %b FROM general WHERE nation = %i', $reqQueryType, $nationID);
}
else if($reqArgType===2){
$generalBasicList = $db->query('SELECT no, name, npc, turntime, value as %b
FROM general LEFT JOIN rank_data
ON general.no = rank_data.general_id
- WHERE rank_data.type = %b',
- $reqQueryType, $reqQueryType
+ WHERE rank_data.type = %b AND general.nation = %i',
+ $reqQueryType, $reqQueryType, $nationID
);
}
else if($reqArgType===3){
$generalBasicList = array_map(function($arr){
$arr['aux'] = Json::decode($arr['aux']);
return $arr;
- }, $db->query('SELECT no, name, npc, turntime, aux FROM general'));
+ }, $db->query('SELECT no, name, npc, turntime, aux FROM general WHERE nation = %i', $nationID));
}
else{
throw new \sammo\MustNotBeReachedException();
@@ -148,16 +141,16 @@ $showGeneral = General::createGeneralObjFromDB($gen);
|
|
- 1 || $permission >= 2): ?>
+getVar('npc') > 1 || $permission >= 2): ?>
| 개인 기록 |
|
diff --git a/hwe/sammo/AutorunGeneralPolicy.php b/hwe/sammo/AutorunGeneralPolicy.php
index 245c4673..5dc086a8 100644
--- a/hwe/sammo/AutorunGeneralPolicy.php
+++ b/hwe/sammo/AutorunGeneralPolicy.php
@@ -39,7 +39,7 @@ class AutorunGeneralPolicy{
- static public $priority = [
+ static public $default_priority = [
'NPC사망대비',
'귀환',
'금쌀구매',
@@ -114,7 +114,8 @@ class AutorunGeneralPolicy{
}
function __construct(General $general, $aiOptions){
-
+ //TODO: 국가 정책을 받아와야함
+ $this->priority = static::$default_priority;
if($general->getVar('npc') >= 2){
$this->doNPCState($general);
diff --git a/hwe/sammo/Command/General/che_군량매매.php b/hwe/sammo/Command/General/che_군량매매.php
index 3896a324..50852b8f 100644
--- a/hwe/sammo/Command/General/che_군량매매.php
+++ b/hwe/sammo/Command/General/che_군량매매.php
@@ -38,7 +38,7 @@ class che_군량매매 extends Command\GeneralCommand{
if(!is_int($amount)){
return false;
}
- $amount = Util::valueFit($amount, 100, GameConst::$maxIncentiveAmount);
+ $amount = Util::valueFit($amount, 100, GameConst::$maxResourceActionAmount);
$this->arg = [
'buyRice'=>$buyRice,
diff --git a/hwe/sammo/Command/General/che_징병.php b/hwe/sammo/Command/General/che_징병.php
index 1815afe6..c6a2d349 100644
--- a/hwe/sammo/Command/General/che_징병.php
+++ b/hwe/sammo/Command/General/che_징병.php
@@ -165,12 +165,11 @@ class che_징병 extends Command\GeneralCommand{
$currCrewType = $this->currCrewType;
$crewTypeName = $reqCrewType->name;
- $josaUl = JosaUtil::pick($crewTypeName, '을');
$logger = $general->getLogger();
if($reqCrewType->id == $currCrewType->id && $currCrew > 0){
- $logger->pushGeneralActionLog("{$crewTypeName}{$josaUl} {$reqCrewText}>명을 추가{$this->getName()}했습니다. <1>$date>");
+ $logger->pushGeneralActionLog("{$crewTypeName} {$reqCrewText}>명을 추가{$this->getName()}했습니다. <1>$date>");
$train = ($currCrew * $general->getVar('train') + $reqCrew * static::$defaultTrain) / ($currCrew + $reqCrew);
$atmos = ($currCrew * $general->getVar('atmos') + $reqCrew * static::$defaultAtmos) / ($currCrew + $reqCrew);
@@ -179,7 +178,7 @@ class che_징병 extends Command\GeneralCommand{
$general->setVar('atmos', $atmos);
}
else{
- $logger->pushGeneralActionLog("{$crewTypeName}{$josaUl} {$reqCrewText}>명을 {$this->getName()}했습니다. <1>$date>");
+ $logger->pushGeneralActionLog("{$crewTypeName} {$reqCrewText}>명을 {$this->getName()}했습니다. <1>$date>");
$general->setVar('crewtype', $reqCrewType->id);
$general->setVar('crew', $reqCrew);
$general->setVar('train', static::$defaultTrain);
diff --git a/hwe/sammo/GeneralAI.php b/hwe/sammo/GeneralAI.php
index 43a98814..09d2dc15 100644
--- a/hwe/sammo/GeneralAI.php
+++ b/hwe/sammo/GeneralAI.php
@@ -85,7 +85,7 @@ class GeneralAI
{
$db = DB::db();
$gameStor = KVStorage::getStorage($db, 'game_env');
- $this->env = $gameStor->getValues(['startyear', 'year', 'month', 'turnterm', 'killturn', 'scenario', 'gold_rate', 'rice_rate', 'develcost', 'autorun_user']);
+ $this->env = $gameStor->getAll(true);
$this->baseDevelCost = $this->env['develcost'] * 12;
$this->general = $general;
if ($general->getRawCity() === null) {
@@ -1684,6 +1684,10 @@ class GeneralAI
}
}
+ if(!$cmdList){
+ return null;
+ }
+
return Util::choiceRandomUsingWeightPair($cmdList);
}
@@ -2093,7 +2097,7 @@ class GeneralAI
}
}
- if(!$cmd){
+ if(!$cmdList){
return null;
}
return Util::choiceRandomUsingWeightPair($cmdList);
@@ -2251,7 +2255,7 @@ class GeneralAI
return null;
}
- if($this->general['crew'] >= $this->nationPolicy->minWarCrew){
+ if($this->general->getVar('crew') >= $this->nationPolicy->minWarCrew){
return null;
}
@@ -2427,8 +2431,9 @@ class GeneralAI
protected function do귀환(GeneralCommand $reservedCommand): ?GeneralCommand
{
- $cityID = $this->general->getCityID();
- if(key_exists($cityID, $this->supplyCities)){
+ $general = $this->general;
+ $city = $this->city;
+ if($city['nation'] == $general->getNationID() && $city['supply']){
return null;
}
@@ -2456,7 +2461,7 @@ class GeneralAI
$general = $this->general;
$lordCities = $db->queryFirstColumn('SELECT city.city as city FROM general LEFT JOIN city ON general.city = city.city WHERE general.officer_level = 12 AND city.nation = 0');
- $nationCities = $db->queryFirstColumn('SELECT city a FROM city WHERE nation != 0');+
+ $nationCities = $db->queryFirstColumn('SELECT city a FROM city WHERE nation != 0');
$occupiedCities = [];
foreach ($lordCities as $tCityId) {
@@ -2636,7 +2641,7 @@ class GeneralAI
return null;
}
- protected function NPC사망대비(): ?GeneralCommand
+ protected function doNPC사망대비(): ?GeneralCommand
{
$general = $this->getGeneralObj();
@@ -2865,7 +2870,7 @@ class GeneralAI
$this->chooseNonLordPromotion();
}
- if($reservedCommand->isRunnable()){
+ if(!($reservedCommand instanceof Command\NationCommand\휴식) && $reservedCommand->isRunnable()){
return $reservedCommand;
}
@@ -2911,11 +2916,6 @@ class GeneralAI
$npcType = $general->getVar('npc');
$nationID = $general->getNationID();
- $cmd = $this->NPC사망대비();
- if($cmd){
- return $cmd;
- }
-
//특별 메세지 있는 경우 출력 하루 4번
$term = $this->env['turnterm'];
if ($general->getVar('npcmsg') && Util::randBool($term / (6 * 60))) {
@@ -2955,14 +2955,14 @@ class GeneralAI
return $this->do집합($reservedCommand);
}
- if($reservedCommand->isRunnable()){
+ if(!($reservedCommand instanceof Command\General\휴식) && $reservedCommand->isRunnable()){
return $reservedCommand;
}
if ($general->getVar('injury') > 10) {
return buildGeneralCommandClass('che_요양', $general, $this->env);
}
-
+
if($npcType == 2 && $nationID == 0){
$result = $this->do거병($reservedCommand);
if($result !== null){
@@ -2977,7 +2977,7 @@ class GeneralAI
}
return $this->do중립($reservedCommand);
}
-
+
if($npcType >= 2 && $general->getVar('officer_level') == 12 && !$this->nation['capital']){
//방랑군 건국
$result = $this->do건국($reservedCommand);
diff --git a/hwe/sammo/TurnExecutionHelper.php b/hwe/sammo/TurnExecutionHelper.php
index b767c7d1..c29d6905 100644
--- a/hwe/sammo/TurnExecutionHelper.php
+++ b/hwe/sammo/TurnExecutionHelper.php
@@ -269,7 +269,7 @@ WHERE turntime < %s ORDER BY turntime ASC, `no` ASC',
}
$generalCommandObj = $ai->chooseGeneralTurn($generalCommandObj); // npc AI 처리
-
+ LogText("turn", "General: {$general->getName()}[{$general->getID()},{$general->getStaticNation()['name']}]; run; {$generalCommandObj->getBrief()}");
}
if(!$turnObj->processBlocked()){