Files
wibosim/server/public/js/state.js
T
db9979andClaude Opus 5.5 cdcab61403 Client: Politik, Anleihen/Rohstoffe/Devisen, Übernahmen, Makro und Admin für Phase 3/4
- Marktliste nach Anlageklassen gruppiert, Instrumentansichten mit Zinskurve und Haushalt
- Übernahmeangebot mit Andienung, Studien, Kontrollbox, Sensitivitäten
- Politik-Ansicht: Gesetzgebung (Pipeline), Vorlagen, Parteien & Wahl, Haushalt & Lobby
- Makro: Szenario, Zinskurve, Frühindikatoren; Briefing und Kalender erweitert
- Admin: Szenario, Übernahme, Kapitalmaßnahmen, Studie, Ölschock, Wahl
- Server: Abstimmungsbeginn wird an alle Clients gemeldet
- API-Doku und Screenshots ergänzt

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018i4GUhQVoPUusUzxgxLWkK
2026-12-03 15:23:06 +00:00

51 lines
1.9 KiB
JavaScript

// Gemeinsamer Client-Zustand und ein kleiner Ereignisbus („was hat sich geändert“).
import { store } from './util.js';
export const S = {
info: null, // /api/info
market: null, // market (ohne tickers)
tickers: [], // ticker[]
tickerMap: new Map(),
prevLast: new Map(), // für Aufblitzen bei Kursänderung
news: [], events: [],
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)
clan: null, clans: null, tournaments: null,
battles: null, quests: null, league: null, friends: null, live: [],
inbox: { items: [], unread: 0 },
calendar: null, briefing: null, journal: null, cases: null,
symbol: store.get('symbol', 'NVLT'),
book: null, // {depth, tape, candle, indicative, status}
candles: [],
company: null,
view: 'markt',
account: 'main', // Ticket/Depot: 'main' | 'battle' | 'fund'
simple: store.get('simple', true),
spectate: null, // beobachtetes Battle
chartMode: 'intraday',
};
const subs = new Map();
/** @param {string} key @param {Function} fn */
export function sub(key, fn) {
for (const k of key.split(' ')) {
if (!subs.has(k)) subs.set(k, new Set());
subs.get(k).add(fn);
}
}
/** @param {...string} keys */
export function changed(...keys) {
const done = new Set();
for (const k of keys) for (const fn of subs.get(k) ?? []) {
if (done.has(fn)) continue;
done.add(fn);
try { fn(k); } catch (e) { console.error(`[render ${k}]`, e); }
}
}
export const loggedIn = () => !!S.profile;
/** aktives Konto für Ticket/Depot */
export const activePortfolio = () => (S.account === 'battle' && S.battlePortfolio ? S.battlePortfolio : S.account === 'fund' && S.fundPortfolio ? S.fundPortfolio : S.portfolio);