@
feat(quantik-game): фаза 2 — карта-созвездие + мир + XP/скины (MVP-мир) Одиночный уровень → играбельный мир: карта-созвездие из 6 физ-уровней (2 главы, нарастающая сложность), разблокировка по звёздам, клиентский XP/уровень игрока, пикер из 8 скинов (тинт героя+нарратора), нарратор PetSprite на интро/победе (mood по звёздам). Навигация карта→интро→игра→ успех→карта/дальше; кнопка «Дальше» пересчитывает nextPlayable после дозагрузки прогресса (фикс stale-hasNext). Логика прогресса — чистый модуль progress-logic.js (unlock/XP/группировка). Только фронт, без бэкенда: XP агрегируется из game_progress (Ф1). Каждый уровень проверен на реальном движке (выигрываем + обе звезды достижимы); цепочка разблокировки доказуемо проходима. npm test 251/8 baseline; lint:routes 0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> @
This commit is contained in:
+353
-41
@@ -10,46 +10,222 @@
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css" />
|
||||
<script src="https://unpkg.com/lucide@0.469.0/dist/umd/lucide.min.js"></script>
|
||||
<style>
|
||||
/* ── Раскладка игровой страницы ── */
|
||||
/* ════════════════════ Игровая страница «Квантик» ════════════════════ */
|
||||
.qg-wrap { display: flex; flex-direction: column; height: 100vh; min-height: 0; }
|
||||
|
||||
/* ── Topbar ── */
|
||||
.qg-top {
|
||||
display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
|
||||
padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--surface);
|
||||
flex-shrink: 0;
|
||||
padding: 11px 20px; border-bottom: 1px solid rgba(148,163,184,0.18);
|
||||
background: #11132A; flex-shrink: 0; position: relative; z-index: 3;
|
||||
}
|
||||
.qg-title { font-family: 'Unbounded', sans-serif; font-weight: 800; font-size: 1.05rem; color: var(--text); white-space: nowrap; }
|
||||
.qg-sub { font-size: .8rem; color: var(--text-3); flex: 1; min-width: 0; }
|
||||
.qg-pill { font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; padding: 3px 10px; border-radius: 99px; background: rgba(34,211,238,0.14); color: #0e7c8a; }
|
||||
.qg-title { font-family: 'Unbounded', sans-serif; font-weight: 800; font-size: 1.02rem; color: #E2E8F0; white-space: nowrap; }
|
||||
.qg-sub { font-size: .8rem; color: #94A3B8; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
||||
.qg-pill { font-size: .66rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; padding: 3px 10px; border-radius: 99px; background: rgba(34,211,238,0.16); color: #67E8F9; }
|
||||
.qg-back {
|
||||
display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: .82rem; font-weight: 600;
|
||||
color: #CBD5E1; background: rgba(148,163,184,0.12); border: 1px solid rgba(148,163,184,0.2);
|
||||
border-radius: 99px; padding: 5px 13px; cursor: pointer; transition: .16s;
|
||||
}
|
||||
.qg-back:hover { background: rgba(34,211,238,0.16); color: #67E8F9; border-color: rgba(34,211,238,0.35); }
|
||||
.qg-back .ic { width: 15px; height: 15px; }
|
||||
|
||||
/* сцена: на всю площадь, тёмный фон (full-bleed root движка растягивается inset:0) */
|
||||
/* ════════════════════ Карта-созвездие ════════════════════ */
|
||||
.qm-root {
|
||||
flex: 1; min-height: 0; position: relative; overflow-y: auto; overflow-x: hidden;
|
||||
background:
|
||||
radial-gradient(1100px 700px at 78% -10%, rgba(167,139,250,0.16), transparent 60%),
|
||||
radial-gradient(900px 600px at 12% 8%, rgba(34,211,238,0.13), transparent 55%),
|
||||
radial-gradient(700px 800px at 50% 120%, rgba(244,114,182,0.10), transparent 60%),
|
||||
linear-gradient(180deg, #0B0B1A 0%, #0D0D1F 55%, #0A0A16 100%);
|
||||
}
|
||||
/* атмосферное зерно поверх фона */
|
||||
.qm-root::before {
|
||||
content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .5;
|
||||
background-image: radial-gradient(rgba(255,255,255,0.025) 1px, transparent 1px);
|
||||
background-size: 3px 3px;
|
||||
}
|
||||
|
||||
/* ── Шапка карты (нарратор + XP + скины) ── */
|
||||
.qm-header { position: relative; z-index: 2; padding: 22px 26px 8px; }
|
||||
.qm-header-inner {
|
||||
display: grid; grid-template-columns: minmax(240px, 1.4fr) minmax(280px, 1.1fr) auto;
|
||||
gap: 18px; align-items: center; max-width: 1180px; margin: 0 auto;
|
||||
}
|
||||
@media (max-width: 920px) { .qm-header-inner { grid-template-columns: 1fr; } }
|
||||
|
||||
.qm-narrator { display: flex; align-items: center; gap: 14px; }
|
||||
.qm-pet { width: 76px; height: 80px; flex-shrink: 0; filter: drop-shadow(0 8px 22px rgba(34,211,238,0.28)); }
|
||||
.qm-pet svg { width: 100%; height: 100%; }
|
||||
.qm-bubble {
|
||||
position: relative; background: rgba(20,22,44,0.78); border: 1px solid rgba(148,163,184,0.18);
|
||||
border-radius: 14px; padding: 12px 15px; backdrop-filter: blur(6px); box-shadow: 0 10px 30px rgba(0,0,0,0.35);
|
||||
}
|
||||
.qm-bubble::before {
|
||||
content: ''; position: absolute; left: -7px; top: 50%; transform: translateY(-50%) rotate(45deg);
|
||||
width: 12px; height: 12px; background: rgba(20,22,44,0.78); border-left: 1px solid rgba(148,163,184,0.18); border-bottom: 1px solid rgba(148,163,184,0.18);
|
||||
}
|
||||
.qm-bubble-t { color: #DCE3EE; font-size: .86rem; line-height: 1.45; }
|
||||
|
||||
.qm-stats { display: flex; align-items: center; gap: 18px; }
|
||||
.qm-level { display: flex; flex-direction: column; align-items: center; line-height: 1; flex-shrink: 0; }
|
||||
.qm-level-num {
|
||||
font-family: 'Unbounded', sans-serif; font-weight: 800; font-size: 2rem;
|
||||
background: linear-gradient(135deg, #67E8F9, #A78BFA); -webkit-background-clip: text; background-clip: text; color: transparent;
|
||||
}
|
||||
.qm-level-lbl { font-size: .62rem; text-transform: uppercase; letter-spacing: .06em; color: #8B9AAE; margin-top: 4px; max-width: 84px; text-align: center; }
|
||||
.qm-xpbox { flex: 1; min-width: 160px; }
|
||||
.qm-xp-head { display: flex; justify-content: space-between; font-size: .74rem; color: #CBD5E1; margin-bottom: 6px; font-weight: 600; font-variant-numeric: tabular-nums; }
|
||||
.qm-xp-next { color: #8B9AAE; font-weight: 500; }
|
||||
.qm-xp-bar { height: 9px; border-radius: 99px; background: rgba(148,163,184,0.18); overflow: hidden; }
|
||||
.qm-xp-fill {
|
||||
height: 100%; border-radius: 99px; width: 0;
|
||||
background: linear-gradient(90deg, #22D3EE, #A78BFA);
|
||||
box-shadow: 0 0 14px rgba(103,232,249,0.5);
|
||||
transition: width .9s cubic-bezier(.22,.61,.36,1);
|
||||
}
|
||||
.qm-starcount {
|
||||
display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
|
||||
font-family: 'Unbounded', sans-serif; font-weight: 700; font-size: 1rem; color: #FBBF24; font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
/* ── Скины ── */
|
||||
.qm-skins { display: flex; flex-direction: column; gap: 7px; }
|
||||
.qm-skins-lbl { font-size: .62rem; text-transform: uppercase; letter-spacing: .06em; color: #8B9AAE; font-weight: 700; }
|
||||
.qm-skins-row { display: flex; gap: 7px; flex-wrap: wrap; max-width: 220px; }
|
||||
.qm-skin {
|
||||
width: 30px; height: 30px; border-radius: 50%; cursor: pointer; padding: 0;
|
||||
background: radial-gradient(circle at 34% 30%, color-mix(in srgb, var(--sk) 70%, #fff), var(--sk) 70%);
|
||||
border: 2px solid rgba(255,255,255,0.18); position: relative; transition: transform .14s, box-shadow .14s, border-color .14s;
|
||||
}
|
||||
.qm-skin:hover:not(.locked) { transform: scale(1.12); }
|
||||
.qm-skin.active { border-color: #fff; box-shadow: 0 0 0 2px var(--sk), 0 0 14px var(--sk); }
|
||||
.qm-skin.locked { filter: grayscale(.7) brightness(.5); cursor: not-allowed; }
|
||||
.qm-skin-lock { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
|
||||
.qm-skin-lock .ic { width: 12px; height: 12px; }
|
||||
|
||||
/* ── Тело: созвездия ── */
|
||||
.qm-body { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 8px 26px 60px; }
|
||||
.qm-constellation { margin-top: 18px; }
|
||||
.qm-con-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 4px; padding-left: 4px; }
|
||||
.qm-con-title {
|
||||
font-family: 'Unbounded', sans-serif; font-weight: 700; font-size: 1.1rem; color: #E8EDF5;
|
||||
position: relative; padding-left: 16px;
|
||||
}
|
||||
.qm-con-title::before {
|
||||
content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
|
||||
width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent);
|
||||
}
|
||||
.qm-con-sub { font-size: .8rem; color: #8B9AAE; flex: 1; }
|
||||
.qm-con-stars { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; color: #FBBF24; font-weight: 700; font-variant-numeric: tabular-nums; }
|
||||
|
||||
.qm-field { position: relative; height: 220px; margin-top: 2px; }
|
||||
@media (max-width: 620px) { .qm-field { height: 280px; } }
|
||||
.qm-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
|
||||
.qm-link { stroke: rgba(148,163,184,0.22); stroke-width: .35; stroke-dasharray: 1.4 1.6; }
|
||||
.qm-link.on { stroke: var(--accent); stroke-opacity: .55; stroke-dasharray: none; stroke-width: .45; }
|
||||
.qm-tw { animation: qmTwinkle var(--tw, 2.4s) ease-in-out var(--td, 0s) infinite; transform-box: fill-box; transform-origin: center; }
|
||||
@keyframes qmTwinkle { 0%,100% { opacity: .25; } 50% { opacity: .9; } }
|
||||
|
||||
/* ── Узлы ── */
|
||||
.qm-node {
|
||||
position: absolute; transform: translate(-50%, -50%); z-index: 2;
|
||||
display: flex; flex-direction: column; align-items: center; gap: 6px;
|
||||
background: none; border: none; cursor: pointer; font: inherit; padding: 0;
|
||||
transition: transform .2s;
|
||||
}
|
||||
.qm-node-core {
|
||||
width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
|
||||
position: relative; transition: transform .18s, box-shadow .18s;
|
||||
}
|
||||
.qm-node-core .ic { color: #fff; }
|
||||
.qm-node-label { font-family: 'Manrope', sans-serif; font-weight: 600; font-size: .76rem; color: #CBD5E1; white-space: nowrap; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
|
||||
.qm-node-stars { display: inline-flex; gap: 1px; }
|
||||
.qm-node-need { display: inline-flex; align-items: center; gap: 3px; font-size: .68rem; color: #94A3B8; font-weight: 600; }
|
||||
|
||||
/* доступный узел */
|
||||
.qm-available .qm-node-core {
|
||||
background: radial-gradient(circle at 35% 30%, #34D399, #0E9F6E);
|
||||
box-shadow: 0 0 0 4px rgba(52,211,153,0.18), 0 8px 24px rgba(16,185,129,0.4);
|
||||
animation: qmPulse 2.4s ease-in-out infinite;
|
||||
}
|
||||
@keyframes qmPulse {
|
||||
0%,100% { box-shadow: 0 0 0 4px rgba(52,211,153,0.18), 0 8px 24px rgba(16,185,129,0.4); }
|
||||
50% { box-shadow: 0 0 0 8px rgba(52,211,153,0.10), 0 10px 32px rgba(16,185,129,0.55); }
|
||||
}
|
||||
.qm-available:hover { transform: translate(-50%, -50%) scale(1.07); }
|
||||
.qm-available:hover .qm-node-core { transform: scale(1.05); }
|
||||
|
||||
/* пройденный узел */
|
||||
.qm-completed .qm-node-core {
|
||||
background: radial-gradient(circle at 35% 30%, #67E8F9, #2563EB);
|
||||
box-shadow: 0 0 0 3px rgba(34,211,238,0.2), 0 6px 20px rgba(37,99,235,0.4);
|
||||
}
|
||||
.qm-completed:hover { transform: translate(-50%, -50%) scale(1.06); }
|
||||
.qm-node-order { font-family: 'Unbounded', sans-serif; font-weight: 800; font-size: 1.15rem; color: #fff; }
|
||||
|
||||
/* заблокированный узел */
|
||||
.qm-locked { cursor: not-allowed; }
|
||||
.qm-locked .qm-node-core {
|
||||
background: rgba(30,33,58,0.85); border: 1.5px solid rgba(148,163,184,0.22);
|
||||
box-shadow: inset 0 2px 10px rgba(0,0,0,0.4);
|
||||
}
|
||||
.qm-locked .qm-node-label { color: #6B7A90; }
|
||||
|
||||
/* фокус для клавиатуры */
|
||||
.qm-node:focus-visible { outline: none; }
|
||||
.qm-node:focus-visible .qm-node-core { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--accent, #22D3EE); }
|
||||
|
||||
/* поэтапное появление */
|
||||
.qm-node.qm-pre { opacity: 0; transform: translate(-50%, -40%) scale(.6); }
|
||||
.qm-node.qm-in { animation: qmNodeIn .5s cubic-bezier(.22,1.2,.4,1) forwards; }
|
||||
@keyframes qmNodeIn {
|
||||
from { opacity: 0; transform: translate(-50%, -40%) scale(.6); }
|
||||
to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
|
||||
}
|
||||
|
||||
/* ════════════════════ Сцена уровня ════════════════════ */
|
||||
.qg-stage { flex: 1; min-height: 0; position: relative; background: #0D0D1A; overflow: hidden; }
|
||||
.qg-stage .sim-spec-root { position: absolute; inset: 0; }
|
||||
|
||||
.qg-fallback { padding: 40px; color: #cbd5e1; font-family: 'Manrope', sans-serif; max-width: 520px; }
|
||||
|
||||
/* ── Экран успеха (оверлей) ── */
|
||||
.qg-view { display: none; flex: 1; min-height: 0; }
|
||||
.qg-view.show { display: flex; flex-direction: column; }
|
||||
|
||||
/* ── Оверлеи (интро / успех) ── */
|
||||
.qg-overlay {
|
||||
position: absolute; inset: 0; z-index: 20;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
background: rgba(7, 7, 18, 0.72); backdrop-filter: blur(4px);
|
||||
background: rgba(7, 7, 18, 0.74); backdrop-filter: blur(5px);
|
||||
}
|
||||
.qg-card {
|
||||
background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
|
||||
padding: 28px 30px; width: min(420px, 90vw); text-align: center;
|
||||
box-shadow: 0 20px 60px rgba(0,0,0,0.45);
|
||||
animation: qg-pop .22s ease;
|
||||
background: linear-gradient(180deg, #15173099, #0F1024EE), #14152C;
|
||||
border: 1px solid rgba(148,163,184,0.18); border-radius: 20px;
|
||||
padding: 26px 30px 24px; width: min(440px, 92vw); text-align: center;
|
||||
box-shadow: 0 24px 70px rgba(0,0,0,0.55);
|
||||
animation: qg-pop .26s cubic-bezier(.22,1.1,.4,1);
|
||||
}
|
||||
@keyframes qg-pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
|
||||
.qg-card-title { font-family: 'Unbounded', sans-serif; font-weight: 800; font-size: 1.3rem; color: var(--text); margin-bottom: 14px; }
|
||||
@keyframes qg-pop { from { transform: scale(.9) translateY(8px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
|
||||
.qg-card-kicker { font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; color: #67E8F9; margin-bottom: 4px; }
|
||||
.qg-card-title { font-family: 'Unbounded', sans-serif; font-weight: 800; font-size: 1.32rem; color: #EAF0F8; margin-bottom: 12px; }
|
||||
.qg-intro-pet, .qg-success-pet { width: 92px; height: 96px; margin: 0 auto 6px; filter: drop-shadow(0 10px 26px rgba(34,211,238,0.3)); }
|
||||
.qg-intro-pet svg, .qg-success-pet svg { width: 100%; height: 100%; }
|
||||
.qg-success-pet { animation: qgBob 1.6s ease-in-out infinite; }
|
||||
@keyframes qgBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
|
||||
.qg-intro-goal { font-weight: 700; font-size: .98rem; color: #DCE3EE; margin-bottom: 8px; }
|
||||
.qg-intro-hint { font-size: .85rem; color: #A8B4C6; line-height: 1.5; margin-bottom: 18px; max-width: 360px; margin-left: auto; margin-right: auto; }
|
||||
|
||||
.qg-stars { display: flex; justify-content: center; gap: 6px; margin-bottom: 18px; }
|
||||
.qg-star { display: inline-flex; }
|
||||
.qg-star-svg { filter: drop-shadow(0 2px 6px rgba(251,191,36,0.4)); }
|
||||
.qg-stats { display: flex; justify-content: center; gap: 22px; margin-bottom: 22px; }
|
||||
.qg-star-on { animation: qgStarPop .45s cubic-bezier(.22,1.3,.4,1) backwards; animation-delay: calc(.12s * var(--si, 0) + .15s); }
|
||||
@keyframes qgStarPop { 0% { transform: scale(0) rotate(-30deg); opacity: 0; } 70% { transform: scale(1.25) rotate(6deg); } 100% { transform: scale(1) rotate(0); opacity: 1; } }
|
||||
.qg-stats { display: flex; justify-content: center; gap: 22px; margin-bottom: 20px; }
|
||||
.qg-stat { display: flex; flex-direction: column; gap: 3px; }
|
||||
.qg-stat-lbl { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }
|
||||
.qg-stat-val { font-family: 'Unbounded', sans-serif; font-weight: 700; font-size: 1.05rem; color: var(--text); font-variant-numeric: tabular-nums; }
|
||||
.qg-stat-lbl { font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: #8B9AAE; }
|
||||
.qg-stat-val { font-family: 'Unbounded', sans-serif; font-weight: 700; font-size: 1.05rem; color: #EAF0F8; font-variant-numeric: tabular-nums; }
|
||||
.qg-actions { display: flex; justify-content: center; gap: 10px; }
|
||||
.qg-btn { min-width: 110px; }
|
||||
.qg-btn { min-width: 118px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -60,9 +236,25 @@
|
||||
<div class="qg-top">
|
||||
<span class="qg-title" id="qg-title">Квантик — Законы Мира</span>
|
||||
<span class="qg-sub" id="qg-sub"></span>
|
||||
<button class="qg-back" id="qg-back" type="button" style="display:none">
|
||||
<svg class="ic" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 18 9 12 15 6"/></svg>
|
||||
К карте
|
||||
</button>
|
||||
<span class="qg-pill">Физика</span>
|
||||
</div>
|
||||
<div class="qg-stage" id="qg-stage"></div>
|
||||
|
||||
<!-- Вид карты -->
|
||||
<div class="qg-view show" id="qg-map-view">
|
||||
<div class="qm-root">
|
||||
<div class="qm-header" id="qg-map-header"></div>
|
||||
<div class="qm-body" id="qg-map-body"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Вид уровня -->
|
||||
<div class="qg-view" id="qg-level-view">
|
||||
<div class="qg-stage" id="qg-stage"></div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
@@ -71,48 +263,168 @@
|
||||
<script src="/js/sidebar.js"></script>
|
||||
<script src="/js/notifications.js"></script>
|
||||
<script src="/js/mobile.js"></script>
|
||||
<!-- модель питомца (нарратор-Квантик) -->
|
||||
<script src="/js/pet-sprite.js"></script>
|
||||
<!-- движок спек-симуляций (тот же путь, что lab.html / sim-builder.html) -->
|
||||
<script src="/js/labs/_sim_expr.js"></script>
|
||||
<script src="/js/labs/_sim_engine.js"></script>
|
||||
<!-- KaTeX для подписей сцены -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/contrib/auto-render.min.js"></script>
|
||||
<!-- уровни (данные) + логика игры -->
|
||||
<!-- уровни (данные) + логика прогресса + карта + игра -->
|
||||
<script src="/js/game/levels.js"></script>
|
||||
<script src="/js/game/progress-logic.js"></script>
|
||||
<script src="/js/game/map.js"></script>
|
||||
<script src="/js/game/quantik-game.js"></script>
|
||||
<script>
|
||||
(function () {
|
||||
// Доступ: любой авторизованный пользователь (играют и ученики).
|
||||
if (!LS.initPage()) { return; } // initPage сам редиректит на /login, если не авторизован
|
||||
if (!LS.initPage()) { return; }
|
||||
|
||||
var stage = document.getElementById('qg-stage');
|
||||
var mapView = document.getElementById('qg-map-view');
|
||||
var lvlView = document.getElementById('qg-level-view');
|
||||
var stage = document.getElementById('qg-stage');
|
||||
var backBtn = document.getElementById('qg-back');
|
||||
var titleEl = document.getElementById('qg-title');
|
||||
var subEl = document.getElementById('qg-sub');
|
||||
|
||||
if (!window.SimEngine || !window.SimExpr || !window.QuantikLevels || !window.QuantikGame) {
|
||||
if (!window.SimEngine || !window.SimExpr || !window.QuantikLevels ||
|
||||
!window.QuantikGame || !window.QuantikMap || !window.QuantikProgress) {
|
||||
stage.innerHTML = '<div class="qg-fallback">Движок игры не загрузился. Обновите страницу.</div>';
|
||||
lvlView.classList.add('show'); mapView.classList.remove('show');
|
||||
return;
|
||||
}
|
||||
|
||||
// Уровень: ?level=<id> или первый из реестра (MVP — один уровень).
|
||||
var params = new URLSearchParams(location.search);
|
||||
var wantId = params.get('level');
|
||||
var level = wantId ? window.QuantikLevels.get(wantId) : null;
|
||||
if (!level) level = window.QuantikLevels.list()[0] || null;
|
||||
var progressMap = {}; // { level_id: row }
|
||||
var curInst = null; // текущий инстанс движка уровня
|
||||
var map = null;
|
||||
|
||||
if (!level) {
|
||||
stage.innerHTML = '<div class="qg-fallback">Уровень не найден.</div>';
|
||||
return;
|
||||
function loadProgress() {
|
||||
if (window.LS && window.LS.gameProgressList) {
|
||||
return window.LS.gameProgressList()
|
||||
.then(function (r) { progressMap = window.QuantikProgress.fromProgressList(r && r.progress); })
|
||||
.catch(function () { progressMap = {}; });
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
document.getElementById('qg-title').textContent = level.title || 'Квантик';
|
||||
document.getElementById('qg-sub').textContent = level.hint || '';
|
||||
|
||||
var inst = window.QuantikGame.start({ host: stage, level: level });
|
||||
if (!inst) {
|
||||
stage.innerHTML = '<div class="qg-fallback">Не удалось запустить уровень.</div>';
|
||||
return;
|
||||
function destroyLevel() {
|
||||
if (curInst) { try { curInst.destroy(); } catch (_e) {} curInst = null; }
|
||||
stage.innerHTML = '';
|
||||
}
|
||||
|
||||
window.__quantik = inst; // для отладки
|
||||
/* ── Показать карту ── */
|
||||
function showMap() {
|
||||
destroyLevel();
|
||||
lvlView.classList.remove('show');
|
||||
mapView.classList.add('show');
|
||||
backBtn.style.display = 'none';
|
||||
titleEl.textContent = 'Квантик — Законы Мира';
|
||||
subEl.textContent = 'Карта мира — выбери уровень и почини закон';
|
||||
history.replaceState(null, '', '/quantik');
|
||||
// перезагрузить прогресс (мог обновиться после победы) и перерисовать
|
||||
loadProgress().then(function () { map.render(progressMap); });
|
||||
}
|
||||
|
||||
/* ── Запустить уровень (после интро) ── */
|
||||
function launchLevel(level) {
|
||||
destroyLevel();
|
||||
mapView.classList.remove('show');
|
||||
lvlView.classList.add('show');
|
||||
backBtn.style.display = '';
|
||||
titleEl.textContent = level.title || 'Квантик';
|
||||
subEl.textContent = (level.spec && level.spec.goal && level.spec.goal.title) || level.hint || '';
|
||||
history.replaceState(null, '', '/quantik?level=' + encodeURIComponent(level.id));
|
||||
|
||||
// Pre-win значение (фолбэк, если пересчёт после победы недоступен).
|
||||
var nextLevel = window.QuantikProgress.nextPlayable(level.id, window.QuantikLevels.list(), progressMap);
|
||||
|
||||
curInst = window.QuantikGame.start({
|
||||
host: stage,
|
||||
level: level,
|
||||
skin: window.QuantikGame.getSkin(),
|
||||
hasNext: !!nextLevel,
|
||||
// Победа разблокирует след. уровень → перезагружаем прогресс и пересчитываем
|
||||
// «следующий доступный» на свежей карте, чтобы экран успеха показал «Дальше».
|
||||
resolveNext: function () {
|
||||
return loadProgress().then(function () {
|
||||
var nx = window.QuantikProgress.nextPlayable(level.id, window.QuantikLevels.list(), progressMap);
|
||||
return { hasNext: !!nx, next: nx };
|
||||
});
|
||||
},
|
||||
onNext: function () {
|
||||
// прогресс уже перезагружен в resolveNext → берём след. доступный из свежей карты
|
||||
var nx = window.QuantikProgress.nextPlayable(level.id, window.QuantikLevels.list(), progressMap);
|
||||
if (nx) openLevel(nx); else showMap();
|
||||
},
|
||||
onMap: showMap
|
||||
});
|
||||
|
||||
if (!curInst) {
|
||||
stage.innerHTML = '<div class="qg-fallback">Не удалось запустить уровень.</div>';
|
||||
}
|
||||
}
|
||||
|
||||
/* ── Открыть уровень: показать интро-карточку, потом launch ── */
|
||||
function openLevel(level) {
|
||||
destroyLevel();
|
||||
mapView.classList.remove('show');
|
||||
lvlView.classList.add('show');
|
||||
backBtn.style.display = '';
|
||||
titleEl.textContent = level.title || 'Квантик';
|
||||
subEl.textContent = (level.spec && level.spec.goal && level.spec.goal.title) || '';
|
||||
|
||||
var intro = window.QuantikGame.buildIntro(level, window.QuantikGame.getSkin());
|
||||
intro.btnGo.addEventListener('click', function () {
|
||||
if (intro.overlay.parentNode) intro.overlay.parentNode.removeChild(intro.overlay);
|
||||
launchLevel(level);
|
||||
});
|
||||
intro.btnBack.addEventListener('click', function () {
|
||||
if (intro.overlay.parentNode) intro.overlay.parentNode.removeChild(intro.overlay);
|
||||
showMap();
|
||||
});
|
||||
stage.appendChild(intro.overlay);
|
||||
}
|
||||
|
||||
/* ── Карта ── */
|
||||
map = window.QuantikMap.create({
|
||||
host: document.getElementById('qg-map-body'),
|
||||
headerHost: document.getElementById('qg-map-header'),
|
||||
onPlay: function (level) { openLevel(level); },
|
||||
getSkin: function () { return window.QuantikGame.getSkin(); },
|
||||
onSkin: function (key) {
|
||||
window.QuantikGame.setSkin(key);
|
||||
map.render(progressMap); // перерисовать (нарратор + активный свотч)
|
||||
}
|
||||
});
|
||||
|
||||
backBtn.addEventListener('click', showMap);
|
||||
|
||||
// Старт: если ?level=<id> в URL и уровень доступен — открыть его, иначе карта.
|
||||
loadProgress().then(function () {
|
||||
map.render(progressMap);
|
||||
var params = new URLSearchParams(location.search);
|
||||
var wantId = params.get('level');
|
||||
if (wantId) {
|
||||
var lvl = window.QuantikLevels.get(wantId);
|
||||
if (lvl && window.QuantikProgress.isUnlocked(lvl, progressMap, window.QuantikLevels.list())) {
|
||||
openLevel(lvl);
|
||||
return;
|
||||
}
|
||||
}
|
||||
showMapNoReload();
|
||||
});
|
||||
|
||||
// показать карту без повторной загрузки прогресса (стартовый случай)
|
||||
function showMapNoReload() {
|
||||
lvlView.classList.remove('show');
|
||||
mapView.classList.add('show');
|
||||
backBtn.style.display = 'none';
|
||||
titleEl.textContent = 'Квантик — Законы Мира';
|
||||
subEl.textContent = 'Карта мира — выбери уровень и почини закон';
|
||||
}
|
||||
|
||||
window.__quantik = { map: map, getInst: function () { return curInst; } };
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user