원조 받으면 불가침 제의
This commit is contained in:
@@ -91,6 +91,7 @@ $zeroPolicy = new AutorunNationPolicy($general, ($gameStor->autorun_user)['optio
|
|||||||
var availableGeneralActionPriorityItems = <?= Json::encode(AutorunGeneralPolicy::$default_priority) ?>;
|
var availableGeneralActionPriorityItems = <?= Json::encode(AutorunGeneralPolicy::$default_priority) ?>;
|
||||||
|
|
||||||
var btnHelpMessage = {
|
var btnHelpMessage = {
|
||||||
|
'불가침제의': '군주가 NPC이고, 타국에서 원조를 받았을 때,<br>세입(금/쌀) 대비 원조량에 따라 불가침제의를 합니다.',
|
||||||
'선전포고': '군주가 NPC이고, 전쟁중이 아닐 때,<br>주변국중 하나를 골라 선포합니다.<br><br>선포 시점은 다음을 참고합니다.<br>- 인구율<br>- 도시내정률<br>- NPC전투장권장 금 충족률<br>- NPC전투장권장 쌀 충족률<br><br>국력이 낮은 국가를 조금 더 선호합니다.',
|
'선전포고': '군주가 NPC이고, 전쟁중이 아닐 때,<br>주변국중 하나를 골라 선포합니다.<br><br>선포 시점은 다음을 참고합니다.<br>- 인구율<br>- 도시내정률<br>- NPC전투장권장 금 충족률<br>- NPC전투장권장 쌀 충족률<br><br>국력이 낮은 국가를 조금 더 선호합니다.',
|
||||||
'천도': '인구가 많은 곳을 찾아 천도를 시도합니다.<br>영토의 가운데를 선호합니다.<br><br>도시 인구가 충분하다면, 굳이 천도하지는 않습니다.',
|
'천도': '인구가 많은 곳을 찾아 천도를 시도합니다.<br>영토의 가운데를 선호합니다.<br><br>도시 인구가 충분하다면, 굳이 천도하지는 않습니다.',
|
||||||
'유저장긴급포상': '금/쌀이 부족한 유저전투장에게 긴급하게 포상합니다.<br>국고가 권장량보다 적어지더라도 시도합니다.',
|
'유저장긴급포상': '금/쌀이 부족한 유저전투장에게 긴급하게 포상합니다.<br>국고가 권장량보다 적어지더라도 시도합니다.',
|
||||||
|
|||||||
@@ -623,7 +623,7 @@ function updateNationState()
|
|||||||
$nation['nation'],
|
$nation['nation'],
|
||||||
$targetKillTurn
|
$targetKillTurn
|
||||||
);
|
);
|
||||||
$nationGenList = General::createGeneralObjListFromDB($nationGenIDList, ['belong'], 2);
|
$nationGenList = General::createGeneralObjListFromDB($nationGenIDList, ['belong', 'npc'], 2);
|
||||||
$chiefObj = null;
|
$chiefObj = null;
|
||||||
|
|
||||||
$uniqueLotteryWeightList = [];
|
$uniqueLotteryWeightList = [];
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ class AutorunNationPolicy {
|
|||||||
static $NPC몰수 = 'NPC몰수';
|
static $NPC몰수 = 'NPC몰수';
|
||||||
|
|
||||||
// 군주 행동
|
// 군주 행동
|
||||||
|
static $불가침제의 = '불가침제의';
|
||||||
static $선전포고 = '선전포고';
|
static $선전포고 = '선전포고';
|
||||||
static $천도 = '천도';
|
static $천도 = '천도';
|
||||||
|
|
||||||
@@ -35,6 +36,7 @@ class AutorunNationPolicy {
|
|||||||
|
|
||||||
//실제 행동
|
//실제 행동
|
||||||
static public $defaultPriority = [
|
static public $defaultPriority = [
|
||||||
|
'불가침제의',
|
||||||
'선전포고',
|
'선전포고',
|
||||||
'천도',
|
'천도',
|
||||||
|
|
||||||
@@ -106,6 +108,7 @@ class AutorunNationPolicy {
|
|||||||
public $canNPC포상 = true;
|
public $canNPC포상 = true;
|
||||||
public $canNPC몰수 = true;
|
public $canNPC몰수 = true;
|
||||||
|
|
||||||
|
public $can불가침제의 = true;
|
||||||
public $can선전포고 = true;
|
public $can선전포고 = true;
|
||||||
public $can천도 = true;
|
public $can천도 = true;
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ use \sammo\{
|
|||||||
GameUnitConst,
|
GameUnitConst,
|
||||||
Command,
|
Command,
|
||||||
Json,
|
Json,
|
||||||
|
KVStorage,
|
||||||
StringUtil
|
StringUtil
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -91,7 +92,7 @@ class che_물자원조 extends Command\NationCommand{
|
|||||||
protected function initWithArg()
|
protected function initWithArg()
|
||||||
{
|
{
|
||||||
$destNationID = $this->arg['destNationID'];
|
$destNationID = $this->arg['destNationID'];
|
||||||
$this->setDestNation($destNationID, ['gold', 'rice', 'surlimit', 'aux']);
|
$this->setDestNation($destNationID, ['gold', 'rice', 'surlimit']);
|
||||||
|
|
||||||
[$goldAmount, $riceAmount] = $this->arg['amountList'];
|
[$goldAmount, $riceAmount] = $this->arg['amountList'];
|
||||||
$limit = $this->nation['level'] * GameConst::$coefAidAmount;
|
$limit = $this->nation['level'] * GameConst::$coefAidAmount;
|
||||||
@@ -223,12 +224,10 @@ class che_물자원조 extends Command\NationCommand{
|
|||||||
$destNationLogger = new ActionLogger(0, $destChiefID, $year, $month);
|
$destNationLogger = new ActionLogger(0, $destChiefID, $year, $month);
|
||||||
$destNationLogger->pushNationalHistoryLog("<D><b>{$nationName}</b></>{$josaRoSrc}부터 금<C>{$goldAmountText}</> 쌀<C>{$riceAmountText}</>을 지원 받음");
|
$destNationLogger->pushNationalHistoryLog("<D><b>{$nationName}</b></>{$josaRoSrc}부터 금<C>{$goldAmountText}</> 쌀<C>{$riceAmountText}</>을 지원 받음");
|
||||||
|
|
||||||
|
$destNationStor = KVStorage::getStorage(DB::db(), $destNationID, 'nation_env');
|
||||||
$destAux = Json::decode($this->destNation['aux']);
|
$destRecvAssist = $destNationStor->getValue('recv_assist')??[];
|
||||||
if(!key_exists('recv_assist', $destAux)){
|
$destRecvAssist["n{$nationID}"] = [$nationID, ($destRecvAssist["n{$nationID}"][1]??0) + $goldAmount + $riceAmount];
|
||||||
$destAux['recv_assist'] = [];
|
$destNationStor->setValue('recv_assist', $destRecvAssist);
|
||||||
}
|
|
||||||
$destAux['recv_assist'][$nationID] = $destAux['recv_assist'][$nationID]??0 + $goldAmount + $riceAmount;
|
|
||||||
|
|
||||||
$db->update('nation', [
|
$db->update('nation', [
|
||||||
'gold'=>$db->sqleval('gold - %i', $goldAmount),
|
'gold'=>$db->sqleval('gold - %i', $goldAmount),
|
||||||
@@ -239,7 +238,6 @@ class che_물자원조 extends Command\NationCommand{
|
|||||||
$db->update('nation', [
|
$db->update('nation', [
|
||||||
'gold'=>$db->sqleval('gold + %i', $goldAmount),
|
'gold'=>$db->sqleval('gold + %i', $goldAmount),
|
||||||
'rice'=>$db->sqleval('rice + %i', $riceAmount),
|
'rice'=>$db->sqleval('rice + %i', $riceAmount),
|
||||||
'aux'=>Json::encode($destAux)
|
|
||||||
], 'nation = %i', $destNationID);
|
], 'nation = %i', $destNationID);
|
||||||
|
|
||||||
$general->addExperience(5);
|
$general->addExperience(5);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ use function \sammo\GetImageUR;
|
|||||||
use \sammo\Constraint\Constraint;
|
use \sammo\Constraint\Constraint;
|
||||||
use \sammo\Constraint\ConstraintHelper;
|
use \sammo\Constraint\ConstraintHelper;
|
||||||
use sammo\Json;
|
use sammo\Json;
|
||||||
|
use sammo\KVStorage;
|
||||||
|
|
||||||
class che_불가침수락 extends Command\NationCommand
|
class che_불가침수락 extends Command\NationCommand
|
||||||
{
|
{
|
||||||
@@ -188,11 +189,12 @@ class che_불가침수락 extends Command\NationCommand
|
|||||||
$destNationID = $destNation['nation'];
|
$destNationID = $destNation['nation'];
|
||||||
$destNationName = $destNation['name'];
|
$destNationName = $destNation['name'];
|
||||||
|
|
||||||
$destNationAux = Json::decode($db->queryFirstField('SELECT aux FROM nation WHERE nation = %i', $destNationID));
|
$destNationStor = KVStorage::getStorage(DB::db(), $destNationID, 'nation_env');
|
||||||
if(!key_exists('resp_assist', $destNationAux)){
|
$destRecvAssist = $destNationStor->getValue('recv_assist')??[];
|
||||||
$destNationAux['resp_assist'] = [];
|
$destRespAssist = $destNationStor->getValue('resp_assist')??[];
|
||||||
}
|
|
||||||
$destNationAux['resp_assist'][$nationID] = $destNationAux['recv_assist'][$nationID]??0;
|
$destRespAssist["n{$nationID}"] = [$nationID, $destRecvAssist["n{$nationID}"][1]??0];
|
||||||
|
$destNationStor->setValue('resp_assist', $destRespAssist);
|
||||||
|
|
||||||
$year = $this->arg['year'];
|
$year = $this->arg['year'];
|
||||||
$month = $this->arg['month'];
|
$month = $this->arg['month'];
|
||||||
@@ -203,10 +205,6 @@ class che_불가침수락 extends Command\NationCommand
|
|||||||
$currentMonth = $env['year'] * 12 + $env['month'] - 1;
|
$currentMonth = $env['year'] * 12 + $env['month'] - 1;
|
||||||
$reqMonth = $year * 12 + $month - 1;
|
$reqMonth = $year * 12 + $month - 1;
|
||||||
|
|
||||||
$db->update('nation', [
|
|
||||||
'aux'=>Json::encode($destNationAux)
|
|
||||||
], 'nation=%i', $destNationID);
|
|
||||||
|
|
||||||
$db->update(
|
$db->update(
|
||||||
'diplomacy',
|
'diplomacy',
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -1712,6 +1712,88 @@ class GeneralAI
|
|||||||
return $cmd;
|
return $cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 군주 행동
|
||||||
|
protected function do불가침제의(LastTurn $lastTurn): ?NationCommand
|
||||||
|
{
|
||||||
|
$general = $this->general;
|
||||||
|
|
||||||
|
if($general->getVar('officer_level') < 12){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$nation = $this->nation;
|
||||||
|
$nationID = $nation['nation'];
|
||||||
|
|
||||||
|
$nationStor = KVStorage::getStorage(DB::db(), $nationID, 'nation_env');
|
||||||
|
$recvAssist = $nationStor->getValue('recv_assist')??[];
|
||||||
|
$respAssist = $nationStor->getValue('resp_assist')??[];
|
||||||
|
$respAssistTry = $nationStor->getValue('resp_assist_try')??[];
|
||||||
|
|
||||||
|
$yearMonth = Util::joinYearMonth($this->env['year'], $this->env['month']);
|
||||||
|
|
||||||
|
$candidateList = [];
|
||||||
|
foreach($recvAssist as [$candNationID, $amount]){
|
||||||
|
$amount -= $respAssist["n{$candNationID}"][1]??0;
|
||||||
|
if($amount <= 0){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(key_exists($candNationID, $this->warTargetNation)){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(($respAssistTry["n{$candNationID}"][1]??0) >= $yearMonth - 8){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$candidateList[$candNationID] = $amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$candidateList){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$cityList = $this->supplyCities;
|
||||||
|
|
||||||
|
if (!$cityList) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$goldIncome = getGoldIncome($nation['nation'], $nation['level'], 15, $nation['capital'], $nation['type'], $cityList);
|
||||||
|
$riceIncome = getRiceIncome($nation['nation'], $nation['level'], 15, $nation['capital'], $nation['type'], $cityList);
|
||||||
|
$wallIncome = getWallIncome($nation['nation'], $nation['level'], 15, $nation['capital'], $nation['type'], $cityList);
|
||||||
|
$income = $goldIncome + $riceIncome + $wallIncome;
|
||||||
|
|
||||||
|
arsort($candidateList);
|
||||||
|
$destNationID = null;
|
||||||
|
$diplomatMonth = 0;
|
||||||
|
foreach($candidateList as $candNationID => $amount){
|
||||||
|
if($amount * 4 < $income){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$destNationID = $candNationID;
|
||||||
|
$diplomatMonth = 24 * $amount / $income;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($destNationID === null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[$targetYear, $targetMonth] = Util::parseYearMonth($yearMonth + $diplomatMonth);
|
||||||
|
|
||||||
|
$cmd = buildNationCommandClass('che_불가침제의', $this->general, $this->env, $lastTurn, [
|
||||||
|
'destNationID' => $destNationID,
|
||||||
|
'year' => $targetYear,
|
||||||
|
'month' => $targetMonth,
|
||||||
|
]);
|
||||||
|
if(!$cmd->hasFullConditionMet()){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$respAssistTry["n{$destNationID}"] = [$destNationID, $yearMonth];
|
||||||
|
$nationStor->setValue('resp_assist_try', $respAssistTry);
|
||||||
|
|
||||||
|
return $cmd;
|
||||||
|
}
|
||||||
|
|
||||||
// 군주 행동
|
// 군주 행동
|
||||||
protected function do선전포고(LastTurn $lastTurn): ?NationCommand
|
protected function do선전포고(LastTurn $lastTurn): ?NationCommand
|
||||||
|
|||||||
Reference in New Issue
Block a user