npc_control form
This commit is contained in:
@@ -113,10 +113,31 @@ class AutorunGeneralPolicy{
|
||||
|
||||
}
|
||||
|
||||
function __construct(General $general, $aiOptions, array $nationPolicy, array $serverPolicy, array $nation, array $env){
|
||||
//TODO: 국가 정책을 받아와야함
|
||||
function __construct(General $general, $aiOptions, ?array $nationPolicy, ?array $serverPolicy, array $nation, array $env){
|
||||
$this->priority = static::$default_priority;
|
||||
|
||||
if($serverPolicy && key_exists('priority', $serverPolicy)){
|
||||
$priority = [];
|
||||
foreach($serverPolicy['priority'] as $priorityItem){
|
||||
if(!property_exists($this, $priorityItem)){
|
||||
continue;
|
||||
}
|
||||
$priority[] = $priorityItem;
|
||||
}
|
||||
$this->priority = $priority;
|
||||
}
|
||||
|
||||
if($nationPolicy && key_exists('priority', $nationPolicy)){
|
||||
$priority = [];
|
||||
foreach($nationPolicy['priority'] as $priorityItem){
|
||||
if(!property_exists($this, $priorityItem)){
|
||||
continue;
|
||||
}
|
||||
$priority[] = $priorityItem;
|
||||
}
|
||||
$this->priority = $priority;
|
||||
}
|
||||
|
||||
if($general->getNPCType() >= 2){
|
||||
$this->doNPCState($general);
|
||||
return;
|
||||
|
||||
@@ -140,22 +140,68 @@ class AutorunNationPolicy {
|
||||
public $safeRecruitCityPopulationRatio = 0.5;
|
||||
public $properWarTrainAtmos = 90;
|
||||
|
||||
///이쪽의 값이 실제 초기화 값임
|
||||
public static $defaultPolicy = [
|
||||
'reqNationGold'=>10000,
|
||||
'reqNationRice'=>12000,
|
||||
'CombatForce'=>[],
|
||||
'SupportForce'=>[],
|
||||
'DevelopForce'=>[],
|
||||
'reqHumanWarUrgentGold'=>0,
|
||||
'reqHumanWarUrgentRice'=>0,
|
||||
'reqHumanWarRecommandGold'=>0,
|
||||
'reqHumanWarRecommandRice'=>0,
|
||||
'reqHumanDevelGold'=>10000,
|
||||
'reqHumanDevelRice'=>10000,
|
||||
'reqNPCWarGold'=>0,
|
||||
'reqNPCWarRice'=>0,
|
||||
'reqNPCDevelGold'=>0,
|
||||
'reqNPCDevelRice'=>500,
|
||||
|
||||
'minimumResourceActionAmount'=>1000,
|
||||
|
||||
'minNPCWarLeadership'=>40,
|
||||
'minWarCrew'=>1500,
|
||||
|
||||
'allowNpcAttackCity'=>true,
|
||||
'minNPCRecruitCityPopulation'=>50000,
|
||||
'safeRecruitCityPopulationRatio'=>0.5,
|
||||
'properWarTrainAtmos'=>90,
|
||||
];
|
||||
|
||||
function __construct(General $general, $aiOptions, array $nationPolicy, array $serverPolicy, array $nation, array $env)
|
||||
function __construct(General $general, $aiOptions, ?array $nationPolicy, ?array $serverPolicy, array $nation, array $env)
|
||||
{
|
||||
foreach($serverPolicy as $policy=>$value){
|
||||
if(!property_exists($this, $policy)){
|
||||
continue;
|
||||
}
|
||||
$this->$policy = $value;
|
||||
foreach(static::$defaultPolicy as $policy=>$value){
|
||||
$this->{$policy} = $value;
|
||||
}
|
||||
|
||||
if($serverPolicy){
|
||||
foreach($serverPolicy['values']??[] as $policy=>$value){
|
||||
if(!property_exists($this, $policy)){
|
||||
continue;
|
||||
}
|
||||
$this->$policy = $value;
|
||||
}
|
||||
|
||||
foreach($nationPolicy as $policy){
|
||||
if(!property_exists($this, $policy)){
|
||||
continue;
|
||||
if(key_exists('priority', $serverPolicy)){
|
||||
$this->priority = $serverPolicy['priority'];
|
||||
}
|
||||
$this->$policy = $value;
|
||||
}
|
||||
|
||||
|
||||
if($nationPolicy){
|
||||
foreach($nationPolicy['values']??[] as $policy){
|
||||
if(!property_exists($this, $policy)){
|
||||
continue;
|
||||
}
|
||||
$this->$policy = $value;
|
||||
}
|
||||
|
||||
if(key_exists('priority', $nationPolicy)){
|
||||
$this->priority = $nationPolicy['priority'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!$this->priority){
|
||||
$this->priority = $this::$defaultPriority;
|
||||
|
||||
@@ -113,11 +113,11 @@ class GeneralAI
|
||||
'name' => '재야',
|
||||
];
|
||||
|
||||
$serverPolicy = KVStorage::getStorage($db, 'autorun_nation_policy_0');
|
||||
$nationPolicy = KVStorage::getStorage($db, "autorun_nation_policy_{$this->nation['nation']}");
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$nationStor = KVStorage::getStorage($db, $this->nation['nation'], 'nation_env');
|
||||
|
||||
$this->nationPolicy = new AutorunNationPolicy($general, $this->env['autorun_user']['options']??[], $nationPolicy->getAll(), $serverPolicy->getAll(), $this->nation, $this->env);
|
||||
$this->generalPolicy = new AutorunGeneralPolicy($general, $this->env['autorun_user']['options']??[], $nationPolicy->getAll(), $serverPolicy->getAll(), $this->nation, $this->env);
|
||||
$this->nationPolicy = new AutorunNationPolicy($general, $this->env['autorun_user']['options'], $nationStor->getValue('npc_general_policy'), $gameStor->getValue('npc_general_policy'), $this->nation, $this->env);
|
||||
$this->generalPolicy = new AutorunGeneralPolicy($general, $this->env['autorun_user']['options'], $nationStor->getValue('npc_nation_policy'), $gameStor->getValue('npc_nation_policy'), $this->nation, $this->env);
|
||||
|
||||
$this->nation['aux'] = Json::decode($this->nation['aux']??'{}');
|
||||
|
||||
|
||||
@@ -303,8 +303,8 @@ class NPC{
|
||||
$killturn = ($this->death - $year) * 12 + mt_rand(0, 11) + $month - 1;
|
||||
}
|
||||
|
||||
$specage = $this->specAge?:$age + 1;
|
||||
$specage2 = $this->specAge2?:$age + 1;
|
||||
$specage = $this->specAge?:($age + 1);
|
||||
$specage2 = $this->specAge2?:($age + 1);
|
||||
|
||||
$db->insert('general',[
|
||||
'npc'=>$this->npc,
|
||||
|
||||
Reference in New Issue
Block a user