test game

This commit is contained in:
2025-07-26 21:07:35 +09:00
parent 3c9ef78696
commit 59fe764291
4 changed files with 155 additions and 162 deletions

View File

@@ -513,6 +513,65 @@ document.addEventListener('DOMContentLoaded', function() {
});
});
// Game functionality
function showGame() {
const gameFrame = document.getElementById('gameFrame');
const chatForm = document.getElementById('chatForm');
const chatHistory = document.getElementById('chatHistory');
const panel = document.getElementById('askAiPanel');
if (gameFrame && chatForm && panel) {
gameFrame.style.display = 'block';
chatForm.style.display = 'none';
chatHistory.style.display = 'none';
panel.classList.add('game-mode');
}
}
function closeGame() {
const gameFrame = document.getElementById('gameFrame');
const chatForm = document.getElementById('chatForm');
const chatHistory = document.getElementById('chatHistory');
const panel = document.getElementById('askAiPanel');
if (gameFrame && chatForm && panel) {
gameFrame.style.display = 'none';
chatForm.style.display = 'block';
chatHistory.style.display = 'block';
panel.classList.remove('game-mode');
}
}
// Show game button when user is authenticated
function showGameButton() {
const gameButton = document.getElementById('gameButton');
if (gameButton) {
gameButton.style.display = 'inline-block';
}
}
// Hide game button when user is not authenticated
function hideGameButton() {
const gameButton = document.getElementById('gameButton');
if (gameButton) {
gameButton.style.display = 'none';
}
}
// Override handleAuthenticationStatus to include game button logic
const originalHandleAuthenticationStatus = handleAuthenticationStatus;
function handleAuthenticationStatus(isAuthenticated) {
originalHandleAuthenticationStatus(isAuthenticated);
if (isAuthenticated) {
showGameButton();
} else {
hideGameButton();
}
}
// Global functions for onclick handlers
window.toggleAskAI = toggleAskAI;
window.askQuestion = askQuestion;
window.showGame = showGame;
window.closeGame = closeGame;