fix: particule clic affiche le vrai gain (clickMult × prestigeMult × treeMult)

Ajout getClickGain() dans economy.ts — utilisé par la particule de feedback
et le cockpit header "Ponte". Avant : affichait toujours +1.
This commit is contained in:
2026-03-20 16:18:45 +01:00
parent 4ad60c9423
commit b475fb8953
3 changed files with 17 additions and 8 deletions

View File

@@ -2,11 +2,13 @@
import { useGameStore } from "../store/useGameStore"; import { useGameStore } from "../store/useGameStore";
import { formatNumber } from "../utils/formatNumber"; import { formatNumber } from "../utils/formatNumber";
import { getClickGain } from "../core/economy";
export function CockpitHeader() { export function CockpitHeader() {
const productionPerSecond = useGameStore((s) => s.productionPerSecond); const productionPerSecond = useGameStore((s) => s.productionPerSecond);
const { clickMultiplier, prestigeMultiplier, ancestralDna, prestigeCount } = const state = useGameStore((s) => s.state);
useGameStore((s) => s.state); const { prestigeMultiplier, ancestralDna, prestigeCount } = state;
const clickGain = getClickGain(state);
return ( return (
<div className="gp gp-cockpit-header"> <div className="gp gp-cockpit-header">
@@ -18,7 +20,7 @@ export function CockpitHeader() {
</div> </div>
<div className="gp-stat"> <div className="gp-stat">
<span className="gp-label">Ponte</span> <span className="gp-label">Ponte</span>
<span className="gp-value">x{clickMultiplier}</span> <span className="gp-value">{formatNumber(clickGain)}</span>
</div> </div>
<div className="gp-stat"> <div className="gp-stat">
<span className="gp-label">Mult</span> <span className="gp-label">Mult</span>

View File

@@ -129,10 +129,15 @@ export function applyIdleGains(state: GameState, now: number): GameState {
}; };
} }
// Gain réel par clic (pour affichage particule)
export function getClickGain(state: GameState): number {
const treeClickMult = getClickMultiplierFromTree(state.evolutionTree);
return state.clickMultiplier * state.prestigeMultiplier * treeClickMult;
}
// Clic manuel // Clic manuel
export function applyClick(state: GameState): GameState { export function applyClick(state: GameState): GameState {
const treeClickMult = getClickMultiplierFromTree(state.evolutionTree); const gain = getClickGain(state);
const gain = state.clickMultiplier * state.prestigeMultiplier * treeClickMult;
return { return {
...state, ...state,
resources: state.resources + gain, resources: state.resources + gain,

View File

@@ -4,6 +4,7 @@ import { useEffect, useCallback } from "react";
import { useGameStore } from "../store/useGameStore"; import { useGameStore } from "../store/useGameStore";
import { formatNumber } from "../utils/formatNumber"; import { formatNumber } from "../utils/formatNumber";
import { getClickGain } from "../core/economy";
import { GeneratorShop } from "../components/GeneratorShop"; import { GeneratorShop } from "../components/GeneratorShop";
import { PrestigePanel } from "../components/PrestigePanel"; import { PrestigePanel } from "../components/PrestigePanel";
import { EvolutionTree } from "../components/EvolutionTree"; import { EvolutionTree } from "../components/EvolutionTree";
@@ -17,19 +18,20 @@ export default function Home() {
const [toggleRain] = useOutletContext(); const [toggleRain] = useOutletContext();
const click = useGameStore((s) => s.click); const click = useGameStore((s) => s.click);
const resources = useGameStore((s) => s.state.resources); const resources = useGameStore((s) => s.state.resources);
const clickMultiplier = useGameStore((s) => s.state.clickMultiplier); const state = useGameStore((s) => s.state);
const clickGain = getClickGain(state);
const createParticle = useCallback((clientX, clientY) => { const createParticle = useCallback((clientX, clientY) => {
const particle = document.createElement("span"); const particle = document.createElement("span");
particle.className = "click-particle"; particle.className = "click-particle";
particle.textContent = `+${formatNumber(clickMultiplier)}`; particle.textContent = `+${formatNumber(clickGain)}`;
particle.style.left = `${clientX}px`; particle.style.left = `${clientX}px`;
particle.style.top = `${clientY}px`; particle.style.top = `${clientY}px`;
document.body.appendChild(particle); document.body.appendChild(particle);
setTimeout(() => { setTimeout(() => {
if (particle.parentNode) particle.parentNode.removeChild(particle); if (particle.parentNode) particle.parentNode.removeChild(particle);
}, 800); }, 800);
}, [clickMultiplier]); }, [clickGain]);
const handleIncrement = useCallback((e) => { const handleIncrement = useCallback((e) => {
click(); click();