diff --git a/public/assets/plan-lab.js b/public/assets/plan-lab.js index 5a6b099..277c61b 100644 --- a/public/assets/plan-lab.js +++ b/public/assets/plan-lab.js @@ -32,15 +32,15 @@ function geometry(){ W = Math.max(1400, GUT + Math.pow(PLAN.w, DEPTHS) * 9 + 30); ROW = (H - TOP - 30) / DEPTHS; svg.setAttribute('viewBox', '0 0 ' + W + ' ' + H); svg.style.minWidth = Math.max(980, Math.round(W * 0.8)) + 'px'; } let quiet = false, tally = null, tallyOrigin = null, licUpFlag = false; // audit: every dollar spent must be received by someone (a position, or 'above'); licences are never money - const AUD = { spent: 0, received: 0, above: 0, treasury: 0 }; - function feeOn(gross){ const f = gross * PLAN.fee; AUD.received += f; AUD.treasury += f; } // the admin wallet's share of a gross price - window.reachAudit = () => ({ treasury: Math.round(AUD.treasury * 100) / 100, spent: Math.round(AUD.spent * 100) / 100, received: Math.round(AUD.received * 100) / 100, above: Math.round(AUD.above * 100) / 100, ok: Math.abs(AUD.spent - AUD.received) <= 0.01 + 1e-9 * AUD.spent }); + const AUD = { spent: 0, received: 0, above: 0, treasury: 0, entryFee: 0 }; + function feeOn(gross, entry){ const f = gross * PLAN.fee; AUD.received += f; if (entry) AUD.entryFee += f; else AUD.treasury += f; } // the admin wallet's share of a gross price + window.reachAudit = () => ({ treasury: Math.round(AUD.treasury * 100) / 100, entryFee: Math.round(AUD.entryFee * 100) / 100, spent: Math.round(AUD.spent * 100) / 100, received: Math.round(AUD.received * 100) / 100, above: Math.round(AUD.above * 100) / 100, ok: Math.abs(AUD.spent - AUD.received) <= 0.01 + 1e-9 * AUD.spent }); function tallyFor(d){ return tally[d] || (tally[d] = { n: 0, L: 0, youCash: 0, youLic: 0, above: 0, licUp: 0, cash: {}, lic: {} }); } let nodes = [], byId = {}, you, totals, youLedger = [], nextId = 0; function mkNode(depth, parent, idx){ const n = { id: nextId++, depth, parent, idx, children: [], level: 1, directs: 2, get qual(){ return this.directs >= 2; }, cashFrom: 0, cashFromHalf: 0, cash: 0, entry: 0, x: 0, y: 0 }; nodes.push(n); byId[n.id] = n; - if (parent) { parent.children.push(n); parent.entry += net(1); AUD.spent += price(1); AUD.received += net(1); feeOn(price(1)); if (parent === you) { totals.entry += net(1); } } // Rule 0: the entry pays the upline directly above + if (parent) { parent.children.push(n); parent.entry += net(1); AUD.spent += price(1); AUD.received += net(1); feeOn(price(1), true); if (parent === you) { totals.entry += net(1); } } // Rule 0: the entry pays the upline directly above return n; } function layout(){ @@ -55,7 +55,7 @@ function build(){ DEPTHS = DEFD[PLAN.w]; geometry(); - nodes = []; byId = {}; nextId = 0; AUD.spent = 0; AUD.received = 0; AUD.above = 0; AUD.treasury = 0; + nodes = []; byId = {}; nextId = 0; AUD.spent = 0; AUD.received = 0; AUD.above = 0; AUD.treasury = 0; AUD.entryFee = 0; totals = { entry: 0, cash: 0, lic: 0, licV: 0, cashN: 0 }; youLedger = []; function mk(depth, parent, idx){ const n = mkNode(depth, parent, idx); @@ -386,7 +386,7 @@ setV('mLic', totals.lic); const lv = document.getElementById('mLicV'); if (lv) lv.textContent = 'worth ' + $$(totals.licV) + ', paid by your org'; setV('mTotal', $$(totals.entry + totals.cash + totals.licV)); - setV('mFuel', $$(AUD.treasury)); const fs = document.getElementById('mFuelS'); if (fs) fs.textContent = PLAN.fee ? Math.round(PLAN.fee * 100) + '% out of every price; the other ' + Math.round((1 - PLAN.fee) * 100) + '% climbs' : 'no fee: the whole price climbs'; + setV('mFuel', $$(AUD.treasury)); const fs = document.getElementById('mFuelS'); if (fs) fs.textContent = PLAN.fee ? Math.round(PLAN.fee * 100) + '% of every level bought so far (plus ' + $$(AUD.entryFee) + ' on the entries paid when this org joined)' : 'no fee: the whole price climbs'; const ol = document.getElementById('youLedger'); if (ol) { ol.innerHTML = ''; @@ -476,16 +476,16 @@ let dp = null; function deepReset(){ const fill = Number(document.getElementById('deepFill').value) / 100, D = PLAN.maxL; - dp = { D, levels: [], counts: [], lic: [], licV: [], cash: [], entry: [], pays: [], waves: 0, above: 0, spent: 0, treasury: 0 }; - window.deepAudit = () => { const rec = dp.cash.reduce((a, b) => a + b, 0) + dp.entry.reduce((a, b) => a + b, 0) + dp.above + dp.treasury; return { spent: Math.round(dp.spent), received: Math.round(rec), ok: Math.abs(dp.spent - rec) <= 1 + 1e-9 * dp.spent }; }; + dp = { D, levels: [], counts: [], lic: [], licV: [], cash: [], entry: [], pays: [], waves: 0, above: 0, spent: 0, treasury: 0, entryFee: 0 }; // treasury = fee on purchases made in waves; entryFee = fee on the entries paid when the org was built + window.deepAudit = () => { const rec = dp.cash.reduce((a, b) => a + b, 0) + dp.entry.reduce((a, b) => a + b, 0) + dp.above + dp.treasury + dp.entryFee; return { spent: Math.round(dp.spent), received: Math.round(rec), ok: Math.abs(dp.spent - rec) <= 1 + 1e-9 * dp.spent }; }; for (let d = 0; d <= D; d++) { dp.levels[d] = 1; dp.counts[d] = d === 0 ? 1 : Math.max(1, Math.round(Math.pow(PLAN.w * fill, d))); dp.lic[d] = 0; dp.licV[d] = 0; dp.cash[d] = 0; dp.entry[d] = 0; dp.pays[d] = 0; } - for (let d = 1; d <= D; d++) { dp.entry[d - 1] += dp.counts[d] * net(1); dp.spent += dp.counts[d] * price(1); dp.treasury += dp.counts[d] * price(1) * PLAN.fee; } // Rule 0, once, when the org is built + for (let d = 1; d <= D; d++) { dp.entry[d - 1] += dp.counts[d] * net(1); dp.spent += dp.counts[d] * price(1); dp.entryFee += dp.counts[d] * price(1) * PLAN.fee; } // Rule 0, once, when the org is built deepRender('Reset. Everyone at level 1, you included; entries paid.'); - const ol = document.getElementById('deepStory'); if (ol) ol.innerHTML = '
Unlisted working page for planning. Not a member page, not an offer. Every number here is a mechanic, not a prediction.
- +