Skip to content

Commit

Permalink
fix: 마피아일 때 기존 타켓 요청이 안가는 버그 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
cheonjiyun committed Dec 22, 2024
1 parent b9f0d5b commit 932771e
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/components/job/MafiaNight.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,22 @@ interface PropsType {
mafiaSkillPlayer: string | null;
}
export const MafiaNight = ({ isAlive, players, publishSkill, mafiaSkillPlayer }: PropsType) => {
const mafiaVoteResult = mafiaSkillPlayer;
// 지금 투표중인사람
const [check, setCheck] = useState(-1);

let nowVoteResult = mafiaSkillPlayer === '' ? 0 : -1;
useEffect(() => {
setCheck(mafiaSkillPlayer === '' ? 0 : -1);

// 이름 -> index로 변경
players.forEach((player, i) => {
if (player.name === mafiaVoteResult) {
nowVoteResult = i + 1;
}
});
players.forEach((player, i) => {
if (player.name === mafiaSkillPlayer) {
setCheck(i + 1);
}
});
}, [mafiaSkillPlayer, players]);

const [check, setCheck] = useState(-1);
// let nowVoteResult = mafiaSkillPlayer === '' ? 0 : -1;

// 이름 -> index로 변경

const findTargetName = (): string => {
let targetName = '';
Expand All @@ -50,9 +54,6 @@ export const MafiaNight = ({ isAlive, players, publishSkill, mafiaSkillPlayer }:
};

useEffect(() => {
// (async () => {

// })();
skill();
}, [check, players]);

Expand All @@ -68,7 +69,7 @@ export const MafiaNight = ({ isAlive, players, publishSkill, mafiaSkillPlayer }:
key={i + 1}
index={i + 1}
myJob={'MAFIA'}
nowVoteResult={nowVoteResult}
nowVoteResult={check}
{...(isAlive && { setCheck: setCheck })}
/>
))}
Expand All @@ -80,7 +81,7 @@ export const MafiaNight = ({ isAlive, players, publishSkill, mafiaSkillPlayer }:
name="vote"
id="0"
css={notkill}
checked={nowVoteResult === 0}
checked={check === 0}
onChange={() => isAlive && setCheck(0)}
/>
<Votelabel text="안죽이기" color="night" htmlFor="0" />
Expand Down

0 comments on commit 932771e

Please sign in to comment.