Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
PenguinKKIM committed Oct 9, 2024
2 parents 9e3be8f + 6ee4620 commit 3ac3034
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 3 deletions.
18 changes: 17 additions & 1 deletion components/ClickSpeedTestGame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,22 @@ export default function ClickSpeedTest({ onClose }: { onClose: () => void }) {
const finalResult = clicks / 10;
setResult(finalResult);
if (finalResult >= 5 && !hasMutated) {
// ์„ฑ๊ณต ์‹œ ๋ชจ๋ฐ”์ผ๋กœ ์•Œ๋ฆผ ์ „์†ก
if (
typeof window !== 'undefined' &&
window.Mobile &&
typeof window.Mobile.sendToMobile === 'function'
) {
window.Mobile.sendToMobile(true);
}
// mutate();
setHasMutated(true);
} else if (!hasMutated) {
setGameFailed(true);
}
}
return () => clearInterval(timer);
}, [gameStarted, timeLeft, hasMutated]);
}, [gameStarted, timeLeft, hasMutated, clicks]);

const startGame = () => {
setClicks(0);
Expand All @@ -47,6 +55,14 @@ export default function ClickSpeedTest({ onClose }: { onClose: () => void }) {
};

const handleCloseModal = () => {
if (
typeof window !== 'undefined' &&
window.Mobile &&
typeof window.Mobile.sendCancel === 'function'
) {
// ๋‹ซ๊ธฐ ์‹œ ๋ชจ๋ฐ”์ผ์— ์ทจ์†Œ ์•Œ๋ฆผ ์ „์†ก
window.Mobile.sendCancel();
}
onClose();
};

Expand Down
24 changes: 23 additions & 1 deletion components/MemoryCardGame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ export default function MemoryCardGame({ onClose }: { onClose: () => void }) {
if (matchedPairs.length + 1 === symbols.length) {
alert('์•ฑ ์‹ฌ์‚ฌ์ค‘์œผ๋กœ ์ฟ ํฐ์ด ๋ฐœ๊ธ‰๋˜์งˆ ์•Š์Šต๋‹ˆ๋‹ค! ์‹ฌ์‚ฌํ›„์— ์ด์šฉํ•ด์ฃผ์„ธ์š”!');
setGameOver(true);

// ์„ฑ๊ณต ์‹œ ๋ชจ๋ฐ”์ผ๋กœ ์•Œ๋ฆผ ์ „์†ก
if (
typeof window !== 'undefined' &&
window.Mobile &&
typeof window.Mobile.sendToMobile === 'function'
) {
window.Mobile.sendToMobile(true);
}

// mutate();
}
} else {
Expand All @@ -58,6 +68,14 @@ export default function MemoryCardGame({ onClose }: { onClose: () => void }) {
};

const handleCloseModal = () => {
if (
typeof window !== 'undefined' &&
window.Mobile &&
typeof window.Mobile.sendCancel === 'function'
) {
// ๋‹ซ๊ธฐ ์‹œ ๋ชจ๋ฐ”์ผ์— ์ทจ์†Œ ์•Œ๋ฆผ ์ „์†ก
window.Mobile.sendCancel();
}
onClose();
};

Expand All @@ -77,7 +95,11 @@ export default function MemoryCardGame({ onClose }: { onClose: () => void }) {
{cards.map((card, index) => (
<div
key={card.id}
className={`h-16 flex items-center justify-center text-2xl cursor-pointer ${flippedIndexes.includes(index) || matchedPairs.includes(card.symbol) ? 'bg-blue-200' : 'bg-gray-300'}`}
className={`h-16 flex items-center justify-center text-2xl cursor-pointer ${
flippedIndexes.includes(index) || matchedPairs.includes(card.symbol)
? 'bg-blue-200'
: 'bg-gray-300'
}`}
onClick={() => handleCardClick(index)}
>
{flippedIndexes.includes(index) || matchedPairs.includes(card.symbol)
Expand Down
14 changes: 14 additions & 0 deletions components/MovingGame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ export default function MovingGame({ onClose }: { onClose: () => void }) {

useEffect(() => {
if (score >= 5) {
if (
typeof window !== 'undefined' &&
window.Mobile &&
typeof window.Mobile.sendToMobile === 'function'
) {
window.Mobile.sendToMobile(true);
}
alert('์•ฑ ์‹ฌ์‚ฌ์ค‘์œผ๋กœ ์ฟ ํฐ์ด ๋ฐœ๊ธ‰๋˜์งˆ ์•Š์Šต๋‹ˆ๋‹ค! ์‹ฌ์‚ฌํ›„์— ์ด์šฉํ•ด์ฃผ์„ธ์š”!');
onClose();
}
Expand Down Expand Up @@ -141,6 +148,13 @@ export default function MovingGame({ onClose }: { onClose: () => void }) {
}, []);

const handleCloseModal = () => {
if (
typeof window !== 'undefined' &&
window.Mobile &&
typeof window.Mobile.sendCancel === 'function'
) {
window.Mobile.sendCancel();
}
onClose();
};

Expand Down
18 changes: 18 additions & 0 deletions components/NumberBaseballGame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ export default function NumberBaseballGame({ onClose }: { onClose: () => void })
setMessage(`์ถ•ํ•˜ํ•ฉ๋‹ˆ๋‹ค! ${attempts + 1}๋ฒˆ ๋งŒ์— ๋งž์ท„์Šต๋‹ˆ๋‹ค.`);
alert('์•ฑ ์‹ฌ์‚ฌ์ค‘์œผ๋กœ ์ฟ ํฐ์ด ๋ฐœ๊ธ‰๋˜์งˆ ์•Š์Šต๋‹ˆ๋‹ค! ์‹ฌ์‚ฌํ›„์— ์ด์šฉํ•ด์ฃผ์„ธ์š”!');
setGameOver(true);

// ๋ชจ๋ฐ”์ผ์— ์„ฑ๊ณต ์•Œ๋ฆผ ์ „์†ก
if (
typeof window !== 'undefined' &&
window.Mobile &&
typeof window.Mobile.sendToMobile === 'function'
) {
window.Mobile.sendToMobile(true);
}

// mutate(); // ํ‹ฐ์ผ“ ์ง€๊ธ‰
} else {
setMessage(`${strikes} ์ŠคํŠธ๋ผ์ดํฌ, ${balls} ๋ณผ`);
Expand All @@ -79,6 +89,14 @@ export default function NumberBaseballGame({ onClose }: { onClose: () => void })
};

const handleCloseModal = () => {
if (
typeof window !== 'undefined' &&
window.Mobile &&
typeof window.Mobile.sendCancel === 'function'
) {
// ๋ชจ๋ฐ”์ผ์— ์ทจ์†Œ ์•Œ๋ฆผ ์ „์†ก
window.Mobile.sendCancel();
}
onClose();
};

Expand Down
20 changes: 19 additions & 1 deletion components/NumberGuessingGame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,17 @@ export default function NumberGuessingGame({ onClose }: { onClose: () => void })
setMessage(`์ถ•ํ•˜ํ•ฉ๋‹ˆ๋‹ค. ${attempts + 1}๋ฒˆ ๋งŒ์— ๋งž์ถ”์…จ์Šต๋‹ˆ๋‹ค.`);
alert('์•ฑ ์‹ฌ์‚ฌ์ค‘์œผ๋กœ ์ฟ ํฐ์ด ๋ฐœ๊ธ‰๋˜์งˆ ์•Š์Šต๋‹ˆ๋‹ค! ์‹ฌ์‚ฌํ›„์— ์ด์šฉํ•ด์ฃผ์„ธ์š”!');
setGameOver(true);
// mutate();

// ์„ฑ๊ณต ์‹œ ๋ชจ๋ฐ”์ผ์— ์•Œ๋ฆผ ์ „์†ก
if (
typeof window !== 'undefined' &&
window.Mobile &&
typeof window.Mobile.sendToMobile === 'function'
) {
window.Mobile.sendToMobile(true);
}

// mutate(); // ํ‹ฐ์ผ“ ์ง€๊ธ‰
} else if (guessNumber < targetNumber) {
setMessage('๋” ํฐ ์ˆซ์ž๋ฅผ ์ž…๋ ฅํ•ด๋ณด์„ธ์š”.');
} else {
Expand All @@ -48,6 +58,14 @@ export default function NumberGuessingGame({ onClose }: { onClose: () => void })
};

const handleCloseModal = () => {
if (
typeof window !== 'undefined' &&
window.Mobile &&
typeof window.Mobile.sendCancel === 'function'
) {
// ๋‹ซ๊ธฐ ์‹œ ๋ชจ๋ฐ”์ผ์— ์ทจ์†Œ ์•Œ๋ฆผ ์ „์†ก
window.Mobile.sendCancel();
}
onClose();
handleResetGame();
};
Expand Down
10 changes: 10 additions & 0 deletions global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export {};

declare global {
interface Window {
Mobile?: {
sendCancel: () => void;
sendToMobile: (status: boolean) => void;
};
}
}

0 comments on commit 3ac3034

Please sign in to comment.