Files
core/hwe/sammo/Constraint/ReqGeneralCrewMargin.php
T
Hide_D f66008da56 refac, fix: General 객체 생성 과정에서 accessLog 분리
- 생성자 인수 1개 추가,
- mergeQueryColumn에서 $accessLogColumn에 정상적으로 enum[] 반영
- createGeneralObjListFromDB를 쿼리 1회 분리
- General에 getAccessLogVar() 추가
  - 변경 기능 제공 예정 '없음'
- 변경된 생성자에 맞게 호출 부 변경
- NPC인 경우 accessLog 조회값이 null일 수 있으므로 반영
2023-07-07 17:08:05 +00:00

58 lines
1.8 KiB
PHP

<?php
namespace sammo\Constraint;
use sammo\GameConst;
use sammo\GameUnitConst;
use sammo\General;
class ReqGeneralCrewMargin extends Constraint{
protected $crewType;
const REQ_VALUES = Constraint::REQ_GENERAL|Constraint::REQ_INT_ARG;
public function checkInputValues(bool $throwExeception=true):bool{
if(!parent::checkInputValues($throwExeception) && !$throwExeception){
return false;
}
if(GameUnitConst::byID($this->arg) === null){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("{$this->arg} is invalid crewtype");
}
foreach(['leadership','strength','intel','crew','crewtype','nation','officer_level'] as $key){
if(!key_exists($key, $this->general)){
if(!$throwExeception){return false; }
throw new \InvalidArgumentException("require {$key} in general");
}
}
$this->crewType = $this->arg;
return true;
}
public function test():bool{
$this->checkInputValues();
$this->tested = true;
$reqCrewType = GameUnitConst::byID($this->arg);
//XXX: 왜 General -> obj -> General 변환을 하고 있나?
//FIXME: RankVar, city에 따라 통솔이 바뀐다면 이 부분에 문제가 발생.
$generalObj = new General($this->general, null, null, null, null, null, null, true);
if($reqCrewType->id != $generalObj->getCrewTypeObj()->id){
return true;
}
$leadership = $generalObj->getLeadership();
$crew = $this->general['crew'];
if($leadership * 100 > $crew){
return true;
}
$this->reason = "이미 많은 병력을 보유하고 있습니다.";
return false;
}
}