rabbit97 님의 블로그
27일 일지 본문
오늘의 개발 진행 사항
# 카드 기능 구현 - 감금장치, 위성 타겟
둘 다 페이즈가 바뀌면 발동하는 카드여서 기존 페이즈 업데이트 로직에 조건문을 걸고
페이즈가 낮일때 장착하고 있는 디버프가 어떤 경우 어떤 효과 발생 이런식으로 로직을 진행
findRandomSurvivingUser(currentUserId) {
const survivingUsers = Object.values(this.users).filter(({ user }) => {
// 현재 자신은 목록에서 제외
return user.id !== currentUserId;
});
if (survivingUsers.length === 0) {
return null;
}
// 다음 디버프를 받은 유저는 랜덤으로 결정
const randomIndex = Math.floor(Math.random() * survivingUsers.length);
return survivingUsers[randomIndex].user.id;
}
nextPhase() {
if (this.phase === PHASE_TYPE.END) {
// 페이즈가 시작할 때 모든 유저의 정보 조회
Object.values(this.users).forEach(({ user, character }) => {
// 만약에 유저가 디버프로 감금장치 장착 시 75퍼센트 확률로 특정 죄표로 이동
if (character.debuffs.includes(CARD_TYPE.CONTAINMENT_UNIT)) {
if (Math.random() >= 0.75) {
user.setPos(0, 0);
}
// 발동 후 제거
const index = character.debuffs.indexOf(CARD_TYPE.CONTAINMENT_UNIT);
if (index !== -1) {
character.debuffs.splice(index, 1);
}
}
// 만약에 디버프 칸에 위성 타겟이 있을 경우
if (character.debuffs.includes(CARD_TYPE.SATELLITE_TARGET)) {
const triggerChance = Math.random() < 0.3;
if (triggerChance) {
// 효과가 발동되었을 때
character.hp -= 1;
handleAnimationNotification({
socket: user.socket,
payload: {
userId: user.id,
animationType: 1,
},
});
// 디버프 제거
const index = character.debuffs.indexOf(CARD_TYPE.SATELLITE_TARGET);
if (index !== -1) {
character.debuffs.splice(index, 1);
}
} else {
// 효과가 발동하지 않았을 때 전이
// 자신의 디버프 제거
const index = character.debuffs.indexOf(CARD_TYPE.SATELLITE_TARGET);
if (index !== -1) {
character.debuffs.splice(index, 1);
}
// 전이된 유저의 디버프 칸에 위성 타겟 추가
const nextUserId = this.findRandomSurvivingUser(user.id);
if (nextUserId !== null) {
this.users[nextUserId].character.debuffs.push(CARD_TYPE.SATELLITE_TARGET);
}
}
}
});
// 모든 로직 종료 후 유저 정보 업데이트
userUpdateNotification(this);
this.phase = PHASE_TYPE.DAY;
} else if (this.phase === PHASE_TYPE.DAY) {
this.phase = PHASE_TYPE.END;
}
}
오늘 이제 로직 구현이 다 끝난 팀원 중 팀장님이 내가 리액션때부터 구현했던 로직들을 보완해주고있다.
변경사항이라고 하면 애니메이션 알림 구조 변경 정도 될 것 같은데
쉴드 이펙트때 걸렸던 무한로딩 문제가 클라이언트 코드 수정 없이 가능할 것 같다.
결과는 아마 빠르면 내일 늦으면 내일 모래 다음 주 안에는 모든 기능들이 동작을 할 것 같은데
발표까진 일주일이 넘게 남아서 추가 구현까지 뭔가 할 수 있을 것 같은 느낌
다들 실력이 좋으셔서 부럽기도 하고 더 열심히 공부를 해야겠다는 생각을 했다.