수비 순서대로 정렬 버튼 활성화

This commit is contained in:
2018-08-26 23:16:42 +09:00
parent be15f1c698
commit 0f175ac4c6
3 changed files with 63 additions and 2 deletions
+18 -1
View File
@@ -16,7 +16,7 @@ if($query === null){
}
$action = Util::getReq('action');
if($action === null || in_array($action, ['reorder', 'battle'])){
if($action === null || !in_array($action, ['reorder', 'battle'])){
Json::die([
'result'=>false,
'reason'=>'원하는 동작이 지정되지 않았습니다.'
@@ -241,6 +241,23 @@ if(!$v->validate()){
]);
}
if($action == 'reorder'){
usort($defenderGenerals, function($lhs, $rhs){
return -(extractBattleOrder($lhs) <=> extractBattleOrder($rhs));
});
$order = [];
foreach($defenderGenerals as $defenderGeneral){
$order[] = $defenderGeneral['no'];
}
Json::die([
'result'=>true,
'reason'=>'success',
'order'=>$order
]);
}
Json::die([
'result'=>true,
'reason'=>'NYI'