feat: add toolbar action to remove existing shot

This commit is contained in:
2026-09-09 13:42:22 +09:00
parent 680cb21c80
commit 43e34b31ce
3 changed files with 12 additions and 1 deletions
+9
View File
@@ -321,6 +321,13 @@ function addShootForOwner() {
if (play === state.play) { state = workingState; renderUi(); document.querySelector('#status').textContent = hasShoot(state.play) ? '슛 행동은 전술당 1개만 가능합니다' : '슛은 마지막 단계의 공 소유 선수만 가능합니다'; return; }
state = workingState; const track = play.sequences[sequenceIndex].tracks.find((candidate) => candidate.playerId === ownerId); updatePlay(play, '슛 행동 추가', track.actions.length - 1);
}
function removeShootAction() {
const shot = state.play.sequences.flatMap((sequence, sequenceIndex) => sequence.tracks.flatMap((track) => track.actions.map((action, actionIndex) => ({ action, actionIndex, playerId: track.playerId, sequenceIndex })))).find(({ action }) => action.type === 'shoot');
if (!shot) return;
const play = removeAction(state.play, shot.sequenceIndex, shot.playerId, shot.actionIndex);
if (play === state.play) return;
setState({ ...commitActionEdit(state, play, shot.sequenceIndex, shot.playerId), selectedAction: -1 }, '슛 행동 삭제');
}
function renderUi() {
const readOnly = currentTeam?.role === 'viewer';
@@ -356,6 +363,7 @@ function renderUi() {
document.querySelector('#delete-action').disabled = state.mode === 'start' || state.selectedAction < 0;
const shootButton = document.querySelector('#shoot-action'); shootButton.hidden = selectedPlayer?.id !== finalOwnerId;
shootButton.disabled = playHasShoot || state.mode === 'start' || state.selectedSequence !== state.play.sequences.length - 1;
const removeShootButton = document.querySelector('#remove-shoot-action'); removeShootButton.hidden = !playHasShoot;
const passButton = document.querySelector('[data-mode="pass"]'); const canPass = selectedPlayer?.team === 'offense' && selectedPlayer.id === finalOwnerId;
passButton.hidden = !canPass; passButton.disabled = playHasShoot || !canPass;
document.querySelector('#add-sequence').disabled = playHasShoot;
@@ -454,6 +462,7 @@ app.addEventListener('click', (event) => {
if (event.target.closest('#save-play')) { saveCurrentPlay(); return; }
if (event.target.closest('#load-play')) { loadSelectedPlay(); return; }
if (event.target.closest('#shoot-action')) { addShootForOwner(); return; }
if (event.target.closest('#remove-shoot-action')) { removeShootAction(); return; }
if (event.target.closest('#undo')) { const next = editorHistory.undo(state); if (next !== state) setState(next, '실행 취소', false); return; }
if (event.target.closest('#redo')) { const next = editorHistory.redo(state); if (next !== state) setState(next, '다시 실행', false); return; }
if (event.target.closest('#set-ball-owner')) { const selectedPlayer = state.play.players.find((player) => player.id === state.selectedPlayerId); if (selectedPlayer?.team === 'offense') { const play = setSequenceBallOwner(state.play, state.selectedSequence, selectedPlayer.id); if (play === state.play) document.querySelector('#status').textContent = hasShoot(state.play) ? '슛 행동을 먼저 삭제하세요' : '먼저 패스 행동을 삭제하세요'; else setState({ ...state, play, mode: 'move', selectedAction: -1 }, `Sequence ${state.selectedSequence + 1} 공 소유자 O${selectedPlayer.number}`); } return; }