feat: 추방 기능 추가
This commit is contained in:
@@ -57,7 +57,6 @@ return [
|
||||
'hwe/b_myPage.php',
|
||||
'hwe/v_processing.php',
|
||||
'hwe/b_tournament.php',
|
||||
'hwe/b_troop.php',
|
||||
'hwe/c_tournament.php',
|
||||
'hwe/func_auction.php',
|
||||
'hwe/func_command.php',
|
||||
|
||||
-251
@@ -1,251 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace sammo;
|
||||
|
||||
include "lib.php";
|
||||
include "func.php";
|
||||
//로그인 검사
|
||||
$session = Session::requireGameLogin()->setReadOnly();
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$db = DB::db();
|
||||
|
||||
increaseRefresh("부대편성", 1);
|
||||
|
||||
$me = $db->queryFirstRow('SELECT no,nation,troop,`officer_level`,permission,penalty FROM general WHERE owner=%i', $userID);
|
||||
$permission = checkSecretPermission($me, false);
|
||||
|
||||
$troops = [];
|
||||
foreach ($db->query('SELECT troop_leader,name FROM troop WHERE nation = %i', $me['nation']) as $rawTroop) {
|
||||
$troops[$rawTroop['troop_leader']] = [
|
||||
'name' => $rawTroop['name'],
|
||||
'users' => []
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($db->query(
|
||||
'SELECT no,name,turntime,troop,city FROM general WHERE troop!=0 AND nation = %i ORDER BY turntime ASC',
|
||||
$me['nation']
|
||||
) as $general) {
|
||||
if (!key_exists($general['troop'], $troops)) {
|
||||
trigger_error("올바르지 않은 부대 소속 {$general['no']}, {$general['name']} : {$general['troop']}");
|
||||
continue;
|
||||
}
|
||||
|
||||
$general['cityText'] = CityConst::byID($general['city'])->name;
|
||||
|
||||
$troops[$general['troop']]['users'][] = $general;
|
||||
}
|
||||
|
||||
if ($troops) {
|
||||
$troopLeaders = $db->query(
|
||||
'SELECT no,name,picture,imgsvr,turntime,city,troop FROM general WHERE no IN %li',
|
||||
array_keys($troops)
|
||||
);
|
||||
$generalTurnList = [];
|
||||
|
||||
foreach ($db->queryAllLists(
|
||||
'SELECT general_id, turn_idx, brief FROM general_turn WHERE general_id IN %li AND turn_idx < 5 ORDER BY general_id ASC, turn_idx ASC',
|
||||
array_column($troopLeaders, 'no')
|
||||
) as [$generalID, $turnIdx, $brief]) {
|
||||
if (!key_exists($generalID, $generalTurnList)) {
|
||||
$generalTurnList[$generalID] = [];
|
||||
}
|
||||
$generalTurnList[$generalID][$turnIdx] = $brief;
|
||||
}
|
||||
|
||||
foreach ($troopLeaders as $troopLeader) {
|
||||
$imageTemp = GetImageURL($troopLeader['imgsvr']);
|
||||
|
||||
$troopLeader['pictureFullPath'] = "$imageTemp/{$troopLeader['picture']}";
|
||||
$troopLeader['cityText'] = CityConst::byID($troopLeader['city'])->name;
|
||||
|
||||
$turnText = [];
|
||||
foreach ($generalTurnList[$troopLeader['no']] as $rawTurnIdx => $brief) {
|
||||
if ($brief != '집합') {
|
||||
$brief = '~';
|
||||
}
|
||||
$turnIdx = $rawTurnIdx + 1;
|
||||
$turnText[] = "{$turnIdx} : {$brief}";
|
||||
}
|
||||
$troopLeader['turnText'] = join('<br>', $turnText);
|
||||
$troops[$troopLeader['troop']]['leader'] = $troopLeader;
|
||||
}
|
||||
}
|
||||
|
||||
uasort($troops, function ($lhs, $rhs) {
|
||||
return $lhs['leader']['turntime'] <=> $rhs['leader']['turntime'];
|
||||
})
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=1024" />
|
||||
<title><?= UniqueConst::$serverName ?>: 부대편성</title>
|
||||
<?= WebUtil::printJS('../d_shared/common_path.js') ?>
|
||||
<?= WebUtil::printCSS('../d_shared/common.css') ?>
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css" />
|
||||
<?= WebUtil::printDist('ts', ['common', 'troop'], true) ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div style="width:1000px;margin:auto;">
|
||||
<table width=1000 class='tb_layout bg0'>
|
||||
<tr>
|
||||
<td>부 대 편 성<br><?= backButton() ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table id="troop_list" class='tb_layout bg0'>
|
||||
<thead>
|
||||
<tr>
|
||||
<td width=64 class='bg1 center'>선 택</td>
|
||||
<td width=130 class='bg1 center'>부 대 정 보</td>
|
||||
<td width=100 class='bg1 center'>부 대 장</td>
|
||||
<td width=576 class='bg1 center' style=table-layout:fixed;word-break:break-all;>장 수</td>
|
||||
<td width=130 class='bg1 center' style=table-layout:fixed;word-break:break-all;>부대장행동</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan='5'>
|
||||
<?php if (!$troops) : ?>
|
||||
<?php elseif ($me['troop'] == 0) : ?>
|
||||
<input type=button id='btnJoinTroop' value='부 대 가 입'>
|
||||
<?php else : ?>
|
||||
<input type=button id="btnLeaveTroop" value='부 대 탈 퇴'>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ($troops as $troopNo => $troop) {
|
||||
$troopLeader = $troop['leader'];
|
||||
$genlistText = [];
|
||||
$cityText = $troopLeader['cityText'];
|
||||
$cityID = $troopLeader['city'];
|
||||
$leaderID = $troopLeader['no'];
|
||||
|
||||
foreach ($troop['users'] as $troopUser) {
|
||||
$spanClass = 'troopUser';
|
||||
if ($troopUser['city'] !== $cityID) {
|
||||
$spanClass .= ' diffCity';
|
||||
}
|
||||
if ($troopUser['no'] == $leaderID) {
|
||||
$spanClass .= ' leader';
|
||||
}
|
||||
$genlistText[] = "<span class='$spanClass' data-general-id='{$troopUser['no']}'
|
||||
><span class='generalName'>{$troopUser['name']}</span><span class='cityText'>【{$troopUser['cityText']}】</span
|
||||
></span>";
|
||||
}
|
||||
|
||||
$genlistText = sprintf('%s (%d명)', join(', ', $genlistText), count($genlistText)); ?>
|
||||
|
||||
<?php if ($me['troop'] == 0) : ?>
|
||||
<tr>
|
||||
<td align=center rowspan=2><input type='radio' class='troopId' 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>
|
||||
<td rowspan=2><?= $troopLeader['turnText'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=center>
|
||||
<font size=2>【턴】 <?= substr($troopLeader['turntime'], 14, 5) ?></font>
|
||||
</td>
|
||||
<td align=center>
|
||||
<font size=1><?= $troopLeader['name'] ?></font>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=5>
|
||||
|
||||
<?php else : ?>
|
||||
<tr>
|
||||
<td align=center rowspan=2> </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>
|
||||
<td rowspan=2>
|
||||
<?php if ($me['no'] == $troopLeader['no']) : ?>
|
||||
<select id='genNo' name=gen size=3 style=color:white;background-color:black;font-size:14px;width:128px;>";
|
||||
<?php foreach ($troop['users'] as $troopUser) : ?>
|
||||
<?php if ($troopUser['no'] == $me['no']) {
|
||||
continue;
|
||||
} ?>
|
||||
<option value='<?= $troopUser['no'] ?>'><?= $troopUser['name'] ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select><br>
|
||||
<input type=button id='btnKickTroop' value='부 대 추 방' style=width:130px;height:25px;>
|
||||
<?php else : ?>
|
||||
<?= $troopLeader['turnText'] ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align=center>
|
||||
<font size=2>【턴】 <?= substr($troopLeader['turntime'], 14, 5) ?></font>
|
||||
</td>
|
||||
<td align=center>
|
||||
<font size=1><?= $troopLeader['name'] ?></font>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=5></td>
|
||||
</tr>
|
||||
<?php endif;
|
||||
} //foreach ($troops as $troopNo=>$troop) {
|
||||
?>
|
||||
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
<br>
|
||||
<div class="row">
|
||||
<?php if($me['troop'] == 0): ?>
|
||||
<div class="col-6"><?php /*TODO: 모바일 */ ?>
|
||||
<div class="row gx-0 bg0">
|
||||
<div class="bg1 col d-grid"><span class="align-self-center center">부대명</span></div>
|
||||
<div class="col d-grid"><input type=text style=color:white;background-color:black; size=18 maxlength=18 id='newTroopName'></div>
|
||||
<div class="col d-grid"><button type='button' id="btnCreateTroop" class='btn btn-sm btn-secondary'>부대 창설</button></div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if($troops && ($me['troop'] == $me['no'] || $permission == 4)): ?>
|
||||
<div class="col-6">
|
||||
<div class="row gx-0 bg0">
|
||||
<div class="bg1 col d-grid"><span class="align-self-center center">부대명</span></div>
|
||||
<div class="col d-grid"><select class="form-select" id="changeNameTroopID">
|
||||
<?php if($permission != 4): ?>
|
||||
<option value="<?=$me['troop']?>"><?=$troops[$me['troop']]['name']?></option>
|
||||
<?php else: ?>
|
||||
<?php foreach ($troops as $troopNo => $troop): ?>
|
||||
<option value="<?=$troopNo?>"><?=$troop['name']?></option>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col d-grid"><input type=text style=color:white;background-color:black; size=18 maxlength=18 id='changeTroopName'></div>
|
||||
<div class="col d-grid"><button type='button' id="btnChangeTroopName" class='btn btn-sm btn-secondary'>이름 변경</button></div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
|
||||
<table width=1000 class='tb_layout bg0'>
|
||||
<tr>
|
||||
<td><?= backButton() ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?= banner() ?> </td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?=$btnBegin??''?><a href='v_board.php' class='commandButton <?=$btnClass??""?> <?= $meLevel >= 1 ? '' : 'disabled' ?>'>회 의 실</a><?=$btnEnd??''?>
|
||||
<?=$btnBegin??''?><a href='v_board.php?isSecret=true' class='commandButton <?= $permission >= 2 ? '' : 'disabled' ?> <?=$btnClass??""?>'>기 밀 실</a><?=$btnEnd??''?>
|
||||
<?=$btnBegin??''?><a href='b_troop.php' class='commandButton <?= ($meLevel >= 1 && $nationLevel >= 1) ? '' : 'disabled' ?> <?=$btnClass??""?>'>부대 편성</a><?=$btnEnd??''?>
|
||||
<?=$btnBegin??''?><a href='v_troop.php' class='commandButton <?= ($meLevel >= 1 && $nationLevel >= 1) ? '' : 'disabled' ?> <?=$btnClass??""?>'>부대 편성</a><?=$btnEnd??''?>
|
||||
<?=$btnBegin??''?><a href='t_diplomacy.php' class='commandButton <?= $showSecret ? '' : 'disabled' ?> <?=$btnClass??""?>'>외 교 부</a><?=$btnEnd??''?>
|
||||
<?=$btnBegin??''?><a href='b_myBossInfo.php' class='commandButton <?= $meLevel >= 1 ? '' : 'disabled' ?> <?=$btnClass??""?>'>인 사 부</a><?=$btnEnd??''?>
|
||||
<?=$btnBegin??''?><a href='v_nationStratFinan.php' class='commandButton <?= $showSecret ? '' : 'disabled' ?> <?=$btnClass??""?>'>내 무 부</a><?=$btnEnd??''?>
|
||||
|
||||
+122
-24
@@ -42,7 +42,10 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="troopAction">
|
||||
<div v-if="tryChangeTroopTarget != troop.troopID" class="d-grid">
|
||||
<div
|
||||
v-if="tryTroopActionTarget.type === undefined || tryTroopActionTarget.targetTroop !== troop.troopID"
|
||||
class="d-grid"
|
||||
>
|
||||
<BButton v-if="!me.troop" variant="primary" @click="joinTroop(troop.troopID)">부대 탑승</BButton>
|
||||
<BButton
|
||||
v-if="me.troop == troop.troopID"
|
||||
@@ -50,26 +53,48 @@
|
||||
@click="exitTroop()"
|
||||
>{{ me.no == me.troop ? "부대 해산" : "부대 탈퇴" }}</BButton
|
||||
>
|
||||
<BButton v-if="me.troop == troop.troopID && me.no == me.troop">부대원 추방...</BButton>
|
||||
<BButton
|
||||
v-if="me.troop == troop.troopID && me.no == me.troop"
|
||||
@click="openKickTroopMemberDialog(troop)"
|
||||
>부대원 추방...</BButton
|
||||
>
|
||||
<BButton variant="info" @click="openChangeTroopNameDialog(troop)"
|
||||
>부대명 변경...</BButton
|
||||
>
|
||||
</div>
|
||||
<div class="row gx-0">
|
||||
<template v-if="tryChangeTroopTarget == troop.troopID">
|
||||
<div class="col-12 bg1 center" style="padding:0.2em;">부대명 변경</div>
|
||||
<div class="col-12 d-grid">
|
||||
<BFormInput v-model="newTroopName" :trim="true" type="text" />
|
||||
</div>
|
||||
</template>
|
||||
<div v-if="tryChangeTroopTarget != troop.troopID" class="col-12 d-grid">
|
||||
<BButton variant="info" @click="tryChangeTroopTarget = troop.troopID">부대명 변경</BButton>
|
||||
<div v-else-if="tryTroopActionTarget.type === 'changeName'" class="row gx-0">
|
||||
<div class="col-12 bg1 center" style="padding: 0.2em">부대명 변경</div>
|
||||
<div class="col-12 d-grid">
|
||||
<BFormInput v-model="newTroopName" :trim="true" type="text" />
|
||||
</div>
|
||||
<div class="col-6 d-grid">
|
||||
<BButton variant="secondary" @click="tryTroopActionTarget = { type: undefined, targetTroop: 0 }"
|
||||
>취소</BButton
|
||||
>
|
||||
</div>
|
||||
<div class="col-6 d-grid">
|
||||
<BButton variant="primary" @click="changeTroopName(troop)">변경</BButton>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="tryTroopActionTarget.type === 'kickMember'" class="row gx-0">
|
||||
<div class="col-12 bg1 center" style="padding: 0.2em">부대명 추방</div>
|
||||
<div class="col-12 d-grid">
|
||||
<BFormSelect v-model="kickTroopMemberID">
|
||||
<template v-for="member of troop.members" :key="member.no">
|
||||
<BFormSelectOption v-if="member.no != troop.troopID" :value="member.no">
|
||||
{{ member.name }}
|
||||
</BFormSelectOption>
|
||||
</template>
|
||||
</BFormSelect>
|
||||
</div>
|
||||
<div class="col-6 d-grid">
|
||||
<BButton variant="secondary" @click="tryTroopActionTarget = { type: undefined, targetTroop: 0 }"
|
||||
>취소</BButton
|
||||
>
|
||||
</div>
|
||||
<div class="col-6 d-grid">
|
||||
<BButton variant="primary" @click="kickTroopMember(troop)">추방</BButton>
|
||||
</div>
|
||||
<template v-else>
|
||||
<div class="col-6 d-grid">
|
||||
<BButton variant="secondary" @click="tryChangeTroopTarget = 0">취소</BButton>
|
||||
</div>
|
||||
<div class="col-6 d-grid">
|
||||
<BButton variant="primary" @click="changeTroopName()">변경</BButton>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -113,7 +138,7 @@ import TopBackBar from "@/components/TopBackBar.vue";
|
||||
import BottomBar from "@/components/BottomBar.vue";
|
||||
import { onMounted, provide, ref } from "vue";
|
||||
import { SammoAPI } from "./SammoAPI";
|
||||
import { BContainer, BButton, useToast, BFormInput } from "bootstrap-vue-3";
|
||||
import { BContainer, BButton, useToast, BFormInput, BFormSelect, BFormSelectOption } from "bootstrap-vue-3";
|
||||
import { unwrap } from "./util/unwrap";
|
||||
import { isString } from "lodash";
|
||||
import type { GeneralListItem, GeneralListItemP1 } from "./defs/API/Nation";
|
||||
@@ -201,8 +226,18 @@ const troopList = ref(new Map<number, TroopInfo>());
|
||||
const generalList = ref(new Map<number, GeneralListItem>());
|
||||
const nationInfo = ref<NationStaticItem>();
|
||||
|
||||
const tryChangeTroopTarget = ref(0);
|
||||
const newTroopName = ref("");
|
||||
const kickTroopMemberID = ref(0);
|
||||
|
||||
type TroopAction = {
|
||||
type: "kickMember" | "changeName" | undefined;
|
||||
targetTroop: number;
|
||||
};
|
||||
|
||||
const tryTroopActionTarget = ref<TroopAction>({
|
||||
type: undefined,
|
||||
targetTroop: 0,
|
||||
});
|
||||
|
||||
async function refresh() {
|
||||
try {
|
||||
@@ -375,10 +410,18 @@ async function exitTroop() {
|
||||
await refresh();
|
||||
}
|
||||
|
||||
async function changeTroopName() {
|
||||
const troopID = tryChangeTroopTarget.value;
|
||||
function openChangeTroopNameDialog(troop: TroopInfo){
|
||||
tryTroopActionTarget.value = {
|
||||
type: 'changeName',
|
||||
targetTroop: troop.troopID
|
||||
}
|
||||
newTroopName.value = troop.troopName;
|
||||
}
|
||||
|
||||
async function changeTroopName(troop: TroopInfo) {
|
||||
const troopID = troop.troopID;
|
||||
const troopName = newTroopName.value;
|
||||
const oldTroopName = troopList.value.get(troopID)?.troopName ?? "??";
|
||||
const oldTroopName = troop.troopName;
|
||||
const josaRo = pick(troopName, "로");
|
||||
if (!confirm(`${oldTroopName} 부대의 이름을 ${troopName}${josaRo} 바꾸시겠습니까?`)) {
|
||||
return;
|
||||
@@ -404,6 +447,61 @@ async function changeTroopName() {
|
||||
}
|
||||
await refresh();
|
||||
}
|
||||
|
||||
|
||||
function openKickTroopMemberDialog(troop: TroopInfo){
|
||||
tryTroopActionTarget.value = {
|
||||
type: 'kickMember',
|
||||
targetTroop: troop.troopID
|
||||
}
|
||||
for(const member of troop.members){
|
||||
if(member.no == troop.troopID){
|
||||
continue;
|
||||
}
|
||||
kickTroopMemberID.value = member.no;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
async function kickTroopMember(troop: TroopInfo) {
|
||||
const kickMember = generalList.value.get(kickTroopMemberID.value);
|
||||
if(kickMember === undefined){
|
||||
toasts.danger({
|
||||
title: "오류",
|
||||
body: "잘못된 접근입니다.",
|
||||
});
|
||||
return;
|
||||
}
|
||||
const troopID = troop.troopID;
|
||||
const troopName = troop.troopName;
|
||||
|
||||
const generalID = kickMember.no;
|
||||
const generalName = kickMember.name;
|
||||
const josaUl = pick(generalName, "을");
|
||||
if (!confirm(`${troopName} 부대에서 ${generalName}${josaUl} 추방하시겠습니까?`)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await SammoAPI.Troop.KickFromTroop({
|
||||
troopID,
|
||||
generalID,
|
||||
});
|
||||
|
||||
toasts.info({
|
||||
title: "완료",
|
||||
body: `${generalName}${josaUl} 추방했습니다.`,
|
||||
});
|
||||
} catch (e) {
|
||||
if (isString(e)) {
|
||||
toasts.danger({
|
||||
title: "오류",
|
||||
body: e,
|
||||
});
|
||||
}
|
||||
console.error(e);
|
||||
}
|
||||
await refresh();
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
Reference in New Issue
Block a user