불가침 외교 커맨드 부활. 버그 수정
This commit is contained in:
@@ -195,7 +195,8 @@ abstract class Constraint{
|
||||
continue;
|
||||
}
|
||||
|
||||
$method = __NAMESPACE__.'\\'.$constraintArgs[0].'::build';
|
||||
$constraintName = $constraintArgs[0];
|
||||
$method = __NAMESPACE__.'\\'.$constraintName.'::build';
|
||||
|
||||
/** @var \sammo\Constraint\Constraint $contraint */
|
||||
$constraint = call_user_func($method,$input);
|
||||
@@ -209,7 +210,11 @@ abstract class Constraint{
|
||||
|
||||
|
||||
if(!$constraint->test()){
|
||||
return [\sammo\Util::getClassNameFromObj($constraint), $constraint->reason()];
|
||||
|
||||
if($constraint->reason() === null){
|
||||
throw new \RuntimeException('Reason is not set:'.$constraintName);
|
||||
}
|
||||
return [$constraintName, $constraint->reason()];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ class DisallowDiplomacyBetweenStatus extends Constraint{
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
|
||||
$state = $db->queryFirstField(
|
||||
'SELECT state FROM diplomacy WHERE me = %i AND you = %i AND `state` IN %li LIMIT 1',
|
||||
$this->nationID,
|
||||
@@ -49,7 +50,7 @@ class DisallowDiplomacyBetweenStatus extends Constraint{
|
||||
if($state === null){
|
||||
return true;
|
||||
}
|
||||
$this->msg = $this->disallowStatus[$state];
|
||||
$this->reason = $this->disallowStatus[$state];
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -10,16 +10,6 @@ class NearNation extends Constraint{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!key_exists('capital', $this->nation)){
|
||||
if(!$throwExeception){return false; }
|
||||
throw new \InvalidArgumentException("require capital in nation");
|
||||
}
|
||||
|
||||
if(!key_exists('capital', $this->destNation)){
|
||||
if(!$throwExeception){return false; }
|
||||
throw new \InvalidArgumentException("require capital in destNation");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -27,19 +17,14 @@ class NearNation extends Constraint{
|
||||
$this->checkInputValues();
|
||||
$this->tested = true;
|
||||
|
||||
$srcCityID = $this->nation['capital'];
|
||||
$srcNationID = $this->nation['nation'];
|
||||
|
||||
$destCityID = $this->destNation['capital'];
|
||||
$destNationID = $this->destNation['nation'];
|
||||
|
||||
$dist = \sammo\searchDistanceListToDest($srcCityID, $destCityID, [$srcNationID, $destNationID]);
|
||||
|
||||
if(!$dist){
|
||||
if(!\sammo\isNeighbor($srcNationID, $destNationID, false)){
|
||||
$this->reason = "인접 국가가 아닙니다.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user