feat: vente items + stats combat avec équipement + forge visible
All checks were successful
CI/CD — Build & Deploy / Build & Deploy (push) Successful in 33s
All checks were successful
CI/CD — Build & Deploy / Build & Deploy (push) Successful in 33s
Inventaire: bouton Vendre sur items non équipés (40% du prix d'achat). Stats forge visibles: "+5 ATK (3+2)" montre base + bonus forge. Dashboard combat: attaque/défense calculés avec arme+armure+forge équipées. 10 side quests Égouts seedées (level 5-7).
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useState } from 'react';
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { characterApi } from '../api/endpoints';
|
||||
import { characterApi, itemApi } from '../api/endpoints';
|
||||
import { Bar } from '../components/Bar';
|
||||
import { Zap, Heart, Star, Coins, Sword, Shield, BedDouble } from 'lucide-react';
|
||||
|
||||
@@ -134,6 +134,42 @@ function StatDistributor({ char }: { char: any }) {
|
||||
);
|
||||
}
|
||||
|
||||
function CombatStatsPanel({ char }: { char: any }) {
|
||||
const { data: inventory } = useQuery({ queryKey: ['inventory'], queryFn: itemApi.inventory });
|
||||
|
||||
const weapon = inventory?.find((ci: any) => ci.equipped && ci.item.type === 'weapon');
|
||||
const armor = inventory?.find((ci: any) => ci.equipped && ci.item.type === 'armor');
|
||||
|
||||
const weaponATK = weapon ? weapon.item.attackBonus + weapon.forgeLevel * 2 : 0;
|
||||
const armorDEF = armor ? armor.item.defenseBonus + armor.forgeLevel * 2 : 0;
|
||||
const baseDmg = 3 + weaponATK + Math.floor(char.force * 1.5);
|
||||
|
||||
return (
|
||||
<div className="card" style={{ gridColumn: '1 / -1' }}>
|
||||
<p style={{ margin: '0 0 0.75rem', fontSize: 13, fontWeight: 700, color: '#9ca3af' }}>Combat actuel</p>
|
||||
<div style={{ display: 'flex', gap: 24, flexWrap: 'wrap' }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<Sword size={14} color="#f4c94e" />
|
||||
<span style={{ fontSize: 13, color: '#6b7a99' }}>Attaque : </span>
|
||||
<span style={{ fontSize: 14, fontWeight: 700 }}>{baseDmg}</span>
|
||||
{weapon && <span style={{ fontSize: 10, color: '#6b7a99' }}>({weapon.item.name} {weapon.forgeLevel > 0 ? `+${weapon.forgeLevel}` : ''})</span>}
|
||||
</div>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<Shield size={14} color="#5ba4f5" />
|
||||
<span style={{ fontSize: 13, color: '#6b7a99' }}>Défense : </span>
|
||||
<span style={{ fontSize: 14, fontWeight: 700 }}>{armorDEF}</span>
|
||||
{armor && <span style={{ fontSize: 10, color: '#6b7a99' }}>({armor.item.name} {armor.forgeLevel > 0 ? `+${armor.forgeLevel}` : ''})</span>}
|
||||
</div>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<Zap size={14} color="#3ddc84" />
|
||||
<span style={{ fontSize: 13, color: '#6b7a99' }}>Critique : </span>
|
||||
<span style={{ fontSize: 14, fontWeight: 700 }}>{(5 + char.chance * 0.2).toFixed(1)}%</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function DashboardPage() {
|
||||
const qc = useQueryClient();
|
||||
const { data: char, isLoading, isError } = useQuery({
|
||||
@@ -266,26 +302,7 @@ export function DashboardPage() {
|
||||
)}
|
||||
|
||||
{/* Équipement résumé */}
|
||||
<div className="card" style={{ gridColumn: '1 / -1' }}>
|
||||
<p style={{ margin: '0 0 0.75rem', fontSize: 13, fontWeight: 700, color: '#9ca3af' }}>Combat actuel</p>
|
||||
<div style={{ display: 'flex', gap: 24 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<Sword size={14} color="#f4c94e" />
|
||||
<span style={{ fontSize: 13, color: '#6b7a99' }}>Attaque : </span>
|
||||
<span style={{ fontSize: 14, fontWeight: 700 }}>{Math.floor(char.force * 1.5)}</span>
|
||||
</div>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<Shield size={14} color="#5ba4f5" />
|
||||
<span style={{ fontSize: 13, color: '#6b7a99' }}>Critique : </span>
|
||||
<span style={{ fontSize: 14, fontWeight: 700 }}>{(5 + char.chance * 0.2).toFixed(1)}%</span>
|
||||
</div>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<Zap size={14} color="#3ddc84" />
|
||||
<span style={{ fontSize: 13, color: '#6b7a99' }}>Esquive : </span>
|
||||
<span style={{ fontSize: 14, fontWeight: 700 }}>{(5 + char.chance * 0.1).toFixed(1)}%</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<CombatStatsPanel char={char} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user