Skip to content

BEYONDWORM-115 서버, worm-died에 death reason추가하기#61

Merged
konempty merged 5 commits into
mainfrom
feature/BEYONDWORM-115
Mar 7, 2026
Merged

BEYONDWORM-115 서버, worm-died에 death reason추가하기#61
konempty merged 5 commits into
mainfrom
feature/BEYONDWORM-115

Conversation

@konempty

@konempty konempty commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

죽은 이유 출력되도록 수정

@konempty konempty self-assigned this Mar 7, 2026
@notion-workspace

Copy link
Copy Markdown

@konempty konempty merged commit 7db5480 into main Mar 7, 2026
2 checks passed
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 게임 내 지렁이 사망 이벤트에 대한 정보 전달을 크게 개선하여 플레이어에게 더 명확하고 유용한 피드백을 제공합니다. 서버에서 사망 원인과 가해자 정보를 포함한 상세한 데이터를 전송하고, 클라이언트에서는 이를 바탕으로 사망 화면에 구체적인 메시지를 표시합니다. 또한, 전반적인 UI 텍스트 렌더링 품질을 향상시켜 사용자 경험을 개선했습니다.

Highlights

  • 사망 원인 상세화: 지렁이가 죽었을 때 발생하는 'worm-died' 이벤트에 사망 원인(map_boundary, worm_collision)과 가해 지렁이 정보(killerWormId, killerNickname)를 추가하여 클라이언트에게 더 상세한 정보를 제공하도록 서버 로직을 수정했습니다.
  • 공통 타입 정의: 서버와 클라이언트 간에 공유되는 shared 모듈에 WormDeathReason 타입과 WormDeathData 인터페이스를 새로 정의하여 지렁이 사망 관련 데이터 구조를 표준화했습니다.
  • 사망 페이로드 생성 유틸리티: 지렁이 사망 이벤트 페이로드를 일관성 있게 생성하기 위한 createWormDeathPayload 유틸리티 함수를 새로 추가했습니다.
  • 사망 화면 개선: 클라이언트의 DeathScene에서 플레이어 사망 시 상세한 사망 원인 메시지를 표시하도록 기능을 개선했습니다.
  • 텍스트 렌더링 품질 향상: 고해상도 디스플레이에서 텍스트가 선명하게 보이도록 TEXT_RESOLUTION 상수를 도입하고, 여러 UI 텍스트 요소에 이를 적용했습니다.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • game-server/src/index.ts
    • createWormDeathPayload 유틸리티 함수를 임포트했습니다.
    • 맵 경계 초과 및 지렁이 충돌로 인한 사망 시 worm-died 이벤트에 deathReasonkillerWorm 정보를 포함하도록 수정했습니다.
  • game-server/src/socket/handlers.ts
    • createWormDeathPayload 유틸리티 함수를 임포트했습니다.
    • 충돌 보고 시 worm-died 이벤트에 deathReasonkillerWorm 정보를 포함하도록 수정했습니다.
  • game-server/src/utils/wormDeath.ts
    • 지렁이 사망 이벤트 페이로드를 생성하는 createWormDeathPayload 함수를 포함하는 새 파일을 추가했습니다.
  • shared/src/types.ts
    • 지렁이 사망 원인을 나타내는 WormDeathReason 타입과 사망 데이터를 정의하는 WormDeathData 인터페이스를 추가했습니다.
  • web-io-game/src/DeathScene.ts
    • FE_CONSTANTS를 임포트했습니다.
    • createrenderUI 메서드에 reasonMessage 파라미터를 추가하여 사망 원인 메시지를 표시할 수 있도록 했습니다.
    • 버튼 그리기 로직을 drawPlayButton 프라이빗 메서드로 리팩토링했습니다.
    • 텍스트 요소에 TEXT_RESOLUTION을 적용하여 렌더링 품질을 향상시켰습니다.
  • web-io-game/src/GameClient.ts
    • WormDeathData 타입을 임포트했습니다.
    • worm-died 소켓 이벤트 리스너가 WormDeathData를 받도록 변경하고, 현재 플레이어가 죽었을 때 사망 원인에 따라 reasonMessage를 생성하여 showDeathScreen에 전달하도록 수정했습니다.
  • web-io-game/src/GameScene.ts
    • WormDeathData 타입을 임포트했습니다.
    • handleWormDiedFromServer 메서드가 WormDeathData를 받도록 시그니처를 변경했습니다.
    • showDeathScreen 메서드에 reasonMessage 파라미터를 추가하고, DeathScene을 시작할 때 이 메시지를 전달하도록 수정했습니다.
    • 닉네임 텍스트에 TEXT_RESOLUTION을 적용하여 렌더링 품질을 향상시켰습니다.
  • web-io-game/src/UIScene.ts
    • FE_CONSTANTS를 임포트했습니다.
    • 다양한 UI 텍스트 요소에 TEXT_RESOLUTION을 적용하여 렌더링 품질을 향상시켰습니다.
  • web-io-game/src/constants.ts
    • 고해상도 디스플레이에서 텍스트 선명도를 높이기 위한 TEXT_RESOLUTION 상수를 FE_CONSTANTS에 추가했습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a good change by adding the cause of death to the worm-died event and displaying it on the client's death screen, along with consistent data structure updates between the server and client, frontend refactoring for readability, and improved text rendering for high-resolution displays. However, a potential Denial of Service (DoS) vulnerability was identified due to missing input validation for the player's username. Further improvements are suggested to clarify type definitions and enhance the robustness of the client's message processing logic.

Comment thread shared/src/types.ts
export interface WormDeathData {
killedWormId: string;
killerWormId: string | null;
deathReason?: WormDeathReason;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

WormDeathData 인터페이스에서 deathReason이 옵셔널(?) 필드로 정의되어 있습니다. 하지만 서버 측 구현을 보면 createWormDeathPayload 함수는 항상 deathReason을 포함하여 페이로드를 생성합니다. 이로 인해 클라이언트에서는 해당 필드가 항상 존재한다고 가정하고 코드를 작성하는 것이 안전한지 불분명할 수 있습니다. 데이터 계약을 명확히 하고 타입 안정성을 높이기 위해 deathReason을 필수 필드로 변경하는 것을 제안합니다.

Suggested change
deathReason?: WormDeathReason;
deathReason: WormDeathReason;

Comment on lines +101 to +107
const reasonMessage =
data.deathReason === "map_boundary"
? "맵의 경계를 넘어서 사망했습니다."
: data.killerNickname
? `${data.killerNickname} 지렁이에 의해 사망했습니다.`
: "다른 지렁이에 의해 사망했습니다.";
this.scene.showDeathScreen(reasonMessage);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

현재 사망 원인 메시지를 생성하는 로직은 중첩된 삼항 연산자를 사용하여 구현되어 있습니다. 지금은 deathReason의 종류가 두 가지뿐이라 문제가 없지만, 나중에 새로운 사망 원인이 추가될 경우 코드를 수정하고 이해하기 어려워질 수 있습니다. switch 문을 사용하여 각 deathReason 케이스를 명시적으로 처리하면 코드가 더 명확해지고, 향후 새로운 사망 원인을 추가하기도 용이해집니다. 또한, 사용자에게 보여지는 메시지를 조금 더 구체적으로 개선할 수 있습니다.

                let reasonMessage: string;
                switch (data.deathReason) {
                    case "map_boundary":
                        reasonMessage = "맵의 경계를 벗어나 사망했습니다.";
                        break;
                    case "worm_collision":
                        reasonMessage = data.killerNickname
                            ? `${data.killerNickname} 님에게 잡아먹혔습니다.`
                            : "다른 지렁이와 충돌하여 사망했습니다.";
                        break;
                    default:
                        reasonMessage = "알 수 없는 이유로 사망했습니다.";
                        console.warn(`Unknown death reason received:`, data.deathReason);
                        break;
                }
                this.scene.showDeathScreen(reasonMessage);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant