@@ -54,32 +54,34 @@ const Game: React.FC = () => { |
| 54 | 54 | const handleMoleKilled = useCallback((response: CommandResponse) => { |
| 55 | 55 | if (!gameState.tree) return; |
| 56 | 56 | |
| 57 | | - // First, show the killed mole briefly |
| 58 | | - updateTreeData((tree) => |
| 57 | + // First, show the killed mole at the player's current location (where it was killed) |
| 58 | + updateTreeData((tree) => |
| 59 | 59 | updateTreeDataToShowMole(tree, gameState.tree!.player_location) |
| 60 | 60 | ); |
| 61 | | - |
| 62 | | - // Trigger falling animation |
| 61 | + |
| 62 | + // Trigger falling animation on the current mole |
| 63 | 63 | setMoleKilled(true); |
| 64 | | - |
| 65 | | - // After animation, update tree with new mole location |
| 64 | + |
| 65 | + // After animation completes, remove old mole and show new mole |
| 66 | 66 | setTimeout(() => { |
| 67 | 67 | setMoleKilled(false); |
| 68 | | - |
| 69 | | - // Update tree to show new mole location |
| 68 | + |
| 69 | + // Now update tree to remove old mole and show new mole location |
| 70 | 70 | if (response.new_mole_location) { |
| 71 | 71 | updateTreeData((tree) => { |
| 72 | + // First remove all moles from the tree |
| 72 | 73 | const cleanTree = removeMoleFromTree(tree); |
| 74 | + // Then add the new mole at its new location |
| 73 | 75 | return updateTreeDataToShowMole(cleanTree, response.new_mole_location!); |
| 74 | 76 | }); |
| 75 | 77 | } |
| 76 | | - |
| 78 | + |
| 77 | 79 | // Set new mole direction |
| 78 | 80 | if (response.mole_direction) { |
| 79 | 81 | setMoleDirection(response.mole_direction); |
| 80 | 82 | } |
| 81 | | - }, 1500); // Wait for falling animation |
| 82 | | - |
| 83 | + }, 1500); // Wait for falling animation to complete |
| 84 | + |
| 83 | 85 | // Update score and moles killed |
| 84 | 86 | if (response.score !== undefined && response.moles_killed !== undefined) { |
| 85 | 87 | updateScore(response.score, response.moles_killed); |
@@ -122,7 +124,7 @@ const Game: React.FC = () => { |
| 122 | 124 | const startLocation = response.tree.player_location; |
| 123 | 125 | const homeDir = response.home_directory || '/home'; |
| 124 | 126 | let locationContext = ''; |
| 125 | | - |
| 127 | + |
| 126 | 128 | if (startLocation.startsWith('/home')) { |
| 127 | 129 | locationContext = "You've been dropped in someone's home directory. "; |
| 128 | 130 | } else if (startLocation.startsWith('/usr')) { |
@@ -134,13 +136,13 @@ const Game: React.FC = () => { |
| 134 | 136 | } else { |
| 135 | 137 | locationContext = "You've been placed somewhere in the filesystem. "; |
| 136 | 138 | } |
| 137 | | - |
| 139 | + |
| 138 | 140 | // Add timer info to starting message |
| 139 | 141 | let timerInfo = ''; |
| 140 | 142 | if (response.initial_timer && response.timer_reason) { |
| 141 | 143 | timerInfo = `\nTimer: ${response.initial_timer}s (mole is ${response.timer_reason})`; |
| 142 | 144 | } |
| 143 | | - |
| 145 | + |
| 144 | 146 | addToHistory({ |
| 145 | 147 | command: 'Hunt started!', |
| 146 | 148 | output: `${response.mole_hint}\n${locationContext}Your home directory is ${homeDir}.\nUse 'pwd' to see where you are, 'cd ~' to go home.${timerInfo}\nType "help" for available commands.`, |
@@ -157,19 +159,19 @@ const Game: React.FC = () => { |
| 157 | 159 | if (response.mole_escaped) { |
| 158 | 160 | // Build the escape message |
| 159 | 161 | let escapeMessage = response.message || 'The mole escaped!'; |
| 160 | | - |
| 162 | + |
| 161 | 163 | // Add distance info for new mole if available |
| 162 | 164 | if (response.escape_data?.timer_reason) { |
| 163 | 165 | escapeMessage += `\nNew mole detected ${response.escape_data.timer_reason}!`; |
| 164 | 166 | } |
| 165 | | - |
| 167 | + |
| 166 | 168 | // Update command history with escape message |
| 167 | 169 | addToHistory({ |
| 168 | 170 | command: 'Mole escaped!', |
| 169 | 171 | output: escapeMessage, |
| 170 | 172 | success: false, |
| 171 | 173 | }); |
| 172 | | - |
| 174 | + |
| 173 | 175 | // Update mole direction if provided |
| 174 | 176 | if (response.escape_data?.new_location) { |
| 175 | 177 | // Update tree to show new mole location |
@@ -177,7 +179,7 @@ const Game: React.FC = () => { |
| 177 | 179 | const cleanTree = removeMoleFromTree(tree); |
| 178 | 180 | return updateTreeDataToShowMole(cleanTree, response.escape_data!.new_location); |
| 179 | 181 | }); |
| 180 | | - |
| 182 | + |
| 181 | 183 | // Show mole direction indicator if provided |
| 182 | 184 | if (response.escape_data?.mole_direction) { |
| 183 | 185 | setMoleDirection(response.escape_data.mole_direction); |
@@ -324,7 +326,7 @@ const Game: React.FC = () => { |
| 324 | 326 | amole |
| 325 | 327 | </h1> |
| 326 | 328 | </div> |
| 327 | | - |
| 329 | + |
| 328 | 330 | <div className="flex items-center gap-3"> |
| 329 | 331 | <div className="text-xs text-slate-400"> |
| 330 | 332 | click adjacent nodes or use the terminal |