Felix Zieger commited on
Commit ·
769c038
1
Parent(s): 0ce34cb
app update
Browse files
src/components/GameContainer.tsx
CHANGED
|
@@ -143,7 +143,7 @@ export const GameContainer = () => {
|
|
| 143 |
|
| 144 |
const getAverageWordsPerRound = () => {
|
| 145 |
if (successfulRounds === 0) return 0;
|
| 146 |
-
return totalWords / successfulRounds + 1; // The total words include the ones in the failed last round, so we also count it in the denominator
|
| 147 |
};
|
| 148 |
|
| 149 |
return (
|
|
|
|
| 143 |
|
| 144 |
const getAverageWordsPerRound = () => {
|
| 145 |
if (successfulRounds === 0) return 0;
|
| 146 |
+
return totalWords / (successfulRounds + 1); // The total words include the ones in the failed last round, so we also count it in the denominator
|
| 147 |
};
|
| 148 |
|
| 149 |
return (
|
src/components/game/SentenceBuilder.tsx
CHANGED
|
@@ -54,23 +54,14 @@ export const SentenceBuilder = ({
|
|
| 54 |
const handleKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {
|
| 55 |
if (e.shiftKey && e.key === 'Enter') {
|
| 56 |
e.preventDefault();
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
preventDefault: () => {},
|
| 66 |
-
} as React.FormEvent;
|
| 67 |
-
onSubmitWord(syntheticEvent);
|
| 68 |
-
|
| 69 |
-
// Wait a brief moment for the state to update before making the guess
|
| 70 |
-
setTimeout(() => {
|
| 71 |
-
onMakeGuess();
|
| 72 |
-
}, 100);
|
| 73 |
-
} else {
|
| 74 |
onMakeGuess();
|
| 75 |
}
|
| 76 |
};
|
|
@@ -99,11 +90,6 @@ export const SentenceBuilder = ({
|
|
| 99 |
{currentWord}
|
| 100 |
</p>
|
| 101 |
</div>
|
| 102 |
-
{successfulRounds > 0 && (
|
| 103 |
-
<p className="mb-4 text-green-600">
|
| 104 |
-
Successful rounds: {successfulRounds}
|
| 105 |
-
</p>
|
| 106 |
-
)}
|
| 107 |
<div className="mb-6 rounded-lg bg-gray-50 p-4">
|
| 108 |
<p className="text-lg text-gray-800">
|
| 109 |
{sentence.length > 0 ? sentence.join(" ") : "Start your sentence..."}
|
|
@@ -130,7 +116,7 @@ export const SentenceBuilder = ({
|
|
| 130 |
</Button>
|
| 131 |
<Button
|
| 132 |
type="button"
|
| 133 |
-
onClick={
|
| 134 |
className="flex-1 bg-secondary text-lg hover:bg-secondary/90"
|
| 135 |
disabled={(!sentence.length && !playerInput.trim()) || isAiThinking}
|
| 136 |
>
|
|
|
|
| 54 |
const handleKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {
|
| 55 |
if (e.shiftKey && e.key === 'Enter') {
|
| 56 |
e.preventDefault();
|
| 57 |
+
if (playerInput.trim()) {
|
| 58 |
+
// Create a synthetic form event to add the current word
|
| 59 |
+
const syntheticEvent = {
|
| 60 |
+
preventDefault: () => {},
|
| 61 |
+
} as React.FormEvent;
|
| 62 |
+
onSubmitWord(syntheticEvent);
|
| 63 |
+
}
|
| 64 |
+
// Make the guess immediately without waiting for AI response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
onMakeGuess();
|
| 66 |
}
|
| 67 |
};
|
|
|
|
| 90 |
{currentWord}
|
| 91 |
</p>
|
| 92 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
<div className="mb-6 rounded-lg bg-gray-50 p-4">
|
| 94 |
<p className="text-lg text-gray-800">
|
| 95 |
{sentence.length > 0 ? sentence.join(" ") : "Start your sentence..."}
|
|
|
|
| 116 |
</Button>
|
| 117 |
<Button
|
| 118 |
type="button"
|
| 119 |
+
onClick={onMakeGuess}
|
| 120 |
className="flex-1 bg-secondary text-lg hover:bg-secondary/90"
|
| 121 |
disabled={(!sentence.length && !playerInput.trim()) || isAiThinking}
|
| 122 |
>
|