mirror of
https://github.com/LHY0125/Gobang-Game.git
synced 2026-06-29 08:55:53 +08:00
feat(frontend): 对局视图 + 回放视图 + 计时器 hook
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useGameStore } from '../../store/gameStore';
|
||||
|
||||
export default function GameInfo() {
|
||||
const { t } = useTranslation();
|
||||
const currentColor = useGameStore((s) => s.currentColor);
|
||||
const status = useGameStore((s) => s.status);
|
||||
const winner = useGameStore((s) => s.winner);
|
||||
|
||||
let text = '';
|
||||
if (status === 'game_over' && winner) {
|
||||
text = winner === 'Black' ? t('game.black_win') : t('game.white_win');
|
||||
} else if (status === 'ai_thinking') {
|
||||
text = t('game.ai_thinking');
|
||||
} else if (status === 'playing') {
|
||||
text = currentColor === 'Black' ? t('game.black_turn') : t('game.white_turn');
|
||||
}
|
||||
|
||||
return <div className="game-info">{text}</div>;
|
||||
}
|
||||
Reference in New Issue
Block a user