j_set_general_command, j_set_nation_command 구현
This commit is contained in:
@@ -8,8 +8,17 @@ $session = Session::requireGameLogin([])->setReadOnly();
|
||||
|
||||
$generalID = $session->generalID;
|
||||
|
||||
|
||||
$action = Util::getReq('action', 'string');
|
||||
$arg = Json::decode(Util::getReq('arg', 'string'));
|
||||
$turnList = Json::decode(Util::getReq('turnList', 'string'));
|
||||
|
||||
if(!is_array($turnList) || !$turnList){
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'턴이 입력되지 않았습니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
if(!$action){
|
||||
Json::die([
|
||||
@@ -18,29 +27,21 @@ if(!$action){
|
||||
]);
|
||||
}
|
||||
|
||||
$defaultCheck = [
|
||||
'string'=>[
|
||||
'nationName', 'optionText', 'itemType', 'nationType'
|
||||
],
|
||||
'integer'=>[
|
||||
'crewType', 'destGeneralID', 'destCityID', 'destNationID',
|
||||
'amount', 'colorType', 'itemCode'
|
||||
],
|
||||
'boolean'=>[
|
||||
'isGold', 'buyRice',
|
||||
],
|
||||
'between'=>[
|
||||
['month', [1, 12]]
|
||||
],
|
||||
'min'=>[
|
||||
['year', 0]
|
||||
],
|
||||
'integerArray'=>[
|
||||
'destNationIDList', 'destGeneralIDList'
|
||||
],
|
||||
'stringWidthBetween'=>[
|
||||
['nationName', 1, 18]
|
||||
]
|
||||
];
|
||||
if($arg === null || !is_array($arg)){
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'올바른 arg 형태가 아닙니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
$v = new Validator($query);
|
||||
$result = setGeneralCommand($generalID, $turnList, $action, $arg);
|
||||
if(!key_exists('result', $result)){
|
||||
$result['result'] = false;
|
||||
}
|
||||
if(!key_exists('arg_test', $result)){
|
||||
$result['arg_test'] = false;
|
||||
}
|
||||
if(!key_exists('reason', $result)){
|
||||
throw new MustNotBeReachedException('reason이 왜 없어?');
|
||||
}
|
||||
Json::die($result);
|
||||
Reference in New Issue
Block a user