시나리오 json 파일에서 받아오는 규격 확장

국가를 'string'으로 표기 가능하도록 변경
전콘 번호를 'string'으로 표기 가능하도록 변경
This commit is contained in:
2018-05-28 23:08:59 +09:00
parent 30e2432fc3
commit d9f6f7956e
5 changed files with 45 additions and 21 deletions
+2 -2
View File
@@ -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,
+28 -8
View File
@@ -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,
+9 -9
View File
@@ -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,
+4
View File
@@ -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){
+2 -2
View File
@@ -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`)