몰수, 포상 구현, 증여 헌납 버그 수정
This commit is contained in:
@@ -188,6 +188,14 @@ class ConstraintHelper{
|
||||
return [__FUNCTION__, $key, $keyNick, $comp, $reqVal];
|
||||
}
|
||||
|
||||
static function ReqNationGold(int $reqGold):array{
|
||||
return [__FUNCTION__, $reqGold];
|
||||
}
|
||||
|
||||
static function ReqNationRice(int $reqRice):array{
|
||||
return [__FUNCTION__, $reqRice];
|
||||
}
|
||||
|
||||
static function ReqNationValue($key, string $keyNick, string $comp, $reqVal):array{
|
||||
return [__FUNCTION__, $key, $keyNick, $comp, $reqVal];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Constraint;
|
||||
|
||||
class ReqNationGold extends Constraint{
|
||||
const REQ_VALUES = Constraint::REQ_NATION|Constraint::REQ_NUMERIC_ARG;
|
||||
|
||||
public function checkInputValues(bool $throwExeception=true){
|
||||
if(!parent::checkInputValues($throwExeception) && !$throwException){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!key_exists('gold', $this->nation)){
|
||||
if(!$throwExeception){return false; }
|
||||
throw new \InvalidArgumentException("require gold in nation");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function test():bool{
|
||||
$this->checkInputValues();
|
||||
$this->tested = true;
|
||||
|
||||
if($this->nation['gold'] < $this->arg){
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->reason = "국고가 부족합니다.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace sammo\Constraint;
|
||||
|
||||
class ReqNationRice extends Constraint{
|
||||
const REQ_VALUES = Constraint::REQ_NATION|Constraint::REQ_NUMERIC_ARG;
|
||||
|
||||
public function checkInputValues(bool $throwExeception=true){
|
||||
if(!parent::checkInputValues($throwExeception) && !$throwException){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!key_exists('rice', $this->nation)){
|
||||
if(!$throwExeception){return false; }
|
||||
throw new \InvalidArgumentException("require rice in nation");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function test():bool{
|
||||
$this->checkInputValues();
|
||||
$this->tested = true;
|
||||
|
||||
if($this->nation['rice'] < $this->arg){
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->reason = "병량이 부족합니다.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user