diff --git a/hwe/sammo/Event/Action/RegNPC.php b/hwe/sammo/Event/Action/RegNPC.php index 8d3a922d..267710eb 100644 --- a/hwe/sammo/Event/Action/RegNPC.php +++ b/hwe/sammo/Event/Action/RegNPC.php @@ -9,7 +9,7 @@ class RegNPC extends \sammo\Event\Action{ public function __construct( int $affinity, string $name, - int $pictureID, + $picturePath, int $nationID, $locatedCity, int $leadership, @@ -24,7 +24,7 @@ class RegNPC extends \sammo\Event\Action{ $this->npc = new \sammo\Scenario\NPC( $affinity, $name, - $pictureID, + $picturePath, $nationID, $locatedCity, $leadership, diff --git a/hwe/sammo/Scenario.php b/hwe/sammo/Scenario.php index 021989e1..a941237b 100644 --- a/hwe/sammo/Scenario.php +++ b/hwe/sammo/Scenario.php @@ -15,6 +15,8 @@ class Scenario{ private $history; private $nations; + private $nationsInv; + private $diplomacy; private $generals; @@ -36,13 +38,17 @@ class Scenario{ $this->initOK = true; $data = $this->data; + $neutralNation = new Scenario\Nation(0, '재야', '#000000', 0, 0); $this->nations = []; - $this->nations[0] = new Scenario\Nation(0, '재야', '#000000', 0, 0); + $this->nations[0] = $neutralNation; + $this->nationsInv = [$neutralNation->getName() => $neutralNation]; + foreach (Util::array_get($data['nation'],[]) as $idx=>$rawNation) { list($name, $color, $gold, $rice, $infoText, $tech, $type, $nationLevel, $cities) = $rawNation; $nationID = $idx+1; - $this->nations[$nationID] = new Scenario\Nation( + + $nation = new Scenario\Nation( $nationID, $name, $color, @@ -54,6 +60,8 @@ class Scenario{ $nationLevel, $cities ); + $this->nations[$nationID] = $nation; + $this->nationsInv[$nation->getName()] = $nation; } $this->diplomacy = Util::array_get($data['diplomacy'], []); @@ -65,12 +73,18 @@ class Scenario{ } list( - $affinity, $name, $pictureID, $nationID, $locatedCity, + $affinity, $name, $picturePath, $nationName, $locatedCity, $leadership, $power, $intel, $level, $birth, $death, $ego, $char, $text ) = $rawGeneral; - if(!key_exists($nationID, $this->nations)){ + if(key_exists($nationName, $this->nationsInv)){ + $nationID = $this->nationsInv[$nationName]->getID(); + } + else if(key_exists($nationName, $this->nations)){ + $nationID = (int)$nationName; + } + else{ $nationID = 0; } @@ -79,7 +93,7 @@ class Scenario{ return new Scenario\NPC( $affinity, $name, - $pictureID, + $picturePath, $nationID, $locatedCity, $leadership, @@ -100,12 +114,18 @@ class Scenario{ } list( - $affinity, $name, $pictureID, $nationID, $locatedCity, + $affinity, $name, $picturePath, $nationName, $locatedCity, $leadership, $power, $intel, $level, $birth, $death, $ego, $char, $text ) = $rawGeneral; - if(!key_exists($nationID, $this->nations)){ + if(key_exists($nationName, $this->nationsInv)){ + $nationID = $this->nationsInv[$nationName]->id;; + } + else if(key_exists($nationName, $this->nations)){ + $nationID = (int)$nationName; + } + else{ $nationID = 0; } @@ -114,7 +134,7 @@ class Scenario{ return new Scenario\NPC( $affinity, $name, - $pictureID, + $picturePath, $nationID, $locatedCity, $leadership, diff --git a/hwe/sammo/Scenario/NPC.php b/hwe/sammo/Scenario/NPC.php index 32965c4a..3bbadc07 100644 --- a/hwe/sammo/Scenario/NPC.php +++ b/hwe/sammo/Scenario/NPC.php @@ -8,7 +8,7 @@ class NPC{ public $affinity; public $name; - public $pictureID; + public $picturePath; public $nationID; public $locatedCity; public $leadership; @@ -26,7 +26,7 @@ class NPC{ public function __construct( int $affinity, string $name, - int $pictureID, + $picturePath, int $nationID, $locatedCity, //FIXME: 7.1로 올릴 때 ?string 으로 변경 int $leadership, @@ -41,7 +41,7 @@ class NPC{ ){ $this->affinity = $affinity; $this->name = $name; - $this->pictureID = $pictureID; + $this->picturePath = $picturePath; $this->nationID = $nationID; $this->locatedCity = $locatedCity; $this->leadership = $leadership; @@ -142,12 +142,12 @@ class NPC{ $name = 'ⓝ'.$this->name; - $pictureID = $this->pictureID; - if($env['show_img_level'] == 3 && $pictureID > 0){ - $picture = "{$pictureID}.jpg"; + $picturePath = $this->picturePath; + if($env['show_img_level'] < 3){ + $picturePath = 'default.jpg'; } - else{ - $picture = 'default.jpg'; + else if(is_numeric($picturePath)){ + $picturePath = "{$picturePath}.jpg"; } $city = $this->locatedCity; @@ -187,7 +187,7 @@ class NPC{ 'npc_org'=>2, 'affinity'=>$affinity, 'name'=>$name, - 'picture'=>$picture, + 'picture'=>$picturePath, 'nation'=>$nationID, 'city'=>$city, 'leader'=>$this->leadership, diff --git a/hwe/sammo/Scenario/Nation.php b/hwe/sammo/Scenario/Nation.php index 9cf9b793..2613ca95 100644 --- a/hwe/sammo/Scenario/Nation.php +++ b/hwe/sammo/Scenario/Nation.php @@ -55,6 +55,10 @@ class Nation{ return $this->id; } + public function getName(){ + return $this->name; + } + public function build($env=[]){ //NOTE: NPC의 숫자는 아직 확정된 것이 아니다. $cities = array_map(function($cityName){ diff --git a/hwe/sql/schema.sql b/hwe/sql/schema.sql index cafda9b9..002a84bb 100644 --- a/hwe/sql/schema.sql +++ b/hwe/sql/schema.sql @@ -18,7 +18,7 @@ CREATE TABLE `general` ( `refresh` INT(6) NULL DEFAULT '0', `logcnt` INT(6) NULL DEFAULT '1', `refcnt` INT(6) NULL DEFAULT '1', - `picture` CHAR(32) NOT NULL, + `picture` VARCHAR(40) NOT NULL, `imgsvr` INT(1) NULL DEFAULT '0', `name` CHAR(32) NOT NULL COLLATE 'utf8mb4_bin', `name2` CHAR(32) NULL DEFAULT NULL COLLATE 'utf8mb4_bin', @@ -370,7 +370,7 @@ create table if not exists hall ( nation char(12) default '', data int(5) default 0, color char(12) default '', - picture char(32) default '', + picture varchar(40) default '', PRIMARY KEY (no), UNIQUE INDEX `type` (`type`, `rank`)