Scenario 초기화 버그 수정

리셋 시 로그 초기화
This commit is contained in:
2018-03-31 19:42:16 +09:00
parent 8713bac296
commit 87c6130d17
4 changed files with 28 additions and 11 deletions
+3
View File
@@ -9,6 +9,9 @@ class FileUtil{
if ($FolderOrFile == "." || $FolderOrFile == "..") { if ($FolderOrFile == "." || $FolderOrFile == "..") {
continue; continue;
} }
if($FolderOrFile[0] == '.'){
continue;
}
$filepath = sprintf('%s/%s', $dir, $FolderOrFile); $filepath = sprintf('%s/%s', $dir, $FolderOrFile);
if (is_dir($filepath)) { if (is_dir($filepath)) {
+4
View File
@@ -40,6 +40,10 @@ if($fullReset && class_exists('\\sammo\\DB')){
} }
} }
} }
if($fullReset){
FileUtil::delInDir(__dir__."/logs");
FileUtil::delInDir(__dir__."/data");
}
function dbConnFail($params){ function dbConnFail($params){
Json::die([ Json::die([
+8 -5
View File
@@ -31,6 +31,8 @@ class Scenario{
if($this->initOK){ if($this->initOK){
return; return;
} }
$this->initOK = true;
$data = $this->data;
$this->nations = []; $this->nations = [];
$this->nations[0] = new Scenario\Nation(0, '재야', '#ffffff', 0, 0); $this->nations[0] = new Scenario\Nation(0, '재야', '#ffffff', 0, 0);
@@ -96,7 +98,7 @@ class Scenario{
list( list(
$affinity, $name, $pictureID, $nationID, $locatedCity, $affinity, $name, $pictureID, $nationID, $locatedCity,
$leadership, $power, $intel, $birth, $death, $ego, $leadership, $power, $intel, $level, $birth, $death, $ego,
$char, $text $char, $text
) = $rawGeneral; ) = $rawGeneral;
@@ -115,6 +117,7 @@ class Scenario{
$leadership, $leadership,
$power, $power,
$intel, $intel,
$level,
$birth, $birth,
$death, $death,
$ego, $ego,
@@ -242,7 +245,7 @@ class Scenario{
continue; continue;
} }
$rawGeneral = $this->tmpGeneralQueue[$general->$name]; $rawGeneral = $this->tmpGeneralQueue[$general->name];
$birth = $general->birth; $birth = $general->birth;
if(!key_exists($birth, $remainGenerals)){ if(!key_exists($birth, $remainGenerals)){
$remainGenerals[$birth] = []; $remainGenerals[$birth] = [];
@@ -256,7 +259,7 @@ class Scenario{
continue; continue;
} }
$rawGeneral = $this->tmpGeneralQueue[$general->$name]; $rawGeneral = $this->tmpGeneralQueue[$general->name];
$birth = $general->birth; $birth = $general->birth;
if(!key_exists($birth, $remainGenerals)){ if(!key_exists($birth, $remainGenerals)){
$remainGenerals[$birth] = []; $remainGenerals[$birth] = [];
@@ -282,7 +285,7 @@ class Scenario{
public function build($env=[]){ public function build($env=[]){
$this->initFull(); $this->initFull();
//NOTE: 초기화가 되어있다고 가정함. //NOTE: 초기화가 되어있다고 가정함.
/* /*
@@ -325,7 +328,7 @@ class Scenario{
$events = array_map(function($rawEvent){ $events = array_map(function($rawEvent){
return [ return [
'cond'=>Json::encode($rawEvent['cond']), 'condition'=>Json::encode($rawEvent['cond']),
'action'=>Json::encode($rawEvent['action']) 'action'=>Json::encode($rawEvent['action'])
]; ];
}, $this->events); }, $this->events);
+13 -6
View File
@@ -14,6 +14,7 @@ class NPC{
public $leadership; public $leadership;
public $power; public $power;
public $intel; public $intel;
public $level;
public $birth; public $birth;
public $death; public $death;
public $ego; public $ego;
@@ -21,6 +22,7 @@ class NPC{
public $charWar = 0; public $charWar = 0;
public $text; public $text;
//[ 1, "헌제",1002, 1, null, 17, 13, 61, 0, 170, 250, "안전", null, "산 넘어 산이로구나..."],
public function __construct( public function __construct(
int $affinity, int $affinity,
string $name, string $name,
@@ -30,11 +32,12 @@ class NPC{
int $leadership, int $leadership,
int $power, int $power,
int $intel, int $intel,
int $level = 0,
int $birth = 160, int $birth = 160,
int $death = 300, int $death = 300,
string $ego = null, $ego = null,
string $char = null, $char = null,
string $text = null $text = null
){ ){
$this->affinity = $affinity; $this->affinity = $affinity;
$this->name = $name; $this->name = $name;
@@ -44,6 +47,7 @@ class NPC{
$this->leadership = $leadership; $this->leadership = $leadership;
$this->power = $power; $this->power = $power;
$this->intel = $intel; $this->intel = $intel;
$this->level = $level;
$this->birth = $birth; $this->birth = $birth;
$this->death = $death; $this->death = $death;
$this->ego = $ego; $this->ego = $ego;
@@ -84,7 +88,10 @@ class NPC{
} }
if($this->ego == null){ if($this->ego == null){
$this->ego = mt_rand(0, 9);//TODO: 나중에 성격을 따로 분리할 경우 클래스를 참조. $ego = mt_rand(0, 9);//TODO: 나중에 성격을 따로 분리할 경우 클래스를 참조.
}
else{
$ego = \sammo\CharCall($this->ego);
} }
$name = 'ⓝ'.$this->name; $name = 'ⓝ'.$this->name;
@@ -108,7 +115,7 @@ class NPC{
$experience = $age * 100; $experience = $age * 100;
$dedication = $age * 100; $dedication = $age * 100;
$level = $nationID?1:0; $level = $nationID?1:$this->level;
$turntime = \sammo\getRandTurn($env['turnterm']); $turntime = \sammo\getRandTurn($env['turnterm']);
@@ -147,7 +154,7 @@ class NPC{
'killturn'=>$killturn, 'killturn'=>$killturn,
'age'=>$age, 'age'=>$age,
'belong'=>1, 'belong'=>1,
'personal'=>$this->ego, 'personal'=>$ego,
'special'=>$this->charDomestic, 'special'=>$this->charDomestic,
'specage'=>$specage, 'specage'=>$specage,
'special2'=>$this->charWar, 'special2'=>$this->charWar,