빙의가 불가능한 general_neutral 항목 추가
This commit is contained in:
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
namespace sammo\Event\Action;
|
||||||
|
|
||||||
|
class RegNeutralNPC extends \sammo\Event\Action{
|
||||||
|
|
||||||
|
private $npc;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
int $affinity,
|
||||||
|
string $name,
|
||||||
|
$picturePath,
|
||||||
|
int $nationID,
|
||||||
|
$locatedCity,
|
||||||
|
int $leadership,
|
||||||
|
int $power,
|
||||||
|
int $intel,
|
||||||
|
int $birth = 160,
|
||||||
|
int $death = 300,
|
||||||
|
$ego = null,
|
||||||
|
$char = '',
|
||||||
|
$text = ''
|
||||||
|
){
|
||||||
|
$this->npc = new \sammo\Scenario\NPC(
|
||||||
|
$affinity,
|
||||||
|
$name,
|
||||||
|
$picturePath,
|
||||||
|
$nationID,
|
||||||
|
$locatedCity,
|
||||||
|
$leadership,
|
||||||
|
$power,
|
||||||
|
$intel,
|
||||||
|
$birth,
|
||||||
|
$death,
|
||||||
|
$ego,
|
||||||
|
$char,
|
||||||
|
$text?:''
|
||||||
|
);
|
||||||
|
$this->npc = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function run($env=null){
|
||||||
|
$result = $this->npc->build($env);
|
||||||
|
return [__CLASS__, $result];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -22,6 +22,7 @@ class Scenario{
|
|||||||
|
|
||||||
private $generals;
|
private $generals;
|
||||||
private $generalsEx;
|
private $generalsEx;
|
||||||
|
private $generalsNeutral;
|
||||||
|
|
||||||
private $tmpGeneralQueue = [];
|
private $tmpGeneralQueue = [];
|
||||||
|
|
||||||
@@ -151,6 +152,50 @@ class Scenario{
|
|||||||
|
|
||||||
}, Util::array_get($data['general_ex'], []));
|
}, Util::array_get($data['general_ex'], []));
|
||||||
|
|
||||||
|
$this->generalsNeutral = array_map(function($rawGeneral){
|
||||||
|
while(count($rawGeneral) < 14){
|
||||||
|
$rawGeneral[] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
list(
|
||||||
|
$affinity, $name, $picturePath, $nationName, $locatedCity,
|
||||||
|
$leadership, $power, $intel, $level, $birth, $death, $ego,
|
||||||
|
$char, $text
|
||||||
|
) = $rawGeneral;
|
||||||
|
|
||||||
|
if(key_exists($nationName, $this->nationsInv)){
|
||||||
|
$nationID = $this->nationsInv[$nationName]->id;;
|
||||||
|
}
|
||||||
|
else if(key_exists($nationName, $this->nations)){
|
||||||
|
$nationID = (int)$nationName;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$nationID = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->tmpGeneralQueue[$name] = $rawGeneral;
|
||||||
|
|
||||||
|
$npc = new Scenario\NPC(
|
||||||
|
$affinity,
|
||||||
|
$name,
|
||||||
|
$picturePath,
|
||||||
|
$nationID,
|
||||||
|
$locatedCity,
|
||||||
|
$leadership,
|
||||||
|
$power,
|
||||||
|
$intel,
|
||||||
|
$level,
|
||||||
|
$birth,
|
||||||
|
$death,
|
||||||
|
$ego,
|
||||||
|
$char,
|
||||||
|
$text
|
||||||
|
);
|
||||||
|
$npc->npc = 6;
|
||||||
|
return $npc;
|
||||||
|
|
||||||
|
}, Util::array_get($data['general_neutral'], []));
|
||||||
|
|
||||||
$this->initialEvents = array_map(function($rawEvent){
|
$this->initialEvents = array_map(function($rawEvent){
|
||||||
$cond = $rawEvent[0];
|
$cond = $rawEvent[0];
|
||||||
$action = array_slice($rawEvent, 1);
|
$action = array_slice($rawEvent, 1);
|
||||||
@@ -247,6 +292,11 @@ class Scenario{
|
|||||||
return $this->generalsEx;
|
return $this->generalsEx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getNPCneutral(){
|
||||||
|
$this->initFull();
|
||||||
|
return $this->generalsNeutral;
|
||||||
|
}
|
||||||
|
|
||||||
public function getNation(){
|
public function getNation(){
|
||||||
$this->initFull();
|
$this->initFull();
|
||||||
return $this->nations;
|
return $this->nations;
|
||||||
@@ -266,6 +316,7 @@ class Scenario{
|
|||||||
$nations = [];
|
$nations = [];
|
||||||
$nationGeneralCnt = [];
|
$nationGeneralCnt = [];
|
||||||
$nationGeneralExCnt = [];
|
$nationGeneralExCnt = [];
|
||||||
|
$nationGeneralNeutralCnt = [];
|
||||||
|
|
||||||
foreach($this->generals as $general){
|
foreach($this->generals as $general){
|
||||||
$nationID = $general->nationID;
|
$nationID = $general->nationID;
|
||||||
@@ -287,15 +338,27 @@ class Scenario{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach($this->generalsNeutral as $general){
|
||||||
|
$nationID = $general->nationID;
|
||||||
|
if(!key_exists($nationID, $nationGeneralNeutralCnt)){
|
||||||
|
$nationGeneralNeutralCnt[$nationID] = 1;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$nationGeneralNeutralCnt[$nationID] += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'year'=>$this->getYear(),
|
'year'=>$this->getYear(),
|
||||||
'title'=>$this->getTitle(),
|
'title'=>$this->getTitle(),
|
||||||
'npc_cnt'=>count($this->getNPC()),
|
'npc_cnt'=>count($this->getNPC()),
|
||||||
'npcEx_cnt'=>count($this->getNPCex()),
|
'npcEx_cnt'=>count($this->getNPCex()),
|
||||||
|
'npcNeutral_cnt'=>count($this->getNPCneutral()),
|
||||||
'nation'=>array_map(function($nation) use ($nationGeneralCnt, $nationGeneralExCnt){
|
'nation'=>array_map(function($nation) use ($nationGeneralCnt, $nationGeneralExCnt){
|
||||||
$brief = $nation->getBrief();
|
$brief = $nation->getBrief();
|
||||||
$brief['generals'] = Util::array_get($nationGeneralCnt[$nation->getID()], 0);
|
$brief['generals'] = Util::array_get($nationGeneralCnt[$nation->getID()], 0);
|
||||||
$brief['generalsEx'] = Util::array_get($nationGeneralExCnt[$nation->getID()], 0);
|
$brief['generalsEx'] = Util::array_get($nationGeneralExCnt[$nation->getID()], 0);
|
||||||
|
$brief['generalsNeutral'] = Util::array_get($nationGeneralNeutralCnt[$nation->getID()], 0);
|
||||||
|
|
||||||
return $brief;
|
return $brief;
|
||||||
},$this->getNation())
|
},$this->getNation())
|
||||||
@@ -350,6 +413,23 @@ class Scenario{
|
|||||||
$remainGenerals[$birth][] = array_merge(['RegNPC'], $rawGeneral);
|
$remainGenerals[$birth][] = array_merge(['RegNPC'], $rawGeneral);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach($this->generalsNeutral as $general){
|
||||||
|
if($general->build($env)){
|
||||||
|
if($general->nationID){
|
||||||
|
$this->nations[$general->nationID]->addGeneral($general);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rawGeneral = $this->tmpGeneralQueue[$general->name];
|
||||||
|
$birth = $general->birth;
|
||||||
|
if(!key_exists($birth, $remainGenerals)){
|
||||||
|
$remainGenerals[$birth] = [];
|
||||||
|
}
|
||||||
|
$remainGenerals[$birth][] = array_merge(['RegNeutralNPC'], $rawGeneral);
|
||||||
|
}
|
||||||
|
|
||||||
return $remainGenerals;
|
return $remainGenerals;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user