// Production - The Idle Game: Corporate IPO & Boardroom Perks View // Fine-grained DOM updates without innerHTML teardowns import { BOARDROOM_PERKS, calculateSharesEarned, IPO_MIN_VALUATION } from '../data/boardroom.js'; import { fmtCurrency, fmtNum } from '../core/formatters.js'; export function mountBoardroom(container, state, onAction) { const earnedShares = calculateSharesEarned(state.lifetimeRevenue); const canIPO = state.lifetimeRevenue >= IPO_MIN_VALUATION; const perks = state.boardroomPerks || {}; let html = `
Executive Boardroom

Corporate IPO & Venture Capital

Take your manufacturing conglomerate public on the global securities exchange. Liquidate current factories to secure permanent Venture Shares ($V-Shares), funding cutting-edge R&D and boardroom privileges.

Corporate Enterprise Valuation
${fmtCurrency(state.valuation)}
Lifetime Gross Revenue: ${fmtCurrency(state.lifetimeRevenue)}
+${fmtNum(earnedShares, 0)} $V-Shares

Initial Public Offering (IPO) Ready

${canIPO ? `Execute corporate IPO now to claim ${fmtNum(earnedShares, 0)} Venture Shares and restart with permanent bonuses.` : `Requires minimum ${fmtCurrency(IPO_MIN_VALUATION)} in lifetime revenue to file for IPO.`}

Available $V-Shares: ${fmtNum(state.ventureShares, 0)}
IPOs Completed: ${state.ipoCount || 0}

Boardroom R&D Tech Tree

Permanent corporate privileges that persist across all future IPO expansions
`; for (const perk of BOARDROOM_PERKS) { const currentLvl = perks[perk.id] || 0; const isMaxed = currentLvl >= perk.maxLevel; const nextCost = !isMaxed ? perk.costShares[currentLvl] : 0; const canAfford = state.ventureShares >= nextCost && !isMaxed; html += `
Level ${currentLvl} / ${perk.maxLevel}

${perk.name}

${perk.description}

${perk.effectDesc}
`; } html += `
`; container.innerHTML = html; const ipoBtn = container.querySelector('.btn-ipo-trigger'); if (ipoBtn) { ipoBtn.onclick = () => onAction({ type: 'TRIGGER_IPO' }); } container.querySelectorAll('.btn-buy-perk').forEach(btn => { btn.onclick = () => onAction({ type: 'BUY_PERK', perkId: btn.dataset.perk }); }); } export function updateBoardroom(container, state) { const earnedShares = calculateSharesEarned(state.lifetimeRevenue); const canIPO = state.lifetimeRevenue >= IPO_MIN_VALUATION; const perks = state.boardroomPerks || {}; const elVal = document.getElementById('boardroom-val-number'); if (elVal) elVal.textContent = fmtCurrency(state.valuation); const elLifetime = document.getElementById('boardroom-val-lifetime'); if (elLifetime) elLifetime.textContent = fmtCurrency(state.lifetimeRevenue); const elEarned = document.getElementById('boardroom-earned-shares'); if (elEarned) elEarned.textContent = `+${fmtNum(earnedShares, 0)} $V-Shares`; const btnIPO = document.getElementById('boardroom-btn-ipo'); if (btnIPO) btnIPO.disabled = !canIPO; const elAvail = document.getElementById('boardroom-avail-shares'); if (elAvail) elAvail.textContent = fmtNum(state.ventureShares, 0); for (const perk of BOARDROOM_PERKS) { const currentLvl = perks[perk.id] || 0; const isMaxed = currentLvl >= perk.maxLevel; const nextCost = !isMaxed ? perk.costShares[currentLvl] : 0; const canAfford = state.ventureShares >= nextCost && !isMaxed; const elBtn = document.getElementById(`btn-perk-${perk.id}`); if (elBtn) elBtn.disabled = !canAfford; } }