부대 번호를 부대장 ID로 변경
This commit is contained in:
+2
-2
@@ -86,7 +86,7 @@ $templates = new \League\Plates\Engine('templates');
|
||||
</table>
|
||||
<?php
|
||||
$troopName = [];
|
||||
foreach($db->queryAllLists('SELECT troop, name FROM troop WHERE nation=%i', $me['nation']) as [$troopID, $tName]){
|
||||
foreach($db->queryAllLists('SELECT troop_leader, name FROM troop WHERE nation=%i', $me['nation']) as [$troopID, $tName]){
|
||||
$troopName[$troopID] = $tName;
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ switch ($type) {
|
||||
case 5: $orderSQL = "order by crew desc"; break;
|
||||
case 6: $orderSQL = "order by killturn"; break;
|
||||
case 7: $orderSQL = "order by turntime"; break;
|
||||
case 8: $orderSQL = "order by troop desc"; break;
|
||||
case 8: $orderSQL = "order by troop_leader desc"; break;
|
||||
}
|
||||
|
||||
$generals = $db->query(
|
||||
|
||||
+4
-6
@@ -14,11 +14,9 @@ increaseRefresh("부대편성", 1);
|
||||
$me = $db->queryFirstRow('SELECT no,nation,troop FROM general WHERE owner=%i', $userID);
|
||||
|
||||
$troops = [];
|
||||
foreach($db->query('SELECT troop,name,no FROM troop WHERE nation = %i', $me['nation']) as $rawTroop){
|
||||
$troops[$rawTroop['troop']] = [
|
||||
'troop'=>$rawTroop['troop'],
|
||||
foreach($db->query('SELECT troop_leader,name FROM troop WHERE nation = %i', $me['nation']) as $rawTroop){
|
||||
$troops[$rawTroop['troop_leader']] = [
|
||||
'name'=>$rawTroop['name'],
|
||||
'no'=>$rawTroop['no'],
|
||||
'users'=>[]
|
||||
];
|
||||
}
|
||||
@@ -41,7 +39,7 @@ foreach($db->query(
|
||||
if($troops){
|
||||
$troopLeaders = $db->query(
|
||||
'SELECT no,name,picture,imgsvr,turntime,city,troop FROM general WHERE no IN %li',
|
||||
array_column($troops, 'no')
|
||||
array_keys($troops)
|
||||
);
|
||||
|
||||
foreach($db->queryAllLists(
|
||||
@@ -147,7 +145,7 @@ foreach ($troops as $troopNo=>$troop) {
|
||||
|
||||
<?php if ($me['troop'] == 0): ?>
|
||||
<tr>
|
||||
<td align=center rowspan=2><input type='radio' name='troop' value='<?=$troop['troop']?>'></td>
|
||||
<td align=center rowspan=2><input type='radio' name='troop' value='<?=$troopNo?>'></td>
|
||||
<td align=center><?=$troop['name']?><br>【 <?=$cityText?> 】</td>
|
||||
<td height=64 class='generalIcon' style='background:no-repeat center url("<?=$troopLeader['pictureFullPath']?>");background-size:64px;'> </td>
|
||||
<td rowspan=2 width=62><?=$genlistText?></td>
|
||||
|
||||
+10
-13
@@ -163,22 +163,19 @@ if($btn == "추방") {
|
||||
], 'no=%i', $general['no']);
|
||||
}
|
||||
}
|
||||
// 부대 처리
|
||||
$query = "select no from troop where troop='{$general['troop']}'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$troop = MYDB_fetch_array($result);
|
||||
|
||||
//부대장일 경우
|
||||
if($troop['no'] == $general['no']) {
|
||||
if($general['troop'] == $general['no']){
|
||||
// 모두 탈퇴
|
||||
$query = "update general set troop='0' where troop='{$general['troop']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
// 부대 삭제
|
||||
$query = "delete from troop where troop='{$general['troop']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
} else {
|
||||
$query = "update general set troop='0' where no='{$general['no']}'";
|
||||
MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$db->update('general', [
|
||||
'troop'=>0,
|
||||
], 'troop = %i', $general['no']);
|
||||
$db->delete('troop', 'troop_leader=%i', $general['no']);
|
||||
}
|
||||
else {
|
||||
$db->update('general', [
|
||||
'troop'=>0,
|
||||
], 'no=%i', $general['no']);
|
||||
}
|
||||
|
||||
// 도시관직해제
|
||||
|
||||
+8
-12
@@ -24,43 +24,39 @@ if($name && mb_strwidth($name) > 18){
|
||||
|
||||
$name = trim($name);
|
||||
if($btn == "부 대 창 설" && $name != "" && $me['troop'] == 0) {
|
||||
$db->insert('troop',[
|
||||
$db->insertIgnore('troop',[
|
||||
'troop_leader'=>$me['no'],
|
||||
'name'=>$name,
|
||||
'nation'=>$me['nation'],
|
||||
'no'=>$me['no']
|
||||
]);
|
||||
$troopID = $db->insertId();
|
||||
|
||||
$db->update('general', [
|
||||
'troop'=>$troopID
|
||||
'troop'=>$me['no'],
|
||||
], 'no=%i',$me['no']);
|
||||
} elseif($btn == "부 대 변 경" && $name != "") {
|
||||
$db->update('troop', [
|
||||
'name'=>$name
|
||||
], 'no=%i',$me['no']);
|
||||
], 'troop_leader=%i',$me['no']);
|
||||
} elseif($btn == "부 대 추 방" && $gen != 0) {
|
||||
$db->update('general', [
|
||||
'troop'=>0
|
||||
], 'no=%i AND troop=(SELECT troop FROM troop WHERE no = %i)', $gen, $me['no']);
|
||||
], 'no=%i AND troop= %i', $gen, $me['no']);
|
||||
} elseif($btn == "부 대 가 입" && $troop != 0) {
|
||||
$troopLeader = $db->queryFirstField('SELECT `no` FROM troop WHERE troop=%i', $troop);
|
||||
$troopLeaderNation = $db->queryFirstField('SELECT `nation` FROM `general` WHERE `no`=%i AND `nation`=%i', $troopLeader, $me['nation']);
|
||||
$troopLeaderNation = $db->queryFirstField('SELECT `nation` FROM `general` WHERE `no`=%i AND `troop`=%i AND `nation`=%i', $troop, $troop, $me['nation']);
|
||||
if($troopLeaderNation){
|
||||
$db->update('general', [
|
||||
'troop'=>$troop
|
||||
], 'no=%i', $me['no']);
|
||||
}
|
||||
} elseif($btn == "부 대 탈 퇴") {
|
||||
$troopLeader = $db->queryFirstField('SELECT `no` FROM troop WHERE troop=%i', $me['troop']);
|
||||
|
||||
//부대장일 경우
|
||||
if($troopLeader == $me['no']) {
|
||||
if($me['troop'] == $me['no']) {
|
||||
// 모두 탈퇴
|
||||
$db->update('general', [
|
||||
'troop'=>0
|
||||
], 'troop=%i',$me['troop']);
|
||||
// 부대 삭제
|
||||
$db->delete('troop', 'troop=%i', $me['troop']);
|
||||
$db->delete('troop', 'troop_leader=%i', $me['troop']);
|
||||
} else {
|
||||
$db->update('general', [
|
||||
'troop'=>0
|
||||
|
||||
+7
-10
@@ -654,7 +654,7 @@ function generalInfo($no) {
|
||||
$lbonus = "";
|
||||
}
|
||||
|
||||
$troop = getTroop($general['troop']);
|
||||
$troopName = getTroopName($general['troop'])??'-';
|
||||
|
||||
$level = getLevel($general['level'], $nation['level']);
|
||||
if($general['level'] == 2) {
|
||||
@@ -723,7 +723,6 @@ function generalInfo($no) {
|
||||
default:
|
||||
$train = "{$general['train']}"; break;
|
||||
}
|
||||
if($general['troop'] == 0) { $troop['name'] = "-"; }
|
||||
if($general['mode'] == 2) { $general['mode'] = "<font color=limegreen>수비 함(훈사80)</font>"; }
|
||||
elseif($general['mode'] == 1) { $general['mode'] = "<font color=limegreen>수비 함(훈사60)</font>"; }
|
||||
else { $general['mode'] = "<font color=red>수비 안함</font>"; }
|
||||
@@ -797,7 +796,7 @@ function generalInfo($no) {
|
||||
</tr>
|
||||
<tr height=20>
|
||||
<td style='text-align:center;' class='bg1'><b>부대</b></td>
|
||||
<td style='text-align:center;' colspan=3>{$troop['name']}</td>
|
||||
<td style='text-align:center;' colspan=3>{$troopName}</td>
|
||||
<td style='text-align:center;' class='bg1'><b>벌점</b></td>
|
||||
<td style='text-align:center;' colspan=5>".getConnect($general['connect'])." {$general['connect']}({$general['con']})</td>
|
||||
</tr>
|
||||
@@ -1885,15 +1884,13 @@ function getMe() {
|
||||
return $me;
|
||||
}
|
||||
|
||||
function getTroop($troop) {
|
||||
function getTroopName(int $troopLeader):?string {
|
||||
if($troopLeader == 0){
|
||||
return null;
|
||||
}
|
||||
$db = DB::db();
|
||||
$connect=$db->get();
|
||||
|
||||
$query = "select * from troop where troop='$troop'";
|
||||
$result = MYDB_query($query, $connect) or Error(__LINE__.MYDB_error($connect),"");
|
||||
$troop = MYDB_fetch_array($result);
|
||||
|
||||
return $troop;
|
||||
return $db->queryFirstField('SELECT `name` FROM troop WHERE troop_leader = %i', $troopLeader);
|
||||
}
|
||||
|
||||
function getCity($city, $sel="*") {
|
||||
|
||||
@@ -983,13 +983,12 @@ function updateNationState() {
|
||||
$npcID = $npcObj->generalID;
|
||||
|
||||
$db->insert('troop', [
|
||||
'troop_leader'=>$npcID,
|
||||
'name'=>$npcObj->realName,
|
||||
'nation'=>$nation['nation'],
|
||||
'no'=>$npcID
|
||||
]);
|
||||
$troopID = $db->insertId();
|
||||
$db->update('general', [
|
||||
'troop'=>$troopID
|
||||
'troop'=>$npcID
|
||||
], 'no=%i', $npcID);
|
||||
|
||||
//TODO: 5턴간 집합턴 입력
|
||||
|
||||
@@ -74,8 +74,8 @@ class che_집합 extends Command\GeneralCommand{
|
||||
$cityName = $this->city['name'];
|
||||
$josaRo = JosaUtil::pick($cityName, '로');
|
||||
|
||||
$troopID = $general->getVar('troop');
|
||||
$troopName = $db->queryFirstField('SELECT name FROM troop WHERE troop = %i', $troopID);
|
||||
$troopID = $general->getID();
|
||||
$troopName = $db->queryFirstField('SELECT name FROM troop WHERE troop_leader = %i', $troopID);
|
||||
|
||||
$logger = $general->getLogger();
|
||||
|
||||
@@ -88,7 +88,6 @@ class che_집합 extends Command\GeneralCommand{
|
||||
], 'no IN %li', $generalList);
|
||||
}
|
||||
foreach($generalList as $targetGeneralID){
|
||||
$targetGeneral = General::createGeneralObjFromDB($targetGeneralID, [], 1);
|
||||
$targetLogger = new ActionLogger($targetGeneralID, $general->getNationID(), $env['year'], $env['month']);
|
||||
$targetLogger->pushGeneralActionLog("{$troopName}의 부대원들은 <G><b>{$cityName}</b></>{$josaRo} 집합되었습니다.", ActionLogger::PLAIN);
|
||||
$targetLogger->flush();
|
||||
|
||||
@@ -24,11 +24,7 @@ class MustBeTroopLeader extends Constraint{
|
||||
$this->checkInputValues();
|
||||
$this->tested = true;
|
||||
|
||||
//XXX: 부대장인지 알 수가 없음
|
||||
$db = DB::db();
|
||||
$troopLeader = $db->queryFirstField('SELECT no FROM troop WHERE troop = %i', $this->general['troop']);
|
||||
|
||||
if($troopLeader == $this->general['no']){
|
||||
if($this->general['no'] == $this->general['troop']){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class ReqTroopMembers extends Constraint{
|
||||
|
||||
$db = DB::db();
|
||||
//NOTE:이 경우에 DB를 사용하지 않을 수 있는가?
|
||||
$troopMember = $db->queryFirstField('SELECT no FROM troop WHERE troop = %i AND no != %i LIMIT 1', $this->general['troop'], $this->general['no']);
|
||||
$troopMember = $db->queryFirstField('SELECT no FROM general WHERE troop = %i AND no != %i LIMIT 1', $this->general['troop'], $this->general['troop']);
|
||||
|
||||
if($troopMember !== null){
|
||||
return true;
|
||||
|
||||
@@ -92,13 +92,7 @@ class Personnel{
|
||||
return [$result, $reason];
|
||||
}
|
||||
|
||||
$isTroopLeader = false;
|
||||
if($general['troop']){
|
||||
$troopLeader = $db->queryFirstField('SELECT `no` FROM troop WHERE troop = %i', $general['troop']);
|
||||
if($troopLeader == $generalID){
|
||||
$isTroopLeader = true;
|
||||
}
|
||||
}
|
||||
$isTroopLeader = ($generalID == $general['troop']);
|
||||
|
||||
$joinedNations = Json::decode($general['nations']);
|
||||
$joinedNations[] = $this->nation['nation'];
|
||||
@@ -183,9 +177,9 @@ class Personnel{
|
||||
// 모두 탈퇴
|
||||
$db->update('general', [
|
||||
'troop'=>0,
|
||||
], 'troop=%i', $general['troop']);
|
||||
], 'troop_leader=%i', $generalID);
|
||||
// 부대 삭제
|
||||
$db->delete('troop', 'troop=%i', $general['troop']);
|
||||
$db->delete('troop', 'troop_leader=%i', $generalID);
|
||||
}
|
||||
|
||||
return [ScoutMessage::ACCEPTED, ''];
|
||||
|
||||
@@ -265,17 +265,15 @@ class General implements iAction{
|
||||
], 'gen3=%i', $generalID);
|
||||
|
||||
// 부대 처리
|
||||
$troopID = $this->getVar('troop');
|
||||
$troopLeaderID = $db->queryFirstField('SELECT `no` FROM troop WHERE troop=%i', $troopID);
|
||||
$troopLeaderID = $this->getVar('troop');
|
||||
if($troopLeaderID == $generalID){
|
||||
//부대장일 경우
|
||||
// 모두 탈퇴
|
||||
$db->update('general', [
|
||||
'troop'=>0
|
||||
], 'troop=%i', $troopID);
|
||||
|
||||
], 'troop_leader=%i', $troopLeaderID);
|
||||
// 부대 삭제
|
||||
$db->delete('troop', 'troop=%i', $troopID);
|
||||
$db->delete('troop', 'troop_leader=%i', $troopLeaderID);
|
||||
}
|
||||
|
||||
$dyingMessage = new TextDecoration\DyingMessage($this->getName(), $this->getVar('npc'));
|
||||
|
||||
+6
-8
@@ -286,14 +286,12 @@ CREATE TABLE `city` (
|
||||
## 부대 테이블
|
||||
###########################################################################
|
||||
|
||||
create table troop (
|
||||
troop int(6) not null auto_increment,
|
||||
name char(64) not null,
|
||||
nation int(6) not null,
|
||||
no int(6) not null,
|
||||
|
||||
PRIMARY KEY (troop)
|
||||
) ENGINE=INNODB DEFAULT CHARSET=utf8mb4;
|
||||
CREATE TABLE `troop` (
|
||||
`troop_leader` INT(6) NOT NULL,
|
||||
`nation` INT(6) NOT NULL,
|
||||
`name` VARCHAR(50) NOT NULL,
|
||||
PRIMARY KEY (`troop_leader`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
##########################################################################
|
||||
## 락 테이블
|
||||
|
||||
Reference in New Issue
Block a user