Spaces:
Running
Running
Upload 2 files
Browse files- index.html +29 -4
- similarity.html +123 -5
index.html
CHANGED
|
@@ -782,12 +782,35 @@
|
|
| 782 |
}
|
| 783 |
|
| 784 |
// ==========================================
|
| 785 |
-
// 結局演習觸發與播放邏輯
|
| 786 |
// ==========================================
|
| 787 |
let audioMayor = new Audio('Assets/1.mp3');
|
| 788 |
let audioCredits = new Audio('Assets/2.mp3');
|
| 789 |
let isEndgameTyping = false;
|
| 790 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 791 |
function checkEndGame() {
|
| 792 |
const hasCompletedAll = (
|
| 793 |
localStorage.getItem('math901_score_similarity') &&
|
|
@@ -798,7 +821,7 @@
|
|
| 798 |
if (hasCompletedAll) {
|
| 799 |
const hasSeen = localStorage.getItem('math901_ending_seen') === 'true';
|
| 800 |
if (!hasSeen) {
|
| 801 |
-
setTimeout(() => startEndGameSequence(),
|
| 802 |
}
|
| 803 |
}
|
| 804 |
}
|
|
@@ -807,8 +830,7 @@
|
|
| 807 |
audioCredits.pause();
|
| 808 |
audioCredits.currentTime = 0;
|
| 809 |
audioMayor.currentTime = 0;
|
| 810 |
-
|
| 811 |
-
audioMayor.play().catch(e => console.log("Audio notice:", e));
|
| 812 |
|
| 813 |
const profile = getEndingProfile();
|
| 814 |
let nickname = localStorage.getItem('player_nickname') || '防衛要塞指揮官';
|
|
@@ -862,6 +884,9 @@
|
|
| 862 |
}
|
| 863 |
|
| 864 |
dialogPhase.onclick = () => {
|
|
|
|
|
|
|
|
|
|
| 865 |
if (!isEndgameTyping) showLine();
|
| 866 |
};
|
| 867 |
|
|
|
|
| 782 |
}
|
| 783 |
|
| 784 |
// ==========================================
|
| 785 |
+
// 結局演習觸發與播放邏輯 (強化 Autoplay 與互動補播機制)
|
| 786 |
// ==========================================
|
| 787 |
let audioMayor = new Audio('Assets/1.mp3');
|
| 788 |
let audioCredits = new Audio('Assets/2.mp3');
|
| 789 |
let isEndgameTyping = false;
|
| 790 |
|
| 791 |
+
function playMayorMusic() {
|
| 792 |
+
if (audioMayor) {
|
| 793 |
+
audioMayor.loop = true;
|
| 794 |
+
const p = audioMayor.play();
|
| 795 |
+
if (p !== undefined) {
|
| 796 |
+
p.catch(() => {
|
| 797 |
+
const resume = () => {
|
| 798 |
+
const isCredits = !document.getElementById('endgame-credits').classList.contains('hidden');
|
| 799 |
+
if (audioMayor && audioMayor.paused && !isCredits) {
|
| 800 |
+
audioMayor.play().catch(() => {});
|
| 801 |
+
}
|
| 802 |
+
document.removeEventListener('pointerdown', resume);
|
| 803 |
+
document.removeEventListener('click', resume);
|
| 804 |
+
document.removeEventListener('touchstart', resume);
|
| 805 |
+
};
|
| 806 |
+
document.addEventListener('pointerdown', resume, { once: true });
|
| 807 |
+
document.addEventListener('click', resume, { once: true });
|
| 808 |
+
document.addEventListener('touchstart', resume, { once: true });
|
| 809 |
+
});
|
| 810 |
+
}
|
| 811 |
+
}
|
| 812 |
+
}
|
| 813 |
+
|
| 814 |
function checkEndGame() {
|
| 815 |
const hasCompletedAll = (
|
| 816 |
localStorage.getItem('math901_score_similarity') &&
|
|
|
|
| 821 |
if (hasCompletedAll) {
|
| 822 |
const hasSeen = localStorage.getItem('math901_ending_seen') === 'true';
|
| 823 |
if (!hasSeen) {
|
| 824 |
+
setTimeout(() => startEndGameSequence(), 1000);
|
| 825 |
}
|
| 826 |
}
|
| 827 |
}
|
|
|
|
| 830 |
audioCredits.pause();
|
| 831 |
audioCredits.currentTime = 0;
|
| 832 |
audioMayor.currentTime = 0;
|
| 833 |
+
playMayorMusic();
|
|
|
|
| 834 |
|
| 835 |
const profile = getEndingProfile();
|
| 836 |
let nickname = localStorage.getItem('player_nickname') || '防衛要塞指揮官';
|
|
|
|
| 884 |
}
|
| 885 |
|
| 886 |
dialogPhase.onclick = () => {
|
| 887 |
+
if (audioMayor.paused) {
|
| 888 |
+
audioMayor.play().catch(() => {});
|
| 889 |
+
}
|
| 890 |
if (!isEndgameTyping) showLine();
|
| 891 |
};
|
| 892 |
|
similarity.html
CHANGED
|
@@ -625,6 +625,9 @@
|
|
| 625 |
} else {
|
| 626 |
this.targetInput.value = currentVal + val;
|
| 627 |
}
|
|
|
|
|
|
|
|
|
|
| 628 |
},
|
| 629 |
backspace: function () {
|
| 630 |
if (!this.targetInput) return;
|
|
@@ -823,14 +826,14 @@
|
|
| 823 |
}
|
| 824 |
};
|
| 825 |
|
| 826 |
-
// --- Secret Cheat Code
|
| 827 |
let secretKeyBuffer = '';
|
| 828 |
function showSecretNotification(msg) {
|
| 829 |
let toast = document.getElementById('secret-toast');
|
| 830 |
if (!toast) {
|
| 831 |
toast = document.createElement('div');
|
| 832 |
toast.id = 'secret-toast';
|
| 833 |
-
toast.className = 'fixed top-
|
| 834 |
document.body.appendChild(toast);
|
| 835 |
}
|
| 836 |
toast.innerText = msg;
|
|
@@ -839,9 +842,17 @@
|
|
| 839 |
setTimeout(() => {
|
| 840 |
toast.style.opacity = '0';
|
| 841 |
toast.style.transform = 'translate(-50%, -20px) scale(0.95)';
|
| 842 |
-
},
|
| 843 |
}
|
| 844 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 845 |
function checkSecretCode(key) {
|
| 846 |
if (typeof key === 'string' && key.length === 1) {
|
| 847 |
secretKeyBuffer = (secretKeyBuffer + key).slice(-5);
|
|
@@ -851,8 +862,97 @@
|
|
| 851 |
loadStage(4); // MIST_TUTORIAL
|
| 852 |
} else if (secretKeyBuffer === '33333') {
|
| 853 |
secretKeyBuffer = '';
|
| 854 |
-
|
| 855 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 856 |
}
|
| 857 |
}
|
| 858 |
}
|
|
@@ -2118,6 +2218,24 @@
|
|
| 2118 |
loadStage(0);
|
| 2119 |
requestAnimationFrame(renderLoop);
|
| 2120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2121 |
// 進入遊戲時預設開啟作戰指引彈窗
|
| 2122 |
setTimeout(() => {
|
| 2123 |
openOpticsBriefingModal();
|
|
|
|
| 625 |
} else {
|
| 626 |
this.targetInput.value = currentVal + val;
|
| 627 |
}
|
| 628 |
+
if (typeof autoCheckAndAdvance === 'function') {
|
| 629 |
+
autoCheckAndAdvance(this.targetInput);
|
| 630 |
+
}
|
| 631 |
},
|
| 632 |
backspace: function () {
|
| 633 |
if (!this.targetInput) return;
|
|
|
|
| 826 |
}
|
| 827 |
};
|
| 828 |
|
| 829 |
+
// --- Secret Cheat Code & Direct Summary Jump ---
|
| 830 |
let secretKeyBuffer = '';
|
| 831 |
function showSecretNotification(msg) {
|
| 832 |
let toast = document.getElementById('secret-toast');
|
| 833 |
if (!toast) {
|
| 834 |
toast = document.createElement('div');
|
| 835 |
toast.id = 'secret-toast';
|
| 836 |
+
toast.className = 'fixed top-16 left-1/2 transform -translate-x-1/2 z-[300] bg-slate-900/95 border-2 border-amber-400 text-amber-300 font-bold px-6 py-2.5 rounded-2xl shadow-[0_0_30px_rgba(251,191,36,0.8)] text-base sm:text-lg font-mono flex items-center gap-3 transition-all duration-300 pointer-events-none opacity-0';
|
| 837 |
document.body.appendChild(toast);
|
| 838 |
}
|
| 839 |
toast.innerText = msg;
|
|
|
|
| 842 |
setTimeout(() => {
|
| 843 |
toast.style.opacity = '0';
|
| 844 |
toast.style.transform = 'translate(-50%, -20px) scale(0.95)';
|
| 845 |
+
}, 2200);
|
| 846 |
}
|
| 847 |
|
| 848 |
+
window.triggerCheatJumpToSummary = function() {
|
| 849 |
+
state.score = Math.max(state.score, 4000);
|
| 850 |
+
state.endlessWins = 4;
|
| 851 |
+
saveSimilarityProgress();
|
| 852 |
+
showSecretNotification('🔓 戰術作弊碼:直接跳轉至任務結算畫面!');
|
| 853 |
+
loadStage(8); // SUMMARY_SCREEN
|
| 854 |
+
};
|
| 855 |
+
|
| 856 |
function checkSecretCode(key) {
|
| 857 |
if (typeof key === 'string' && key.length === 1) {
|
| 858 |
secretKeyBuffer = (secretKeyBuffer + key).slice(-5);
|
|
|
|
| 862 |
loadStage(4); // MIST_TUTORIAL
|
| 863 |
} else if (secretKeyBuffer === '33333') {
|
| 864 |
secretKeyBuffer = '';
|
| 865 |
+
triggerCheatJumpToSummary();
|
| 866 |
+
}
|
| 867 |
+
}
|
| 868 |
+
}
|
| 869 |
+
|
| 870 |
+
// --- Auto-Advance Mechanism for Seamless Input ---
|
| 871 |
+
function autoCheckAndAdvance(currentInput) {
|
| 872 |
+
if (!currentInput || !state.currentLevel) return;
|
| 873 |
+
const val = parseFloat(currentInput.value);
|
| 874 |
+
if (isNaN(val)) return;
|
| 875 |
+
|
| 876 |
+
const s = state.reticleUnits;
|
| 877 |
+
const H_m = state.sizeH;
|
| 878 |
+
const H_cm = H_m * 100;
|
| 879 |
+
const D_cm = state.distanceD_cm;
|
| 880 |
+
const ratio = state.currentLevel.mode === 'CALCULATE_DISTANCE' ? (H_cm / s) : (D_cm / 10);
|
| 881 |
+
|
| 882 |
+
if (state.currentLevel.mode === 'CALCULATE_DISTANCE') {
|
| 883 |
+
// Mode B: 目視測距模式
|
| 884 |
+
if (currentInput.id === 'in-s' && val === s) {
|
| 885 |
+
handleInputCheck(2, encodeURIComponent(JSON.stringify([{id:'in-s', val:s}])));
|
| 886 |
+
setTimeout(() => {
|
| 887 |
+
const next = document.getElementById('in-h-cm');
|
| 888 |
+
if (next) keypad.open(next);
|
| 889 |
+
}, 120);
|
| 890 |
+
} else if (currentInput.id === 'in-h-cm' && val === H_cm) {
|
| 891 |
+
handleInputCheck(3, encodeURIComponent(JSON.stringify([{id:'in-h-cm', val:H_cm}])));
|
| 892 |
+
setTimeout(() => {
|
| 893 |
+
const next = document.getElementById('in-h-cm2');
|
| 894 |
+
if (next) keypad.open(next);
|
| 895 |
+
}, 120);
|
| 896 |
+
} else if (currentInput.id === 'in-h-cm2' && val === H_cm) {
|
| 897 |
+
const next = document.getElementById('in-s2');
|
| 898 |
+
if (next) keypad.open(next);
|
| 899 |
+
} else if (currentInput.id === 'in-s2' && val === s) {
|
| 900 |
+
const next = document.getElementById('in-ratio');
|
| 901 |
+
if (next) keypad.open(next);
|
| 902 |
+
} else if (currentInput.id === 'in-ratio' && val === ratio) {
|
| 903 |
+
const el1 = document.getElementById('in-h-cm2');
|
| 904 |
+
const el2 = document.getElementById('in-s2');
|
| 905 |
+
if (el1 && parseFloat(el1.value) === H_cm && el2 && parseFloat(el2.value) === s) {
|
| 906 |
+
handleInputCheck(4, encodeURIComponent(JSON.stringify([{id:'in-h-cm2', val:H_cm}, {id:'in-s2', val:s}, {id:'in-ratio', val:ratio}])));
|
| 907 |
+
setTimeout(() => {
|
| 908 |
+
const next = document.getElementById('in-ratio2');
|
| 909 |
+
if (next) keypad.open(next);
|
| 910 |
+
}, 120);
|
| 911 |
+
}
|
| 912 |
+
} else if (currentInput.id === 'in-ratio2' && val === ratio) {
|
| 913 |
+
const next = document.getElementById('in-d-cm');
|
| 914 |
+
if (next) keypad.open(next);
|
| 915 |
+
} else if (currentInput.id === 'in-d-cm' && val === D_cm) {
|
| 916 |
+
const el1 = document.getElementById('in-ratio2');
|
| 917 |
+
if (el1 && parseFloat(el1.value) === ratio) {
|
| 918 |
+
handleInputCheck(5, encodeURIComponent(JSON.stringify([{id:'in-ratio2', val:ratio}, {id:'in-d-cm', val:D_cm}])));
|
| 919 |
+
keypad.close();
|
| 920 |
+
}
|
| 921 |
+
}
|
| 922 |
+
} else {
|
| 923 |
+
// Mode A: 迷霧尋標模式
|
| 924 |
+
const H_cm_target = s * ratio;
|
| 925 |
+
if (currentInput.id === 'in-s' && val === s) {
|
| 926 |
+
handleInputCheck(2, encodeURIComponent(JSON.stringify([{id:'in-s', val:s}])));
|
| 927 |
+
setTimeout(() => {
|
| 928 |
+
const next = document.getElementById('in-d-cm2');
|
| 929 |
+
if (next) keypad.open(next);
|
| 930 |
+
}, 120);
|
| 931 |
+
} else if (currentInput.id === 'in-d-cm2' && val === D_cm) {
|
| 932 |
+
const next = document.getElementById('in-ratio');
|
| 933 |
+
if (next) keypad.open(next);
|
| 934 |
+
} else if (currentInput.id === 'in-ratio' && val === ratio) {
|
| 935 |
+
const el1 = document.getElementById('in-d-cm2');
|
| 936 |
+
if (el1 && parseFloat(el1.value) === D_cm) {
|
| 937 |
+
handleInputCheck(3, encodeURIComponent(JSON.stringify([{id:'in-d-cm2', val:D_cm}, {id:'in-ratio', val:ratio}])));
|
| 938 |
+
setTimeout(() => {
|
| 939 |
+
const next = document.getElementById('in-s2');
|
| 940 |
+
if (next) keypad.open(next);
|
| 941 |
+
}, 120);
|
| 942 |
+
}
|
| 943 |
+
} else if (currentInput.id === 'in-s2' && val === s) {
|
| 944 |
+
const next = document.getElementById('in-ratio2');
|
| 945 |
+
if (next) keypad.open(next);
|
| 946 |
+
} else if (currentInput.id === 'in-ratio2' && val === ratio) {
|
| 947 |
+
const next = document.getElementById('in-h-cm');
|
| 948 |
+
if (next) keypad.open(next);
|
| 949 |
+
} else if (currentInput.id === 'in-h-cm' && val === H_cm_target) {
|
| 950 |
+
const el1 = document.getElementById('in-s2');
|
| 951 |
+
const el2 = document.getElementById('in-ratio2');
|
| 952 |
+
if (el1 && parseFloat(el1.value) === s && el2 && parseFloat(el2.value) === ratio) {
|
| 953 |
+
handleInputCheck(4, encodeURIComponent(JSON.stringify([{id:'in-s2', val:s}, {id:'in-ratio2', val:ratio}, {id:'in-h-cm', val:H_cm_target}])));
|
| 954 |
+
keypad.close();
|
| 955 |
+
}
|
| 956 |
}
|
| 957 |
}
|
| 958 |
}
|
|
|
|
| 2218 |
loadStage(0);
|
| 2219 |
requestAnimationFrame(renderLoop);
|
| 2220 |
|
| 2221 |
+
// 支援在平板上連點 3 次 STAGE 徽章直通結算
|
| 2222 |
+
let badgeClickCount = 0;
|
| 2223 |
+
let badgeClickTimer = null;
|
| 2224 |
+
const badgeEl = document.getElementById('level-badge');
|
| 2225 |
+
if (badgeEl) {
|
| 2226 |
+
badgeEl.style.cursor = 'pointer';
|
| 2227 |
+
badgeEl.title = '連點 3 次可直接跳至任務結算';
|
| 2228 |
+
badgeEl.addEventListener('click', () => {
|
| 2229 |
+
badgeClickCount++;
|
| 2230 |
+
clearTimeout(badgeClickTimer);
|
| 2231 |
+
badgeClickTimer = setTimeout(() => { badgeClickCount = 0; }, 800);
|
| 2232 |
+
if (badgeClickCount >= 3) {
|
| 2233 |
+
badgeClickCount = 0;
|
| 2234 |
+
triggerCheatJumpToSummary();
|
| 2235 |
+
}
|
| 2236 |
+
});
|
| 2237 |
+
}
|
| 2238 |
+
|
| 2239 |
// 進入遊戲時預設開啟作戰指引彈窗
|
| 2240 |
setTimeout(() => {
|
| 2241 |
openOpticsBriefingModal();
|