Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pages/games/SnackGame/game/SnackGameBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const SnackGameBase = ({ replaceErrorHandler }: Props) => {
const handleStreak = async (streak: StreakWithMeta, isGolden: boolean) => {

Choose a reason for hiding this comment

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

medium

장기적인 유지보수성 관점에서 handleStreak 함수의 시그니처 개선을 제안합니다. isGolden 파라미터를 별도로 받는 대신, streak 객체에 관련 정보를 모두 포함시키는 것이 좋습니다. 예를 들어 StreakWithMeta 타입을 확장하여 isGolden 프로퍼티를 추가하는 방식입니다.

// in snackGame/SnackGameUtil.ts
export type StreakWithMeta = {
  coordinates: Streak;
  isFever: boolean;
  isGolden: boolean; // 속성 추가
  occurredAt: string;
};

// in SnackGameBase.tsx
const handleStreak = async (streak: StreakWithMeta) => {
  // ...
  if (streak.isGolden || streak.isFever) { /* ... */ }
}

이렇게 리팩토링하면 streak 관련 데이터가 하나의 객체로 캡슐화되어 코드의 명확성과 일관성이 향상됩니다. 향후 리팩토링 시 고려해보시면 좋겠습니다.

cumulativeStreaks = [...cumulativeStreaks, streak];

if (isGolden) {
if (isGolden || streak.isFever) {
session = await handleStreaksMove();
}
return session!;
Expand Down
Loading