From ceffedf684d648ddefe174550f45db723720ac8a Mon Sep 17 00:00:00 2001
From: math-pixel <59537610+math-pixel@users.noreply.github.com>
Date: Tue, 12 May 2026 16:51:35 +0200
Subject: [PATCH] fix : lint
---
src/components/game/GameFlow.tsx | 18 +---
src/components/ui/IntroUI.tsx | 7 +-
.../ui/debug/GameStateDebugPanel.tsx | 15 +---
src/components/zone/ZoneDetection.tsx | 83 ++++++++-----------
src/hooks/useDialog.ts | 27 ------
src/managers/stores/useGameStore.ts | 42 +---------
src/types/game.ts | 17 +++-
src/types/gameplay/repairMission.ts | 40 +++++++++
8 files changed, 93 insertions(+), 156 deletions(-)
delete mode 100644 src/hooks/useDialog.ts
diff --git a/src/components/game/GameFlow.tsx b/src/components/game/GameFlow.tsx
index c6eb975..1434ac7 100644
--- a/src/components/game/GameFlow.tsx
+++ b/src/components/game/GameFlow.tsx
@@ -11,22 +11,16 @@ export function GameFlow(): null {
const hasInitialized = useRef(false);
useEffect(() => {
- console.log("[GameFlow] Current step:", step);
if (!hasInitialized.current && step === "intro") {
hasInitialized.current = true;
- console.log("[GameFlow] Transition to start-intro");
setStep("start-intro");
}
}, [step, setStep]);
useEffect(() => {
- console.log("[GameFlow] useEffect triggered, step:", step);
-
if (step === "start-intro") {
- console.log("[GameFlow] Playing intro audio");
const audio = AudioManager.getInstance();
audio.playSoundWithCallback(AUDIO_PATHS.intro, 0.5, () => {
- console.log("[GameFlow] Intro audio ended, transition to naming");
setStep("naming");
});
@@ -34,10 +28,8 @@ export function GameFlow(): null {
}
if (step === "bienvenue") {
- console.log("[GameFlow] Playing bienvenue audio");
const audio = AudioManager.getInstance();
audio.playSoundWithCallback(AUDIO_PATHS.bienvenue, 0.5, () => {
- console.log("[GameFlow] Bienvenue audio ended, enable movement");
setCanMove(true);
setStep("star-move");
});
@@ -46,30 +38,22 @@ export function GameFlow(): null {
}
if (step === "mission2") {
- console.log("[GameFlow] mission2 - setting activityCity to false");
setActivityCity(false);
const audio = AudioManager.getInstance();
audio.playSound(AUDIO_PATHS.alertCentral, 0.5);
}
if (step === "searching") {
- console.log("[GameFlow] Playing searching audio");
const audio = AudioManager.getInstance();
- audio.playSoundWithCallback(AUDIO_PATHS.searching, 0.5, () => {
- console.log("[GameFlow] searching audio ended");
- });
-
- return () => {};
+ audio.playSound(AUDIO_PATHS.searching, 0.5);
}
if (step === "helped") {
- console.log("[GameFlow] Playing helped audio");
const audio = AudioManager.getInstance();
audio.playSound(AUDIO_PATHS.helped, 0.5);
}
if (step === "manipulation") {
- console.log("[GameFlow] manipulation - blocking movement");
setCanMove(false);
}
diff --git a/src/components/ui/IntroUI.tsx b/src/components/ui/IntroUI.tsx
index 751175c..45ace4e 100644
--- a/src/components/ui/IntroUI.tsx
+++ b/src/components/ui/IntroUI.tsx
@@ -12,11 +12,8 @@ export function IntroUI(): React.JSX.Element | null {
const handleSubmit = (): void => {
if (inputValue.trim() === "") return;
- console.log("[IntroUI] Submitting, name:", inputValue.trim());
setPlayerName(inputValue.trim());
- console.log("[IntroUI] Calling transitionTo('bienvenue')");
setStep("bienvenue");
- console.log("[IntroUI] After transitionTo, step should be:", step);
};
const handleKeyDown = (e: React.KeyboardEvent): void => {
@@ -59,14 +56,14 @@ export function IntroUI(): React.JSX.Element | null {
textAlign: "center",
}}
>
- Quel est votre prénom ?
+ Quel est votre prenom ?
setInputValue(e.target.value)}
onKeyDown={handleKeyDown}
- placeholder="Votre prénom"
+ placeholder="Votre prenom"
autoFocus
style={{
padding: "0.75rem",
diff --git a/src/components/ui/debug/GameStateDebugPanel.tsx b/src/components/ui/debug/GameStateDebugPanel.tsx
index 92a1ffc..7632d6f 100644
--- a/src/components/ui/debug/GameStateDebugPanel.tsx
+++ b/src/components/ui/debug/GameStateDebugPanel.tsx
@@ -4,20 +4,7 @@ import {
useGameStore,
} from "@/managers/stores/useGameStore";
import { isMissionStep, MISSION_STEPS } from "@/types/gameplay/repairMission";
-import { type GameStep } from "@/types/game";
-
-const GAME_STEPS: GameStep[] = [
- "intro",
- "start-intro",
- "naming",
- "bienvenue",
- "star-move",
- "mission2",
- "searching",
- "helped",
- "manipulation",
- "outOfFabrik",
-];
+import { GAME_STEPS, type GameStep } from "@/types/game";
const MAIN_STATES: MainGameState[] = [
"intro",
diff --git a/src/components/zone/ZoneDetection.tsx b/src/components/zone/ZoneDetection.tsx
index 3ce4f56..16070f6 100644
--- a/src/components/zone/ZoneDetection.tsx
+++ b/src/components/zone/ZoneDetection.tsx
@@ -4,24 +4,11 @@ import * as THREE from "three";
import { ZONES } from "@/data/zones";
import { useGameStore } from "@/managers/stores/useGameStore";
import { Debug } from "@/utils/debug/Debug";
-import type { GameStep } from "@/types/game";
+import { GAME_STEPS } from "@/types/game";
const _playerPos = new THREE.Vector3();
const _zonePos = new THREE.Vector3();
-const GAME_STEPS: GameStep[] = [
- "intro",
- "start-intro",
- "naming",
- "bienvenue",
- "star-move",
- "mission2",
- "searching",
- "helped",
- "manipulation",
- "outOfFabrik",
-];
-
export function ZoneDetection(): null {
const camera = useThree((state) => state.camera);
const triggeredZones = useRef>(new Set());
@@ -88,41 +75,6 @@ export function ZoneDetection(): null {
return null;
}
-interface ZoneVisualProps {
- position: [number, number, number];
- radius: number;
- height: number;
- triggered: boolean;
-}
-
-function ZoneVisual({
- position,
- radius,
- height,
- triggered,
-}: ZoneVisualProps): React.JSX.Element {
- const color = triggered ? "#00ff00" : "#ff0000";
-
- return (
-
-
-
-
-
-
-
-
-
-
- );
-}
-
export function ZoneDebugVisuals(): React.JSX.Element | null {
const debug = Debug.getInstance();
const camera = useThree((state) => state.camera);
@@ -161,3 +113,36 @@ export function ZoneDebugVisuals(): React.JSX.Element | null {
>
);
}
+
+function ZoneVisual({
+ position,
+ radius,
+ height,
+ triggered,
+}: {
+ position: [number, number, number];
+ radius: number;
+ height: number;
+ triggered: boolean;
+}): React.JSX.Element {
+ const color = triggered ? "#00ff00" : "#ff0000";
+
+ return (
+
+
+
+
+
+
+
+
+
+
+ );
+}
diff --git a/src/hooks/useDialog.ts b/src/hooks/useDialog.ts
deleted file mode 100644
index 40cedbb..0000000
--- a/src/hooks/useDialog.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { useState } from "react";
-
-interface DialogState {
- message: string;
- visible: boolean;
-}
-
-export function useDialog(): {
- dialog: DialogState;
- showDialog: (message: string) => void;
- hideDialog: () => void;
-} {
- const [dialog, setDialog] = useState({
- message: "",
- visible: false,
- });
-
- const showDialog = (message: string): void => {
- setDialog({ message, visible: true });
- };
-
- const hideDialog = (): void => {
- setDialog((prev) => ({ ...prev, visible: false }));
- };
-
- return { dialog, showDialog, hideDialog };
-}
diff --git a/src/managers/stores/useGameStore.ts b/src/managers/stores/useGameStore.ts
index 810855f..15489dd 100644
--- a/src/managers/stores/useGameStore.ts
+++ b/src/managers/stores/useGameStore.ts
@@ -2,6 +2,8 @@ import { create } from "zustand";
import type { GameStep } from "@/types/game";
import {
isRepairMissionId,
+ getNextMissionStep,
+ getPreviousMissionStep,
type MissionStep,
type RepairMissionId,
} from "@/types/gameplay/repairMission";
@@ -77,46 +79,6 @@ interface GameActions {
type GameStore = GameState & GameActions;
type GameStateUpdate = Partial;
-function getNextMissionStep(step: MissionStep): MissionStep {
- switch (step) {
- case "locked":
- return "waiting";
- case "waiting":
- return "inspected";
- case "inspected":
- return "fragmented";
- case "fragmented":
- return "scanning";
- case "scanning":
- return "repairing";
- case "repairing":
- return "reassembling";
- case "reassembling":
- case "done":
- return "done";
- }
-}
-
-function getPreviousMissionStep(step: MissionStep): MissionStep {
- switch (step) {
- case "locked":
- case "waiting":
- return "locked";
- case "inspected":
- return "waiting";
- case "fragmented":
- return "inspected";
- case "scanning":
- return "fragmented";
- case "repairing":
- return "scanning";
- case "reassembling":
- return "repairing";
- case "done":
- return "reassembling";
- }
-}
-
function completeIntroState(state: GameState): GameStateUpdate {
return {
mainState: "bike",
diff --git a/src/types/game.ts b/src/types/game.ts
index 292f30a..44bd7a5 100644
--- a/src/types/game.ts
+++ b/src/types/game.ts
@@ -12,6 +12,19 @@ export type GameStep =
| "manipulation"
| "outOfFabrik";
+export const GAME_STEPS: readonly GameStep[] = [
+ "intro",
+ "start-intro",
+ "naming",
+ "bienvenue",
+ "star-move",
+ "mission2",
+ "searching",
+ "helped",
+ "manipulation",
+ "outOfFabrik",
+] as const;
+
export interface Zone {
id: string;
position: Vector3Tuple;
@@ -19,7 +32,3 @@ export interface Zone {
height: number;
targetStep: GameStep;
}
-
-export interface GameState {
- step: GameStep;
-}
diff --git a/src/types/gameplay/repairMission.ts b/src/types/gameplay/repairMission.ts
index f8836b0..dc78e93 100644
--- a/src/types/gameplay/repairMission.ts
+++ b/src/types/gameplay/repairMission.ts
@@ -30,3 +30,43 @@ export function isRepairMissionId(value: string): value is RepairMissionId {
export function isMissionStep(value: string): value is MissionStep {
return (MISSION_STEPS as readonly string[]).includes(value);
}
+
+export function getNextMissionStep(step: MissionStep): MissionStep {
+ switch (step) {
+ case "locked":
+ return "waiting";
+ case "waiting":
+ return "inspected";
+ case "inspected":
+ return "fragmented";
+ case "fragmented":
+ return "scanning";
+ case "scanning":
+ return "repairing";
+ case "repairing":
+ return "reassembling";
+ case "reassembling":
+ case "done":
+ return "done";
+ }
+}
+
+export function getPreviousMissionStep(step: MissionStep): MissionStep {
+ switch (step) {
+ case "locked":
+ case "waiting":
+ return "locked";
+ case "inspected":
+ return "waiting";
+ case "fragmented":
+ return "inspected";
+ case "scanning":
+ return "fragmented";
+ case "repairing":
+ return "scanning";
+ case "reassembling":
+ return "repairing";
+ case "done":
+ return "reassembling";
+ }
+}