refactor(phase1.4): clean up debug logging and finalize score calculation
- Remove all console.log debug statements - Score calculation now working correctly: * Each food worth current level points * Level up happens AFTER food is eaten and scored * Example: food1(+1)=1pt, food2(+1, lvlup)=2pts, food3(+2)=4pts - FOODS_PER_LEVEL = 2 (final production setting) - Code is clean and production-ready
This commit is contained in:
@@ -92,8 +92,6 @@ export function useGameStatus(
|
|||||||
|
|
||||||
foodsEatenRef.current += 1;
|
foodsEatenRef.current += 1;
|
||||||
|
|
||||||
console.log(`[FOOD] Eaten: ${foodsEatenRef.current}, Will Level Up: ${willLevelUp}, Current Level: ${levelRef.current}`);
|
|
||||||
|
|
||||||
// Save the current level BEFORE any changes
|
// Save the current level BEFORE any changes
|
||||||
const pointsToAdd = levelRef.current;
|
const pointsToAdd = levelRef.current;
|
||||||
|
|
||||||
@@ -104,15 +102,12 @@ export function useGameStatus(
|
|||||||
setLevel(newLevel);
|
setLevel(newLevel);
|
||||||
currentFpsRef.current = INITIAL_FPS + (newLevel - 1);
|
currentFpsRef.current = INITIAL_FPS + (newLevel - 1);
|
||||||
foodsEatenRef.current = 0;
|
foodsEatenRef.current = 0;
|
||||||
console.log(`[LEVELUP] New Level: ${newLevel}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setScore((prev) => {
|
setScore((prev) => {
|
||||||
// Add points at CURRENT level
|
// Add points at CURRENT level
|
||||||
let newScore = prev + pointsToAdd;
|
let newScore = prev + pointsToAdd;
|
||||||
|
|
||||||
console.log(`[SCORE] Adding ${pointsToAdd} points, Total: ${newScore}`);
|
|
||||||
|
|
||||||
foodManagerRef.current.spawnFood(
|
foodManagerRef.current.spawnFood(
|
||||||
snakeManagerRef.current.snakeBodyRef.current,
|
snakeManagerRef.current.snakeBodyRef.current,
|
||||||
1
|
1
|
||||||
|
|||||||
Reference in New Issue
Block a user