Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

rabbit97 님의 블로그

29일 일지 본문

프로젝트 Final

29일 일지

rabbit97 2024. 11. 30. 17:40

# 개발 진행 상황

 

모든 패킷 명세가 클라이언트가 원하는대로 작성이 완료 되었다.

 

나의 마무리 작업은 감금장치 마무리하기

 

잘 안풀려서 팀원의 도움을 받았지만 덕분에 정상적으로 잘 합칠 수 있었고

 

이제 남은 개발은 명세는 끝났고 리펙토링 및 추가 구현만 남았다.

 

오늘 진행한 감금장치 로직

처음에는 인터벌로 매 순간 감금장치 상태인지 확인하는 로직을 작성했었는데

 

이미 매 초마다 유저의 정보를 관리하는 유틸 함수가 있어서 팀원 중 한분이 거기에 작성하는게 좋을 것 같다 추천

 

그래서 유저 업데이트에 감금 장치와 관련된 로직을 추가하고 (사실 이해를 못해서 도움을 많이 받았다.)

gameUpdate() {
  // 체력이 0이되면 죽도록 없데이트.
  const userDatas = this.getAllUserDatas();
  let targetCount = 0;
  let hitmanCount = 0;
  let psychopathCount = 0;

  userDatas.forEach((user) => {
    if (user.character.hp === 0) {
      return;
    }
    // 캐릭터가 핑크군일때 손패가 없으면 한장뽑기.
    // 사망 캐릭터 발생시 그캐릭터 모든 장비, 총, 디버프, 손 카드를 가면군의 손패로
    // 죽는 딱 그순간만 만들어서 그때 처리.

    // 만약 내가 감금디버프를 가지고있으면서, is감금이 true이면 감금상태로 변환.
    if (
      user.character.debuffs.includes(CARD_TYPE.CONTAINMENT_UNIT) &&
      user.character.isContain === true
    ) {
      this.setCharacterState(
        user.id,
        CHARACTER_STATE_TYPE.CONTAINED,
        CHARACTER_STATE_TYPE.NONE_CHARACTER_STATE,
        INTERVAL.PHASE_UPDATE_DAY,
        0,
      );
    } else if (
      !user.character.debuffs.includes(CARD_TYPE.CONTAINMENT_UNIT) &&
      user.character.isContain === true
    ) {
      user.character.isContain = false;
    }

    // 이거를 주기적으로 검사.

    const roleType = user.character.roleType;

    if (roleType === ROLE_TYPE.TARGET) {
      targetCount++;
    } else if (roleType === ROLE_TYPE.HITMAN) {
      hitmanCount++;
    } else if (roleType === ROLE_TYPE.PSYCHOPATH) {
      psychopathCount++;
    }
  });

  this.targetCount = targetCount;
  this.hitmanCount = hitmanCount;
  this.psychopathCount = psychopathCount;

  const gameEndNotiData = {
    winners: null,
    winType: 0,
  };

  this.winnerUpdate(gameEndNotiData);
  if (gameEndNotiData.winners !== null) {
    gameEndNotification(this.getAllUsers(), this.id, gameEndNotiData);
    return;
  }
  userUpdateNotification(this);
}

 

기존 디버프 로직에 간단한 로직 추가


// 위성타겟 디버프 가졌는지 확인하고 다음유저에게 넘기기까지
debuffUpdate() {
  // 위성 타겟 디버프 처리
  const satelliteTargetUser = this.getDebuffUser(CARD_TYPE.SATELLITE_TARGET);
  if (satelliteTargetUser) {
    const satelliteCharacter = this.getCharacter(satelliteTargetUser.id);

    const satelIndex = satelliteCharacter.debuffs.indexOf(CARD_TYPE.SATELLITE_TARGET);
    if (satelIndex !== -1) {
      satelliteCharacter.debuffs.splice(satelIndex, 1);
    }

    if (Math.random() < 0.03) {
      console.log(`위성 터졌다!`);

      // 효과가 발동되었을 때
      satelliteCharacter.hp -= 3;
      animationNotification(this, ANIMATION_TYPE.SATELLITE_TARGET_ANIMATION, satelliteTargetUser);
    } else {
      const nextUser = this.getNextUser(satelliteTargetUser.id);
      const nextUserCharacter = this.getCharacter(nextUser.id);
      nextUserCharacter.debuffs.push(CARD_TYPE.SATELLITE_TARGET);
    }
  }

  // 감옥 디버프 처리
  const containmentUnitUser = this.getDebuffUser(CARD_TYPE.CONTAINMENT_UNIT);
  if (containmentUnitUser) {
    const containmentCharacter = this.getCharacter(containmentUnitUser.id);

    if (Math.random() < 1) {
      this.users[containmentUnitUser.id].character.isContain = true;
    } else {
      const containmentIndex = containmentCharacter.debuffs.indexOf(CARD_TYPE.CONTAINMENT_UNIT);
      if (containmentIndex !== -1) {
        containmentCharacter.debuffs.splice(containmentIndex, 1);
      }
      this.users[containmentUnitUser.id].character.isContain = false;
    }
  }
}

 

# 그럼 이제 일주일동안 뭘 진행할거냐

 

사실 특별한 기능은 아이디어도 없기도 한데 구현이 일주일만에 가능할까 하는 걱정이 있다.

https://tech.inflab.com/20230404-test-code/

 

테스트 코드를 왜 그리고 어떻게 작성해야 할까?

테스트 코드가 필요한 이유와 잘 작성하는 방법에 대해 공유합니다.

tech.inflab.com

 

그래서 이번 프로젝트에서 사용 할 수 있는 테스트 코드를 찾아볼 예정

 

한번도 해본 적이 없어 관련 내용을 좀 찾아보고 진행 하기

당장 주말은 알고리즘에 시간을 투자하고

월요일부터 진행

'프로젝트 Final' 카테고리의 다른 글

4일 일지  (1) 2024.12.04
3일 일지  (1) 2024.12.03
28일 일지  (0) 2024.11.28
27일 일지  (0) 2024.11.27
26일 일지  (0) 2024.11.26