인재탐색 추가. gencount, npc_id 관련 수정

This commit is contained in:
2018-10-21 21:53:34 +09:00
parent ff87555eba
commit 39db811361
16 changed files with 877 additions and 268 deletions
+62 -19
View File
@@ -5,6 +5,9 @@ namespace sammo\Constraint;
use \sammo\JosaUtil;
use \sammo\Util;
/**
* 범용으로 사용 가능한 장수 변수 검사도구
*/
class RegGeneralValue extends Constraint{
const REQ_VALUES = Constraint::REQ_GENERAL|Constraint::REQ_ARRAY_ARG;
@@ -18,13 +21,26 @@ class RegGeneralValue extends Constraint{
return false;
}
[$this->key, $this->keyNick, $this->reqVal] = $this->arg;
if(count($this->arg) == 4){
[$this->key, $this->keyNick, $comp, $this->reqVal] = $this->arg;
if(!in_array($comp, ['>', '>=', '==', '<=', '<', '!='])){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("invalid comparator");
}
}
else{
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("require key, keyNick, comp, reqVal");
}
$this->comp = $comp;
$this->maxKey = $this->key.'2';
if(!key_exists($this->key, $this->city)){
if(!key_exists($this->key, $this->general)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("require {$this->key} in city");
throw new \InvalidArgumentException("require {$this->key} in general");
}
if(is_numeric($this->reqVal)){
@@ -37,7 +53,7 @@ class RegGeneralValue extends Constraint{
throw new \InvalidArgumentException("require valid reqVal(percentStr|numeric) format");
}
if(!key_exists($this->maxKey, $this->city)){
if(!key_exists($this->maxKey, $this->general)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("require {$this->maxKey} in general");
}
@@ -51,26 +67,53 @@ class RegGeneralValue extends Constraint{
$this->checkInputValues();
$this->tested = true;
if($this->isPercent){
if($this->general[$this->key] >= $this->general[$this->maxKey] * $this->reqVal){
return true;
}
if ($this->isPercent) {
$reqVal = $this->general[$this->maxKey] * $this->reqVal;
}
else{
if($this->general[$this->key] >= $this->reqVal){
return true;
}
$reqVal = $this->reqVal;
}
if($this->reqVal === 1){
$josaYi = JosaUtil::pick($keyNick, '이');
$this->reason = "{$keyNick}{$josaUn} 없습니다.";
}
else{
$josaYi = JosaUtil::pick($keyNick, '이');
$this->reason = "{$keyNick}{$josaUn} 부족합니다.";
$compList = [
'<'=>function($target, $src){
return ($target < $src)?true:'너무 많습니다.';
},
'<='=>function($target, $src){
return ($target <= $src)?true:'너무 많습니다.';
},
'=='=>function($target, $src)use($keyNick){
return ($target == $src)?true:"올바르지 않은 {$keyNick} 입니다.";
},
'!='=>function($targeta, $src)use($keyNick){
return ($target == $src)?true:"올바르지 않은 {$keyNick} 입니다.";
},
'>='=>function($target, $src){
if($target >= $src){
return true;
}
if($src == 1){
return '없습니다';
}
return '부족합니다.';
},
'>'=>function($target, $src){
return $target >= $src;
if($src == 0){
return '없습니다';
}
return '부족합니다.';
},
];
$comp = $compList[$this->comp];
$result = ($comp)($this->general[$this->key], $reqVal);
if($result === true){
return true;
}
$josaYi = JosaUtil::pick($keyNick, '이');
$this->reason = "{$keyNick}{$josaYi} {$result}";
return false;
}