// =============================================================================
// COLLECTION BINDER
// =============================================================================
const { useState } = React;
function CollectionScreen({ state, actions }) {
const { PROVIDERS:CP, CARDS:CC, MYTHIC_CARDS:CM, COLLECTIONS:CCL } = window.GAME_DATA;
const owned = state.collection;
const [filter, setFilter] = useState('all');
const [rarityFilter, setRarityFilter] = useState('all');
const providersList = ['all', ...Object.keys(CP)];
const raritiesList = ['all', 'common', 'rare', 'epic', 'legendary', 'mythic'];
return (
◈ COLECCIÓN / TODOS LOS PROVEEDORES
Tu colección
o === 'all' ? 'TODOS' : CP[o].code}/>
o === 'all' ? 'TODAS' : window.GAME_DATA.RARITIES[o].label.slice(0,4)}/>
{Object.values(CP)
.filter(p => filter === 'all' || p.id === filter)
.map(p => {
const cards = CC.filter(c =>
c.provider === p.id &&
(rarityFilter === 'all' || c.rarity === rarityFilter)
);
const have = cards.filter(c => owned[c.id]).length;
const total = CC.filter(c => c.provider === p.id).length;
const totalHave = CC.filter(c => c.provider === p.id && owned[c.id]).length;
const complete = totalHave === total;
if (cards.length === 0) return null;
return (
{totalHave} / {total}
{complete &&
✓ +1500 CRD · ◆ BADGE {p.code}-MASTER
}
{cards.map(c => {
const has = !!owned[c.id];
return (
);
})}
);
})}
{/* MYTHIC SECTION */}
◆ MYTHIC
CARTAS MÍTICAS
Solo se obtienen derrotando campeones
{Object.keys(owned).filter(k => CM[k]).length} / 5
{Object.values(CM).map(c => (
))}
);
}
function FilterGroup({ label, options, active, onSelect, formatLabel }) {
return (
{label}
{options.map(o => (
))}
);
}
window.CollectionScreen = CollectionScreen;