Files
core/hwe/sammo/Constraint/AllowJoinDestNation.php
T
Hide_D b14afd6a29 태수국 추가 설정
- 태수국 장수의 수명(10년 후 6년마다 절반 정도)
- 유저장은 태수국 임관 불가
- 공백지 시나리오에 기본 세팅
2021-08-10 02:36:48 +09:00

66 lines
2.0 KiB
PHP

<?php
namespace sammo\Constraint;
use \sammo\DB;
use \sammo\GameConst;
class AllowJoinDestNation extends Constraint{
const REQ_VALUES = Constraint::REQ_GENERAL|Constraint::REQ_DEST_NATION|Constraint::REQ_INT_ARG;
protected $relYear;
public function checkInputValues(bool $throwExeception=true):bool{
if(!parent::checkInputValues($throwExeception) && !$throwExeception){
return false;
}
if(!key_exists('auxVar', $this->general)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("require auxVar in general");
}
if(!key_exists('scout', $this->destNation)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("require scout in nation");
}
if(!key_exists('gennum', $this->destNation)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("require gennum in nation");
}
$this->relYear = $this->arg;
return true;
}
public function test():bool{
$this->checkInputValues();
$this->tested = true;
$db = DB::db();
if($this->relYear < GameConst::$openingPartYear && $this->destNation['gennum'] >= GameConst::$initialNationGenLimit){
$this->reason = "임관이 제한되고 있습니다.";
return false;
}
if($this->destNation['scout'] == 1){
$this->reason = "임관이 금지되어 있습니다.";
return false;
}
if($this->general['npc']??2 < 2 && \sammo\Util::starts_with($this->destNation['name'], 'ⓤ')){
$this->reason = "유저장은 태수국에 임관할 수 없습니다.";
return false;
}
$joinedNations = $this->general['auxVar']['joinedNations']??[];
if(in_array($this->destNation['nation'], $joinedNations)){
$this->reason = "이미 임관했었던 국가입니다.";
return false;
}
return true;
}
}