general.turn0 기반 코드 일부를 general_turn 기반으로 변경

This commit is contained in:
2018-10-04 01:18:23 +09:00
parent f5212b4aa1
commit 9b4bf148cc
8 changed files with 55 additions and 122 deletions
+3 -77
View File
@@ -14,8 +14,6 @@ $double = Util::getReq('double', 'int', 0);
$third = Util::getReq('third', 'int', 0);
$fourth = Util::getReq('fourth', 'int', 0);
extractMissingPostToGlobals();
if(!$turn){
$turn = [0];
}
@@ -28,8 +26,10 @@ if(!$turn){
$session = Session::requireGameLogin()->setReadOnly();
$userID = Session::getUserID();
//TODO: 삭제. 새로 짜
throw new \sammo\NotImplementedException();
$db = DB::db();
$connect=$db->get();
if($command < 0) { $command = 0; }
if($double < 0) { $double = 0; }
@@ -39,74 +39,20 @@ if($command > 99) { $command = 0; }
if($double > 9999) { $double = 9999; }
if($fourth > 9999) { $fourth = 9999; }
$comStr = EncodeCommand($fourth, $third, $double, $command);
// 건국
if($command == 46) {
$name = StringUtil::neutralize($name);
if($name == "") { $name = "무명"; }
$db->update('general', [
'makenation'=>$name
], 'owner=%i', $userID);
$query = [];
foreach($turn as $turnIdx){
$query['turn'.$turnIdx] = $comStr;
}
$db->update('general', $query, 'owner=%i', $userID);
header('Location:./');
die();
}
//통합제의
if($command == 53) {
$query = "select nation,level from general where owner='{$userID}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$me = MYDB_fetch_array($result);
if($me['level'] >= 5) {
$nationname = StringUtil::neutralize($nationname, 18);
if($nationname == "") { $nationname = "무명"; }
$db->update('general', [
'makenation'=>$nationname
], 'level>=5 and nation=%i', $me['nation']);
$count = count($turn);
$str = "type=type";
for($i=0; $i < $count; $i++) {
$str .= ",l{$me['level']}turn{$turn[$i]}='{$comStr}'";
}
$query = "update nation set {$str} where nation='{$me['nation']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
}
header('location:b_chiefcenter.php');
die();
}
//불가침
if($command == 61) {
$query = "select nation,level from general where owner='{$userID}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$me = MYDB_fetch_array($result);
if($me['level'] >= 5) {
$note = StringUtil::neutralize($note, 90);
$query = "update diplomacy set reserved='{$note}' where me='{$me['nation']}' and you='$double'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$count = count($turn);
$str = "type=type";
for($i=0; $i < $count; $i++) {
$str .= ",l{$me['level']}turn{$turn[$i]}='{$comStr}'";
}
$query = "update nation set {$str} where nation='{$me['nation']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
}
header('location:b_chiefcenter.php');
die();
}
@@ -116,30 +62,10 @@ if($command == 61) {
//백성동원, 수몰, 허보, 피장파장, 의병모집, 이호경식, 급습
//국기변경
if($command == 23 || $command == 24 || $command == 27 || $command == 51 || $command == 52 || $command > 60) {
$query = "select no,nation,level from general where owner='{$userID}'";
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
$me = MYDB_fetch_array($result);
if(($command == 23 || $command == 24 || $command == 27) && $me['no'] == $third) {
// 자기자신에게 악용 금지
} elseif($me['level'] >= 5) {
$count = count($turn);
$str = "type=type";
for($i=0; $i < $count; $i++) {
$str .= ",l{$me['level']}turn{$turn[$i]}='{$comStr}'";
}
$query = "update nation set {$str} where nation='{$me['nation']}'";
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
}
header('location:b_chiefcenter.php');
die();
}
//일반 턴
$query = [];
foreach($turn as $turnIdx){
$query['turn'.$turnIdx] = $comStr;
}
$db->update('general', $query, 'owner=%i', $userID);
header('Location:./');