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:
@@ -2,11 +2,13 @@
|
||||
|
||||
import { useGameStore } from "../store/useGameStore";
|
||||
import { formatNumber } from "../utils/formatNumber";
|
||||
import { getClickGain } from "../core/economy";
|
||||
|
||||
export function CockpitHeader() {
|
||||
const productionPerSecond = useGameStore((s) => s.productionPerSecond);
|
||||
const { clickMultiplier, prestigeMultiplier, ancestralDna, prestigeCount } =
|
||||
useGameStore((s) => s.state);
|
||||
const state = useGameStore((s) => s.state);
|
||||
const { prestigeMultiplier, ancestralDna, prestigeCount } = state;
|
||||
const clickGain = getClickGain(state);
|
||||
|
||||
return (
|
||||
<div className="gp gp-cockpit-header">
|
||||
@@ -18,7 +20,7 @@ export function CockpitHeader() {
|
||||
</div>
|
||||
<div className="gp-stat">
|
||||
<span className="gp-label">Ponte</span>
|
||||
<span className="gp-value">x{clickMultiplier}</span>
|
||||
<span className="gp-value">{formatNumber(clickGain)}</span>
|
||||
</div>
|
||||
<div className="gp-stat">
|
||||
<span className="gp-label">Mult</span>
|
||||
|
||||
@@ -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
|
||||
export function applyClick(state: GameState): GameState {
|
||||
const treeClickMult = getClickMultiplierFromTree(state.evolutionTree);
|
||||
const gain = state.clickMultiplier * state.prestigeMultiplier * treeClickMult;
|
||||
const gain = getClickGain(state);
|
||||
return {
|
||||
...state,
|
||||
resources: state.resources + gain,
|
||||
|
||||
@@ -4,6 +4,7 @@ import { useEffect, useCallback } from "react";
|
||||
|
||||
import { useGameStore } from "../store/useGameStore";
|
||||
import { formatNumber } from "../utils/formatNumber";
|
||||
import { getClickGain } from "../core/economy";
|
||||
import { GeneratorShop } from "../components/GeneratorShop";
|
||||
import { PrestigePanel } from "../components/PrestigePanel";
|
||||
import { EvolutionTree } from "../components/EvolutionTree";
|
||||
@@ -17,19 +18,20 @@ export default function Home() {
|
||||
const [toggleRain] = useOutletContext();
|
||||
const click = useGameStore((s) => s.click);
|
||||
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 particle = document.createElement("span");
|
||||
particle.className = "click-particle";
|
||||
particle.textContent = `+${formatNumber(clickMultiplier)}`;
|
||||
particle.textContent = `+${formatNumber(clickGain)}`;
|
||||
particle.style.left = `${clientX}px`;
|
||||
particle.style.top = `${clientY}px`;
|
||||
document.body.appendChild(particle);
|
||||
setTimeout(() => {
|
||||
if (particle.parentNode) particle.parentNode.removeChild(particle);
|
||||
}, 800);
|
||||
}, [clickMultiplier]);
|
||||
}, [clickGain]);
|
||||
|
||||
const handleIncrement = useCallback((e) => {
|
||||
click();
|
||||
|
||||
Reference in New Issue
Block a user