diff --git a/hwe/b_myPage.php b/hwe/b_myPage.php index b5170e04..e72171e4 100644 --- a/hwe/b_myPage.php +++ b/hwe/b_myPage.php @@ -28,7 +28,7 @@ $connect=$db->get(); increaseRefresh("내정보", 1); -$query = "select no,npc,mode,tnmt,myset from general where owner='{$userID}'"; +$query = "select no,npc,mode,tnmt,myset,train,atmos from general where owner='{$userID}'"; $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect), ""); $me = MYDB_fetch_array($result); @@ -46,13 +46,30 @@ if (($btn == "설정저장" || $detachNPC) && $me['myset'] > 0) { $submit = 'hidden'; } - $me['myset'] -= 1; + if($mode == 0){ + $db->update('general', [ + 'myset'=>$db->sqleval('myset-1'), + 'mode'=>$mode, + 'train'=>max(0, $me['train'] - 3), + 'atmos'=>max(0, $me['atmos'] - 3), + ], 'owner=%i AND mode!=%i', $userID, $mode); + } + else{ + $db->update('general', [ + 'myset'=>$db->sqleval('myset-1'), + 'mode'=>$mode + ], 'owner=%i AND mode!=%i', $userID, $mode); + } - $db->update('general', [ - 'myset'=>$db->sqleval('myset-1'), - 'mode'=>$mode, - 'tnmt'=>$tnmt - ], 'owner=%i', $userID); + if($db->affectedRows()){ + $me['myset'] -= 1; + } + + if($me['tnmt'] != $tnmt){ + $db->update('general', [ + 'tnmt'=>$tnmt + ], 'owner=%i', $userID); + } $me['mode'] = $mode; $me['tnmt'] = $tnmt; diff --git a/hwe/func_command.php b/hwe/func_command.php index 0064cf43..7c7d3a16 100644 --- a/hwe/func_command.php +++ b/hwe/func_command.php @@ -478,9 +478,7 @@ function processCommand($no) { $gameStor = KVStorage::getStorage($db, 'game_env'); $connect=$db->get(); - $query = "select npc,no,name,picture,imgsvr,nation,nations,city,troop,injury,affinity,leader,leader2,power,power2,intel,intel2,experience,dedication,level,gold,rice,crew,crewtype,train,atmos,weap,book,horse,item,turntime,makenation,makelimit,killturn,block,dedlevel,explevel,age,belong,personal,special,special2,term,turn0,dex0,dex10,dex20,dex30,dex40,warnum,killnum,deathnum,killcrew,deathcrew,recwar from general where no='$no'"; - $result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); - $general = MYDB_fetch_array($result); + $general = $db->queryFirstRow('SELECT npc,no,name,picture,imgsvr,nation,nations,city,troop,injury,affinity,leader,leader2,power,power2,intel,intel2,experience,dedication,level,gold,rice,crew,crewtype,train,atmos,weap,book,horse,item,turntime,makenation,makelimit,killturn,block,dedlevel,explevel,age,belong,personal,special,special2,term,turn0,dex0,dex10,dex20,dex30,dex40,warnum,killnum,deathnum,killcrew,deathcrew,recwar,myset from general where no = %i', $no); list($month, $killturn) = $gameStor->getValuesAsArray(['month', 'killturn']); $log = []; @@ -546,17 +544,24 @@ function processCommand($no) { } $command = DecodeCommand($general['turn0']); + $newKillturn = $killturn; //삭턴 처리 if($general['npc'] >= 2 || $general['killturn'] > $killturn) { - $query = "update general set recturn=turn0,resturn='FAIL',myset=3,con=0,killturn=killturn-1 where no='{$general['no']}'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); + $newKillturn = $general['killturn'] - 1; } elseif($command[0] == 0) { - $query = "update general set recturn=turn0,resturn='FAIL',myset=3,con=0,killturn=killturn-1 where no='{$general['no']}'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); + $newKillturn = $general['killturn'] - 1; } else { - $query = "update general set recturn=turn0,resturn='FAIL',myset=3,con=0,killturn='{$killturn}' where no='{$general['no']}'"; - MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),""); + $newKillturn = $killturn; } + + $newMySet = min($general['myset'] + 1, 3); + $db->update('general', [ + 'recturn'=>$db->sqleval('turn0'), + 'resturn'=>'FAIL', + 'con'=>0, + 'killturn'=>$newKillturn, + 'myset'=>$newMySet + ], 'no = %i', $general['no']); //FIXME: 운영자 같이 사망하면 안되는 인물에 대한 처리가 필요 //연속턴 아닌경우 텀 리셋