feedback3 WC: the room's host can remove a human before the match (room.kick), the player is told and may join again

This commit is contained in:
sganggs committed 2026-10-04 17:15:21 +08:00
1 parent db57c39c7a
commit a308317041
5 files changed
+175 -6

No files matched your search

+11 -2
View File
@@ -76,7 +76,7 @@ export function inviteLink(code) {
*/
export { copyText };
function SeatCard({ seat, index, room, facts, myId, busy, onAddBot, onRemoveBot }) {
function SeatCard({ seat, index, room, facts, myId, busy, onAddBot, onRemoveBot, onKick }) {
const coop = room.mode !== 'solo';
if (!seat) {
const canAdd = coop && facts.isHost;
@@ -126,6 +126,9 @@ function SeatCard({ seat, index, room, facts, myId, busy, onAddBot, onRemoveBot
${seat.isBot && facts.isHost ? html`<${Tooltip} text="移除该 AI 队友">
<${Button} variant="ghost" size="sm" square=${true} icon="close" loading=${busy === `rm${index}`} onClick=${() => onRemoveBot(index)} aria-label="移除 AI 队友" />
<//>` : null}
${!seat.isBot && !isMe && facts.isHost ? html`<${Tooltip} text="将该博士移出同盟">
<${Button} variant="ghost" size="sm" square=${true} icon="close" loading=${busy === `kick${index}`} onClick=${() => onKick(index, seat.name)} aria-label="移出该博士" />
<//>` : null}
</footer>
</article>`;
}
@@ -194,6 +197,12 @@ export function RoomScreen() {
const start = () => run('start', () => net.request('room.start', {}));
const addBot = () => run('add', () => net.request('room.addBot', {}));
const removeBot = (seat) => run(`rm${seat}`, () => net.request('room.removeBot', { seat }));
// the host removes a human before the match (community report #17): asked first; the player may join again
const kick = async (seat, name) => {
if (inFlight.current) return;
const ok = await confirmDialog({ title: '移出同盟', text: `确定将「${name || '博士'}」移出同盟吗?对方可以凭同盟密钥重新加入。`, okText: '移出', danger: true });
if (ok) run(`kick${seat}`, () => net.request('room.kick', { seat }));
};
const setDifficulty = (difficulty) => run('diff', () => net.request('room.setDifficulty', { difficulty }));
const leave = async () => {
if (inFlight.current) return;
@@ -251,7 +260,7 @@ export function RoomScreen() {
<main class=${`seats${coop ? '' : ' seats--solo'}`}>
${facts.seats.map((s, i) => html`<${SeatCard} key=${s ? `p${s.playerId}` : `e${i}`} seat=${s} index=${i} room=${room} facts=${facts}
myId=${me.playerId} busy=${busy} onAddBot=${addBot} onRemoveBot=${removeBot} />`)}
myId=${me.playerId} busy=${busy} onAddBot=${addBot} onRemoveBot=${removeBot} onKick=${kick} />`)}
${coop ? null : html`<aside class="solo-brief brackets">
<${MicroLabel} tone="mint">BRIEFING<//>
<h2>${DIFFICULTY_NAMES[room.difficulty] || ''}<span class="num t-dim"> ${info.code}</span></h2>