Files
core/hwe/sammo/Constraint/ReqGeneralCrewMargin.php
T
Hide_D c59019f5f7 Squashed commit of the following:
commit 3ef363a01e
Author: hide_d <hided62@gmail.com>
Date:   Mon Sep 6 02:30:00 2021 +0900

    fix: 은퇴 시 숙련 포인트를 지나치게 많이 받는 문제 수정

commit 9e68bc90c2
Author: hide_d <hided62@gmail.com>
Date:   Mon Sep 6 02:17:56 2021 +0900

    재야에서 도시보기 warning

commit d2590607c2
Author: hide_d <hided62@gmail.com>
Date:   Sun Sep 5 23:05:06 2021 +0900

    fix: div 0

commit 2bce6e4f02
Author: hide_d <hided62@gmail.com>
Date:   Sun Sep 5 23:02:52 2021 +0900

    warning 메시지 수정

commit e64812da72
Author: hide_d <hided62@gmail.com>
Date:   Sat Sep 4 03:42:09 2021 +0900

    fix: m장, 의병장 숙련이 설정되지 않는 버그 수정

commit 7cd40fca03
Author: hide_d <hided62@gmail.com>
Date:   Sat Aug 21 16:04:03 2021 +0900

    fix: 모병/징병에서 조건 검사부 통솔 계산값

commit d1568a3b2c
Author: hide_d <hided62@gmail.com>
Date:   Sat Aug 21 02:50:54 2021 +0900

    허보에 수몰이 같이 들어간 버그 수정

commit e7dcc84afc
Author: hide_d <hided62@gmail.com>
Date:   Thu Aug 19 14:51:50 2021 +0900

    REAMDME.md 버전 수정

commit 8eaa940d4e
Author: hide_d <hided62@gmail.com>
Date:   Wed Aug 18 20:40:37 2021 +0900

    Revert "fix: 7.2에서 오동작 버그 수정"

    This reverts commit 9997675b1d.

commit 9997675b1d
Author: hide_d <hided62@gmail.com>
Date:   Wed Aug 18 20:32:47 2021 +0900

    fix: 7.2에서 오동작 버그 수정

commit 9ef566f11f
Author: hide_d <hided62@gmail.com>
Date:   Wed Aug 18 20:26:31 2021 +0900

    fix: 아이템중 WarActivateSkill 관련 중첩 해제 버그 수정
2021-09-09 00:53:35 +09: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, 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;
}
}