diff --git a/docs/API.md b/docs/API.md index f0ec2e4..6480776 100644 --- a/docs/API.md +++ b/docs/API.md @@ -152,3 +152,69 @@ Nachrichten sind JSON-Objekte mit `type` (≤ 30 Zeichen) und optional `reqId`. **briefing**: `{phase, phaseText, news[], today[], holdings[{symbol, qty, last, prevClose, indicative, change}], macro, parliament, index, reportingSeason}` **recap**: `{season, returnPct, equity, rank, of, percentile, trades, bestTrade, worstTrade, winRate, sharpe, tier, newTier, leagueChange, xp, level}` + + +## Phase 3/4: Politik, Anlageklassen, Unternehmensereignisse, Szenarien + +### Client → Server (zusätzlich) + +| type | Felder | Antwortdaten | +|---|---|---| +| `government` | – | `{government}` | +| `partyFound` | `name (3–32), short (2–5 Großbuchstaben/Ziffern), pos? {markt, staat, oeko} (−1…1)` | `{government}` – kostet 5.000 € | +| `partyJoin` / `partyLeave` | `partyId` (bei join) | `{government}` | +| `electionVote` | `partyId` | `{government}` – bis zur Wahl änderbar | +| `noConfidenceVote` | `yes` | `{government}` | +| `lobby` | `partyId, amount (≥ 5.000), sector, direction ('plus'\|'minus')` | `{entry, government}` – öffentlicher Eintrag im Lobbyregister | +| `propose` | `template, sector` (Bausteine siehe `info.billTemplates`) | `{parliament}` – nur Parteimitglieder, eine offene Vorlage je Spieler | +| `cosign` | `id` (Vorlage; erneut = zurückziehen) | `{parliament}` | +| `withdrawBill` | `id` | `{parliament}` | +| `tender` | `symbol, qty` (0 = Andienung zurückziehen) | `{offer}` – Andienung aus dem Hauptdepot bei laufendem Übernahmeangebot | +| `curve` | – | `{curve}` | +| `company` | `symbol` | `{company}` – bei Anleihen/Rohstoffen/Devisen die Instrumentansicht (siehe unten) | + +`order` funktioniert für alle Instrumente (Aktien, `WIB2`, `WIB10`, `OEL`, `GOLD`, `USD`); Leerverkauf ist überall möglich. +Wer ein Ministerium leitet, darf Aktien der zugeordneten Sektoren nur abbauen (Fehler „Interessenkonflikt“). + +### Server → Client (zusätzlich) + +| type | Inhalt | +|---|---| +| `government` | `{government}` – nach Umfragen, Wahl, Regierungsbildung, Misstrauensvotum | +| `parliament` | jetzt mit `pipeline[]` und `proposals[]` (siehe unten) | + +`hello` enthält zusätzlich `government` und `assetClasses`, die `auth`-Antwort zusätzlich `government`. +`GET /api/info` liefert zusätzlich `assetClasses, scenarios, ministries[{id, name, sectors[]}], billTemplates {key: {label, title, axis, eff, cost, legal}}, sectorPhrase`. Titel einer Spielervorlage: `${billTemplates[t].title} ${sectorPhrase[sector]}`. + +### Datenstrukturen + +**ticker** (zusätzlich): `kind ('stock'|'bond'|'commodity'|'fx'), corp ('offer'|'trial'|null)`; für Anleihen `yield` (in %), `duration`, `exDivIn` = Handelstage bis zum Kupon, `divYield` = laufende Verzinsung (Kupon/Kurs); `sector` = `kind` bei Nicht-Aktien; `mcap`, `pe`, `earningsIn` sind bei Nicht-Aktien `null`. +Preiseinheiten: Anleihen in € je 100 € Nennwert, `OEL` je Barrel, `GOLD` je 10 g, `USD` je 100 $. + +**market** (zusätzlich): `season.scenario {id, title, desc}`, `politics {coalition[] (Kürzel), rating, electionAt, noConfidence}`; `macro.indicators {pmi, climate, consensus, surprise, ts, history[]}`, `macro.curve` (siehe curve). + +**curve**: `{points[{T (Jahre), y (%)}], y2, y10, spread, inverted, foreignRate, riskPremium, longNeutral}` + +**company (Aktie, zusätzlich)**: `kind: 'stock', corporate {offer {target, targetName, bidder, bidderName, price, premium, probability, daysLeft, authority, tenderedTotal, myTender, role ('target'|'bidder')}|null, trial {drug, phase, daysLeft, probability, up, down}|null, control {by, floor, daysLeft}|null, history[]}, oilSens, fxSens, ministry` + +**company (Instrument)**: `{symbol, name, kind, kindName, desc, last, prevClose, vol, baseVol, info, curve (Anleihen), budget {debt, deficit, rating, riskPremium} (Anleihen), foreignRate (USD), rate, holders[], shortInterest, lending, flowPrev, status, volaEndsAt, indicative, lastAuction, news[], dailyBars[]}`; +`info` bei Anleihen `{kind, maturity, coupon, yield, accrued, cleanPrice, duration, nextCouponIn}`, sonst `{kind, base, changeFromStart}`. `holders[].pct` ist bei Instrumenten `null`; es gibt keine Analysten-, Quartals- und Dividendenfelder. + +**parliament** (neu aufgebaut): Felder der laufenden Abstimmung wie bisher (`id, bill, endsAt, secretFrom, secret, yes, no, voters, weight, register[{name, pct, mp, proposer, yes}], myVote, myConflict, probability, …` – `id: null`, wenn gerade keine Vorlage in der Abstimmung ist), dazu +`pipeline[{id, stage ('lesung'|'ausschuss'|'abstimmung'|'laenderkammer'|'gericht'), stageLabel, stageEndsAt, bill {id, title, effects, macro, axis, cost (% BIP p. a.), legal}, probability (Inkrafttreten), pParl, pChamber, pCourt, baseline, source ('agenda'|'player'|'news'|'catalog'), proposer, compromise, sectors}]`, +`proposals[{id, title, by, party, cosigners (ohne Antragsteller), needed (inkl. Antragsteller), byGov, ts, effects, cost, axis, mine, signed}]`, `templates`, `stages`, `laws[{title, inForceDay, cost}]`, `history[{title, passed, reason, share (null möglich), expected, source, proposer, playerVotes, playerYes, conflicts, ts}]`. +Hinweise: Ohne laufende Abstimmung ist `source` der Name des Parlaments, sonst der Herkunftsschlüssel der Vorlage. `mine`/`signed` und `myVote` stehen nur in persönlichen Antworten; Broadcasts enthalten sie nicht. `propose`, `cosign` und `withdrawBill` werden nicht an alle gesendet – Clients laden `parliament` bei Bedarf neu. + +**government**: `{parties[{id, name, short, color, pos, npc, members, founder, memberNames, funds, onBallot, seats, projected, poll}], seatsTotal, threshold, minMembers, foundCost, lobbyMin, coalition {parties[], leader, head, formedAt, agenda[{id, title, done}], seats}|null, ministers[{id (Ressort), name (Person), sectors[], party (Kürzel), player}] (Ressortname über `info.ministries` per `id`), polls[{ts, day, institute, shares{partyId: Anteil}}], election {at, done, voters, myVote, weight}, lastResult {shares, seats, turnout}, chamber {pos}, budget {debt, deficit, structural, rating, crisis, riskPremium, history[{day, debt, deficit, rp}]}, lobby[{ts, name, party, amount, sector, direction}], noConfidence {endsAt, alt[], voters, myVote}|null, history[], me {party, office {ministry, sectors}|null, mp}}` – `me`, `election.myVote` und `noConfidence.myVote` nur in persönlichen Antworten (Broadcast: `me: null`). + +**briefing** (zusätzlich): `curve, assets[{symbol, name, kind, last, change, yield}], government {coalition, rating, election (Zeitpunkt oder null)}, scenario`. + +**calendar.items.kind** (zusätzlich): `'corporate'` (Annahmefrist, Studienergebnis; mit `symbol`), `'election'`; Kuponzahlungen der Anleihen erscheinen als `'exdiv'`. + +**profile** (zusätzlich): `party, office`. + +### Admin-Aktionen (zusätzlich) +`scenario` (value: Szenario-ID, sofort anwenden), `takeover` (value: `{target, bidder?}` oder Symbol), `capitalIncrease`, `buyback`, `trial` (value: Symbol), `oilShock` (value: −0,5…0,5, log. Größe), `election` (Wahl sofort abhalten). + +### Einstellungen (zusätzlich) +`billCosigners` (Politik), `corporateEvents`, `scenario` (Gruppe „Wirtschaft & Szenarien“; `zufall` wählt bei Saisonstart zufällig). diff --git a/docs/screenshots/client/anleihen.png b/docs/screenshots/client/anleihen.png new file mode 100644 index 0000000..ef44f7c Binary files /dev/null and b/docs/screenshots/client/anleihen.png differ diff --git a/docs/screenshots/client/makro.png b/docs/screenshots/client/makro.png new file mode 100644 index 0000000..001f394 Binary files /dev/null and b/docs/screenshots/client/makro.png differ diff --git a/docs/screenshots/client/politik-mobil.png b/docs/screenshots/client/politik-mobil.png new file mode 100644 index 0000000..8758dff Binary files /dev/null and b/docs/screenshots/client/politik-mobil.png differ diff --git a/docs/screenshots/client/politik.png b/docs/screenshots/client/politik.png new file mode 100644 index 0000000..3c1a144 Binary files /dev/null and b/docs/screenshots/client/politik.png differ diff --git a/docs/screenshots/client/uebernahme.png b/docs/screenshots/client/uebernahme.png new file mode 100644 index 0000000..dc9027f Binary files /dev/null and b/docs/screenshots/client/uebernahme.png differ diff --git a/server/public/app.js b/server/public/app.js index a8d6e1c..176cf3f 100644 --- a/server/public/app.js +++ b/server/public/app.js @@ -6,7 +6,7 @@ import { esc, $, $$, num, int, eur, pct, chg, countdown, now, when, syncClock, s import { initTrade, selectSymbol, subscribe, loadCompany, tradeHooks } from './js/trade.js'; import { initDepot, showDepot } from './js/depot.js'; import { initInfo, showTermine, showNews } from './js/info.js'; -import { initPolitics, showParliament, mergeParliament } from './js/politics.js'; +import { initPolitics, showParliament, mergeParliament, mergeGovernment, setPolTab } from './js/politics.js'; import { initBattles, showBattles, loadBattles, onSpectate } from './js/battles.js'; import { initClans, showClans, loadClan } from './js/clans.js'; import { loadTournaments } from './js/tournaments.js'; @@ -47,7 +47,7 @@ function go(view, opt = {}) { function renderMore() { const items = [ - ['termine', '📅', 'Termine & Morgenbriefing'], ['parlament', '🏛️', 'Parlament'], ['battles', '⚔️', 'Battles & Turniere'], ['clans', '🛡️', 'Clans & Fonds'], + ['termine', '📅', 'Termine & Morgenbriefing'], ['parlament', '🏛️', 'Politik & Parlament'], ['battles', '⚔️', 'Battles & Turniere'], ['clans', '🛡️', 'Clans & Fonds'], ['fortschritt', '⭐', 'Aufgaben, Ligen & Ranglisten'], ['community', '👥', 'Freunde & Posteingang'], ['news', '📰', 'Nachrichten & Konjunktur'], ]; $('#v-mehr').innerHTML = `
@@ -71,6 +71,15 @@ function renderHeader() { $('#seasonLbl').textContent = `Saison ${m.season?.n ?? ''}`; $('#repSeason').hidden = !m.reportingSeason; $('#timeMode').textContent = S.info?.timeModes?.[m.timeMode] ?? m.timeMode; + const po = m.politics; + const gov = $('#hGov'); + if (po && gov) { + const coal = po.coalition?.length ? po.coalition.join('/') : 'ohne Mehrheit'; + const html = `${esc(coal)} · ${esc(po.rating ?? '–')}${po.noConfidence ? ' · MV' : ''}`; + if (gov._h !== html) { gov.innerHTML = html; gov._h = html; } + $('#govStat').setAttribute('aria-label', `Regierung ${coal}, Rating ${po.rating ?? 'unbekannt'}${po.electionAt ? `, Wahl ${when(po.electionAt)}` : ''}${po.noConfidence ? ', Misstrauensvotum läuft' : ''}`); + $('#govSub').textContent = po.electionAt && po.electionAt > now() ? `Wahl in ${countdown(po.electionAt - now())}` : 'Regierung'; + } tickClock(); } @@ -88,6 +97,7 @@ function tickClock() { $('#phaseSub').textContent = sub; $('#phase').setAttribute('aria-label', `${PHASE_SHORT[m.phase]}, ${sub}`); $('#hSeason').textContent = m.season ? `endet in ${countdown(m.season.endsAt - now())}` : '–'; + if (m.politics?.electionAt && m.politics.electionAt > now()) $('#govSub').textContent = `Wahl in ${countdown(m.politics.electionAt - now())}`; const ban = $('#marketBanner'); if (m.phase === 'closed' || m.phase === 'preopen') { ban.hidden = false; @@ -135,8 +145,9 @@ function applyAuth(r) { S.profile = r.profile; S.portfolio = r.portfolio; S.battlePortfolio = r.battlePortfolio; S.battle = r.battle; S.fundPortfolio = r.fundPortfolio ?? null; if (r.parliament) mergeParliament(r.parliament, true); + if (r.government) mergeGovernment(r.government, true); S.battles = r.battles; S.quests = r.quests; S.inbox = r.inbox ?? { items: [], unread: 0 }; - changed('profile', 'portfolio', 'battles', 'quests', 'inbox', 'parliament'); + changed('profile', 'portfolio', 'battles', 'quests', 'inbox', 'parliament', 'government'); renderUser(); go(S.view, { keepScroll: true }); } @@ -144,7 +155,8 @@ function applyAuth(r) { function loggedOut() { S.profile = null; S.portfolio = null; S.battlePortfolio = null; S.battle = null; S.battles = null; S.quests = null; S.fundPortfolio = null; S.clan = null; S.league = null; S.friends = null; S.journal = null; S.inbox = { items: [], unread: 0 }; S.account = 'main'; - changed('profile', 'portfolio', 'inbox', 'battles', 'quests'); + if (S.government) S.government = { ...S.government, me: null }; + changed('profile', 'portfolio', 'inbox', 'battles', 'quests', 'government'); renderUser(); go(S.view, { keepScroll: true }); } @@ -185,8 +197,9 @@ function wire() { }); on('hello', (m) => { S.news = m.news ?? []; S.events = m.events ?? []; S.leaderboard = m.leaderboard; S.motd = m.motd; - if (S.info) { S.info.battleModes ??= m.battleModes; S.info.sectors ??= m.sectors; } + if (S.info) { S.info.battleModes ??= m.battleModes; S.info.sectors ??= m.sectors; S.info.assetClasses ??= m.assetClasses; } if (m.parliament) mergeParliament(m.parliament); + if (m.government) mergeGovernment(m.government); applyMarket(m.market); changed('news', 'events', 'leaderboard'); if (m.motd && store.get('motd') !== m.motd) { toast(m.motd, 'info', { title: 'Willkommen' }); store.set('motd', m.motd); } @@ -210,6 +223,7 @@ function wire() { on('news', (m) => { S.news = [m.news, ...S.news.filter((n) => n.id !== m.news.id)].slice(0, 100); changed('news'); }); on('event', (m) => { S.events = [m.event, ...S.events].slice(0, 200); changed('events'); }); on('parliament', (m) => mergeParliament(m.parliament)); + on('government', (m) => mergeGovernment(m.government)); on('inbox', onInboxItem); on('comment', (m) => onComment(m.comment)); on('commentDeleted', (m) => onCommentDeleted(m.id)); @@ -273,6 +287,7 @@ document.addEventListener('click', (e) => { else if (act === 'login') { closeAllModals(); openAuth(); } else if (act === 'tutorial') { closeAllModals(); runTour(); } else if (act === 'reconnect') reconnectNow(); + else if (act === 'polTab') { closeAllModals(); setPolTab(a.dataset.tab); go('parlament'); } else if (act === 'closeAnnounce') $('#announce').hidden = true; }); diff --git a/server/public/index.html b/server/public/index.html index 8806c46..269f3ce 100644 --- a/server/public/index.html +++ b/server/public/index.html @@ -20,6 +20,7 @@
WIBO-10–
Saison–
+
@@ -39,7 +40,7 @@ - + @@ -52,7 +53,7 @@

Markt

-
WertKursÄnd.
+
WertKursÄnd.
@@ -69,7 +70,7 @@
-
+
@@ -99,7 +100,7 @@
-
+
diff --git a/server/public/js/admin.js b/server/public/js/admin.js index f877c43..4a8715c 100644 --- a/server/public/js/admin.js +++ b/server/public/js/admin.js @@ -49,7 +49,8 @@ function overviewHtml() {

Konjunktur

Leitzins
${num(m.rate, 2)} %
Inflation
${num(m.inflation, 1)} %
BIP
${num(m.gdp, 1)} %
-
Arbeitslosigkeit
${num(m.unemployment, 1)} %
Stimmung
${num(m.sentiment * 100, 0)}
+
Arbeitslosigkeit
${num(m.unemployment, 1)} %
Stimmung
${num(m.sentiment * 100, 0)}
+
Szenario
${esc(ov.scenario?.title ?? '–')}
Rating
${esc(ov.government?.budget?.rating ?? '–')}

Letzte Aufsichtsfälle

${ov.cases.slice(0, 6).map((c) => `

${when(c.ts)} – ${esc(c.name)}: ${esc(c.text)} ${c.fine ? `(${eur(c.fine)})` : '(Verwarnung)'}

`).join('') || '

Keine.

'}
`; } @@ -228,9 +229,62 @@ function controlHtml() {

Durchsage an alle Spieler

+ ${econHtml()}

Turniere (K.-o.-System)

Lade …

`; } +// ================================================================ Wirtschaft & Politik +function econHtml() { + const scs = Object.entries(ov.scenarios ?? {}); + const stocks = ov.stockSymbols ?? ov.symbols ?? []; + const opts = (list, sel) => list.map((s) => ``).join(''); + const gv = ov.government; + const b = gv?.budget ?? {}; + const short = (id) => gv?.parties?.find((p) => p.id === id)?.short ?? id; + const offers = ov.corporate?.offers ?? []; + const trials = ov.corporate?.trials ?? []; + return `
+

Wirtschaft & Politik

+

Szenario

+

Aktuell: ${esc(ov.scenario?.title ?? '–')}${ov.scenario?.desc ? ` – ${esc(ov.scenario.desc)}` : ''}

+
+
+

${esc(ov.scenarios?.[ov.scenario?.id]?.desc ?? scs[0]?.[1]?.desc ?? '')}

+

Unternehmensereignisse

+
+ +
+
+ + +
+

Rohstoffe

+
+ +

Wahl

+

Die Parlamentswahl findet regulär zur Saisonmitte statt${gv?.election && !gv.election.done ? ` (${when(gv.election.at)})` : ''}.

+ +
+

Regierung & Haushalt nur lesen

+ ${gv ? `
+
Koalition
${gv.coalition ? `${gv.coalition.parties.map((id) => esc(short(id))).join('/')} (${int(gv.coalition.seats)} von ${int(gv.seatsTotal)} Sitzen)` : 'keine Mehrheit'}
+
Regierungschef/in
${esc(gv.coalition?.head ?? '–')}
+
Sitze
${gv.parties.filter((p) => p.seats).map((p) => `${esc(p.short)} ${int(p.seats)}`).join(' · ')}
+
Spielerparteien
${gv.parties.filter((p) => !p.npc).map((p) => `${esc(p.short)} (${int(p.members)})`).join(', ') || 'keine'}
+
Wahl
${gv.election?.done ? 'abgehalten' : `${when(gv.election?.at)} · ${int(gv.election?.voters)} Stimmen`}
+
Misstrauensvotum
${gv.noConfidence ? `läuft bis ${when(gv.noConfidence.endsAt)} (${esc((gv.noConfidence.alt ?? []).join('/'))})` : 'keins'}
+
Schulden
${num(b.debt, 1)} % des BIP
+
Defizit
${num(b.deficit, 2)} % (strukturell ${num(b.structural, 2)} %)
+
Rating
${esc(b.rating ?? '–')}${b.crisis ? ' Haushaltskrise' : ''}
+
Risikoaufschlag
${num(b.riskPremium, 2)} Pp.
+
Lobbyspenden
${int(gv.lobby?.length)} Einträge
+
` : '

Keine Daten.

'} +

Laufende Unternehmensereignisse

+ ${offers.length || trials.length ? `
    ${offers.map((o) => `
  • Übernahme ${esc(o.bidder)} → ${esc(o.target)}: ${eur(o.price)} (${frac(o.probability, 0)}, noch ${int(o.daysLeft)} T, ${int(o.tenderedTotal)} St. angedient)
  • `).join('')} + ${trials.map((t) => `
  • Studie ${esc(t.drug)} (${esc(t.symbol)}): Tag ${int(t.day)}, ${frac(t.p, 0)}
  • `).join('')}
` : '

Keine.

'} +
`; +} + // ================================================================ Turniere const durLabel = (m) => (m >= 1440 ? `${num(m / 1440, m % 1440 ? 1 : 0)} Tag(e)` : m >= 60 ? `${num(m / 60, m % 60 ? 1 : 0)} Std.` : `${m} Min.`); const localInput = (ts) => { const d = new Date(ts - new Date(ts).getTimezoneOffset() * 60_000); return d.toISOString().slice(0, 16); }; @@ -271,7 +325,26 @@ async function controlAction(a) { else if (a === 'nextBill') { if (await ask({ title: 'Abstimmung jetzt beenden?', text: 'Die laufende Abstimmung wird sofort ausgezählt; eine neue Vorlage startet.' })) action('nextBill', {}, 'Abstimmung beendet.'); } else if (a === 'backup') { const r = await action('backup', {}, 'Sicherung erstellt.'); if (r?.detail?.file) toast(r.detail.file, 'ok', { title: 'Datei' }); } else if (a === 'earnings') { const s = $('#earnSym').value; action('earnings', { value: s }, `${s} veröffentlicht Zahlen zum nächsten Handelstag.`); } - else if (a === 'endSeason') { + else if (a === 'scenario') { + const id = $('#scSel').value; + const sc = ov.scenarios?.[id]; + if (!sc) return; + if (await ask({ title: `Szenario „${sc.title}“ jetzt anwenden?`, text: `${sc.desc} Ausgangslage (Konjunktur, Stimmung, Haushalt, Sektoren) wird sofort gesetzt; das Drehbuch läuft über den Rest der Saison.`, typed: sc.title, ok: 'Anwenden', danger: true })) action('scenario', { value: id }, `Szenario „${sc.title}“ angewendet.`); + } else if (a === 'takeover') { + const target = $('#toTarget').value, bidder = $('#toBidder').value; + if (bidder && bidder === target) { toast('Ziel und Bieter müssen verschieden sein', 'err'); return; } + if (await ask({ title: 'Übernahmeangebot auslösen?', text: `${bidder || 'Ein passender Bieter'} bietet für ${target}. Alle Spieler mit ${target}-Aktien werden benachrichtigt.`, ok: 'Auslösen' })) action('takeover', { value: { target, bidder: bidder || undefined } }, `Übernahmeangebot für ${target} veröffentlicht.`); + } else if (a === 'capitalIncrease' || a === 'buyback' || a === 'trial') { + const sym = $('#corpSym').value; + const lbl = { capitalIncrease: 'Kapitalerhöhung', buyback: 'Aktienrückkauf', trial: 'Studienankündigung' }[a]; + if (await ask({ title: `${lbl} für ${sym}?`, text: 'Die Meldung wird sofort veröffentlicht und wirkt auf den Kurs.', ok: 'Auslösen' })) action(a, { value: sym }, `${lbl} für ${sym} ausgelöst.`); + } else if (a === 'oilShock') { + const v = Number($('#oilSize').value); + if (!v) { toast('Bitte eine Größe ungleich 0 wählen', 'err'); return; } + if (await ask({ title: 'Ölschock auslösen?', text: `${v > 0 ? 'Förderkürzung – Öl wird teurer' : 'Förderausweitung – Öl wird billiger'} (Größe ${num(v, 2)}). Wirkt auf Inflation und Energie-, Auto- und Industriewerte.`, ok: 'Auslösen' })) action('oilShock', { value: v }, 'Ölschock ausgelöst.'); + } else if (a === 'election') { + if (await ask({ title: 'Wahl jetzt abhalten?', text: 'Die Parlamentswahl wird sofort ausgezählt (Umfragen + Spielerstimmen), Sitze neu verteilt und eine Regierung gebildet. Märkte reagieren auf die Überraschung.', typed: 'WAHL', ok: 'Wahl abhalten', danger: true })) action('election', {}, 'Wahl abgehalten.'); + } else if (a === 'endSeason') { if (await ask({ title: `Saison ${ov.season.n} beenden?`, text: 'Alle Depots werden zurückgesetzt, Battles abgebrochen, Rückblicke und Ruhmeshalle erstellt. Das kann nicht rückgängig gemacht werden.', typed: 'SAISON BEENDEN', ok: 'Saison beenden', danger: true })) action('endSeason', {}, 'Neue Saison gestartet.'); } else if (a === 'news') { const title = $('#nTitle').value.trim(); @@ -356,6 +429,8 @@ document.addEventListener('submit', (e) => { document.addEventListener('input', (e) => { if (e.target.id === 'pFilter') { filter = e.target.value; render(); } else if (e.target.id === 'nSent') $('#nSentV').textContent = num(Number(e.target.value), 1); + else if (e.target.id === 'oilSize') { const v = Number(e.target.value); $('#oilSizeV').textContent = `${v > 0 ? '+' : v < 0 ? '−' : '±'}${num(Math.abs(v), 2)}`; } + else if (e.target.id === 'scSel') $('#scDesc').textContent = ov.scenarios?.[e.target.value]?.desc ?? ''; else if (e.target.closest('#sec-settings [data-key]')) { const { changed } = diffSettings(); $('#setChanged').textContent = changed.length ? `Geändert: ${changed.join(', ')}` : 'Keine Änderungen.'; diff --git a/server/public/js/charts.js b/server/public/js/charts.js index 18e628b..b4130c3 100644 --- a/server/public/js/charts.js +++ b/server/public/js/charts.js @@ -140,6 +140,140 @@ export class CandleChart extends Base { } } +// ================================================================ Kleine Diagramme mit Zeichenfunktion +/** Canvas mit austauschbarer Zeichenfunktion – überlebt Neuzeichnen bei Größenänderung */ +class FnChart extends Base { + constructor(canvas) { super(canvas); this.fn = null; } + set(fn) { this.fn = fn; this.draw(); } + draw() { + if (!this.c.isConnected) { this.ro.disconnect(); return; } + const { w, h } = this.size(); + this.ctx.clearRect(0, 0, w, h); + this.ctx.font = '12px system-ui, sans-serif'; + this.ctx.setLineDash([]); + this.fn?.(this.ctx, w, h, this.colors(), this.hover); + } +} +const fnCharts = new WeakMap(); +/** Zeichenfunktion an ein Canvas hängen (wiederverwendbar nach patch()) */ +export function paint(canvas, fn) { + if (!canvas) return; + let c = fnCharts.get(canvas); + if (!c) { c = new FnChart(canvas); fnCharts.set(canvas, c); } + c.set(fn); +} + +/** + * XY-Linien: series [{name, color, dash?, points [{x, y}]}] + * opt: {yFmt, xFmt, xTicks [x], xScale (x→x'), hlines [{y, label, color}], marks [{x, y, label, color}], yMin, yMax, legend, empty} + */ +export function lineChart(series, opt = {}) { + return (ctx, w, h, col, hover) => { + const pts = series.flatMap((s) => s.points); + if (!pts.length) { ctx.fillStyle = col.text; ctx.textAlign = 'center'; ctx.fillText(opt.empty ?? 'Noch keine Daten', w / 2, h / 2); return; } + const xs = opt.xScale ?? ((x) => x); + const axisW = 46, padT = opt.legend ? 22 : 8, padB = 18, plotW = w - axisW - 8, plotH = h - padT - padB; + let lo = Math.min(...pts.map((p) => p.y), ...(opt.hlines ?? []).map((l) => l.y)), hi = Math.max(...pts.map((p) => p.y), ...(opt.hlines ?? []).map((l) => l.y)); + if (opt.yMin !== undefined) lo = Math.min(lo, opt.yMin); + if (opt.yMax !== undefined) hi = Math.max(hi, opt.yMax); + if (hi - lo < 1e-6) { hi += 0.5; lo -= 0.5; } + const pad = (hi - lo) * 0.08; hi += pad; lo -= pad; + const x0 = Math.min(...pts.map((p) => xs(p.x))), x1 = Math.max(...pts.map((p) => xs(p.x))); + const X = (x) => axisW + (x1 === x0 ? plotW / 2 : ((xs(x) - x0) / (x1 - x0)) * plotW); + const Y = (y) => padT + ((hi - y) / (hi - lo)) * plotH; + const yFmt = opt.yFmt ?? ((v) => num(v, 1)); + ctx.strokeStyle = col.line; ctx.fillStyle = col.text; ctx.lineWidth = 1; ctx.textAlign = 'right'; ctx.textBaseline = 'middle'; + const step = niceStep(hi - lo, 4); + for (let v = Math.ceil(lo / step) * step; v <= hi; v += step) { + const yy = Math.round(Y(v)) + 0.5; + ctx.beginPath(); ctx.moveTo(axisW, yy); ctx.lineTo(axisW + plotW, yy); ctx.stroke(); + ctx.fillText(yFmt(v, step), axisW - 6, yy); + } + ctx.textAlign = 'center'; ctx.textBaseline = 'alphabetic'; + const xFmt = opt.xFmt ?? ((x) => String(x)); + const ticks = opt.xTicks ?? [pts[0].x, pts[pts.length - 1].x]; + for (const t of ticks) ctx.fillText(xFmt(t), Math.min(w - 20, Math.max(axisW + 14, X(t))), h - 4); + for (const l of opt.hlines ?? []) { + const yy = Math.round(Y(l.y)) + 0.5; + ctx.strokeStyle = l.color ?? col.text; ctx.setLineDash([4, 4]); + ctx.beginPath(); ctx.moveTo(axisW, yy); ctx.lineTo(axisW + plotW, yy); ctx.stroke(); ctx.setLineDash([]); + if (l.label) { ctx.fillStyle = l.color ?? col.text; ctx.textAlign = 'left'; ctx.textBaseline = 'bottom'; ctx.fillText(l.label, axisW + 4, yy - 2); } + } + const palette = [col.accent, col.gold, col.up, col.down]; + let lx = axisW; + series.forEach((s, i) => { + const c = s.color ?? palette[i % palette.length]; + ctx.strokeStyle = c; ctx.fillStyle = c; ctx.lineWidth = 2; ctx.setLineDash(s.dash ?? []); + ctx.beginPath(); + s.points.forEach((p, j) => (j ? ctx.lineTo(X(p.x), Y(p.y)) : ctx.moveTo(X(p.x), Y(p.y)))); + ctx.stroke(); ctx.setLineDash([]); ctx.lineWidth = 1; + if (s.points.length <= 12) for (const p of s.points) { ctx.beginPath(); ctx.arc(X(p.x), Y(p.y), 2.5, 0, 7); ctx.fill(); } + if (opt.legend) { + ctx.fillRect(lx, 8, 12, 3); + ctx.fillStyle = col.fg; ctx.textAlign = 'left'; ctx.textBaseline = 'middle'; + ctx.fillText(s.name, lx + 16, 10); + lx += ctx.measureText(s.name).width + 30; + } + }); + for (const m of opt.marks ?? []) { + const xx = X(m.x), yy = Y(m.y); + ctx.fillStyle = m.color ?? col.gold; ctx.strokeStyle = col.bg; ctx.lineWidth = 2; + ctx.beginPath(); ctx.arc(xx, yy, 5, 0, 7); ctx.fill(); ctx.stroke(); ctx.lineWidth = 1; + ctx.fillStyle = col.fg; ctx.textAlign = 'center'; ctx.textBaseline = 'bottom'; + ctx.fillText(m.label, Math.min(w - 30, Math.max(axisW + 30, xx)), yy - 8); + } + if (hover && hover.x > axisW && opt.hoverFmt) { + let best = null, bd = Infinity; + for (const p of pts) { const d = Math.abs(X(p.x) - hover.x); if (d < bd) { bd = d; best = p; } } + if (best) { + const txt = opt.hoverFmt(best); + ctx.font = '12px ui-monospace, monospace'; + const tw = ctx.measureText(txt).width + 12; + const bx = Math.min(w - tw - 2, Math.max(2, X(best.x) - tw / 2)); + ctx.fillStyle = 'rgba(11,15,23,.9)'; ctx.fillRect(bx, padT, tw, 18); + ctx.fillStyle = col.fg; ctx.textAlign = 'left'; ctx.textBaseline = 'middle'; ctx.fillText(txt, bx + 6, padT + 9); + } + } + }; +} + +/** Halbkreis-Sitzverteilung: parties [{short, color, seats, coalition}] in Reihenfolge links → rechts */ +export function hemicycle(parties, total) { + return (ctx, w, h, col) => { + const cx = w / 2, cy = h - 6; + const R = Math.min(w / 2 - 6, h - 12), r0 = R * 0.38; + const rows = Math.max(4, Math.round(Math.sqrt(total / 3.2))); + const radii = Array.from({ length: rows }, (_, i) => r0 + ((R - r0) * (i + 0.5)) / rows); + const sumR = radii.reduce((a, x) => a + x, 0); + const spots = []; + let left = total; + radii.forEach((r, i) => { + const n = i === rows - 1 ? left : Math.round((total * r) / sumR); + left -= n; + for (let k = 0; k < n; k++) { + const a = Math.PI - (Math.PI * (k + 0.5)) / n; + spots.push({ a, x: cx + r * Math.cos(a), y: cy - r * Math.sin(a) }); + } + }); + spots.sort((p, q) => q.a - p.a); + const dot = Math.max(1.5, Math.min(7, ((R - r0) / rows) * 0.38)); + let i = 0; + for (const p of parties) { + for (let k = 0; k < p.seats && i < spots.length; k++, i++) { + const s = spots[i]; + ctx.fillStyle = p.color; + ctx.beginPath(); ctx.arc(s.x, s.y, dot, 0, 7); ctx.fill(); + if (p.coalition) { ctx.strokeStyle = col.fg; ctx.lineWidth = 1; ctx.stroke(); } + } + } + ctx.fillStyle = col.fg; ctx.textAlign = 'center'; ctx.textBaseline = 'alphabetic'; + ctx.font = 'bold 18px system-ui, sans-serif'; + ctx.fillText(String(total), cx, cy - 18); + ctx.font = '12px system-ui, sans-serif'; ctx.fillStyle = col.text; + ctx.fillText(`Mehrheit ab ${Math.floor(total / 2) + 1}`, cx, cy - 2); + }; +} + /** Linienchart (z. B. Battle-Verlauf in %) */ export class LineChart extends Base { constructor(canvas) { super(canvas); this.series = []; this.opt = {}; } @@ -187,3 +321,15 @@ export class LineChart extends Base { ctx.fillText(time(t1), plotW - 20, h - 3); } } + +/** Zinskurve mit Markierungen bei 2 und 10 Jahren */ +export function curveChart(cv) { + if (!cv?.points?.length) return lineChart([], { empty: 'Keine Zinskurve' }); + const tf = (T) => (T < 1 ? `${Math.round(T * 12)} M` : `${T} J`); + return lineChart([{ name: 'Rendite', points: cv.points.map((p) => ({ x: p.T, y: p.y })) }], { + xScale: Math.sqrt, xTicks: [0.25, 2, 5, 10, 30].filter((T) => cv.points.some((p) => p.T === T)), xFmt: tf, + yFmt: (v, step) => `${num(v, step < 0.1 ? 2 : 1)} %`, + marks: [{ x: 2, y: cv.y2, label: `2 J. ${num(cv.y2, 2)} %` }, { x: 10, y: cv.y10, label: `10 J. ${num(cv.y10, 2)} %` }], + hoverFmt: (p) => `${tf(p.x)}: ${num(p.y, 2)} %`, + }); +} diff --git a/server/public/js/info.js b/server/public/js/info.js index d7326db..6c55e46 100644 --- a/server/public/js/info.js +++ b/server/public/js/info.js @@ -3,11 +3,13 @@ import { S, sub, loggedIn } from './state.js'; import { request } from './net.js'; import { toast, gl } from './ui.js'; import { newsList } from './trade.js'; +import { paint, lineChart, curveChart } from './charts.js'; import { esc, $, int, num, eur, pct, chg, frac, dirCls, arrow, countdown, now, when, wdDate, time, ago, patch, player } from './util.js'; const KIND = { earnings: ['📊', 'Quartalszahlen'], exdiv: ['💶', 'Ex-Dividende'], macro: ['📈', 'Konjunktur'], cb: ['🏦', 'Zentralbank'], bill: ['🏛️', 'Parlament'], law: ['📜', 'Gesetz'], auction: ['🔔', 'Auktion'], season: ['🏁', 'Saison'], + corporate: ['🤝', 'Unternehmen'], election: ['🗳️', 'Wahl'], }; let newsTab = 'news'; @@ -24,14 +26,46 @@ function calendarHtml(cal) { `).join('') || '

Keine Termine.

'; + ${esc(i.kind === 'exdiv' && /Kupon/.test(i.title) ? 'Kupon' : KIND[i.kind]?.[1] ?? i.kind)}${i.detail ? ` · ${esc(i.detail)}` : ''}${Number.isFinite(i.dayIn) && i.dayIn > 0 ? ` · in ${int(i.dayIn)} Handelstag(en)` : ''}${i.ts > now() ? ` · in ${countdown(i.ts - now())}` : ''}`).join('')}`).join('') || '

Keine Termine.

'; +} + +/** Szenario der Saison als Karte */ +function scenarioHtml(sc) { + if (!sc) return ''; + return `
${gl('Szenario')} dieser Saison${esc(sc.title)}

${esc(sc.desc)}

`; +} + +/** Regierungszusammenfassung aus market.politics */ +function govLine(po) { + if (!po) return ''; + return `

🏛️ Regierung ${esc(po.coalition?.length ? po.coalition.join('/') : 'ohne Mehrheit')} · ${gl('Rating')} ${esc(po.rating ?? '–')} + ${po.electionAt ? ` · Wahl ${when(po.electionAt)} (in ${countdown(po.electionAt - now())})` : ''} + ${po.noConfidence ? ` · ${gl('Misstrauensvotum')} läuft` : ''} +

`; +} + +function indicatorsHtml(ind) { + if (!ind) return '

Frühindikatoren erscheinen zur Monatsmitte.

'; + const row = (label, k, d = 1) => { + const v = ind[k], c = ind.consensus?.[k], su = ind.surprise?.[k]; + return `${label}${num(v, d)}${num(c, d)}${Number.isFinite(su) ? `${arrow(su)} ${su > 0 ? '+' : ''}${num(su, d)}` : '–'}`; + }; + return ` + ${row(gl('Einkaufsmanagerindex', 'Einkaufsmanagerindex'), 'pmi')}${row('Klimaindex', 'climate')}
aktuellKonsensÜberraschung
+

${ind.pmi >= 50 ? '▲ über 50: Expansion' : '▼ unter 50: Schrumpfung'}${ind.ts ? ` · veröffentlicht ${when(ind.ts)}` : ''}

+
`; } function macroHtml(m) { if (!m) return ''; const probs = Object.entries(m.cb?.probs ?? {}).map(([k, v]) => [Number(k), v]).sort((a, b) => a[0] - b[0]); const ld = m.lastDecision; - return `
+ const cv = m.curve; + return `${scenarioHtml(S.market?.season?.scenario)}${govLine(S.market?.politics)} +
+
+

Konjunktur

+
Leitzins
${num(m.rate, 2)} %
Inflation
${num(m.inflation, 1)} % (Ziel ${num(m.targets?.inflation, 1)} %)
BIP-Wachstum
${num(m.gdp, 1)} %
@@ -41,19 +75,45 @@ function macroHtml(m) { ${ld ? `
Letzter Zinsentscheid
${ld.decision > 0 ? '+' : ''}${num(ld.decision * 100, 0)} Bp. → ${num(ld.rate, 2)} %
` : ''}
${probs.length ? `

Zentralbank – Markterwartung ${m.cbAt ? `(Sitzung ${when(m.cbAt)})` : ''}

-
${probs.map(([k, v]) => `
${k > 0 ? '+' : ''}${num(k * 100, 0)} Bp.
${frac(v, 0)}
`).join('')}
` : ''}`; +
${probs.map(([k, v]) => `
${k > 0 ? '+' : ''}${num(k * 100, 0)} Bp.
${frac(v, 0)}
`).join('')}
` : ''} +

Frühindikatoren

+ ${indicatorsHtml(m.indicators)} +
+
+

${gl('Zinskurve')} Wiborien

+ ${cv ? `
+

2 J. ${num(cv.y2, 2)} % · 10 J. ${num(cv.y10, 2)} % · Abstand ${num(cv.spread * 100, 0)} Bp. ${cv.inverted ? 'invertiert – Rezessionssignal' : 'normal'}

+

${gl('Risikoaufschlag')} ${num(cv.riskPremium, 2)} Pp. · Auslandszins ${num(cv.foreignRate, 2)} % · langfristiges Niveau ${num(cv.longNeutral, 2)} %. + ·

` : '

Keine Daten.

'} +
`; +} + +/** Diagramme in einer gerenderten Makro-Ansicht zeichnen */ +function paintMacro(m) { + if (!m) return; + paint($('#macroCurve'), curveChart(m.curve)); + const h = m.indicators?.history ?? []; + paint($('#pmiChart'), lineChart([{ name: 'Einkaufsmanagerindex', points: h.map((x) => ({ x: x.day, y: x.pmi })) }], { + hlines: [{ y: 50, label: '50 = Stagnation' }], yMin: 48, yMax: 52, yFmt: (v, st) => num(v, st < 1 ? 1 : 0), xFmt: (d) => `Tag ${d}`, empty: 'Noch kein Verlauf', hoverFmt: (p) => `Tag ${p.x}: ${num(p.y, 1)}`, + })); } function briefingHtml(b) { if (!b) return '

Lade Briefing …

'; const pa = b.parliament; - return `

${esc(b.phaseText)} · WIBO-10 ${num(b.index?.value, 0)} ${chg(b.index?.change ?? 0)}${b.reportingSeason ? ' · Berichtssaison' : ''}

+ const gvb = b.government; + return `${scenarioHtml(b.scenario)} + ${gvb ? `

🏛️ Regierung ${esc(gvb.coalition?.parties?.map((id) => S.government?.parties?.find((p) => p.id === id)?.short ?? id.toUpperCase()).join('/') ?? 'ohne Mehrheit')}${gvb.coalition?.head ? ` (Regierungschef/in ${esc(gvb.coalition.head)})` : ''} · ${gl('Rating')} ${esc(gvb.rating ?? '–')}${gvb.election ? ` · Wahl ${when(gvb.election)}` : ''}

` : ''} +

${esc(b.phaseText)} · WIBO-10 ${num(b.index?.value, 0)} ${chg(b.index?.change ?? 0)}${b.reportingSeason ? ' · Berichtssaison' : ''}

${b.holdings?.length ? `

Deine Positionen

${b.holdings.map((h) => ``).join('')}
WertStückKursVortagIndikativÄnd.
${int(h.qty)}${num(h.last)}${num(h.prevClose)}${h.indicative ? num(h.indicative) : '–'}${chg(h.indicative ? (h.indicative / h.prevClose - 1) * 100 : h.change)}
` : (loggedIn() ? '

Keine offenen Positionen.

' : '')}

Heute wichtig

${b.today?.length ? `` : '

Keine Termine heute.

'} - ${pa ? `

Parlament

${esc(pa.bill.title)} – Markt erwartet ${frac(pa.probability, 0)} Annahme, Abstimmung endet ${when(pa.endsAt)}.

` : ''} + ${pa?.bill ? `

Parlament

${esc(pa.bill.title)} – Markt erwartet ${frac(pa.probability, 0)} für das Inkrafttreten, Abstimmung endet ${when(pa.endsAt)}.

` + : pa?.pipeline?.length ? `

Parlament

${int(pa.pipeline.length)} Vorlage(n) im Verfahren, z. B. „${esc(pa.pipeline[0].bill.title)}“ (${esc(pa.pipeline[0].stageLabel)}).

` : ''} + ${b.curve ? `

Zinsen & Märkte

Rendite 2 J. ${num(b.curve.y2, 2)} % · 10 J. ${num(b.curve.y10, 2)} %${b.curve.inverted ? ' Kurve invertiert' : ''}

+ ${b.assets?.length ? `
${b.assets.map((x) => ``).join('')}
` : ''}` : ''}

Was seit Handelsschluss passiert ist

${newsList(b.news, 'Keine neuen Meldungen seit dem letzten Handelsschluss.')}`; } @@ -73,7 +133,7 @@ function renderTermine() { } function eventsHtml() { - const ICON = { market: '🔔', policy: '🏛️', battle: '⚔️', achievement: '🏅', regulator: '⚖️', player: '👋', season: '🏁', admin: '🛠️' }; + const ICON = { market: '🔔', policy: '🏛️', politics: '🗳️', corporate: '🤝', macro: '📈', battle: '⚔️', achievement: '🏅', regulator: '⚖️', player: '👋', season: '🏁', admin: '🛠️' }; return S.events.length ? `` : '

Noch keine Ereignisse.

'; } @@ -85,7 +145,7 @@ function casesHtml() { } function renderNews() { - const tabs = { news: 'Nachrichten', events: 'Ereignisse', macro: 'Konjunktur', cases: 'Börsenaufsicht (WiBaFin)' }; + const tabs = { news: 'Nachrichten', events: 'Ereignisse', macro: 'Konjunktur & Zinsen', cases: 'Börsenaufsicht (WiBaFin)' }; let body = ''; if (newsTab === 'news') body = newsList(S.news, 'Noch keine Nachrichten.'); else if (newsTab === 'events') body = eventsHtml(); @@ -94,6 +154,7 @@ function renderNews() { patch($('#v-news'), `
${Object.entries(tabs).map(([k, v]) => ``).join('')}
${body}
`); + if (newsTab === 'macro') paintMacro(S.market?.macro); } export function initInfo() { diff --git a/server/public/js/politics.js b/server/public/js/politics.js index 180ca47..74392d8 100644 --- a/server/public/js/politics.js +++ b/server/public/js/politics.js @@ -1,53 +1,145 @@ -// Parlament von Wiborien: aktuelle Vorlage, Wirkungen je Sektor, Markterwartung, Quorum, verdeckte Schlussphase, -// Interessenregister, Abstimmung, Gesetze vor Inkrafttreten, Verlauf und Kommentare. +// Politik in Wiborien: Gesetzgebung (Verfahren mit Lesung, Ausschuss, Abstimmung, Länderkammer, Gericht), +// Spielervorlagen mit Mitzeichnern, Parteien & Wahl (Sitze, Koalition, Umfragen, Stimmzettel, Parteigründung, +// Ämter, Misstrauensvotum) sowie Haushalt & Lobbyregister. import { S, sub, changed, loggedIn } from './state.js'; import { request } from './net.js'; -import { toast, gl } from './ui.js'; +import { toast, gl, ask } from './ui.js'; import { renderComments } from './social.js'; -import { esc, $, int, num, pct, frac, dirCls, arrow, countdown, now, when, patch, player, meter } from './util.js'; +import { paint, lineChart, hemicycle } from './charts.js'; +import { esc, $, int, num, eur, pct, frac, arrow, countdown, now, when, patch, player, meter, store } from './util.js'; const MACRO = { gdp: 'BIP-Wachstum', inflation: 'Inflation', unemployment: 'Arbeitslosigkeit', rate: 'Zins' }; -const AXIS = { staat: 'Staat & Markt', oeko: 'Ökologie', sozial: 'Soziales', wirtschaft: 'Wirtschaft' }; +const AXIS = { staat: 'Staat & Soziales', markt: 'Markt & Wirtschaft', oeko: 'Ökologie', sozial: 'Soziales', wirtschaft: 'Wirtschaft' }; +const POS = { + markt: ['Markt', '−1 staatlich gelenkt … +1 freier Markt'], + staat: ['Staat', '−1 schlanker Staat … +1 starker Sozialstaat'], + oeko: ['Öko', '−1 Wachstum zuerst … +1 Klimaschutz zuerst'], +}; +const SOURCE = { agenda: 'Koalitionsvertrag', player: 'Spieler', news: 'Nachrichten', catalog: 'Katalog' }; +const STAGES = [['lesung', 'Lesung'], ['ausschuss', 'Ausschuss'], ['abstimmung', 'Abstimmung'], ['laenderkammer', 'Länderkammer'], ['gericht', 'Gericht']]; +const TABS = { gesetz: 'Gesetzgebung', vorlagen: 'Vorlagen', parteien: 'Parteien & Wahl', haushalt: 'Haushalt & Lobby' }; -/** Broadcasts enthalten keine persönliche Stimme → aus der letzten persönlichen Ansicht übernehmen */ +let tab = TABS[store.get('polTab', 'gesetz')] ? store.get('polTab', 'gesetz') : 'gesetz'; +let loadedGov = false; + +/** Unterseite wählen (z. B. von der Anleihe aus) */ +export function setPolTab(t) { if (TABS[t]) { tab = t; store.set('polTab', t); } } + +const color = (c) => (/^#[0-9a-f]{3,8}$/i.test(String(c ?? '')) ? c : '#888888'); +const swatch = (c) => ``; +const ppt = (x, d = 2) => `${x > 0 ? '+' : x < 0 ? '−' : '±'}${num(Math.abs(x ?? 0), d)}`; +const costText = (c) => (c ? `${ppt(c)} % BIP p. a. (${c > 0 ? 'belastet' : 'entlastet'} den Haushalt)` : '±0 (haushaltsneutral)'); +const sectorName = (k) => S.info?.sectors?.[k]?.name ?? k; +const ministryName = (id) => S.info?.ministries?.find((m) => m.id === id)?.name ?? id; +const partyOf = (id) => S.government?.parties?.find((p) => p.id === id); +const partyLabel = (id) => { const p = partyOf(id); return p ? `${swatch(p.color)}${esc(p.short)}` : esc(id ?? '–'); }; + +/** Broadcasts enthalten keine persönlichen Angaben → aus der letzten persönlichen Ansicht übernehmen */ export function mergeParliament(pa, personal = false) { - if (pa && !personal && S.parliament && S.parliament.id === pa.id) { - pa.myVote = S.parliament.myVote; - pa.myConflict = S.parliament.myConflict; + const prev = S.parliament; + if (pa && !personal && prev) { + if (prev.id === pa.id) { pa.myVote = prev.myVote; pa.myConflict = prev.myConflict; } + const old = new Map((prev.proposals ?? []).map((x) => [x.id, x])); + for (const x of pa.proposals ?? []) { const o = old.get(x.id); if (o) { x.mine = o.mine; x.signed = o.signed; } } } S.parliament = pa; changed('parliament'); } -function render() { - const el = $('#v-parlament'); - const pa = S.parliament; - if (!pa) { patch(el.querySelector('.pa-main') ?? el, '

Derzeit liegt keine Vorlage zur Abstimmung vor.

'); return; } - if (!el.querySelector('.pa-main')) { - el._html = null; - el.innerHTML = `

Debatte

`; +export function mergeGovernment(gv, personal = false) { + const prev = S.government; + if (gv && !personal && prev && loggedIn()) { + gv.me = prev.me; + if (gv.election && prev.election && gv.election.myVote === undefined) gv.election.myVote = prev.election.myVote; + if (gv.noConfidence && prev.noConfidence?.id === gv.noConfidence.id && gv.noConfidence.myVote === undefined) gv.noConfidence.myVote = prev.noConfidence.myVote; + } + S.government = gv; + changed('government'); +} + +/** Formular nur neu aufbauen, wenn sich die Voraussetzungen ändern (Eingaben bleiben erhalten) */ +function patchOnce(el, key, html) { + if (!el || el._key === key) return false; + el._key = key; + el.innerHTML = html; + return true; +} + +// ================================================================ Gerüst +const card = (title, id, cls = '') => `

${title}

`; + +function skeleton() { + const el = $('#v-parlament'); + if (el._tab === tab && el.querySelector('.pol-body')) return; + el._tab = tab; + el._html = null; + const body = { + gesetz: `
${card('Gesetzgebungsverfahren', 'plPipe')}
+
${card('Debatte zur Abstimmung', 'paComments')}${card('Beschlossen, noch nicht in Kraft', 'plLaws')}
+ ${card('Letzte Entscheidungen', 'plHist', 'flush scroll-x')}`, + vorlagen: `
${card('Vorlage einbringen', 'plPropForm')}${card('Eingebrachte Vorlagen', 'plProps')}
`, + parteien: `
+
+

Sitzverteilung

+
+ ${card(`Regierung (${gl('Koalition')})`, 'plGov')} +
+
+ ${card('Parlamentswahl', 'plElection')} +

Umfragen

+
+
+ ${card('Parteien', 'plParties', 'flush scroll-x')} +
${card('Mein Amt', 'plOffice')}${card('Partei gründen', 'plFound')}
`, + haushalt: `

Staatshaushalt

+

Schulden in % des BIP

+

Defizit in % des BIP

+
${card(gl('Lobbyregister'), 'plLobby', 'flush scroll-x')}${card('Spenden', 'plDonate')}
+ ${card(gl('Länderkammer'), 'plChamber')}`, + }[tab]; + el.innerHTML = `
+
${Object.entries(TABS).map(([k, v]) => ``).join('')}
+
${body}
`; +} + +function render() { + if (S.view !== 'parlament') return; + skeleton(); + if (tab === 'gesetz') renderGesetz(); + else if (tab === 'vorlagen') renderVorlagen(); + else if (tab === 'parteien') renderParteien(); + else renderHaushalt(); +} + +// ================================================================ Gesetzgebung +function effectChips(effects, sectors) { + return Object.entries(effects ?? {}).sort((a, b) => b[1] - a[1]).map(([k, v]) => ` ${esc(sectors?.[k] ?? sectorName(k))} ${pct(v * 100, 1)}`).join(''); +} + +function voteHtml(pa) { + if (!pa.id || !pa.bill) { + const next = (pa.pipeline ?? []).find((e) => ['lesung', 'ausschuss'].includes(e.stage)); + return `

Aktuelle Abstimmung

Derzeit läuft keine Abstimmung im Parlament.${next ? ` Als Nächstes: ${esc(next.bill.title)} (${esc(next.stageLabel)}, Abstimmung in ca. ${countdown(next.stageEndsAt - now())}${next.stage === 'lesung' ? ' + Ausschuss' : ''}).` : ''}

`; } - const effects = Object.entries(pa.bill.effects ?? {}).sort((a, b) => b[1] - a[1]); const macro = Object.entries(pa.bill.macro ?? {}).filter(([, v]) => v); const left = Math.max(0, pa.endsAt - now()); const secretIn = pa.secretFrom - now(); const quorumOk = pa.voters >= pa.quorum; const total = (pa.yes ?? 0) + (pa.no ?? 0); const voted = pa.myVote !== undefined && pa.myVote !== null; - patch(el.querySelector('.pa-main'), ` -
-

${esc(pa.source)} · Vorlage ${esc(AXIS[pa.bill.axis] ?? pa.bill.axis ?? '')}

+ return `
+

Abstimmung im Parlament · ${esc(AXIS[pa.bill.axis] ?? pa.bill.axis ?? '')} · ${esc(SOURCE[pa.source] ?? pa.source)}${pa.compromise ? ' Kompromissfassung' : ''}${pa.proposer ? ` · eingebracht von ${player(pa.proposer)}` : ''}

${esc(pa.bill.title)}

Abstimmung endet ${when(pa.endsAt)} – noch ${countdown(left)}. ${pa.secret ? 'Verdeckte Schlussphase' : secretIn > 0 ? `Verdeckte Schlussphase ab ${when(pa.secretFrom)}.` : ''}

Erwartete Wirkung auf Unternehmensgewinne

-
${effects.map(([k, v]) => ` ${esc(pa.sectors?.[k] ?? k)} ${pct(v * 100, 0)}`).join('')}
- ${macro.length ? `

Makro: ${macro.map(([k, v]) => `${esc(MACRO[k] ?? k)} ${v > 0 ? '+' : '−'}${num(Math.abs(v), 2)} Pkt.`).join(' · ')} – wirkt ${int(pa.inForceDays)} Handelstage nach Beschluss.

` : ''} +
${effectChips(pa.bill.effects, pa.sectors)}
+

${macro.length ? `Makro: ${macro.map(([k, v]) => `${esc(MACRO[k] ?? k)} ${ppt(v)} Pkt.`).join(' · ')} · ` : ''}Haushalt: ${costText(pa.bill.cost)} · wirkt ${int(pa.inForceDays)} Handelstage nach Verkündung.

Markterwartung

${frac(pa.probability, 0)}
-

Annahmewahrscheinlichkeit, die die Kurse bereits einpreisen. Ohne Spielerstimmen rechnet der Markt mit ${int(pa.baseline)} % Ja-Anteil der Fraktionen.

+

Wahrscheinlichkeit, dass das Gesetz am Ende in Kraft tritt (Parlament ${frac(pa.pParl, 0)} × ${gl('Länderkammer')} ${frac(pa.pChamber, 0)} × Gericht ${frac(pa.pCourt, 0)}). Ohne Spielerstimmen rechnet der Markt mit ${int(pa.baseline)} % Ja-Anteil der Fraktionen.

Spielerstimmen

@@ -65,37 +157,370 @@ function render() { ${pa.myConflict ? ` Du stehst im Interessenregister (${int(pa.myConflict)} % deines Depots in betroffenen Sektoren).` : ''} Handel in betroffenen Werten nach deiner Stimmabgabe in der verdeckten Phase prüft die Börsenaufsicht.

` : '

Zum Abstimmen bitte .

'} -
-
-

Interessenregister

- ${pa.register?.length ? `${pa.register.map((r) => ``).join('')}
SpielerDepotanteilStimme
${player(r.name)}${int(r.pct)} %${r.yes === null ? 'verdeckt' : r.yes ? 'Ja' : 'Nein'}
` - : '

Keine Einträge. Wer mit mind. 20 % des Depots in betroffenen Sektoren abstimmt, wird hier geführt.

'} -
-

Beschlossen, noch nicht in Kraft

- ${pa.laws?.length ? `
    ${pa.laws.map((l) => `
  • 📜 ${esc(l.title)} – tritt an Handelstag ${int(l.inForceDay)} in Kraft${S.market ? ` (in ${int(Math.max(0, l.inForceDay - S.market.day))} T)` : ''}
  • `).join('')}
` : '

Keine.

'} -
-
-

Letzte Abstimmungen

- ${pa.history?.length ? ` - ${pa.history.map((h) => ``).join('')}
VorlageErgebnisJa-AnteilErwartetSpielerZeit
${esc(h.title)}${h.passed ? '✓ angenommen' : '✗ abgelehnt'}${Math.abs((h.passed ? 1 : 0) - h.expected) > 0.5 ? ' Überraschung' : ''}${frac(h.share, 0)}${frac(h.expected, 0)}${int(h.playerYes)}/${int(h.playerVotes)}${h.conflicts ? ` (${int(h.conflicts)} Register)` : ''}${when(h.ts)}
` : '

Noch keine.

'} -
`); - renderComments($('#paComments'), `bill:${pa.id}`); +

Interessenregister

+ ${pa.register?.length ? `
${pa.register.map((r) => ` + + `).join('')}
SpielerRolleDepotanteil betroffenStimme
${player(r.name)}${[r.proposer ? 'Antragsteller/in' : '', r.mp ? 'Abgeordnete/r' : '', r.pct ? 'Interessen' : ''].join(' ') || '–'}${r.pct ? `${int(r.pct)} %` : '–'}${r.yes === null || r.yes === undefined ? 'verdeckt' : r.yes ? 'Ja' : 'Nein'}
` + : '

Keine Einträge. Geführt werden Abgeordnete aus Spielerparteien, Antragsteller und wer mit mind. 20 % des Depots in betroffenen Sektoren abstimmt.

'} +
`; +} + +function stepper(e) { + const idx = STAGES.findIndex(([k]) => k === e.stage); + const court = e.stage === 'gericht' || (e.bill.legal ?? 0) > 0; + return `
    ${STAGES.map(([k, l], i) => { + const cls = i < idx ? 'done' : i === idx ? 'cur' : 'todo'; + const opt = k === 'gericht'; + return `
  1. ${opt ? `(${esc(l)})` : esc(l)}
  2. `; + }).join('')}
`; +} + +function pipelineHtml(pa) { + const list = pa.pipeline ?? []; + if (!list.length) return '

Keine Vorlagen im Verfahren.

'; + return `
    ${list.map((e) => `
  • +
    ${esc(e.bill.title)} + ${esc(SOURCE[e.source] ?? e.source)} + ${e.compromise ? 'Kompromiss' : ''} + ${e.proposer ? `von ${player(e.proposer)}` : ''}
    + ${stepper(e)} +

    ${esc(e.stageLabel)} endet in ${countdown(e.stageEndsAt - now())} · ${esc(AXIS[e.bill.axis] ?? e.bill.axis ?? '')}

    +
    + Parlament ${frac(e.pParl, 0)} + ${gl('Länderkammer')} ${frac(e.pChamber, 0)} + ${gl('Normenkontrolle', 'Gericht')} ${frac(e.pCourt, 0)} + Inkrafttreten ${frac(e.probability, 0)} +
    +

    Kosten: ${costText(e.bill.cost)} · Rechtsrisiko: ${frac(e.bill.legal ?? 0, 0)} · Fraktionen ca. ${int(e.baseline)} % Ja

    +
    ${effectChips(e.bill.effects, e.sectors)}
    +
  • `).join('')}
+

Ablauf: Erste Lesung → Ausschuss (evtl. Kompromissfassung) → Abstimmung → ${gl('Länderkammer')} → bei rechtlich umstrittenen Gesetzen ggf. ${gl('Normenkontrolle')} beim Verfassungsgericht. Die Kurse preisen die Wahrscheinlichkeit des Inkrafttretens laufend ein.

`; +} + +function historyHtml(pa) { + if (!pa.history?.length) return '

Noch keine.

'; + return ` + ${pa.history.map((h) => ` + + + + `).join('')}
VorlageErgebnisHerkunftJa-AnteilErwartetSpielerZeit
${esc(h.title)}${h.passed ? '✓ beschlossen' : '✗ gescheitert'}${Math.abs((h.passed ? 1 : 0) - (h.expected ?? 0.5)) > 0.5 ? ' Überraschung' : ''}${esc(h.reason ?? '')}${esc(SOURCE[h.source] ?? h.source ?? '–')}${h.proposer ? `${esc(h.proposer)}` : ''}${Number.isFinite(h.share) ? frac(h.share, 0) : '–'}${frac(h.expected, 0)}${int(h.playerYes)}/${int(h.playerVotes)}${h.conflicts ? ` (${int(h.conflicts)} Register)` : ''}${when(h.ts)}
`; +} + +function renderGesetz() { + const pa = S.parliament; + if (!pa) { patch($('#plVote'), '

Lade …

'); return; } + patch($('#plVote'), voteHtml(pa)); + patch($('#plPipe'), pipelineHtml(pa)); + patch($('#plLaws'), pa.laws?.length ? `
    ${pa.laws.map((l) => `
  • 📜 ${esc(l.title)} – Handelstag ${int(l.inForceDay)}${S.market ? ` (in ${int(Math.max(0, l.inForceDay - S.market.day))} T)` : ''}${l.cost ? ` · Haushalt ${ppt(l.cost)} % BIP` : ''}
  • `).join('')}
` : '

Keine.

'); + patch($('#plHist'), historyHtml(pa)); + const c = $('#paComments'); + if (pa.id) renderComments(c, `bill:${pa.id}`); + else if (c._commentsTarget !== null) { c._commentsTarget = null; c._html = null; c.innerHTML = '

Die Debatte öffnet mit der nächsten Abstimmung.

'; } +} + +// ================================================================ Vorlagen +function propPreview() { + const box = $('#propPreview'); + if (!box) return; + const tk = $('#propTpl')?.value, sec = $('#propSector')?.value; + const t = S.info?.billTemplates?.[tk]; + if (!t || !sec) { box.innerHTML = ''; return; } + const title = `${t.title ?? t.label} ${S.info?.sectorPhrase?.[sec] ?? ''}`.trim(); + box.innerHTML = `

„${esc(title)}“

+
Wirkung auf Gewinne
${arrow(t.eff)} ${esc(sectorName(sec))} ${pct(t.eff * 100, 1)}
+
Haushalt
${costText(t.cost)}
+
Rechtsrisiko
${frac(t.legal ?? 0, 0)}${t.legal ? ' (mögliche Normenkontrolle)' : ''}
+
Politische Richtung
${esc(AXIS[t.axis] ?? t.axis)}
`; +} + +function renderVorlagen() { + const pa = S.parliament, gv = S.government; + const me = gv?.me; + const mine = (pa?.proposals ?? []).find((x) => x.mine); + const needed = pa?.proposals?.[0]?.needed; + const key = `${loggedIn()}|${me?.party ?? ''}|${mine?.id ?? ''}|${S.info ? 1 : 0}`; + const tpls = Object.entries(S.info?.billTemplates ?? {}); + const secs = Object.keys(S.info?.sectorPhrase ?? S.info?.sectors ?? {}); + const explain = `

Nur Parteimitglieder können Vorlagen einbringen – eine offene Vorlage je Spieler. Sie kommt ins Verfahren, sobald genug Spieler mitzeichnen${needed ? ` (${int(needed)} inkl. dir)` : ''}; Regierungsmitglieder brauchen keine Mitzeichner. Ohne Unterstützung verfällt sie nach 7 Tagen.

`; + let form; + if (!loggedIn()) form = `

Zum Einbringen bitte .

${explain}`; + else if (!me?.party) form = `

Du bist in keiner Partei.

${explain}`; + else if (mine) form = `

Du hast bereits „${esc(mine.title)}“ eingebracht. Ziehe sie zurück, um eine neue Vorlage einzubringen.

${explain}`; + else { + form = `
+
+
+
+
${explain}`; + } + if (patchOnce($('#plPropForm'), key, form)) propPreview(); + const props = pa?.proposals ?? []; + patch($('#plProps'), props.length ? `
    ${props.map((x) => `
  • +
    ${esc(x.title)}${x.byGov ? ' Regierung' : ''}${x.mine ? ' deine' : ''}
    +

    von ${player(x.by)}${x.party ? ` (${esc(x.party)})` : ''} · ${when(x.ts)} · ${esc(AXIS[x.axis] ?? x.axis ?? '')}

    +
    ${effectChips(x.effects)}
    +

    Haushalt: ${costText(x.cost)}

    +
    ${meter((x.cosigners + 1) / Math.max(1, x.needed), { label: 'Unterstützer', cls: x.cosigners + 1 >= x.needed ? 'ok' : '' })}${int(x.cosigners + 1)} / ${int(x.needed)} Unterstützer + ${loggedIn() && !x.mine ? `` : ''} + ${x.mine ? `` : ''}
    +
  • `).join('')}
` : '

Keine offenen Vorlagen. Bring die erste ein!

'); +} + +// ================================================================ Parteien & Wahl +function posBars(pos) { + return `
${Object.entries(POS).map(([k, [l, hint]]) => { + const v = Math.max(-1, Math.min(1, Number(pos?.[k]) || 0)); + const left = v < 0 ? 50 + v * 50 : 50; + return `${esc(l)}`; + }).join('')}
`; +} + +function noConfHtml(gv) { + const nc = gv.noConfidence; + if (!nc) return ''; + return `

${gl('Misstrauensvotum')} läuft ${countdown(nc.endsAt - now())}

+

${esc((nc.alt ?? []).join('/'))} wollen die Regierung ablösen. ${int(nc.voters)} Spielerstimmen bisher.

+ ${loggedIn() ? `
+ +
` : '

Zum Abstimmen bitte .

'} +

Ein erfolgreiches Misstrauensvotum bringt eine neue Koalition und erhöht kurzfristig die Schwankungen am Markt.

`; +} + +function renderParteien() { + const gv = S.government; + if (!gv) { patch($('#plSeats'), '

Lade …

'); return; } + const coal = new Set(gv.coalition?.parties ?? []); + patch($('#plNoConf'), noConfHtml(gv)); + // Sitze + const seated = gv.parties.filter((p) => p.seats > 0).sort((a, b) => (a.pos?.markt ?? 0) - (b.pos?.markt ?? 0)); + paint($('#plHemi'), hemicycle(seated.map((p) => ({ short: p.short, color: color(p.color), seats: p.seats, coalition: coal.has(p.id) })), gv.seatsTotal)); + $('#plSeatsMeta').textContent = `${int(gv.seatsTotal)} Sitze`; + patch($('#plSeats'), `
    ${seated.map((p) => `
  • ${swatch(p.color)}${esc(p.short)} ${esc(p.name)}${int(p.seats)}${coal.has(p.id) ? 'Reg.' : ''}
  • `).join('')}
+

Links staatsnah, rechts marktliberal. Umrandete Punkte: Regierungsparteien. ${gl('Sperrklausel')}: ${frac(gv.threshold, 0)}.

`); + // Regierung + const c = gv.coalition; + const mins = gv.ministers ?? []; + patch($('#plGov'), c ? `

${c.parties.map(partyLabel).join(' + ')} · ${int(c.seats)} von ${int(gv.seatsTotal)} Sitzen

+

Regierungschef/in: ${esc(c.head)} seit ${when(c.formedAt)}

+

Koalitionsvertrag

+
    ${c.agenda.map((a) => `
  • ${esc(a.title)}${a.done ? ' (umgesetzt)' : ''}
  • `).join('')}
+

Kabinett

+
+ ${mins.map((m) => ``).join('')}
RessortLeitungParteiSektoren (nur Abbau)
${esc(ministryName(m.id))}${m.player ? `${player(m.name)} Spieler` : esc(m.name)}${esc(m.party ?? '–')}${(m.sectors ?? []).map((s) => esc(sectorName(s))).join(', ')}
` + : '

Keine Mehrheit – geschäftsführende Regierung.

'); + // Wahl + const e = gv.election ?? {}; + const ballot = gv.parties.filter((p) => p.onBallot); + const lr = gv.lastResult; + patch($('#plElection'), `${e.done ? '

Die Wahl dieser Legislatur ist vorbei. Die nächste findet zur Mitte der nächsten Saison statt.

' + : `

Wahl ${when(e.at)} – in ${countdown(e.at - now())}

`} +

${int(e.voters)} Spielerstimmen · Gewicht der Spielerstimmen: ${frac(e.weight, 0)} (0 % bis zum Quorum; sonst mischt sich das Spielerergebnis mit den Umfragen)

+ ${!e.done && loggedIn() ? `

Stimmzettel

${ballot.map((p) => ``).join('')}
+

${e.myVote ? `Deine Stimme: ${esc(partyOf(e.myVote)?.short ?? e.myVote)} – bis zur Wahl änderbar.` : 'Du hast noch nicht gewählt.'} Spielerparteien stehen ab ${int(gv.minMembers)} Mitgliedern auf dem Stimmzettel.

` + : !e.done ? '

Zum Wählen bitte .

' : ''} + ${lr ? `

${lr.initial ? 'Ausgangslage der Legislatur' : 'Letztes Wahlergebnis'}

+ + ${Object.entries(lr.shares ?? {}).sort((a, b) => b[1] - a[1]).map(([id, v]) => ``).join('')}
ParteiStimmenSitze
${partyLabel(id)}${frac(v, 1)}${int(lr.seats?.[id] ?? 0)}
+ ${lr.initial ? '' : `

${int(lr.turnout)} Spielerstimmen${Number.isFinite(lr.weight) ? ` · Gewicht ${frac(lr.weight, 0)}` : ''}

`}` : ''}`); + // Umfragen + const polls = gv.polls ?? []; + const last = polls[0]; + const pollRows = gv.parties.filter((p) => p.onBallot).map((p) => ({ p, v: last?.shares?.[p.id] ?? p.projected ?? 0 })).sort((a, b) => b.v - a.v); + const maxV = Math.max(0.01, ...pollRows.map((r) => r.v)); + patch($('#plPolls'), `

${last ? `${esc(last.institute)} · Tag ${int(last.day)}` : 'Noch keine veröffentlichte Umfrage – Projektion'}

+ ${pollRows.map(({ p, v }) => `
${swatch(p.color)}${esc(p.short)}${frac(v, 1)}
`).join('')}`); + const chron = [...polls].reverse(); + const shown = gv.parties.filter((p) => chron.some((x) => x.shares?.[p.id] !== undefined)); + paint($('#plPollChart'), lineChart(shown.map((p) => ({ name: p.short, color: color(p.color), points: chron.filter((x) => x.shares?.[p.id] !== undefined).map((x) => ({ x: x.day, y: x.shares[p.id] * 100 })) })), { + legend: true, yFmt: (v) => `${num(v, 0)} %`, xFmt: (d) => `Tag ${d}`, hlines: [{ y: (gv.threshold ?? 0.05) * 100, label: '5-%-Hürde' }], yMin: 0, + empty: 'Der Verlauf erscheint nach den ersten Umfragen', hoverFmt: (pt) => `Tag ${pt.x}: ${num(pt.y, 1)} %`, + })); + // Parteien + const me = gv.me; + patch($('#plParties'), ` + ${gv.parties.map((p) => ` + + `).join('')}
ParteiPositionenSitzeUmfrageMitgliederAktion
${swatch(p.color)}${esc(p.short)} ${esc(p.name)}${p.npc ? '' : ` Spielerpartei${p.onBallot ? '' : ` nicht auf dem Stimmzettel`}`} + ${p.npc ? '' : `Gründer/in ${esc(p.founder ?? '–')}${p.memberNames?.length ? ` · ${p.memberNames.map((n) => esc(n)).join(', ')}` : ''}${p.funds ? ` · Kasse ${eur(p.funds, 0)}` : ''}`}${posBars(p.pos)}${int(p.seats)}${frac(p.poll ?? p.projected, 1)}${p.npc ? '–' : int(p.members)}${!loggedIn() ? '' : me?.party === p.id ? '' : me?.party ? '' : ``}
+

Positionen von −1 bis +1: ${Object.values(POS).map(([l, h]) => `${esc(l)} (${esc(h)})`).join(' · ')}.

`); + // Mein Amt + let office; + if (!loggedIn()) office = '

Bitte .

'; + else { + const mp = partyOf(me?.party); + office = `

Partei: ${mp ? `${swatch(mp.color)}${esc(mp.name)} (${esc(mp.short)})` : 'keine'}${me?.mp ? ' · Abgeordnete/r' : ''}

+ ${me?.office ? `

${esc(me.office.ministry)}

+ ${me.office.sectors?.length ? `

Handelsbeschränkung (Interessenkonflikt): Aktien aus ${me.office.sectors.map((s) => esc(sectorName(s))).join(', ')} darfst du nur verkaufen bzw. Short-Positionen eindecken – kein Positionsaufbau, solange du im Amt bist. Orders dagegen lehnt die Börse ab.

` : '

Als Regierungschef/in gilt keine sektorbezogene Handelsbeschränkung.

'}
` + : `

Kein Regierungsamt. Sitzt deine Spielerpartei in der Koalition, besetzen ihre Mitglieder Ministerien – wer ein Ressort leitet, darf Aktien der zugehörigen Sektoren nur noch abbauen.

`} + ${me?.mp ? '

Als Abgeordnete/r stehst du bei Abstimmungen im Interessenregister.

' : ''}`; + } + patch($('#plOffice'), office); + // Partei gründen + const fkey = `${loggedIn()}|${me?.party ?? ''}`; + let found; + if (!loggedIn()) found = '

Zum Gründen bitte .

'; + else if (me?.party) found = `

Du bist bereits Mitglied einer Partei. Zum Gründen erst austreten.

`; + else { + found = `
+
+
+ ${Object.entries(POS).map(([k, [l, hint]]) => `
`).join('')} +

Gründung kostet ${eur(gv.foundCost ?? 5000, 0)} aus dem Hauptdepot. Auf den Stimmzettel kommt die Partei ab ${int(gv.minMembers)} Mitgliedern; mit ${frac(gv.threshold, 0)} der Stimmen zieht sie ins Parlament ein. Positionen bestimmen, welche Vorlagen deine Fraktion unterstützt.

+
`; + } + patchOnce($('#plFound'), fkey, found); +} + +// ================================================================ Haushalt & Lobby +function renderHaushalt() { + const gv = S.government; + if (!gv) { patch($('#plBudget'), '

Lade …

'); return; } + const b = gv.budget ?? {}; + patch($('#plBudget'), `
+
Schulden${num(b.debt, 1)} %des BIP
+
Defizit${num(b.deficit, 2)} %des BIP
+
davon strukturell${num(b.structural, 2)} %
+
${gl('Rating')}${esc(b.rating ?? '–')}
+
${gl('Risikoaufschlag')}${num(b.riskPremium, 2)} Pp.
+
Lage${b.crisis ? '⚠ Haushaltskrise' : '✓ stabil'}
+
+

Beschlossene Gesetze verändern das strukturelle Defizit (Kosten in % BIP p. a.). Schulden über 80 % und Defizite über 3 % erhöhen den Risikoaufschlag auf Wiborien-Anleihen; über 1,2 Pp. gilt das Land als in der Haushaltskrise – das kostet die Regierung Zustimmung.

`); + const hist = b.history ?? []; + paint($('#plDebt'), lineChart([{ name: 'Schulden', color: '#f5b942', points: hist.map((x) => ({ x: x.day, y: x.debt })) }], { yFmt: (v) => `${num(v, 0)} %`, xFmt: (d) => `Tag ${d}`, hlines: [{ y: 80, label: '80 %' }], empty: 'Verlauf ab dem nächsten Handelstag', hoverFmt: (p) => `Tag ${p.x}: ${num(p.y, 1)} %` })); + paint($('#plDef'), lineChart([{ name: 'Defizit', color: '#ff5c5c', points: hist.map((x) => ({ x: x.day, y: x.deficit })) }], { yFmt: (v, s) => `${num(v, s < 1 ? 1 : 0)} %`, xFmt: (d) => `Tag ${d}`, hlines: [{ y: 3, label: '3 %' }], empty: 'Verlauf ab dem nächsten Handelstag', hoverFmt: (p) => `Tag ${p.x}: ${num(p.y, 2)} %` })); + const lobby = gv.lobby ?? []; + patch($('#plLobby'), lobby.length ? ` + ${lobby.map((l) => ``).join('')}
ZeitSpender/inParteiBetragInteresse
${when(l.ts)}${player(l.name)}${esc(l.party)}${eur(l.amount, 0)}${esc(sectorName(l.sector))} ${esc(l.direction)}
` + : '

Noch keine Einträge.

'); + const dkey = `${loggedIn()}|${gv.parties.map((p) => p.id).join(',')}`; + let form; + if (!loggedIn()) form = '

Zum Spenden bitte .

'; + else { + form = `
+
+
+
+
Richtung
+

Spenden landen mit deinem Namen im öffentlichen ${gl('Lobbyregister')}. Vorlagen, die dem Sektor nützen (Förderung) bzw. schaden (Belastung), kommen eher auf die Tagesordnung, Regierungsfraktionen stimmen eher zu. Das Geld ist weg.

+
`; + } + patchOnce($('#plDonate'), dkey, form); + const ch = gv.chamber?.pos ?? {}; + patch($('#plChamber'), `${posBars(ch)} +

Die ${gl('Länderkammer')} spiegelt die Stimmung zur letzten Wahl (mit Streuung). Je weiter eine Vorlage von ihrer Haltung entfernt ist, desto eher legt sie Einspruch ein – die Wahrscheinlichkeit dafür steht bei jeder Vorlage im Verfahren.

+ ${gv.chamber?.formedAt ? `

Zusammensetzung seit ${when(gv.chamber.formedAt)}.

` : ''}`); +} + +// ================================================================ Aktionen +async function act(type, data, ok, apply) { + try { + const r = await request(type, data); + apply?.(r); + if (ok) toast(ok, 'ok'); + return r; + } catch (err) { toast(err.message, 'err'); return null; } +} +const applyGov = (r) => { if (r?.government) mergeGovernment(r.government, true); }; +const applyPa = (r) => { if (r?.parliament) mergeParliament(r.parliament, true); }; +const refreshMe = async () => { try { S.profile = (await request('me')).profile; changed('profile'); } catch { /* egal */ } }; + +async function onClick(e) { + const a = e.target.closest('[data-act]'); + if (!a) return; + const k = a.dataset.act; + if (k === 'polSub') { setPolTab(a.dataset.tab); render(); $('#v-parlament .pol-tabs [aria-selected="true"]')?.focus(); refresh(); return; } + if (k === 'vote') { + if (!S.parliament?.id) return; + a.disabled = true; + await act('vote', { billId: S.parliament.id, yes: a.dataset.yes === '1' }, `Stimme abgegeben: ${a.dataset.yes === '1' ? 'Ja' : 'Nein'}`, applyPa); + a.disabled = false; + } else if (k === 'cosign') { + const was = a.getAttribute('aria-pressed') === 'true'; + await act('cosign', { id: a.dataset.id }, was ? 'Mitzeichnung zurückgezogen.' : 'Vorlage mitgezeichnet.', applyPa); + } else if (k === 'withdrawBill') { + if (await ask({ title: 'Vorlage zurückziehen?', text: 'Die Vorlage und alle Mitzeichnungen werden gelöscht.', ok: 'Zurückziehen', danger: true })) await act('withdrawBill', { id: a.dataset.id }, 'Vorlage zurückgezogen.', applyPa); + } else if (k === 'elVote') { + await act('electionVote', { partyId: a.dataset.id }, `Stimme für ${partyOf(a.dataset.id)?.short ?? ''} abgegeben – bis zur Wahl änderbar.`, applyGov); + } else if (k === 'ncVote') { + await act('noConfidenceVote', { yes: a.dataset.yes === '1' }, 'Stimme zum Misstrauensvotum abgegeben.', applyGov); + } else if (k === 'partyJoin') { + if (await act('partyJoin', { partyId: a.dataset.id }, `Willkommen in der ${a.dataset.name}!`, applyGov)) refreshMe(); + } else if (k === 'partyLeave') { + if (!(await ask({ title: 'Aus der Partei austreten?', text: 'Ämter gehen verloren. Bist du das letzte Mitglied einer Spielerpartei, löst sie sich auf.', ok: 'Austreten', danger: true }))) return; + if (await act('partyLeave', {}, 'Du bist ausgetreten.', applyGov)) refreshMe(); + } +} + +async function onSubmit(e) { + const f = e.target; + if (f.id === 'propForm') { + e.preventDefault(); + const t = S.info?.billTemplates?.[$('#propTpl').value]; + const title = `${t?.title ?? t?.label ?? ''} ${S.info?.sectorPhrase?.[$('#propSector').value] ?? ''}`; + if (!(await ask({ title: 'Vorlage einbringen?', html: `

„${esc(title)}“

Die Vorlage erscheint öffentlich mit deinem Namen. Sie kommt ins Verfahren, sobald genug Spieler mitzeichnen.

`, ok: 'Einbringen' }))) return; + await act('propose', { template: $('#propTpl').value, sector: $('#propSector').value }, 'Vorlage eingebracht – jetzt Mitzeichner finden!', applyPa); + } else if (f.id === 'foundForm') { + e.preventDefault(); + const name = $('#fpName').value.trim(), short = $('#fpShort').value.trim().toUpperCase(); + if (name.length < 3) { toast('Parteiname: 3–32 Zeichen', 'err'); $('#fpName').focus(); return; } + if (!/^[A-ZÄÖÜ0-9]{2,5}$/.test(short)) { toast('Kürzel: 2–5 Großbuchstaben oder Ziffern', 'err'); $('#fpShort').focus(); return; } + const pos = Object.fromEntries(Object.keys(POS).map((k) => [k, Number($(`#fp-${k}`).value)])); + const cost = S.government?.foundCost ?? 5000; + const ok = await ask({ title: 'Partei gründen?', html: `

${esc(name)} (${esc(short)})

${Object.entries(POS).map(([k, [l]]) => `${esc(l)} ${num(pos[k], 1)}`).join(' · ')}

Die Gründung kostet ${eur(cost, 0)} (Registrierung, Satzung, Notar) aus deinem Hauptdepot – das Geld ist weg.

`, ok: `Gründen (${eur(cost, 0)})` }); + if (!ok) return; + if (await act('partyFound', { name, short, pos }, `Partei „${name}“ gegründet. Ab ${int(S.government?.minMembers ?? 3)} Mitgliedern steht sie auf dem Stimmzettel.`, applyGov)) refreshMe(); + } else if (f.id === 'donateForm') { + e.preventDefault(); + const partyId = $('#dParty').value, amount = Math.round(Number($('#dAmount').value)), sector = $('#dSector').value; + const direction = f.querySelector('input[name="dDir"]:checked')?.value ?? 'plus'; + const min = S.government?.lobbyMin ?? 5000; + if (!(amount >= min)) { toast(`Spenden ab ${eur(min, 0)}`, 'err'); $('#dAmount').focus(); return; } + const p = partyOf(partyId); + const ok = await ask({ + title: 'Spende bestätigen', danger: true, ok: `${eur(amount, 0)} spenden`, + html: `

${eur(amount, 0)} an ${esc(p?.name ?? partyId)} – Interesse: ${esc(sectorName(sector))} (${direction === 'minus' ? 'Belastung' : 'Förderung'}).

+

Die Spende wird öffentlich mit deinem Namen im Lobbyregister eingetragen. Das Geld wird sofort aus deinem Hauptdepot abgebucht und ist weg – es gibt keine Rendite und keine Erstattung.

`, + }); + if (!ok) return; + await act('lobby', { partyId, amount, sector, direction }, 'Spende eingetragen.', applyGov); + } +} + +function onInput(e) { + const t = e.target; + if (t.id === 'propTpl' || t.id === 'propSector') propPreview(); + else if (t.dataset?.axis && t.id?.startsWith('fp-')) { const o = $(`#${t.id}-v`); if (o) o.textContent = num(Number(t.value), 1); } } export function initPolitics() { - document.addEventListener('click', async (e) => { - const a = e.target.closest('[data-act="vote"]'); - if (!a || !S.parliament) return; - a.disabled = true; - try { - const r = await request('vote', { billId: S.parliament.id, yes: a.dataset.yes === '1' }); - mergeParliament(r.parliament, true); - toast(`Stimme abgegeben: ${a.dataset.yes === '1' ? 'Ja' : 'Nein'}`, 'ok'); - } catch (err) { toast(err.message, 'err'); } finally { a.disabled = false; } - }); - sub('parliament', () => { if (S.view === 'parlament') render(); }); + document.addEventListener('click', onClick); + document.addEventListener('submit', onSubmit); + document.addEventListener('input', onInput); + document.addEventListener('change', onInput); + sub('parliament government profile', () => { if (S.view === 'parlament') render(); }); + // Stufenwechsel ohne Broadcast abfangen: fällige Stufen neu laden + let lastRefresh = 0; + setInterval(() => { + if (S.view !== 'parlament' || !S.parliament || now() - lastRefresh < 5000) return; + if ((S.parliament.pipeline ?? []).some((e) => e.stageEndsAt < now() - 1500)) { lastRefresh = now(); refresh(); } + }, 2000); } + +/** Persönliche Ansichten neu laden (Vorlagen und Mitzeichnungen werden nicht an alle gesendet) */ +async function refresh() { + try { + const [pa, gv] = await Promise.all([request('parliament'), request('government')]); + mergeParliament(pa.parliament, true); + mergeGovernment(gv.government, true); + } catch { /* egal */ } +} + export async function showParliament() { render(); - try { mergeParliament((await request('parliament')).parliament, true); } catch { /* egal */ } + try { + const [pa, gv] = await Promise.all([request('parliament'), loggedIn() || !loadedGov || !S.government ? request('government') : null]); + mergeParliament(pa.parliament, true); + if (gv) { loadedGov = true; mergeGovernment(gv.government, true); } + } catch { /* egal */ } } diff --git a/server/public/js/state.js b/server/public/js/state.js index c16830a..12fb504 100644 --- a/server/public/js/state.js +++ b/server/public/js/state.js @@ -8,7 +8,7 @@ export const S = { tickerMap: new Map(), prevLast: new Map(), // für Aufblitzen bei Kursänderung news: [], events: [], - parliament: null, leaderboard: null, motd: '', + parliament: null, government: null, leaderboard: null, motd: '', profile: null, // eigenes Profil (null = nicht angemeldet) portfolio: null, battlePortfolio: null, battle: null, fundPortfolio: null, // Clan-Fonds (nur für den Fondsmanager) diff --git a/server/public/js/trade.js b/server/public/js/trade.js index c3b04fb..bbf83eb 100644 --- a/server/public/js/trade.js +++ b/server/public/js/trade.js @@ -1,7 +1,7 @@ // Handel: Marktliste, Aktienansicht (Kopf, Chart, Detail-Tabs), Orderticket, Orderbuch und Umsätze. import { S, sub, changed, loggedIn, activePortfolio } from './state.js'; import { request } from './net.js'; -import { CandleChart } from './charts.js'; +import { CandleChart, paint, curveChart } from './charts.js'; import { toast, ask, gl } from './ui.js'; import { esc, $, $$, num, int, eur, compact, pct, frac, chg, dirCls, arrow, countdown, now, when, time, timeS, ago, patch, player, meter, safeUrl, store } from './util.js'; import { renderComments } from './social.js'; @@ -21,6 +21,7 @@ let chart = null; let stab = 'company'; let side = 'buy'; let navigate = () => {}; +let lastNewsId = null; export const ticker = (sym = S.symbol) => S.tickerMap.get(sym); @@ -31,25 +32,58 @@ function statusBadges(t, { long = false } = {}) { if (t.status === 'vola') b.push(`${long ? gl('Volatilitätsunterbrechung', 'Volatilitätsunterbrechung') : 'VU'} ${t.volaEndsAt ? `${countdown(t.volaEndsAt - now())}` : ''}`); if (t.htb) b.push(`HTB`); if (Number.isFinite(t.earningsIn) && t.earningsIn >= 0 && t.earningsIn <= 3) b.push(`${t.earningsIn === 0 ? 'Zahlen heute' : `Zahlen in ${t.earningsIn} T`}`); - if (Number.isFinite(t.exDivIn) && t.exDivIn >= 0 && t.exDivIn <= 3) b.push(`${t.exDivIn === 0 ? 'Ex-Tag heute' : `Ex-Div. in ${t.exDivIn} T`}`); + if (t.kind === 'bond' && Number.isFinite(t.exDivIn)) b.push(`${t.exDivIn <= 0 ? 'Kupon heute' : `Kupon in ${t.exDivIn} T`}`); + else if (Number.isFinite(t.exDivIn) && t.exDivIn >= 0 && t.exDivIn <= 3) b.push(`${t.exDivIn === 0 ? 'Ex-Tag heute' : `Ex-Div. in ${t.exDivIn} T`}`); + if (t.corp === 'offer') b.push(`${long ? gl('Übernahmeangebot', 'Übernahme') : 'Übernahme'}`); + if (t.corp === 'trial') b.push('Studie'); return b.join(''); } +// ================================================================ Anlageklassen & Einheiten +const CLASS_ORDER = ['stock', 'bond', 'commodity', 'fx']; +const CLASS_FALLBACK = { stock: 'Aktien', bond: 'Anleihen', commodity: 'Rohstoffe', fx: 'Devisen' }; +export const kindOf = (t) => t?.kind ?? 'stock'; +export const className = (k) => S.info?.assetClasses?.[k] ?? CLASS_FALLBACK[k] ?? k; +/** Preiseinheit eines Instruments */ +export function unitOf(t) { + if (!t) return ''; + if (kindOf(t) === 'bond') return 'je 100 € Nennwert'; + return { OEL: 'je Barrel', GOLD: 'je 10 g', USD: 'je 100 $' }[t.symbol] ?? (kindOf(t) === 'stock' ? 'je Aktie' : 'je Stück'); +} +/** Was treibt den Preis (Rohstoffe/Devisen) */ +const DRIVERS = { + OEL: ['Weltkonjunktur (BIP-Wachstum über/unter Trend)', 'Marktstimmung', 'Förderentscheidungen des Petrolia-Kartells (Angebotsschocks, klingen über Wochen ab)', 'Wirkt zurück: teures Öl erhöht die Inflation und belastet Auto, Industrie und Handel – Energiewerte profitieren'], + GOLD: ['Realzins (Leitzins minus Inflation): fallende Realzinsen machen Gold attraktiver', 'Angst: schlechte Stimmung treibt den sicheren Hafen', 'Risikoaufschlag auf Wiborien-Anleihen (Zweifel an den Staatsfinanzen)'], + USD: ['Zinsdifferenz: Auslandszins minus Leitzins – sinkt der Leitzins relativ, wird der Dollar teurer', 'Risikoaufschlag Wiboriens (Kapitalflucht schwächt den Euro)', 'Wirkt zurück: teurer Dollar hilft Exporteuren und erhöht die Inflation'], +}; +const groupClosed = new Set(store.get('mgrpClosed', [])); + function renderMarketList() { const rules = S.account === 'battle' ? S.battlePortfolio?.rules : null; const visible = rules?.symbols ? S.tickers.filter((t) => rules.symbols.includes(t.symbol) || t.symbol === S.symbol) : S.tickers; const hidden = S.tickers.length - visible.length; - const rows = visible.map((t) => { + const row = (t) => { const prev = S.prevLast.get(t.symbol); const flash = prev !== undefined && prev !== t.last ? (t.last > prev ? 'flash-up' : 'flash-down') : ''; const blocked = rules?.symbols && !rules.symbols.includes(t.symbol); const ind = t.indicative && t.status !== 'continuous' ? `ind. ${num(t.indicative.price)} · ${compact(t.indicative.volume)} St.` : ''; + const extra = kindOf(t) === 'bond' ? `Rendite ${num(t.yield, 2)} % · Dur. ${num(t.duration, 1)}` : ''; return ` -
${statusBadges(t)}
+
${statusBadges(t)}
${num(t.last)}${ind} ${chg(t.change)}`; - }).join('') + (hidden ? `${hidden} weitere Aktien im Battle-Modus „3 Aktien“ ausgeblendet – für alle Aktien auf das Hauptdepot wechseln.` : ''); + }; + const kinds = [...new Set([...CLASS_ORDER, ...visible.map(kindOf)])]; + const multi = kinds.filter((k) => visible.some((t) => kindOf(t) === k)).length > 1; + const rows = kinds.map((k) => { + const list = visible.filter((t) => kindOf(t) === k); + if (!list.length) return ''; + if (!multi) return list.map(row).join(''); + const closed = groupClosed.has(k); + const shown = closed ? list.filter((t) => t.symbol === S.symbol) : list; + return `${shown.map(row).join('')}`; + }).join('') + (hidden ? `${hidden} weitere Werte im Battle-Modus „3 Aktien“ ausgeblendet – für alle Werte auf das Hauptdepot wechseln.` : ''); patch($('#mlist'), rows); const m = S.market; if (m) $('#marketMeta').textContent = `Tag ${m.day}`; @@ -125,22 +159,37 @@ function renderStock() { const t = ticker(); if (!t) return; const spread = t.bid && t.ask ? t.ask - t.bid : null; - const pe = t.pe ? num(t.pe, 1) : 'n. a.'; - patch($('#sHead'), ` -
-

${esc(t.symbol)}

${esc(t.name)} · ${esc(S.info?.sectors?.[t.sector]?.name ?? t.sector)}
-
${num(t.last)} € ${chg(t.change)}
-
${statusBadges(t, { long: true })}
-
-
+ const kind = kindOf(t); + const common = `
Geld / Brief
${num(t.bid)} / ${num(t.ask)}
${gl('Spread')}
${spread !== null ? num(spread) : '–'}
Hoch / Tief
${num(t.high)} / ${num(t.low)}
Eröffnung
${num(t.open)}
-
Volumen
${compact(t.volume)}
+
Volumen
${compact(t.volume)}
`; + let kv; + if (kind === 'stock') { + const pe = t.pe ? num(t.pe, 1) : 'n. a.'; + kv = `${common}
Börsenwert
${compact(t.mcap)} €
${gl('KGV')}
${pe}
-
${gl('Dividende', 'Div.-Rendite')}
${frac(t.divYield, 2)}
+
${gl('Dividende', 'Div.-Rendite')}
${frac(t.divYield, 2)}
`; + } else if (kind === 'bond') { + kv = `${common} +
${gl('Rendite')}
${num(t.yield, 2)} %
+
${gl('Duration')}
${num(t.duration, 1)} J.
+
${gl('Kupon')}
${Number.isFinite(t.exDivIn) ? (t.exDivIn <= 0 ? 'heute' : `in ${int(t.exDivIn)} T`) : '–'}
`; + } else { + kv = `${common} +
Volatilität p. a.
${frac(t.vol, 0)}
`; + } + patch($('#sHead'), ` +
+

${esc(t.symbol)}

${esc(t.name)} · ${esc(kind === 'stock' ? (S.info?.sectors?.[t.sector]?.name ?? t.sector) : className(kind))}
+
${num(t.last)} € ${chg(t.change)}
+
${statusBadges(t, { long: true })}
+
+ ${kind !== 'stock' ? `

Kurs in € ${esc(unitOf(t))} · gehandelt wie Aktien (Orderbuch, Auktionen, Leerverkauf möglich)

` : ''} +
${kv}
Leihzins p. a.
${frac(t.borrowRate, 1)}${t.htb ? ' HTB' : ''}
`); // Status-Hinweis (Auktion / Unterbrechung / geschlossen) @@ -166,15 +215,24 @@ function renderStock() { // ---------------------------------------------------------------- Detail-Tabs function renderStabs() { for (const b of $$('#sTabs [data-stab]')) b.setAttribute('aria-selected', String(b.dataset.stab === stab)); + const t0 = $('#sTabs [data-stab="company"]'); + const k0 = kindOf(ticker()); + const lbl = k0 === 'stock' ? 'Unternehmen' : k0 === 'bond' ? 'Anleihe' : k0 === 'fx' ? 'Devise' : 'Rohstoff'; + if (t0 && t0.textContent !== lbl) t0.textContent = lbl; + const t1 = $('#sTabs [data-stab="holders"]'); + if (t1) t1.textContent = k0 === 'stock' ? 'Aktionäre' : 'Halter'; const el = $('#sTabBody'); const c = S.company; if (stab === 'comments') { renderComments(el, `stock:${S.symbol}`); return; } el._commentsTarget = null; - if (!c || c.symbol !== S.symbol) { patch(el, '

Lade Unternehmensdaten …

'); return; } - if (stab === 'company') patch(el, companyHtml(c)); + if (!c || c.symbol !== S.symbol) { patch(el, '

Lade Daten …

'); return; } + if (stab === 'company') { + if (c.kind && c.kind !== 'stock') { patch(el, instrumentHtml(c)); paint($('#instCurve'), curveChart(c.curve)); } + else patch(el, companyHtml(c)); + } else if (stab === 'lending') patch(el, lendingHtml(c)); else if (stab === 'holders') patch(el, holdersHtml(c)); - else if (stab === 'news') patch(el, newsList(c.news, 'Keine Meldungen zu diesem Unternehmen.')); + else if (stab === 'news') patch(el, newsList(c.news, c.kind && c.kind !== 'stock' ? 'Keine Meldungen zu diesem Wertpapier.' : 'Keine Meldungen zu diesem Unternehmen.')); } function companyHtml(c) { @@ -200,9 +258,13 @@ function companyHtml(c) {
Tief ${num(a.low)} €Median ${num(a.target)} €Hoch ${num(a.high)} €
Einzelne Analysehäuser${a.ratings.map((r) => ``).join('')}
${esc(r.firm)}${esc(r.rating)}${num(r.target)} €
`; } + const sens = (x, what) => (Number.isFinite(x) && x !== 0 ? `${x > 0 ? '+' : '−'}${num(Math.abs(x), 2)} (${what} +10 % → Gewinn ${x > 0 ? '+' : '−'}${num(Math.abs(x) * 10, 1)} %)` : 'kaum betroffen'); + const office = S.government?.me?.office ?? S.profile?.office; + const conflict = office?.sectors?.includes(c.sector); const policy = (c.policy ?? []).length ? `

Wirkung beschlossener Gesetze

    ${c.policy.map((p) => `
  • ${esc(p.bill)}: ${pct(p.pct, 1)} auf den Gewinn ab Tag ${int(p.startDay)}
  • `).join('')}
` : ''; return ` + ${corpHtml(c)}

Profil

@@ -225,6 +287,9 @@ function companyHtml(c) { ${c.pendingDividend ? `
Nächste Dividende
${eur(c.pendingDividend)} · ${gl('Ex-Tag')} ${c.exDivIn === 0 ? 'heute' : `in ${int(c.exDivIn)} Handelstagen`}
` : ''}
Nächste Zahlen
${c.earningsIn <= 0 ? 'heute' : `in ${int(c.earningsIn)} Handelstagen`} · Konsens ${eur(c.consensus)}
${c.lastAuction?.price ? `
Letzte Auktion
${eur(c.lastAuction.price)} · ${int(c.lastAuction.volume)} St.
` : ''} +
Zuständiges Ministerium
${esc(c.ministry ?? '–')}${conflict ? ' dein Ressort' : ''}
+
Ölpreis-Empfindlichkeit
${sens(c.oilSens, 'Öl')}
+
Dollar-Empfindlichkeit
${sens(c.fxSens, 'Dollar')}
@@ -234,7 +299,135 @@ function companyHtml(c) {

Quartale: Gewinn je Aktie (Balken grün = Erwartung übertroffen, rot = verfehlt)

${bars}
- ${policy}`; + ${policy} + ${c.corporate?.history?.length ? `

Unternehmensereignisse

` : ''}`; +} + +const symLink = (sym, label = sym) => ``; + +/** Übernahmeangebot, Studie, Beherrschung – oben in der Unternehmensansicht */ +function corpHtml(c) { + const k = c.corporate; + if (!k) return ''; + const out = []; + const o = k.offer; + if (o) { + const target = o.role === 'target'; + const own = Math.max(0, S.portfolio?.positions?.find((x) => x.symbol === c.symbol)?.qty ?? 0); + const mine = o.myTender ?? 0; + const tender = !target ? `

${esc(c.name)} ist hier der Bieter. Bieter zahlen im Mittel zu viel – scheitert die Übernahme, erholt sich der Kurs meist etwas.

` + : loggedIn() ? `
+

Deine ${gl('Andienung')}: ${int(mine)} St.${mine ? ` → bei Erfolg ${eur(mine * o.price)}` : ''} · Bestand im Hauptdepot: ${int(own)} St.

+ ${own > 0 || mine ? `
+ + + ${mine ? `` : ''}
` + : '

Du hältst keine Aktien dieses Unternehmens im Hauptdepot.

'} +

Angedient wird aus dem Hauptdepot (höchstens dein Bestand, 0 = zurückziehen). Gelingt die Übernahme, werden die Aktien zum Angebotspreis gebührenfrei ausgebucht; scheitert sie, bleiben sie im Depot. Verkaufst du vorher, zählt nur der verbleibende Bestand.

` + : '

Zum Andienen bitte .

'; + out.push(`
+

${gl('Übernahmeangebot')}${target ? '' : ' – als Bieter'}

+

${target ? `${esc(o.bidderName)} (${symLink(o.bidder)}) bietet` : `${esc(c.name)} bietet für ${esc(o.targetName)} (${symLink(o.target)})`} ${eur(o.price)} je Aktie.

+
+
Angebotspreis${eur(o.price)}
+
Aufschlag${frac(o.premium, 0)}
+
Erfolgschance${frac(o.probability, 0)}
+
Annahmefrist${o.daysLeft <= 0 ? 'endet heute' : `${int(o.daysLeft)} Handelstage`}
+
Angedient (Spieler)${int(o.tenderedTotal)} St.
+ ${target ? `
Kurs → Angebot${pct((o.price / c.last - 1) * 100, 1)}
` : ''} +
+

${o.authority ? `Prüfung durch das ${esc(o.authority)} (gleiche Branche) – kann den Zusammenschluss untersagen.` : 'Keine kartellrechtliche Prüfung (verschiedene Branchen).'}

+ ${tender}
`); + } + const t = k.trial; + if (t) { + out.push(`
+

Studienergebnis erwartet

+
+
Wirkstoff${esc(t.drug)}Phase ${esc(t.phase)}
+
Ergebnis${t.daysLeft <= 0 ? 'heute' : `in ${int(t.daysLeft)} T`}
+
Erfolgschance${frac(t.probability, 0)}
+
bei Erfolg▲ ${pct(t.up * 100, 0)}
+
bei Misserfolg▼ ${pct(-t.down * 100, 0)}
+
+

Wirkung auf den Unternehmenswert. Der Kurs preist die Erfolgschance schon ein – bei der Veröffentlichung bewegt er sich nur um die Überraschung.

`); + } + const ctl = k.control; + if (ctl) { + out.push(`
+

Beherrscht von ${symLink(ctl.by)}

+

Abfindungsangebot für Minderheitsaktionäre: ${eur(ctl.floor)} je Aktie – noch ${int(ctl.daysLeft)} Handelstage. So lange dient es als Untergrenze für den Kurs.

`); + } + return out.join(''); +} + +/** Detailansicht für Anleihen, Rohstoffe und Devisen */ +function instrumentHtml(c) { + const i = c.info ?? {}; + const t = ticker(c.symbol); + const unit = unitOf(t ?? c); + const head = `

${esc(c.desc)}

`; + const auction = c.lastAuction?.price ? `
Letzte Auktion
${eur(c.lastAuction.price)} · ${int(c.lastAuction.volume)} St.
` : ''; + if (c.kind === 'bond') { + const cv = c.curve ?? {}; + const b = c.budget ?? {}; + return `${head} +
+
+

Anleihe

+
+
Restlaufzeit
${int(i.maturity)} Jahre (konstant)
+
${gl('Kupon')}
${num(i.coupon, 2)} % p. a., vierteljährlich
+
${gl('Rendite')}
${num(i.yield, 2)} %
+
${gl('Duration')}
${num(i.duration, 2)} Jahre (Rendite +1 Pp. ≈ Kurs −${num(i.duration, 1)} %)
+
Stückzinsen
${num(i.accrued, 3)} €
+
Kurs ohne Stückzinsen
${num(i.cleanPrice, 2)} € („clean“)
+
Kurs mit Stückzinsen
${num(c.last, 2)} € ${esc(unit)}
+
Nächster Kupon
${i.nextCouponIn <= 0 ? 'heute' : `in ${int(i.nextCouponIn)} Handelstagen`} · ${num(i.coupon / 4, 3)} € je 100 €
+
Volatilität p. a.
${frac(c.vol, 1)}
+ ${auction} +
+
+
+

${gl('Zinskurve')}

+
+

2 J. ${num(cv.y2, 2)} % · 10 J. ${num(cv.y10, 2)} % · Abstand ${num((cv.spread ?? 0) * 100, 0)} Bp. + ${cv.inverted ? 'invertiert' : 'normal'}

+

${cv.inverted ? 'Kurze Laufzeiten rentieren höher als lange – klassisches Rezessionssignal.' : 'Lange Laufzeiten rentieren höher als kurze.'} Leitzins ${num(c.rate, 2)} % · langfristiges Niveau ${num(cv.longNeutral, 2)} %.

+
+
+

Staatshaushalt Wiborien

+
+
Schulden${num(b.debt, 1)} %des BIP
+
Defizit${num(b.deficit, 1)} %des BIP
+
${gl('Rating')}${esc(b.rating ?? '–')}
+
${gl('Risikoaufschlag')}${num(b.riskPremium, 2)} Pp.
+
+

Hohe Schulden und Defizite treiben den Risikoaufschlag – er wächst mit der Laufzeit und drückt besonders lange Anleihen.

`; + } + const fx = c.kind === 'fx'; + const diff = Number.isFinite(c.foreignRate) ? c.foreignRate - c.rate : null; + return `${head} +
+
+

Kennzahlen

+
+
Kurs
${eur(t?.last ?? c.last)} ${esc(unit)}
+
Basiskurs
${eur(i.base)}
+
Seit Spielstart
${chg(i.base ? ((t?.last ?? c.last) / i.base - 1) * 100 : i.changeFromStart)}
+
Vortag
${eur(c.prevClose)}
+
Volatilität p. a.
${frac(c.vol, 0)} (normal ${frac(c.baseVol, 0)})
+ ${fx ? `
Zins im Ausland (USA)
${num(c.foreignRate, 2)} %
Leitzins Wiborien
${num(c.rate, 2)} %
+
Zinsdifferenz
${diff > 0 ? '+' : diff < 0 ? '−' : '±'}${num(Math.abs(diff), 2)} Pp. ${diff > 0 ? '(spricht für den Dollar)' : '(spricht für den Euro)'}
` : ''} + ${auction} +
+
+
+

Was den Preis treibt

+
    ${(DRIVERS[c.symbol] ?? ['Angebot und Nachfrage im Orderbuch', 'Konjunktur und Marktstimmung']).map((d) => `
  • ${esc(d)}
  • `).join('')}
+ ${fx ? '

Steigt der Kurs, bekommst du für 100 $ mehr Euro – der Euro ist schwächer geworden.

' : ''} +
+
`; } function lendingHtml(c) { @@ -267,9 +460,9 @@ function lendingHtml(c) { } function holdersHtml(c) { - if (!c.holders?.length) return '

Kein Spieler hält diese Aktie.

'; + if (!c.holders?.length) return `

Kein Spieler hält ${c.kind && c.kind !== 'stock' ? 'dieses Wertpapier' : 'diese Aktie'}.

`; return ` - ${c.holders.map((h) => ``).join('')}
SpielerStückAnteil
${player(h.name)}${int(h.qty)}${num(h.pct, 4)} %
`; + ${c.holders.map((h) => `${player(h.name)}${int(h.qty)}${Number.isFinite(h.pct) ? `${num(h.pct, 4)} %` : '–'}`).join('')}`; } /** Nachrichtenliste (auch für andere Ansichten) */ @@ -429,6 +622,9 @@ function updateTicket() { v('ocoF').hidden = !v('oOco').checked; v('oOcoLbl').textContent = type === 'takeprofit' ? 'Stop-Loss (€)' : 'Take-Profit (€)'; v('simpleToggle').checked = S.simple; + const qLbl = $('label[for="oQty"]'); + const qTxt = kindOf(t) === 'bond' ? 'Stück (à 100 € nominal)' : 'Stück'; + if (qLbl && qLbl.textContent !== qTxt) qLbl.textContent = qTxt; // Konto-Umschalter const hasBattle = !!S.battlePortfolio, hasFund = !!S.fundPortfolio; @@ -481,6 +677,12 @@ function updateTicket() { const rules = S.account === 'battle' ? S.battlePortfolio?.rules : null; if (rules?.symbols && !rules.symbols.includes(S.symbol)) hints.push(`Im Battle nur ${esc(rules.symbols.join(', '))} handelbar.`); if (p?.locked) hints.push('Depot gesperrt: nur Positionsabbau möglich.'); + const kind = kindOf(t); + if (t && kind !== 'stock') hints.push(`Kurs in € ${esc(unitOf(t))}${kind === 'bond' && qty > 0 ? ` – ${int(qty)} St. = ${eur(qty * 100, 0)} Nennwert` : ''}.`); + const office = S.government?.me?.office ?? S.profile?.office; + if (t && kind === 'stock' && office?.sectors?.includes(t.sector) && ((side === 'buy' && pos >= 0) || (side === 'sell' && pos <= 0))) { + hints.push(`Interessenkonflikt: Als ${esc(office.ministry)} darfst du ${esc(S.info?.sectors?.[t.sector]?.name ?? t.sector)}-Aktien nur abbauen – diese Order würde abgelehnt.`); + } patch(v('oHint'), hints.join('
')); const btn = v('oSubmit'); @@ -566,7 +768,8 @@ async function submitOrder(e) { else if (ord.status === 'cancelled') toast(ord.filled ? `Teilweise ausgeführt (${int(ord.filled)} St.), Rest gestrichen.` : 'Nicht ausgeführt und gestrichen (IOC/FOK oder Preiskorridor).', 'warn', { title: 'Order beendet' }); else toast(`Order #${ord.id} liegt im Buch${ord.filled ? ` (${int(ord.filled)} St. ausgeführt)` : ''}.`, 'ok', { title: 'Order angenommen' }); } catch (err) { - toast(err.message, 'err', { title: 'Order abgelehnt' }); + const coi = /Interessenkonflikt/.test(err.message); + toast(err.message, 'err', { title: coi ? 'Interessenkonflikt – Order abgelehnt' : 'Order abgelehnt', ms: coi ? 10000 : undefined }); } finally { btn.disabled = !loggedIn(); } } @@ -598,6 +801,23 @@ function quickQty(f) { updateTicket(); } +async function tender(btn) { + const sym = btn.dataset.sym; + const qty = btn.dataset.zero ? 0 : Math.floor(Number($('#tenderQty')?.value ?? 0)); + if (!Number.isFinite(qty) || qty < 0) { toast('Bitte eine gültige Stückzahl eingeben', 'err'); return; } + const o = S.company?.corporate?.offer; + if (qty > 0 && o) { + const ok = await ask({ title: 'Aktien andienen?', html: `

${int(qty)} × ${esc(sym)} zum Angebotspreis von ${eur(o.price)} (zusammen ${eur(qty * o.price)}) andienen.

Gelingt die Übernahme (Erfolgschance ${frac(o.probability, 0)}), werden die Aktien in ${int(Math.max(0, o.daysLeft))} Handelstag(en) ausgebucht. Bis dahin kannst du die Andienung ändern oder zurückziehen.

`, ok: 'Andienen' }); + if (!ok) return; + } + btn.disabled = true; + try { + const r = await request('tender', { symbol: sym, qty }); + toast(qty ? `${int(r.offer?.myTender ?? qty)} × ${sym} angedient.` : `Andienung für ${sym} zurückgezogen.`, 'ok', { title: 'Übernahmeangebot' }); + await loadCompany(); + } catch (err) { toast(err.message, 'err'); } finally { btn.disabled = false; } +} + function updateSticky() { const t = ticker(); if (!t) return; @@ -650,6 +870,14 @@ export function initTrade(nav) { const a = e.target.closest('[data-act]'); if (!a) return; const act = a.dataset.act; + if (act === 'mgrp') { + const g = a.dataset.g; + if (groupClosed.has(g)) groupClosed.delete(g); else groupClosed.add(g); + store.set('mgrpClosed', [...groupClosed]); + renderMarketList(); + return; + } + if (act === 'tender') { tender(a); return; } if (act === 'bookPx') { if (v('oType').value !== 'limit' && v('oType').value !== 'stoplimit') v('oType').value = 'limit'; v('oPrice').value = Number(a.dataset.px).toFixed(2); updateTicket(); } else if (act === 'chartMode') { S.chartMode = a.dataset.mode; @@ -663,8 +891,15 @@ export function initTrade(nav) { } }); + let lastDay = null; + sub('market', () => { if (S.market?.day !== lastDay) { if (lastDay !== null) loadCompany(); lastDay = S.market?.day; } }); + sub('news', () => { + const n = S.news[0]; + if (n && (n.symbol === S.symbol || n.affected?.includes(S.symbol)) && n.id !== lastNewsId) { lastNewsId = n.id; loadCompany(); } + }); + sub('market', () => { if (stab === 'company' && S.company?.kind && S.company.kind !== 'stock' && S.company.symbol === S.symbol) renderStabs(); }); sub('market', () => { renderMarketList(); renderStock(); updateTicket(); if (S.chartMode === 'intraday') drawChart(); if (!v('oPrice').value) syncTicketDefaults(false); }); - sub('portfolio account profile', () => { updateTicket(); renderMarketList(); }); + sub('portfolio account profile government', () => { updateTicket(); renderMarketList(); }); syncTicketDefaults(true); setSide('buy'); } diff --git a/server/public/js/ui.js b/server/public/js/ui.js index 778c7a6..92d7587 100644 --- a/server/public/js/ui.js +++ b/server/public/js/ui.js @@ -122,6 +122,24 @@ export const GLOSSARY = { 'Maker/Taker': 'Maker/Taker: Wer mit einer Limit-Order Liquidität ins Buch stellt (Maker), zahlt weniger Gebühr als wer eine bestehende Order sofort ausführt (Taker).', Orderbuch: 'Orderbuch: alle offenen Kauf- (Geld) und Verkaufsorders (Brief) mit Preis und Menge.', Kaufkraft: 'Kaufkraft: Betrag, den du nach Abzug offener Orders und gebundener Sicherheiten noch für Käufe einsetzen kannst.', + Rendite: 'Rendite: Verzinsung einer Anleihe pro Jahr, wenn du sie zum aktuellen Kurs kaufst und bis zum Ende hältst. Steigt der Kurs, sinkt die Rendite – und umgekehrt.', + Duration: 'Duration: Zinsempfindlichkeit einer Anleihe in Jahren. Faustregel: Steigt die Rendite um 1 Prozentpunkt, fällt der Kurs um etwa „Duration“ Prozent.', + Kupon: 'Kupon: fester Zins einer Anleihe in % des Nennwerts pro Jahr. Hier wird er vierteljährlich ausgezahlt; bis dahin laufen Stückzinsen auf, die im Kurs enthalten sind.', + Zinskurve: 'Zinskurve: Renditen nach Laufzeit. Normal steigt sie an (lange Laufzeiten bringen mehr). Liegt die 2-jährige Rendite über der 10-jährigen („invertiert“), gilt das als Rezessionssignal.', + Risikoaufschlag: 'Risikoaufschlag: Zusätzliche Rendite, die Anleger für Zweifel an den Staatsfinanzen verlangen. Steigt mit hoher Verschuldung, hohem Defizit und in einer Haushaltskrise – verteuert Kredite für Staat und Unternehmen.', + Rating: 'Rating: Bonitätsnote einer Ratingagentur (AAA = beste Note, dann AA, A, BBB, BB, B). Eine Herabstufung lässt Anleihekurse fallen.', + Einkaufsmanagerindex: 'Einkaufsmanagerindex (PMI): Umfrage unter Einkaufsleitern. Über 50 = Wachstum, unter 50 = Schrumpfung. Läuft der Konjunktur voraus; entscheidend ist die Abweichung von der Erwartung (Konsens).', + Andienung: 'Andienung: Du bietest deine Aktien im Rahmen eines Übernahmeangebots dem Bieter an. Gelingt die Übernahme, erhältst du den Angebotspreis; scheitert sie, bleiben die Aktien im Depot. Bis zum Fristende kannst du die Andienung ändern oder zurückziehen.', + Übernahmeangebot: 'Übernahmeangebot: Ein Unternehmen bietet allen Aktionären einen festen Preis je Aktie – meist mit Aufschlag. Der Kurs liegt bis zur Entscheidung zwischen altem Kurs und Angebotspreis, je nach Erfolgswahrscheinlichkeit.', + Kapitalerhöhung: 'Kapitalerhöhung: Das Unternehmen gibt neue Aktien (meist mit Abschlag) aus. Es bekommt frisches Geld, der Gewinn verteilt sich aber auf mehr Aktien (Verwässerung).', + Aktienrückkauf: 'Aktienrückkauf: Das Unternehmen kauft eigene Aktien zurück. Weniger Aktien bedeuten mehr Gewinn je Aktie – meist ein positives Signal.', + Koalition: 'Koalition: Bündnis mehrerer Parteien, die zusammen die Mehrheit der Sitze haben und die Regierung stellen. Was im Koalitionsvertrag steht, hat im Parlament gute Chancen.', + Sperrklausel: 'Sperrklausel (5-%-Hürde): Nur Parteien mit mindestens 5 % der Stimmen bekommen Sitze im Parlament.', + Länderkammer: 'Länderkammer: Vertretung der Regionen. Jedes beschlossene Gesetz braucht ihre Zustimmung; sie kann es mit einem Einspruch stoppen.', + Normenkontrolle: 'Normenkontrolle: Die Opposition kann ein rechtlich umstrittenes Gesetz vom Verfassungsgericht prüfen lassen. Wird es für verfassungswidrig erklärt, tritt es nicht in Kraft.', + Lobbyregister: 'Lobbyregister: Öffentliches Verzeichnis aller Parteispenden ab 5.000 € mit Spender, Partei, Betrag und Interessengebiet. Spenden beeinflussen, welche Vorlagen auf die Tagesordnung kommen.', + Misstrauensvotum: 'Konstruktives Misstrauensvotum: Das Parlament kann die Regierung nur stürzen, indem es zugleich eine neue Mehrheit wählt. Gelingt es, übernimmt die neue Koalition.', + Szenario: 'Szenario: Ausgangslage und Drehbuch einer Saison (z. B. Zinswende oder Energiekrise). Es setzt Anstöße – die Kurse entstehen weiterhin im Orderbuch durch Angebot und Nachfrage.', }; /** Begriff mit Glossar-Tooltip */ diff --git a/server/public/style.css b/server/public/style.css index 99aea18..df85363 100644 --- a/server/public/style.css +++ b/server/public/style.css @@ -395,6 +395,88 @@ ul.inbox p { margin: 2px 0 6px; } td, th { padding: 6px 6px; } } + +/* ---------------------------------------------------------------- Anlageklassen & Unternehmensereignisse */ +.badge-s.offer { background: rgba(245,185,66,.25); color: var(--gold); } +.badge-s.trial { background: rgba(167,139,250,.2); color: #c4b5fd; } +.mlist tr.grp { cursor: default; } +.mlist tr.grp th { position: static; padding: 0; background: var(--panel2); border-top: 1px solid var(--line); } +.grp-btn { width: 100%; text-align: left; background: none; border: 0; padding: 7px 8px; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--text); } +.grp-btn:hover { background: var(--panel3); } +.sym-btn small.yl { color: #a9c6ff; } +.unit-line { margin: 4px 0 0; } +.corp-box { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; background: var(--panel2); } +.corp-box.offer { border-color: rgba(245,185,66,.5); } +.corp-box .kpis { margin: 6px 0; } +.tender { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; } +.tender .inline-form { max-width: 440px; margin: 6px 0; } +.chart-wrap.mini { height: 190px; margin: 4px 0; } +.chart-wrap.hemi { height: 210px; margin: 0 0 6px; } +.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: baseline; } +.linkchip { border: 0; cursor: pointer; } + +/* ---------------------------------------------------------------- Politik */ +.pol-tabs { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 8px 0; } +.pol-body { display: flex; flex-direction: column; gap: 10px; } +.pa-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; } +ul.pipe-list, ul.prop-list, ul.seat-legend, ul.agenda { list-style: none; margin: 0; padding: 0; } +.pipe, .prop-list li { padding: 10px 0; border-bottom: 1px solid #1c2538; } +.pipe:first-child, .prop-list li:first-child { padding-top: 0; } +.pipe.live { border-left: 3px solid var(--gold); padding-left: 10px; } +.pipe-h { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; } +.stepper { display: flex; list-style: none; margin: 8px 0 4px; padding: 0; counter-reset: st; flex-wrap: wrap; row-gap: 4px; } +.stepper li { flex: 1 1 0; min-width: 70px; position: relative; font-size: 12px; color: var(--muted); padding-top: 14px; text-align: center; } +.stepper li::before { content: ''; position: absolute; top: 3px; left: 0; right: 0; height: 4px; background: var(--panel3); } +.stepper li::after { content: ''; position: absolute; top: 0; left: calc(50% - 5px); width: 10px; height: 10px; border-radius: 50%; background: var(--panel3); border: 1px solid var(--line); } +.stepper li.done::before, .stepper li.done::after { background: var(--up); } +.stepper li.cur { color: var(--text); font-weight: 700; } +.stepper li.cur::before { background: linear-gradient(90deg, var(--up), var(--panel3)); } +.stepper li.cur::after { background: var(--gold); box-shadow: 0 0 0 3px rgba(245,185,66,.25); } +.stepper li.off { opacity: .45; } +.psplit { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; font-size: 13px; background: var(--bg); border-radius: 8px; padding: 6px 10px; margin: 6px 0; } +.psplit b { font-family: var(--mono); } +.psplit b.big { font-size: 16px; color: var(--gold); } +.badge-s.src-agenda { background: rgba(76,141,255,.2); color: #a9c6ff; } +.badge-s.src-player { background: rgba(245,185,66,.2); color: var(--gold); } +.badge-s.src-news { background: rgba(43,211,107,.15); color: var(--up); } +.cosign { display: grid; grid-template-columns: minmax(80px, 160px) auto auto auto; gap: 8px; align-items: center; margin-top: 6px; } +.prop-prev { background: var(--bg); border-radius: 8px; padding: 8px 10px; margin: 4px 0 10px; } +.prop-prev:empty { display: none; } +.prop-title { font-weight: 700; font-size: 15px; margin: 0 0 6px; } +.posbars { display: flex; gap: 10px; flex-wrap: wrap; } +.pb { display: inline-flex; flex-direction: column; gap: 2px; } +.pb small { color: var(--muted); font-size: 11px; } +.pbar { position: relative; display: inline-block; width: 64px; height: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; } +.pbar::after { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--muted); } +.pbar i { position: absolute; top: 0; bottom: 0; background: var(--accent); } +.pbar i.neg { background: #c084fc; } +.seat-legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2px 14px; margin-bottom: 6px; } +.seat-legend li { display: flex; gap: 6px; align-items: center; font-size: 13px; } +.seat-legend li .muted { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +ul.agenda li { padding: 3px 0; } +ul.agenda li.done { color: var(--up); } +.ballot { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; margin: 4px 0 6px; } +.ballot-btn { display: flex; align-items: center; gap: 4px; text-align: left; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 40px; } +.ballot-btn span:not(.swatch):not(.up) { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } +.ballot-btn[aria-pressed="true"] { border-color: var(--up); background: rgba(43,211,107,.12); } +.poll-row { display: grid; grid-template-columns: 70px 1fr 56px; gap: 8px; align-items: center; margin: 3px 0; font-size: 13px; } +.pollbar { height: 10px; background: var(--bg); border-radius: 5px; overflow: hidden; } +.pollbar i { display: block; height: 100%; } +.nc-card { border-color: var(--gold); } +fieldset.dir { margin: 0 0 9px; padding: 4px 10px; display: flex; gap: 14px; flex-wrap: wrap; } +.scenario { border: 1px solid rgba(245,185,66,.45); background: rgba(245,185,66,.08); border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; } +.scenario.calm { border-color: var(--line); background: var(--panel2); } +.scenario small { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; } +.scenario b { font-size: 15px; } +.scenario p { margin: 2px 0 0; font-size: 13px; } +.gov-line { font-size: 13px; } +.ind-t th[scope="row"] { position: static; font-size: 13px; color: var(--text); } +@media (max-width: 760px) { + .cosign { grid-template-columns: 1fr auto; } + .stepper li { min-width: 56px; font-size: 11px; } + .chart-wrap.hemi { height: 180px; } +} + /* ---------------------------------------------------------------- Admin */ .admin-wrap { max-width: 1400px; margin: 0 auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; } .set-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 10px; } diff --git a/server/src/politics.js b/server/src/politics.js index 151bad9..5598a14 100644 --- a/server/src/politics.js +++ b/server/src/politics.js @@ -365,7 +365,7 @@ export class Politics { continue; } if (e.stage === 'lesung') { this.#reprice(e, () => this.#advance(e, 'ausschuss')); this.#broadcast(); } - else if (e.stage === 'ausschuss') this.#committee(e); + else if (e.stage === 'ausschuss') { this.#committee(e); this.#broadcast(); } else if (e.stage === 'abstimmung') this.close(); else if (e.stage === 'laenderkammer') this.#chamber(e); else if (e.stage === 'gericht') this.#court(e);