argTest를 로직 순서에 맞게 변경

This commit is contained in:
2018-10-21 14:28:29 +09:00
parent c08459e370
commit 6c5c2d40bc
27 changed files with 289 additions and 304 deletions
+10 -10
View File
@@ -16,16 +16,6 @@ use \sammo\Constraint\Constraint;
class che_NPC능동 extends Command\GeneralCommand{
static protected $actionName = 'NPC능동';
protected function init(){
$general = $this->generalObj;
$this->runnableConstraints=[
['MustBeNPC']
];
}
protected function argTest():bool{
if(!key_exists('optionText', $this->arg)){
return false;
@@ -48,6 +38,16 @@ class che_NPC능동 extends Command\GeneralCommand{
return false;
}
protected function init(){
$general = $this->generalObj;
$this->runnableConstraints=[
['MustBeNPC']
];
}
public function getCost():array{
return [0, 0];
}
+14 -14
View File
@@ -23,6 +23,19 @@ use sammo\CityConst;
class che_강행 extends Command\GeneralCommand{
static protected $actionName = '강행';
protected function argTest():bool{
if(!key_exists('destCityID', $this->arg)){
return false;
}
if(!key_exists($this->arg['destCityID'], CityConst::all())){
return false;
}
$this->arg = [
'destCityID'=>$this->arg['destCityID']
];
return true;
}
protected function init(){
$general = $this->generalObj;
@@ -40,20 +53,7 @@ class che_강행 extends Command\GeneralCommand{
['ReqGeneralRice', $reqRice],
];
}
protected function argTest():bool{
if(!key_exists('destCityID', $this->arg)){
return false;
}
if(!key_exists($this->arg['destCityID'], CityConst::all())){
return false;
}
$this->arg = [
'destCityID'=>$this->arg['destCityID']
];
return true;
}
public function getCost():array{
$env = $this->env;
return [$env['develcost'] * 5, 0];
+5 -5
View File
@@ -21,6 +21,11 @@ use \sammo\TextDecoration\SightseeingMessage;
class che_견문 extends Command\GeneralCommand{
static protected $actionName = '견문';
protected function argTest():bool{
$this->arg = null;
return true;
}
protected function init(){
@@ -31,11 +36,6 @@ class che_견문 extends Command\GeneralCommand{
}
protected function argTest():bool{
$this->arg = null;
return true;
}
public function getCost():array{
return [0, 0];
}
+18 -18
View File
@@ -33,6 +33,24 @@ class che_군량매매 extends Command\GeneralCommand{
'item'=>'도구',
];
protected function argTest():bool{
$buyRice = $this->arg['buyRice']??null;
if(!is_bool($buyRice)){
return false;
}
$amount = $this->arg['amount']??null;
if(!is_int($amount)){
return false;
}
$amount = Util::valueFit($amount, 100, 10000);
$this->arg = [
'buyRice'=>$buyRice,
'amount'=>$amount
];
return true;
}
protected function init(){
$general = $this->generalObj;
@@ -54,24 +72,6 @@ class che_군량매매 extends Command\GeneralCommand{
}
}
protected function argTest():bool{
$buyRice = $this->arg['buyRice']??null;
if(!is_bool($buyRice)){
return false;
}
$amount = $this->arg['amount']??null;
if(!is_int($amount)){
return false;
}
$amount = Util::valueFit($amount, 100, 10000);
$this->arg = [
'buyRice'=>$buyRice,
'amount'=>$amount
];
return true;
}
public function getCost():array{
return [0, 0];
}
+5 -5
View File
@@ -23,6 +23,11 @@ use sammo\CityConst;
class che_귀환 extends Command\GeneralCommand{
static protected $actionName = '귀환';
protected function argTest():bool{
$this->arg = null;
return true;
}
protected function init(){
$general = $this->generalObj;
@@ -39,11 +44,6 @@ class che_귀환 extends Command\GeneralCommand{
];
}
protected function argTest():bool{
$this->arg = null;
return true;
}
public function getCost():array{
return [0, 0];
}
@@ -25,6 +25,11 @@ class che_기술연구 extends che_상업투자{
static protected $actionKey = '기술';
static protected $actionName = '기술 연구';
protected function argTest():bool{
$this->arg = null;
return true;
}
protected function init(){
$general = $this->generalObj;
@@ -46,11 +51,6 @@ class che_기술연구 extends che_상업투자{
$this->reqGold = $reqGold;
}
protected function argTest():bool{
$this->arg = null;
return true;
}
public function run():bool{
if(!$this->isRunnable()){
throw new \RuntimeException('불가능한 커맨드를 강제로 실행 시도');
+5 -5
View File
@@ -22,6 +22,11 @@ use \sammo\Constraint\Constraint;
class che_단련 extends Command\GeneralCommand{
static protected $actionName = '단련';
protected function argTest():bool{
$this->arg = null;
return true;
}
protected function init(){
$general = $this->generalObj;
@@ -42,11 +47,6 @@ class che_단련 extends Command\GeneralCommand{
}
protected function argTest():bool{
$this->arg = null;
return true;
}
public function getCost():array{
$env = $this->env;
return [$env['develcost'], $env['develcost']];
+21 -21
View File
@@ -25,6 +25,27 @@ use \sammo\Constraint\Constraint;
class che_등용 extends Command\GeneralCommand{
static protected $actionName = '등용';
protected function argTest():bool{
//NOTE: 사망 직전에 '등용' 턴을 넣을 수 있으므로, 존재하지 않는 장수여도 argTest에서 바로 탈락시키지 않음
if(!key_exists('destGeneralID', $this->arg)){
return false;
}
$destGeneralID = $this->arg['destGeneralID'];
if(!is_int($destGeneralID)){
return false;
}
if($destGeneralID <= 0){
return false;
}
if($destGeneralID == $this->generalObj->getID()){
return false;
}
$this->arg = [
'destGeneralID'=>$destGeneralID
];
return true;
}
protected function init(){
$general = $this->generalObj;
@@ -58,27 +79,6 @@ class che_등용 extends Command\GeneralCommand{
}
}
protected function argTest():bool{
//NOTE: 사망 직전에 '등용' 턴을 넣을 수 있으므로, 존재하지 않는 장수여도 argTest에서 바로 탈락시키지 않음
if(!key_exists('destGeneralID', $this->arg)){
return false;
}
$destGeneralID = $this->arg['destGeneralID'];
if(!is_int($destGeneralID)){
return false;
}
if($destGeneralID <= 0){
return false;
}
if($destGeneralID == $this->generalObj->getID()){
return false;
}
$this->arg = [
'destGeneralID'=>$destGeneralID
];
return true;
}
public function getCost():array{
$env = $this->env;
if(!$this->isArgValid){
@@ -24,6 +24,11 @@ use \sammo\Constraint\Constraint;
class che_물자조달 extends Command\GeneralCommand{
static protected $actionName = '물자조달';
protected function argTest():bool{
$this->arg = null;
return true;
}
protected function init(){
$general = $this->generalObj;
@@ -40,11 +45,6 @@ class che_물자조달 extends Command\GeneralCommand{
}
protected function argTest():bool{
$this->arg = null;
return true;
}
public function getCost():array{
return [0, 0];
}
@@ -21,6 +21,11 @@ use \sammo\Constraint\Constraint;
class che_사기진작 extends Command\GeneralCommand{
static protected $actionName = '사기진작';
protected function argTest():bool{
$this->arg = null;
return true;
}
protected function init(){
$general = $this->generalObj;
@@ -42,11 +47,6 @@ class che_사기진작 extends Command\GeneralCommand{
}
protected function argTest():bool{
$this->arg = null;
return true;
}
public function getCost():array{
return [Util::round($this->getVar('crew')/100), 0];
}
@@ -28,6 +28,11 @@ class che_상업투자 extends Command\GeneralCommand{
static protected $actionName = '상업 투자';
static protected $debuffFront = 0.5;
protected function argTest():bool{
$this->arg = null;
return true;
}
protected function init(){
$general = $this->generalObj;
@@ -50,11 +55,6 @@ class che_상업투자 extends Command\GeneralCommand{
$this->reqGold = $reqGold;
}
protected function argTest():bool{
$this->arg = null;
return true;
}
public function getCost():array{
$develCost = $this->env['develcost'];
$reqGold = $general->onCalcDomestic(static::$actionKey, 'cost', $develCost);
@@ -17,11 +17,14 @@ use function \sammo\{
use \sammo\Constraint\Constraint;
class che_소집해제 extends Command\GeneralCommand{
static protected $actionName = '소집해제';
protected function argTest():bool{
$this->arg = null;
return true;
}
protected function init(){
$general = $this->generalObj;
@@ -35,11 +38,6 @@ class che_소집해제 extends Command\GeneralCommand{
}
protected function argTest():bool{
$this->arg = null;
return true;
}
public function getCost():array{
return [0, 0];
}
+5 -5
View File
@@ -22,6 +22,11 @@ use \sammo\Constraint\Constraint;
class che_요양 extends Command\GeneralCommand{
static protected $actionName = '요양';
protected function argTest():bool{
$this->arg = null;
return true;
}
protected function init(){
$general = $this->generalObj;
@@ -33,11 +38,6 @@ class che_요양 extends Command\GeneralCommand{
}
protected function argTest():bool{
$this->arg = null;
return true;
}
public function getCost():array{
return [0, 0];
}
+13 -13
View File
@@ -23,6 +23,19 @@ use sammo\CityConst;
class che_이동 extends Command\GeneralCommand{
static protected $actionName = '이동';
protected function argTest():bool{
if(!key_exists('destCityID', $this->arg)){
return false;
}
if(!key_exists($this->arg['destCityID'], CityConst::all())){
return false;
}
$this->arg = [
'destCityID'=>$this->arg['destCityID']
];
return true;
}
protected function init(){
$general = $this->generalObj;
@@ -41,19 +54,6 @@ class che_이동 extends Command\GeneralCommand{
];
}
protected function argTest():bool{
if(!key_exists('destCityID', $this->arg)){
return false;
}
if(!key_exists($this->arg['destCityID'], CityConst::all())){
return false;
}
$this->arg = [
'destCityID'=>$this->arg['destCityID']
];
return true;
}
public function getCost():array{
$env = $this->env;
return [$env['develcost'], 0];
+19 -19
View File
@@ -32,6 +32,25 @@ class che_장비매매 extends Command\GeneralCommand{
'item'=>'도구',
];
protected function argTest():bool{
$itemType = $this->arg['itemType']??null;
if(!in_array($itemType, array_keys(static::$itemMap))){
return false;
}
$itemCode = $this->arg['itemCode']??null;
if(!is_int($itemCode)){
return false;
}
if($itemCode < 0 || 6 < $itemCode){
return false;
}
$this->arg = [
'itemType'=>$itemType,
'itemCode'=>$itemCode
];
return true;
}
protected function init(){
$general = $this->generalObj;
@@ -64,25 +83,6 @@ class che_장비매매 extends Command\GeneralCommand{
}
protected function argTest():bool{
$itemType = $this->arg['itemType']??null;
if(!in_array($itemType, array_keys(static::$itemMap))){
return false;
}
$itemCode = $this->arg['itemCode']??null;
if(!is_int($itemCode)){
return false;
}
if($itemCode < 0 || 6 < $itemCode){
return false;
}
$this->arg = [
'itemType'=>$itemType,
'itemCode'=>$itemCode
];
return true;
}
public function getCost():array{
if(!$this->isArgValid){
return [0, 0];
@@ -22,6 +22,11 @@ use \sammo\Constraint\Constraint;
class che_전투태세 extends Command\GeneralCommand{
static protected $actionName = '전투태세';
protected function argTest():bool{
$this->arg = null;
return true;
}
protected function init(){
$general = $this->generalObj;
@@ -44,11 +49,6 @@ class che_전투태세 extends Command\GeneralCommand{
}
protected function argTest():bool{
$this->arg = null;
return true;
}
public function getCost():array{
$crew = $this->getVar('crew');
$techCost = getTechCost($this->nation['tech']);
@@ -28,6 +28,11 @@ class che_정착장려 extends Command\GeneralCommand{
static protected $actionKey = '인구';
static protected $actionName = '정착 장려';
protected function argTest():bool{
$this->arg = null;
return true;
}
protected function init(){
$general = $this->generalObj;
@@ -50,11 +55,6 @@ class che_정착장려 extends Command\GeneralCommand{
$this->reqRice = $reqRice;
}
protected function argTest():bool{
$this->arg = null;
return true;
}
public function getCost():array{
$develCost = $this->env['develcost'] * 2;
$reqGold = 0;
@@ -27,6 +27,11 @@ class che_주민선정 extends Command\GeneralCommand{
static protected $actionKey = '민심';
static protected $actionName = '주민 선정';
protected function argTest():bool{
$this->arg = null;
return true;
}
protected function init(){
$general = $this->generalObj;
@@ -49,11 +54,6 @@ class che_주민선정 extends Command\GeneralCommand{
$this->reqRice = $reqRice;
}
protected function argTest():bool{
$this->arg = null;
return true;
}
public function getCost():array{
$develCost = $this->env['develcost'] * 2;
$reqGold = 0;
+38 -44
View File
@@ -24,6 +24,44 @@ use \sammo\Constraint\Constraint;
class che_증여 extends Command\GeneralCommand{
static protected $actionName = '증여';
protected function argTest():bool{
//NOTE: 사망 직전에 '증여' 턴을 넣을 수 있으므로, 존재하지 않는 장수여도 argTest에서 바로 탈락시키지 않음
if(!key_exists('isGold', $this->arg)){
return false;
}
if(!key_exists('amount', $this->arg)){
return false;
}
if(!key_exists('destGeneralID', $this->arg)){
return false;
}
$isGold = $this->arg['isGold'];
$amount = $this->arg['amount'];
$destGeneralID = $this->arg['destGeneralID'];
if(!is_int($amount)){
return false;
}
$amount = Util::valueFit($amount, 100, 10000);
if(!is_bool($isGold)){
return false;
}
if(!is_int($destGeneralID)){
return false;
}
if($destGeneralID <= 0){
return false;
}
if($destGeneralID == $this->generalObj->getID()){
return false;
}
$this->arg = [
'isGold'=>$isGold,
'amount'=>$amount,
'destGeneralID'=>$destGeneralID
];
return true;
}
protected function init(){
$general = $this->generalObj;
@@ -55,50 +93,6 @@ class che_증여 extends Command\GeneralCommand{
}
protected function argTest():bool{
//NOTE: 사망 직전에 '증여' 턴을 넣을 수 있으므로, 존재하지 않는 장수여도 argTest에서 바로 탈락시키지 않음
if(!key_exists('isGold', $this->arg)){
return false;
}
if(!key_exists('amount', $this->arg)){
return false;
}
if(!key_exists('destGeneralID', $this->arg)){
return false;
}
$isGold = $this->arg['isGold'];
$amount = $this->arg['amount'];
$destGeneralID = $this->arg['destGeneralID'];
if(!is_int($amount)){
return false;
}
if($amount < 100){
return false;
}
if($amount > 10000){
return false;
}
$amount = (int)$amount;
if(!is_bool($isGold)){
return false;
}
if(!is_int($destGeneralID)){
return false;
}
if($destGeneralID <= 0){
return false;
}
if($destGeneralID == $this->generalObj->getID()){
return false;
}
$this->arg = [
'isGold'=>$isGold,
'amount'=>$amount,
'destGeneralID'=>$destGeneralID
];
return true;
}
public function getCost():array{
return [0, 0];
}
+5 -5
View File
@@ -23,6 +23,11 @@ use sammo\CityConst;
class che_집합 extends Command\GeneralCommand{
static protected $actionName = '집합';
protected function argTest():bool{
$this->arg = null;
return true;
}
protected function init(){
$general = $this->generalObj;
@@ -42,11 +47,6 @@ class che_집합 extends Command\GeneralCommand{
];
}
protected function argTest():bool{
$this->arg = null;
return true;
}
public function getCost():array{
return [0, 0];
}
+30 -30
View File
@@ -39,6 +39,36 @@ class che_징병 extends Command\GeneralCommand{
static::$defaultAtmos = GameConst::$defaultAtmosLow;
}
protected function argTest():bool{
if(!key_exists('crewType', $this->arg)){
return false;
}
if(!key_exists('amount', $this->arg)){
return false;
}
$crewType = $this->arg['crewType'];
$amount = $this->arg['amountCrew'];
if(!is_int($crewType)){
return false;
}
if(!is_int($amount)){
return false;
}
if(GameUnitConst::byID($crewType) === null){
return false;
}
if($amount < 100){
return false;
}
$this->arg = [
'crewType'=>$crewType,
'amount'=>$amount
];
return true;
}
protected function init(){
$general = $this->generalObj;
@@ -74,36 +104,6 @@ class che_징병 extends Command\GeneralCommand{
}
protected function argTest():bool{
if(!key_exists('crewType', $this->arg)){
return false;
}
if(!key_exists('amount', $this->arg)){
return false;
}
$crewType = $this->arg['crewType'];
$amount = $this->arg['amountCrew'];
if(!is_int($crewType)){
return false;
}
if(!is_int($amount)){
return false;
}
if(GameUnitConst::byID($crewType) === null){
return false;
}
if($amount < 100){
return false;
}
$this->arg = [
'crewType'=>$crewType,
'amount'=>$amount
];
return true;
}
public function getCost():array{
if(!$this->isArgValid){
return [0, 0];
+13 -13
View File
@@ -24,6 +24,19 @@ use sammo\CityConst;
class che_첩보 extends Command\GeneralCommand{
static protected $actionName = '첩보';
protected function argTest():bool{
if(!key_exists('destCityID', $this->arg)){
return false;
}
if(!key_exists($this->arg['destCityID'], CityConst::all())){
return false;
}
$this->arg = [
'destCityID'=>$this->arg['destCityID']
];
return true;
}
protected function init(){
$general = $this->generalObj;
@@ -42,19 +55,6 @@ class che_첩보 extends Command\GeneralCommand{
];
}
protected function argTest():bool{
if(!key_exists('destCityID', $this->arg)){
return false;
}
if(!key_exists($this->arg['destCityID'], CityConst::all())){
return false;
}
$this->arg = [
'destCityID'=>$this->arg['destCityID']
];
return true;
}
public function getCost():array{
$env = $this->env;
return [$env['develcost'], 0];
+13 -13
View File
@@ -24,6 +24,19 @@ use sammo\CityConst;
class che_출병 extends Command\GeneralCommand{
static protected $actionName = '출병';
protected function argTest():bool{
if(!key_exists('destCityID', $this->arg)){
return false;
}
if(!key_exists($this->arg['destCityID'], CityConst::all())){
return false;
}
$this->arg = [
'destCityID'=>$this->arg['destCityID']
];
return true;
}
protected function init(){
$general = $this->generalObj;
@@ -47,19 +60,6 @@ class che_출병 extends Command\GeneralCommand{
];
}
protected function argTest():bool{
if(!key_exists('destCityID', $this->arg)){
return false;
}
if(!key_exists($this->arg['destCityID'], CityConst::all())){
return false;
}
$this->arg = [
'destCityID'=>$this->arg['destCityID']
];
return true;
}
public function getCost():array{
return [0, Util::round($this->general->getVar('crew')/100)];
}
+23 -29
View File
@@ -24,6 +24,29 @@ use \sammo\Constraint\Constraint;
class che_헌납 extends Command\GeneralCommand{
static protected $actionName = '헌납';
protected function argTest():bool{
if(!key_exists('isGold', $this->arg)){
return false;
}
if(!key_exists('amount', $this->arg)){
return false;
}
$isGold = $this->arg['isGold'];
$amount = $this->arg['amount'];
if(!is_int($amount)){
return false;
}
$amount = Util::valueFit($amount, 100, 10000);
if(!is_bool($isGold)){
return false;
}
$this->arg = [
'isGold'=>$isGold,
'amount'=>$amount
];
return true;
}
protected function init(){
$general = $this->generalObj;
@@ -45,35 +68,6 @@ class che_헌납 extends Command\GeneralCommand{
}
protected function argTest():bool{
if(!key_exists('isGold', $this->arg)){
return false;
}
if(!key_exists('amount', $this->arg)){
return false;
}
$isGold = $this->arg['isGold'];
$amount = $this->arg['amount'];
if(!is_int($amount)){
return false;
}
if($amount < 100){
return false;
}
if($amount > 10000){
return false;
}
$amount = (int)$amount;
if(!is_bool($isGold)){
return false;
}
$this->arg = [
'isGold'=>$isGold,
'amount'=>$amount
];
return true;
}
public function getCost():array{
return [0, 0];
}
+5 -5
View File
@@ -22,6 +22,11 @@ use \sammo\Constraint\Constraint;
class che_훈련 extends Command\GeneralCommand{
static protected $actionName = '훈련';
protected function argTest():bool{
$this->arg = null;
return true;
}
protected function init(){
$general = $this->generalObj;
@@ -39,11 +44,6 @@ class che_훈련 extends Command\GeneralCommand{
}
protected function argTest():bool{
$this->arg = null;
return true;
}
public function getCost():array{
return [0, 0];
}
+4 -4
View File
@@ -8,14 +8,14 @@ use \sammo\JosaUtil;
class 휴식 extends Command\GeneralCommand{
static protected $actionName = '휴식';
protected function init(){
//아무것도 하지 않음
}
protected function argTest():bool{
return true;
}
protected function init(){
//아무것도 하지 않음
}
public function getCost():array{
return [0, 0];
}
+3 -4
View File
@@ -9,14 +9,13 @@ use sammo\LastTurn;
class 휴식 extends Command\NationCommand{
static protected $actionName = '휴식';
protected function init(){
//아무것도 하지 않음
}
protected function argTest():bool{
return true;
}
protected function init(){
//아무것도 하지 않음
}
public function getCost():array{
return [0, 0];
}