
私が作った単語を学習するツールのコードを本物の高校生が1分で要約!
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>イディオムクイズ</title>
<style>
*{
font-weight:400!important;
}
body {
background-color: #ffffff;
font-family: 'm-plus-1m', sans-serif;
text-align: center;
color: #444;
padding: 20px;
max-width: 100vw; overflow-x: hidden;
}
h1 {
font-size: 28px;
color: #774400;
}
p {
font-size: 20px;
}
.link{
background-color: #8e009e;
color: #f8bdff;
padding: 0.2em 2em;
font-size: 1.2em;
border: none;
border-radius: 8px;
cursor: pointer;
text-decoration: none;
margin: 0.5em 0!important;
}
.score-board {
background-color: #321;
color: #ddd;
font-size: 1.4em;
padding: 4px;
border-radius: 8px;
display: inline-block;
line-height: 1.4em;
margin-bottom: 4px;
}
.score-board span {
font-size: 1em;
}
red{
color:red;
}
#question {
font-size: 20px;
color: #221100;
margin: 20px 0;
padding: 10px;
background: #fff;
border-radius: 10px;
display: inline-block;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
width: 80%;
min-height: 45px; /* 問題文の高さが変動してもレイアウトが崩れないように */
display: inline-block;
white-space: nowrap; /* 折り返し禁止 */
max-width: 100%; /* pタグが親に収まるようにする */
transition: transform 0.3s;
}
.option {
width: 80%;
max-width: 400px;
height: 50px;
font-size: 20px;
margin: 10px;
border: none;
border-radius: 8px;
background: #fff8f0;
color: #774400;
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
cursor: pointer;
transition: transform 0.2s, background-color 0.3s;
}
.option:hover:not(:disabled) { /* 無効化されていない時だけホバーエフェクトを適用 */
background-color: #ffddaa;
transform: scale(1.02);
}
.option:disabled { /* 回答後はカーソルをデフォルトに */
cursor: default;
}
.correct {
background-color: #aaffaa !important;
transform: scale(1.05);
}
.incorrect {
background-color: #ffaaaa !important;
transform: scale(1.05);
}
.text-outline {
-webkit-text-stroke: 5px transparent;
background: linear-gradient(180deg, rgba(255, 0, 255, 1), rgba(246, 8, 246, 1) 0%, rgba(0, 0, 255, 1) 61%, rgba(0, 255, 255, 1));
-webkit-background-clip: text;
background-clip: text;
white-space: nowrap;
}
li{
font-size:1.2em;
margin: 0.5em 0!important;
}
.message {
background: #fff;
padding: 1.5em;
margin-bottom: 2em;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
display: inline-block;
text-align: left;
}
.button {
background-color: #670073;
color: #f280ff;
padding: 1em 2em;
font-size: 1.2em;
border: none;
border-radius: 8px;
cursor: pointer;
text-decoration: none;
}
.steal {
background-color: #000000;
color: pink;
padding: 1em 2em;
font-size: 1.2em;
border: none;
border-radius: 8px;
cursor: pointer;
text-decoration: none;
}
.button:hover {
background-color: #cc002a;
}
.game-status {
background: linear-gradient(145deg, #2c3e50, #34495e);
color: #ecf0f1;
border-radius: 16px;
padding: 20px;
max-width: 350px;
margin: 20px auto;
font-family: 'm-plus-1m', sans-serif;
box-shadow: 0 8px 15px rgba(0, 0, 0, 0.3);
border: 1px solid #4a627a;
}
.status-header {
display: flex;
align-items: center;
justify-content: center;
font-size: 1.8em;
font-weight: bold;
color: #ffffff;
margin-bottom: 15px;
text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
.stage-icon {
margin-right: 10px;
transform: translateY(-2px);
}
.hp-bar-container {
background-color: #1c2833;
border-radius: 8px;
height: 25px;
padding: 4px;
box-shadow: inset 0 2px 4px rgba(0,0,0,0.4);
position: relative;
margin-bottom: 15px;
}
#userIdDisplay {
font-size: 2.5em;
font-weight: bold;
color: #0055ff;
text-align: center;
background: #f0f8ff;
border: 2px solid #0055ff;
padding: 1em;
border-radius: 10px;
margin: 1em auto;
width: fit-content;
}
.hp-bar {
background: linear-gradient(90deg, #2ecc71, #27ae60);
height: 100%;
border-radius: 5px;
transition: width 0.5s ease-in-out;
box-shadow: 0 0 10px rgba(46, 204, 113, 0.5);
}
.hp-text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
font-weight: bold;
font-size: 0.9em;
text-shadow: 1px 1px 2px black;
white-space: nowrap;
}
.stats-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px;
text-align: center;
}
.stat-item {
background: rgba(255, 255, 255, 0.05);
padding: 10px;
border-radius: 8px;
border: 1px solid rgba(255, 255, 255, 0.1);
}
.stat-label {
display: block;
font-size: 0.85em;
color: #bdc3c7;
margin-bottom: 5px;
}
.stat-value {
display: block;
font-size: 1.2em;
font-weight: bold;
color: #ffffff;
}
@media screen and (max-width: 600px) {
.score-board {
font-size: 1.1em;
padding: 6px;
line-height: 1.2em;
}
#question {
font-size: 20px;
padding: 8px;
width: 95%;
margin: 10px 0;
}
.option {
font-size: 16px;
height: 45px;
width: 90%;
margin: 6px auto;
}
.game-status {
max-width: 100%;
padding: 10px;
margin: 10px auto;
font-size: 0.9em;
}
.status-header {
font-size: 1.4em;
flex-wrap: wrap;
justify-content: center;
}
.button {
font-size: 1em;
padding: 0.7em 1.2em;
}
.message {
font-size: 0.9em;
padding: 1em;
}
#nextDamageDisplay,
#critRateDisplay {
font-size: 1em;
}
}
.affiliate{
background-color : rgba(0,0,0,0.4);
color : #ffe ;
width: 90%;
margin: auto;
text-align: center;
box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}
a{
color: #8ff ;
}
</style>
</head>
<body>
<h1>ver2025.11.07.arr.fixed</h1>
<div class="phlogo" style="font-size:24px;"><span style="color:#fff;background:#000;padding:0 16px;">クイズで暗記</span><span style="color:#000;background:#ff9000;padding:0 16px;">4択クイズRPG</span></div>
<div class="score-board">
正誤: <span id="ratecorrect" style="color:#00ff00;">0</span>/
<span id="rateincorrect" style="color:#ff0000;">0</span>(
<span id="rate" style="color:white;">0%</span>)<br>
スコア:<span class="text-outline"><span id="score">0</span></span>
本日スコア: <span id="todayScore">0</span><br>コンボ:<span id="combotext">0</span>
</div>
<br>
<div id="question-wrapper">
<p id="question"></p>
</div>
<button class="option" onclick="checkAnswer(this)"></button><br>
<button class="option" onclick="checkAnswer(this)"></button><br>
<button class="option" onclick="checkAnswer(this)"></button><br>
<button class="option" onclick="checkAnswer(this)"></button><hr>
<p id="remainingCount" style="font-weight: bold; color: #333;">このキューに残り 0 問</p>
<div class="game-status">
<div class="status-header">
<span class="stage-icon">{emj_ip_0626}</span>
<span class="stage-label">ステージ</span>
<span id="statusStage" class="stage-value">1</span>
</div>
<div class="hp-bar-container">
<div id="statusHpBar" class="hp-bar" style="width: 100%;"></div>
<div id="statusHpText" class="hp-text">11 / 11</div>
</div>
<div class="stats-grid">
<div class="stat-item">
<span class="stat-label">{emj_ip_0173} 体力</span>
<span id="statusHpValue" class="stat-value">11</span>
</div>
<div class="stat-item">
<span class="stat-label">ダメージ</span>
<span id="statusDamage" class="stat-value">1.00</span>
</div>
<div class="stat-item">
<span class="stat-label">{emj_ip_0092} 転生</span>
<span id="statusRebirth" class="stat-value">0</span>
</div>
</div>
</div>
<br>
<div id="nextDamageDisplay" style="margin-top:10px; font-size: 1.2em; color: #007700;">
次のダメージ予測:
</div>
<div id="critRateDisplay" style="margin-top:10px; font-size: 1.2em; color:#337ab7;"></div>
<button class="button" onclick="rebirth()" style="background:#00f2ff;color:#fb00ff;">転生する</button>
<button onclick="toggleHardMode()" class="button" style="background:#ff00fb;color:#fff;">ハードモード: OFF</button>
<button class="button" onclick="promote()" style="background-color:#30f;color:white;">昇格する</button>
<p id="rebirthCooldownText"></p>
<p id="promotionInfo" style="margin-top: 10px; font-size: 1.1em; color: #007acc;">
現在の昇格倍率:×<span id="promotionMultiplierText">1.00</span>
</p>
<p id="supremacyDisplay"> サプレマシー: 0</p>
<p id="coinDisplay"> コイン: 0</p>
<button class="button" onclick="openShop()">ショップを開く</button>
<div id="shop">
<h3>{emj_ip_0091} 一時的強化(コイン)</h3>
<div id="tempShop"></div>
<h3> 恒久的強化(サプレマシー)</h3>
<div id="permShop"></div>
</div>
<div id="powerupChoices" style="margin: 20px 0;">
<p><strong>以下のうち1つを選んで強化(リロードで選び直せるがコンボもリセットされます)↓不具合発生中:</strong></p>
<button class="button" onclick="choosePowerup('hpReduce')">敵の体力が1乗→0.95乗になる</button>
<button class="button" onclick="choosePowerup('atkBoost')">自分の攻撃力が1乗→1.04乗になる</button>
<button class="button" onclick="choosePowerup('rebirthBoost')">転生時の増加量が1乗→1.10乗になる</button>
<button class="button" onclick="choosePowerup('doubleAtk')">攻撃力2倍はバグのため辞めました。</button>
</div>
<p style="font-size: 0.9em; color: #555;">
敵HP指数: <span id="hpPowerText">1.00</span><br>
攻撃力指数: <span id="atkPowerText">1.00</span><br>
転生指数: <span id="rebirthPowerText">1.00</span>
</p>
<button onclick="giveLoginBonus()" class="button">1日1回ログインボーナスを受け取る</button>
<h2>万引き</h2>
<p>75%の確率で万引きに成功すれば今のサプレマシーを2倍にします。バレたら全額失います</p>
<button onclick="trySteal()" class="steal">** 万引きする</button>
<h3>回答ログ</h3>
<table id="answerLog" border="1">
<thead>
<tr>
<th>English</th>
<th>Japanese</th>
<th>正解数</th>
<th>不正解数</th>
</tr>
</thead>
<tbody></tbody>
</table>
<h3>{emj_ip_0757} 転生とは?</h3>
<p>
転生は、ステージ20以上に到達することで可能になるシステムです。
転生を行うと、基礎ダメージ(攻撃力)が上昇します。
転生によるダメージ増加量は「現在のステージ」に比例し、転生すればするほど強くなっていきます。
コインとサプレマシーも同様です
</p>
<h3>
{emj_ip_0757} 昇格(昇華)とは?
</h3>
<p>
昇格(昇華)は、ステージ1000以上に到達し、かつ現在の攻撃力が前回の昇格時より高い場合にだけ可能になる、特別な成長システムです。
昇格を行うと、攻撃力は一時的に半減しますが、その代わりに「転生時の成長倍率」が永続的に上昇します。
この倍率は、基礎攻撃力の平方根(√)が増加されます、以後の転生による強化が飛躍的に高まります。
つまり、適切なタイミングで昇格を重ねるほど転生が強力になるという仕組みです。
</p>
<h2>1学期期末テストクイズ(終了)</h2>
<ul>
<li><a class="link" href="http://khp.jp/idiomquiz/37">37(物理)</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/36">36(数3)</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/35">35(英コミュ)</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/33">33(国語)</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/32">32(デザイン実践)</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/31">31(歴史)</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/25">25(工業英語)</a></li>
</ul>
<h2>単語テスト</h2>
<ul>
<li><a class="link" href="http://khp.jp/idiomquiz/46">46(ターゲット1400-701)</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/47">47(ターゲット1400-801)</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/49">49(ターゲット1400-901)</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/50">50(ターゲット1400-1001)</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/51">51(ターゲット1400-1101)</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/52">52(ターゲット1400-1201)</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/53">53(ターゲット1400-1301)</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/59">英語lesson2裏</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/60">英語lesson3表</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/61">英語lesson3裏</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/62">英語lesson4表</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/63">英語lesson4裏</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/64">英語lesson5表</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/65">英語lesson5裏</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/66">英語lesson6表</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/67">英語lesson6裏</a></li>
<li><a class="link" href="https://khp.jp/idiomquiz/1">イディオム1</a></li>
<li><a class="link" href="https://khp.jp/idiomquiz/2">イディオム2</a></li>
<li><a class="link" href="https://khp.jp/idiomquiz/3">イディオム3</a></li>
<li><a class="link" href="https://khp.jp/idiomquiz/4">イディオム4</a></li>
<li><a class="link" href="https://khp.jp/idiomquiz/5">イディオム5</a></li>
<li><a class="link" href="https://khp.jp/idiomquiz/6">イディオム6</a></li>
<li><a class="link" href="https://khp.jp/idiomquiz/7">イディオム7</a></li>
<li><a class="link" href="https://khp.jp/idiomquiz/8">イディオム8</a></li>
<li><a class="link" href="https://khp.jp/idiomquiz/58">イディオム前半</a></li>
</ul>
<h2>その他のゲーム</h2>
<ul>
<li><a class="link" href="http://khp.jp/idiomquiz/30">30(1/4を当てるだけ)</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/34">34(ネットワーク通信知識(旧1学期期末))</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/38">38(元素記号クイズ)</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/40">40(キセキの世代2014クイズ)</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/42">42(面接マナークイズ)</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/44/">44(駅ナンバリング(23区内))</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/48/">48数学基礎知識(数3含む)</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/56/">56数学積分基礎知識</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/69/">69(SQL基礎)</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/70/">70(数C 楕円・双曲線・放物線)</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/71/">71(16進数→10進数)</a></li>
<li><a class="link" href="http://khp.jp/idiomquiz/72/">72(2進数→10進数)</a></li>
</ul>
<div id="userIdDisplay" style="font-size: 2em; font-weight: bold; margin: 1em 0; color: #333;"></div>
<div style="margin: 1em auto; text-align: center;">
<label for="nicknameInput">表示名(ニックネーム):</label>
<input id="nicknameInput" type="text" placeholder="例: あいうえお" style="padding: 0.5em; border-radius: 6px;">
<button onclick="saveNickname()" class="button" style="margin-left: 0.5em;">保存</button>
</div>
<h1>お友達にこのリンクをシェアしよう!</h1>
<!-- Twitterボタン -->
<a class="btn twitter" href="https://twitter.com/intent/tweet?text=覚えて起きたいイディオムクイズ&url=http://khp.jp/idiomquiz/" target="_blank">
Twitterでシェア
</a>
<!-- LINEボタン -->
<a class="btn lineA" href="https://social-plugins.line.me/lineit/share?url=http://khp.jp/idiomquiz/" target="_blank">
LINEでシェア
</a>
<!-- クリップボードコピー -->
<a class="btn copy" href="#" onclick="copyToClipboard(); return false;">
リンクをコピー
</a>
<p id="copiedMessage" style="display:none; color: green; font-weight: bold;">コピーしました!</p>
</div>
</div>
<hr>
<div id="log" style="text-align:left; white-space:pre-wrap; max-height:200px; overflow:auto; border:1px solid #ccc; padding:10px;"></div>
<script>
// --- Global Variables with initial values ---
let adBlock = 0;
const permanentUpgrades = {
coinBoostFlat: { name: "コイン増加", level: 0, get cost() { return Math.floor(2 ** this.level); }, get effect() { return 1.1 ** this.level; } },
coinBoostPerStage: { name: "ステージ比例コイン増加", level: 0, get cost() { return Math.floor(1000 ** this.level); }, get effect() { return 0.01 * this.level; } },
costReduceAll: {
name: "全てのコスト減",
level: 0,
get cost() { return Math.floor(1e9 * 10 ** this.level); },
get effect() { return 1 / Math.max(1, this.level); }
},
permanentAtk: {
name: "恒久攻撃力増加",
level: 0,
get cost() { return Math.floor(10 ** Math.sqrt(this.level)); },
get effect() { return 1.01 ** this.level; }
},
enemyHpExpDown: {
name: "恒久敵HP指数減少",
level: 0,
get cost() { return Math.floor(1e12 * 2 ** this.level); },
get effect() { return -0.001 * this.level; } // マイナス指数
},
rebirthBoostExp: {
name: "恒久転生量指数増加",
level: 0,
get cost() { return Math.floor(1e8 * 2 ** this.level); },
get effect() { return 0.002 * this.level; }
},
stageAtkBoost: {
name: "ステージ比例攻撃力増加",
level: 0,
get cost() { return Math.floor(1e15 * 1e4 **is.level); },
get effect() {
return Math.log(Math.max(2, currentStage)) ** this.level;
}
},
};
const temporaryUpgrades = {
atkBoost1: {
name: "攻撃力増加1",
level: 0,
get cost() { return Math.floor(10000 * 1.1 ** this.level); },
get effect() { return 1 + 0.10 * this.level; }, // 乗算用 (例: 1.3 = +30%)
},
atkBoost2: {
name: "攻撃力増加2",
level: 0,
get cost() { return Math.floor(1 * 10 ** this.level); },
get effect() { return 2 ** this.level; }, // 乗算用
},
hpReduce: {
name: "敵体力減少",
level: 0,
get cost() { return Math.floor(1 * 10 ** this.level); },
get effect() { return 0.9 ** this.level; }, // 敵HP × 値
},
};
let redeemedDonations = []; // 使用済みコード一覧
let correctAnsCount = 0;
let incorrectAnsCount = 0;
let totalAnsCount = 0;
let combo = 0;
let score = 0;
let todayScore = 0;
let currentQuestion = null;
let currentQuestionType = 0; // 0: 英文→和訳, 1: 和訳→英文
let currentStage = 1;
let enemyHP = 11; // This will be recalculated or loaded from cookie
let chosenPowerup = null;
let baseDamage = 1.0;
let rebirthCount = 0;
let lastDamage = 0;
let cooldownInterval = null;
let idiomQueue = []; // 出題待ちリスト
let lastLoginDate = ""; // ログインボーナス受け取り日
let maxStageReached = 1; // ステージ進行に合わせて更新する
let promotionMultiplier = 1; // 転生ボーナス倍率(初期1)
let nextPromotionThreshold = 1;
let donationCount = 1.00 ; //寄付額*0.01
let atkPower = 1.00;
let loading = 0;
let quizQueue = []; // 現在の出題キュー
let mistakeQueue = []; // 間違えた問題の記録
let isReviewMode = false; // 復習モードかどうか
let coin = 0; // 一時強化用通貨
let supremacy = 0; // 恒久強化用通貨
let var2 = 0;
let var3 = 0;
let var4 = 0;
let var5 = 0;
let var6 = 0;
let var7 = 0;
let var8 = 0;
let var9 = 0;
let var10 = 0;
let lastRebirthTime = 0;
//session
let session = []; // セッションデータを保存する配列
let sessionId = 0; // セッションID
let currentPlayTime = 0; // 秒数
let currentCorrectCount = 0; // 現セッションの正解数
let currentAnswerCount = 0; // 現セッションの回答数
let currentLoadedTime = Date.now(); // 読み込んだ時の時間
//const idioms = [{english : "1" , japanese : "1"},{english : "2" , japanese : "2"},{english : "3" , japanese : "3"},{english : "4" , japanese : "4"},]
let donationList = [
["donation000001", 1 ** 2 * 1e6 * (1e8 + 10 * maxStageReached ** 2) * donationCount],
//例
];
let ttsEnabled = true;
let ttsVoice = null; // 選択中の声
let ttsRate = 1; // 速度(0.*10)
let ttsPitch = 1; // ピッチ(*2)
function initTTS() {
if ('speechSynthesis' in window) {
ttsEnabled = true;
loadVoices().then(voices => {
if (voices.length > 0) {
// 日本語音声を優先的に選択
const japaneseVoice = voices.find(voice =>
voice.lang.includes('ja') || voice.lang.includes('JP')
);
ttsVoice = japaneseVoice || voices[0];
}
});
} else {
console.warn('このブラウザは音声合成をサポートしていません');
alert("このブラウザは音声合成をサポートしていません。LINEブラウザなどでは対応していませんがChromeだと対応してるのでchromeで開いてみてください")
ttsEnabled = false;
}
}
// 音声一覧を取得(ページ読み込み時に1回呼び出す)
function loadVoices() {
return new Promise((resolve) => {
let voices = speechSynthesis.getVoices();
if (voices.length) {
resolve(voices);
return;
}
speechSynthesis.onvoiceschanged = () => {
resolve(speechSynthesis.getVoices());
};
});
}
function speak(text) {
if (!ttsEnabled || !text || !window.speechSynthesis) return;
try {
// 既に話していたらキャンセル
if (speechSynthesis.speaking) {
speechSynthesis.cancel();
}
// 少し待ってから読み上げ開始(キャンセル直後の無視対策)
setTimeout(() => {
const utter = new SpeechSynthesisUtterance(text);
utter.lang = detectLang(text); // 言語自動判定
if (ttsVoice) utter.voice = ttsVoice;
utter.rate = ttsRate || 1;
utter.pitch = ttsPitch || 1;
// デバッグ用イベント
utter.onstart = () => console.log("読み上げ開始:", text);
utter.onend = () => console.log("読み上げ終了");
utter.onerror = (event) => {
console.warn("音声合成エラー:", event);
// 無効化せず、次回以降も試せるようにする
};
speechSynthesis.speak(utter);
}, 100);
} catch (error) {
console.warn("音声合成に失敗:", error);
// ttsEnabled = false; ←消す(無効化はユーザーが手動でON/OFFする)
}
}
function detectLang(text) {
if (!text) return "en-US";
// 日本語(ひらがな・カタカナ・漢字)が含まれていたら日本語
if (/[ぁ-んァ-ン一-龠]/.test(text)) {
return "ja-JP";
}
// アルファベットのみの場合 → 英語
if (/^[a-zA-Z\s]+$/.test(text)) {
return "en-US";
}
// 数字や記号だけの場合 → 英語に寄せる
if (/^[0-9\s\.,!?'"-]+$/.test(text)) {
return "en-US";
}
// デフォルトは英語
return "en-US";
}
function processDonationCode(code) {
if (redeemedDonations.includes(code)) {
alert("この寄付コードはすでに使用されています。");
return;
}
const entry = donationList.find(([id, _]) => id === code);
if (!entry) {
alert("無効な寄付コードです。");
return;
}
const amount = entry[1];
supremacy += amount;
alert(` ご支援ありがとうございます! ${formatNumber(amount).toExponential(3)} サプレマシーを獲得しました!`);
redeemedDonations.push(code);
updateSupremacyDisplay();
saveData();
alert(` ご支援ありがとうございます! ${formatNumber(amount).toExponential(3)} サプレマシーを獲得しました!`);
}
function getUpgradeCost(upgrade) {
const raw = upgrade.cost;
const reduction = permanentUpgrades.costReduceAll.effect;
return Math.floor(raw * reduction);
}
let answerStats = {}; // { "english文": { correct: 0, wrong: 0, japanese: "" } }
function initializeAnswerStats() {
answerStats = {}; // 必ず初期化
idioms.forEach(question => {
if (question && question.english) {
answerStats[question.english] = {
correct: 0,
wrong: 0,
japanese: question.japanese || '',
};
}
});
}
function logAnswer(isCorrect) {
if (!currentQuestion || !currentQuestion.english) return;
const key = currentQuestion.english;
// answerStats が初期化されていることを確認
if (!answerStats[key]) {
answerStats[key] = {
correct: 0,
wrong: 0,
japanese: currentQuestion.japanese || '',
};
}
if (isCorrect) {
answerStats[key].correct++;
} else {
answerStats[key].wrong++;
}
updateAnswerLogTable();
}
function updateAnswerLogTable() {
const tbody = document.querySelector("#answerLog tbody");
tbody.innerHTML = ""; // テーブルをクリア
Object.keys(answerStats).forEach(key => {
const stat = answerStats[key];
const row = document.createElement("tr");
row.innerHTML = `
<td>${key}</td>
<td>${stat.japanese}</td>
<td>${stat.correct}</td>
<td>${stat.wrong}</td>
`;
tbody.appendChild(row);
});
}
function trySteal() {
if (supremacy <= 0) {
alert("サプレマシーがないので万引きできません!");
return;
}
const confirmAction = confirm(
` 万引きを実行しますか?\n\n成功すればサプレマシーが2倍になりますが、\n25%の確率で全額を失います!`
);
if (!confirmAction) return;
const success = Math.random() >= 0.25;
if (success) {
let bonusMultiplier = 2 * Math.random() ** -1;
supremacy *= bonusMultiplier;
alert(` 万引き成功!サプレマシーが${bonusMultiplier.toFixed()}倍になりました!`);
} else {
supremacy = 0;
alert(" バレた!サプレマシーを全額失いました!これがゲームで良かったね。");
}
updateSupremacyDisplay();
saveData();
}
function getNickname() {
return localStorage.getItem("nickname") || "";
}
function saveNickname() {
const nick = document.getElementById("nicknameInput").value.trim();
if (nick.length === 0) {
alert("ニックネームを入力してください");
return;
}
localStorage.setItem("nickname", nick);
alert("ニックネームを保存しました!");
}
function giveLoginBonus() {
const today = new Date().toLocaleDateString();
if (lastLoginDate === today) {
alert("今日はすでにログインボーナスを受け取りました!");
return;
}
const bonus = Math.floor(10000 * maxStageReached ** 2 * permanentUpgrades.coinBoostFlat.effect * donationCount);
supremacy += bonus;
lastLoginDate = today;
saveData();
alert(` ログインボーナスで ${bonus} サプレマシーを獲得しました!`);
updateSupremacyDisplay();
}
function showUserId() {
const uid = getOrCreateUserId();
const display = document.getElementById("userIdDisplay");
display.textContent = "あなたのユーザーID: " + uid;
}
function addLog(text) {
const logDiv = document.getElementById("log");
const timestamp = new Date().toLocaleTimeString();
logDiv.innerHTML = `[${timestamp}] ${text}<br>` + logDiv.innerHTML;
}
let hpPower = getHpPower()
let rebirthPower = getRebirthPower()
function getHpPower() {
return 1.00 + permanentUpgrades.enemyHpExpDown.effect;
}
function getRebirthPower() {
return 1.00 + permanentUpgrades.rebirthBoostExp.effect;
}
function getTodayKey() {
const d = new Date();
return "score_" + d.toISOString().slice(0, 10); // YYYY-MM-DD
}
function choosePowerup(type) {
if(chosenPowerup) return;
switch(type) {
case 'hpReduce':
hpPower -= 0.05;
chosenPowerup = "敵の体力の指数を -0.05";
break;
case 'atkBoost':
atkPower += 0.04;
chosenPowerup = "攻撃力の指数を +0.04";
break;
case 'rebirthBoost':
rebirthPower += 0.1;
chosenPowerup = "転生ボーナスの指数を +0.10";
break;
case 'doubleAtk':
baseDamage *= 1;
chosenPowerup = "攻撃力を1倍にする";
break;
}
document.getElementById("powerupChoices").innerHTML = `<p>選択された強化: ${chosenPowerup}</p>`;
updateBoostDisplay();
}
function getPromotionPreview() {
const currentMultiplier = promotionMultiplier;
const gain = Math.sqrt(baseDamage);
const nextMultiplier = gain;
const beforeDamage = baseDamage;
const afterDamage = baseDamage * 0.5;
return `今昇華すると以下のようになります:\n` +
`転生時の基礎ダメ増加量増加: ${currentMultiplier.toFixed(2)} → ${nextMultiplier.toFixed(2)} (×${(gain / currentMultiplier).toFixed(2)} \n 最終昇華時の基礎ダメ: ${nextPromotionThreshold.toFixed(0)})\n` +
`基礎ダメ: ${beforeDamage.toFixed(0)} → ${afterDamage.toFixed(0)}`;
}
function updatePromotionUI() {
document.getElementById("promotionMultiplierText").innerText = getPromotionPreview()
}
let hardMode = false;
function toggleHardMode() {
hardMode = !hardMode;
document.querySelector('button[onclick="toggleHardMode()"]').innerText =
`ハードモード: ${hardMode ? "ON" : "OFF"}`;
addLog(`{emj_ip_0373} ハードモードを${hardMode ? "ON" : "OFF"}にしました`);
updateNextDamageDisplay(); // ←これを追加
}
function startRebirthCooldownTimer() {
const el = document.getElementById("rebirthCooldownText");
if (!el) return;
if (cooldownInterval) clearInterval(cooldownInterval);
cooldownInterval = setInterval(() => {
const remaining = 60 - Math.floor((Date.now() - lastRebirthTime) / 1000);
if (remaining <= 0) {
el.innerText = "";
clearInterval(cooldownInterval);
cooldownInterval = null;
} else {
el.innerText = `あと ${remaining} 秒で転生可能`;
}
}, 1000);
}
function shuffleIdioms() {
const array = idioms.slice(); // 元配列をコピー
for(let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
idiomQueue = array;
}
// --- Data Persistence (Modified) ---
function saveData() {
localStorage.setItem("coin", coin);
localStorage.setItem("supremacy", supremacy);
localStorage.setItem("score", score);
localStorage.setItem("correctAnsCount", correctAnsCount);
localStorage.setItem("incorrectAnsCount", incorrectAnsCount);
localStorage.setItem("promotionMultiplier", promotionMultiplier);
localStorage.setItem("nextPromotionThreshold", nextPromotionThreshold);
localStorage.setItem("currentStage", currentStage);
localStorage.setItem("baseDamage", baseDamage);
localStorage.setItem("rebirthCount", rebirthCount);
localStorage.setItem("maxStageReached", maxStageReached);
localStorage.setItem("lastLoginDate", lastLoginDate);
localStorage.setItem("lastRebirthTime", lastRebirthTime);
for (let i = 2; i <= 10; i++) {
localStorage.setItem(`var${i}`, window[`var${i}`]);//予備
}
localStorage.setItem("enemyHP", enemyHP);
localStorage.setItem("permUpgrades", JSON.stringify(Object.fromEntries(
Object.entries(permanentUpgrades).map(([k, v]) => [k, v.level])
)));
localStorage.setItem("tempUpgrades", JSON.stringify(Object.fromEntries(
Object.entries(temporaryUpgrades).map(([k, v]) => [k, v.level])
)));
localStorage.setItem("redeemedDonations", JSON.stringify(redeemedDonations));
const currentSession = {
id: sessionId,
playTime: currentPlayTime,
correct: currentCorrectCount,
answer: currentAnswerCount,
loadedTime: currentLoadedTime,
savedTime: Date.now()
};
// session配列を更新(同じIDがあれば上書き、なければ追加)
const existingIndex = session.findIndex(s => s.id === sessionId);
if (existingIndex >= 0) {
session[existingIndex] = currentSession;
} else {
session.push(currentSession);
}
// localStorageに保存(文字列化して保存する必要がある)
localStorage.setItem("sessionData", JSON.stringify(session));
}
function setQuestion(text) {
const textEl = document.getElementById("question");
textEl.textContent = text;
requestAnimationFrame(() => {
adjustScale();
});
}
function updateBoostDisplay() {
document.getElementById("hpPowerText").innerText = getHpPower().toFixed(2);
document.getElementById("atkPowerText").innerText = atkPower.toFixed(2);
document.getElementById("rebirthPowerText").innerText = rebirthPower.toFixed(2);
}
function promote() {
if(currentStage < 1000) {
alert("ステージ1000以上でないと昇格できません。");
console.log(nextPromotionThreshold);
console.log(baseDamage)
updateRate()
return;
}
if(baseDamage < nextPromotionThreshold) {
alert(`昇格には攻撃力${nextPromotionThreshold}以上が必要です。`);
updateRate()
return;
}
const gain = Math.sqrt(baseDamage); // 昇格倍率増加量
if(baseDamage - 10 >= nextPromotionThreshold) {
promotionMultiplier = gain;
nextPromotionThreshold = baseDamage;
baseDamage *= 0.5; // 昇格ペナルティ
updateRate()
alert(`昇格!現在の総倍率:×${promotionMultiplier.toFixed(2)}\n攻撃力は ${baseDamage.toFixed(2)} に半減しました。`);
console.log(nextPromotionThreshold);
return;
}
}
function shuffleArray(array) {
if (!array || !Array.isArray(array)) return [];
const newArray = [...array];
for (let i = newArray.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[newArray[i], newArray[j]] = [newArray[j], newArray[i]];
}
return newArray;
}
function updateSupremacyDisplay() {
document.getElementById("supremacyDisplay").innerText = ` サプレマシー: ${supremacy.toExponential()}`;
}
function hardModeJudge(n){
if(n<100){
return false
}else if(n<5000){
return n%10 !== 1
}else if(n<100000){
return n%100 !== 1
}else if(n<1000000){
return n%1000 !== 1
}else {
return n%2000 !== 1
}
}
function getCoinGain() {
let base = 10000 * donationCount;
let multiplier = permanentUpgrades.coinBoostFlat.effect;
let stageBonus = Math.floor(currentStage * (permanentUpgrades.coinBoostPerStage.effect));
return Math.floor((base * (1+stageBonus) * (1+multiplier)));
saveData();
}
function buyUpgrade(type, key) {
let upgrades = (type === 'temp') ? temporaryUpgrades : permanentUpgrades;
let upgrade = upgrades[key];
let cost = getUpgradeCost(upgrade);
if (type === 'temp' && coin >= cost) {
coin -= cost;
upgrade.level++;
updateCoinDisplay();
} else if (type === 'perm' && supremacy >= cost) {
supremacy -= cost;
upgrade.level++;
updateSupremacyDisplay();
saveData(); // 恒久なので保存
} else {
alert("通貨が足りません!");
}
updateShopDisplay();
}
function updateShopDisplay() {
const tempEl = document.getElementById("tempShop");
const permEl = document.getElementById("permShop");
tempEl.innerHTML = "";
permEl.innerHTML = "";
for (let key in temporaryUpgrades) {
const u = temporaryUpgrades[key];
tempEl.innerHTML += `
<button onclick="buyUpgrade('temp','${key}')">
${u.name} Lv.${u.level}<br>
効果: ${formatEffect(u.effect)} / コスト: ${u.cost.toExponential()}コイン
</button><br>
`;
}
for (let key in permanentUpgrades) {
const u = permanentUpgrades[key];
permEl.innerHTML += `
<button onclick="buyUpgrade('perm','${key}')">
${u.name} Lv.${u.level}<br>
効果: ${formatEffect(u.effect)} / コスト: ${u.cost.toExponential()}サプレマシー
</button><br>
`;
}
}
function formatEffect(eff) {
return (eff >= 2) ? `×${eff.toFixed(2)}` : `+${(eff).toFixed(2)}`;
}
function startNewRound() {
quizQueue = [...idioms]; // idiomsは全問題配列
shuffleArray(quizQueue); // ランダム化(関数定義必要)
isReviewMode = false;
mistakeQueue = [];
initializeAnswerStats(); // ← ここで必ず最新の idioms を登録
generateQuiz();
}
function startQuiz() {
idiomQueue = [...idioms];
shuffleArray(idiomQueue);
mistakeQueue = [];
isReviewMode = false;
initializeAnswerStats(); // ← ここで必ず最新の idioms を登録
generateQuiz();
}
function loadData() {
const getItem = (key, def = null) => {
const val = localStorage.getItem(key);
return val !== null ? val : def;
};
const safeParseInt = (val, def = 0) => val !== null ? parseInt(val, 10) : def;
const safeParseFloat = (val, def = 0) => val !== null ? parseFloat(val) : def;
coin = safeParseInt(getItem("coin"));
supremacy = safeParseInt(getItem("supremacy"));
score = safeParseInt(getItem("score"));
correctAnsCount = safeParseInt(getItem("correctAnsCount"));
incorrectAnsCount = safeParseInt(getItem("incorrectAnsCount"));
promotionMultiplier = safeParseFloat(getItem("promotionMultiplier"), 1);
nextPromotionThreshold = safeParseFloat(getItem("nextPromotionThreshold"), 100);
currentStage = safeParseInt(getItem("currentStage"), 1);
baseDamage = safeParseFloat(getItem("baseDamage"), 1);
rebirthCount = safeParseInt(getItem("rebirthCount"), 0);
maxStageReached = safeParseInt(getItem("maxStageReached"), 1);
lastLoginDate = getItem("lastLoginDate") || "";
lastRebirthTime = safeParseInt(getItem("lastRebirthTime"), Date.now());
for (let i = 2; i <= 10; i++) {
window[`var${i}`] = safeParseInt(getItem(`var${i}`));
}
const savedEnemyHP = getItem("enemyHP");
enemyHP = savedEnemyHP && parseInt(savedEnemyHP, 10) > 0 ? parseInt(savedEnemyHP, 10) : calcEnemyHP(currentStage);
try {
const saved = getItem("permUpgrades");
if (saved) {
const levels = JSON.parse(saved);
for (let k in levels) {
if (permanentUpgrades[k]) {
permanentUpgrades[k].level = levels[k] || 0;
}
}
}
} catch (e) {
console.warn("permUpgrades load failed", e);
}
try {
const savedTemp = getItem("tempUpgrades");
if (savedTemp) {
const levels = JSON.parse(savedTemp);
for (let k in levels) {
if (temporaryUpgrades[k]) {
temporaryUpgrades[k].level = levels[k] || 0;
}
}
}
} catch (e) {
console.warn("tempUpgrades load failed", e);
}
// 今日のスコア
todayScore = safeParseInt(localStorage.getItem(getTodayKey()), 0);
try {
const redeemed = getItem("redeemedDonations");
if (redeemed) redeemedDonations = JSON.parse(redeemed);
} catch (e) {
redeemedDonations = {};
}
const data = localStorage.getItem("sessionData");
if (data) {
session = JSON.parse(data); // 復元
// 新しいセッションを開始(既存のID最大値+1)
sessionId = session.length;
} else {
session = [];
sessionId = 0;
}
currentPlayTime = 0;
currentCorrectCount = 0;
currentAnswerCount = 0;
currentLoadedTime = Date.now();
}
function formatNumber(n) {
return n.toLocaleString();
}
function updateRemainingCount() {
const el = document.getElementById("remainingCount");
el.innerText = `このキューに残り ${idiomQueue.length+1} 問`;
}
function updateCoinDisplay() {
document.getElementById("coinDisplay").innerText = ` コイン: ${coin.toExponential()}`;
}
function openShop() {
document.getElementById("shop").style.display = "block";
updateShopDisplay(); // ← UI内容を最新に更新
}
function closeShop() {
document.getElementById("shop").style.display = "none";
}
function updateRate() {
totalAnsCount = correctAnsCount + incorrectAnsCount;
document.getElementById('ratecorrect').innerText = correctAnsCount;
document.getElementById('rateincorrect').innerText = incorrectAnsCount;
document.getElementById('combotext').innerText = `${combo}(次: ${(combo + 1) ** 3 * donationCount})`;
document.getElementById('rate').innerText = totalAnsCount > 0 ? (correctAnsCount / totalAnsCount * 100).toFixed(1) + "%" : "0%";
document.getElementById('score').innerText = score;
document.getElementById('todayScore').innerText = todayScore;
saveData();
updateCritRateDisplay(); // ← 追加!
updateNextDamageDisplay(); // ← これを追加
updatePromotionUI()
updateCoinDisplay();
updateSupremacyDisplay();
updateAnswerLogTable()
}
function boss(n) {
if(n % 100 == 0){
return 1000;
}else{
return 1;
}
}
function updateNextDamageDisplay() {
let base = 1;
// 一時強化
base *= temporaryUpgrades.atkBoost1.effect;
base *= temporaryUpgrades.atkBoost2.effect;
// 恒久攻撃力補正
base *= permanentUpgrades.permanentAtk.effect;
// ステージ依存補正(log(stage)^level)
base *= permanentUpgrades.stageAtkBoost.effect;
// ベースダメージに補正をかけた攻撃力
let rawBase = base;
// ダメージ計算(atkPower指数乗あり)
let normal = Math.floor((combo + 1) * rawBase * baseDamage) ** atkPower;
let critical = Math.floor((combo + 1) * rawBase *baseDamage ** 2) ** atkPower;
let superCritical = Math.floor((combo + 1) ** 2 * rawBase * baseDamage ** 2) ** atkPower;
let superCriticalCritical = Math.floor((combo + 1) ** 2 * rawBase * baseDamage ** 2 * (rebirthCount + 1)) ** atkPower;
if (hardMode) {
normal = Math.ceil(normal / 200);
critical = Math.ceil(critical / 200);
superCritical = Math.ceil(superCritical / 200);
superCriticalCritical = Math.ceil(superCriticalCritical / 200);
}
document.getElementById("nextDamageDisplay").innerHTML =
` 通常: <p>${normal.toExponential(2)}</p> / ` +
`クリティカル: <p style="color:orange">${critical.toExponential(2)}</p> / ` +
` 強い一撃: <p style="color:red">${superCritical.toExponential(2)}</p>` +
`核:<p style="color:purple">${superCriticalCritical.toExponential(2)}</p>` +
(hardMode ? "(ハード補正)" : "");
}
// ---- Game Mechanics ----
function uploadScore(){}//ここでは非表示にしてる
function calcEnemyHP(stage) {
let enemyExp = getHpPower(); // 変更前: hpPower
if(stage >= 5000) {
return Math.floor((1e30 * 1.1 ** (stage/10000) + (10001 - stage%10000) * 1e6 * (stage - 4999) ** 8 )*temporaryUpgrades.hpReduce.effect * boss(stage / 100) * boss(stage/10000) * Math.max(stage - 100000 , 1)**2) ** enemyExp * temporaryUpgrades.hpReduce.effect;
}else if(stage >= 1000) {
return Math.floor(2 ** (35 + stage / 40 - Math.floor(stage / 100)) / stage* temporaryUpgrades.hpReduce.effect) ** enemyExp * boss(stage) ** 0.5 /10 * temporaryUpgrades.hpReduce.effect;
} else if(stage >= 500) {
return Math.floor((2 ** (stage / 20)) / stage * 100 * temporaryUpgrades.hpReduce.effect) ** enemyExp * boss(stage) ** 0.5 * temporaryUpgrades.hpReduce.effect;
} else if(stage >= 400) {
return Math.floor((2 ** (stage / 20)) * temporaryUpgrades.hpReduce.effect) ** enemyExp * boss(stage) ** 0.5* temporaryUpgrades.hpReduce.effect;
} else {
return Math.floor( 2 ** (stage / 20) * temporaryUpgrades.hpReduce.effect ) ** enemyExp * boss(stage) ** 0.5* temporaryUpgrades.hpReduce.effect;
}
}
function updateEnemyStatus() {
const maxHP = calcEnemyHP(currentStage);
const hpPercentage = maxHP > 0 ? (enemyHP / maxHP) * 100 : 0;
// 新しいUI要素に値を設定
document.getElementById('statusStage').innerText = currentStage;
document.getElementById('statusHpBar').style.width = `${hpPercentage}%`;
document.getElementById('statusHpText').innerText = `${enemyHP.toExponential(4)} / ${maxHP.toExponential(4)}`;
document.getElementById('statusHpValue').innerText = enemyHP.toExponential(2);
document.getElementById('statusDamage').innerText = baseDamage.toExponential(2);
document.getElementById('statusRebirth').innerText = rebirthCount;
// データを保存する関数呼び出しはそのまま
saveData();
}
if(currentStage==1){
alert("ようこそ!4択RPGオンラインへ!");
alert("問題に対して4択で答えを表示するから正しい回答を連続で選び続けてね!")
alert("連続で正解した数に応じてスコアとダメージアップ!目指せステージ100万!");
alert("読み込みが完了するまで操作しないでください。ヤッちゃうと...データ消えます")
}
function attackEnemy() {
let damage;
let base = 1;
base *= permanentUpgrades.permanentAtk.effect;
base *= permanentUpgrades.stageAtkBoost.effect;
base *= temporaryUpgrades.atkBoost1.effect;
base *= temporaryUpgrades.atkBoost2.effect;
if(Math.random() < Math.log(currentStage * combo * baseDamage * score * rebirthCount) / 100) {
damage = Math.floor((combo + 1) ** 2 * baseDamage ** 2 * (rebirthCount + 1)*base) ** atkPower;
} else if(Math.random() < Math.log(currentStage * combo * baseDamage * score * rebirthCount) / 100) {
damage = Math.floor((combo + 1) ** 2 * baseDamage ** 2 * base) ** atkPower;
} else if(Math.random() < Math.log(currentStage * combo * baseDamage * score * rebirthCount) / 100) {
damage = Math.floor((combo + 1) * baseDamage ** 2 * base) ** atkPower;
} else {
damage = Math.floor((combo + 1) * baseDamage * base) ** atkPower;
}
if(hardMode) {
damage = Math.ceil(damage / 200);
}
let overkill = damage;
let killCount = 0;
while(overkill > 0) {
const maxHP = calcEnemyHP(currentStage);
if(currentStage==1000001){
alert("こんなゲームにマジになっちゃってどうするの");
}
if(currentStage==20){
alert("ステージ20達成!そろそろ転生してみよう!転生するボタンを押してね!転生するとコインとさプレマシーを貰えて強くなってくよ!");
}
if(currentStage==1001){
alert("ステージ1000達成!ここからは昇格ができるよ!詳細は下の方に書いてあるから見てね!試しに青いボタン(昇格する)を押してみよう!");
}
if(currentStage==5001){
alert("ステージ5000達成!ここからは敵のhpが緩やかになっていくよ!");
}
if(hardMode && hardModeJudge(currentStage)) {
// スキップ対象
currentStage++;
enemyHP = calcEnemyHP(currentStage);
continue;
}
if(enemyHP <= overkill) {
overkill -= enemyHP;
killCount++;
currentStage++;
if (currentStage > maxStageReached) {
maxStageReached = currentStage;
}
enemyHP = calcEnemyHP(currentStage);
const coinGain = getCoinGain();
coin += coinGain;
supremacy += coinGain; // ←ここ追加
updateCoinDisplay();
updateSupremacyDisplay();
if(hardMode) {
score += Math.floor(currentStage/10000 * donationCount);
todayScore += Math.floor(currentStage/10000 * donationCount);
} else {
score += Math.floor(donationCount);
todayScore += Math.floor(donationCount);
}
} else {
enemyHP -= overkill;
overkill = 0;
}
}
if(killCount > 0) {
addLog(`{emj_ip_0088} ${killCount}体の敵を撃破!(${hardMode ? "ハードモード" : "通常モード"})`);
}
updateEnemyStatus();
return damage;
}
function updateCritRateDisplay() {
const critRate = Math.log(currentStage * combo * baseDamage * score * rebirthCount) / 100;
const ratePercent = Math.min(critRate * 100, 100).toFixed(2); // 上限100%
document.getElementById("critRateDisplay").innerText = `核率: ${ratePercent}%、強い一撃率:${(100-ratePercent)/100*ratePercent}%`;
}
function rebirth() {
const now = Date.now();
if (now - lastRebirthTime < 60000) {
const secondsLeft = Math.ceil((60000 - (now - lastRebirthTime)) / 1000);
alert(`転生のクールダウン中です。あと ${secondsLeft} 秒待ってください。`);
return;
}
const reward = getCoinGain() * 10000;
coin += reward;
supremacy += reward * 10;
// 攻撃力加算を復活
const baseBonus = (currentStage ** 2) / 1000;
const totalBonus = baseBonus * promotionMultiplier;
baseDamage += totalBonus ** (1.00 + permanentUpgrades.rebirthBoostExp.effect); // ← rebirthPower が動的でないため直書き
rebirthCount++;
lastRebirthTime = now;
alert(
`転生完了!\n・コイン +${reward.toLocaleString()}\n・サプレマシー +${reward.toLocaleString()}\n・攻撃力 +${(totalBonus ** (1.00 + permanentUpgrades.rebirthBoostExp.effect)).toFixed(2)}`
);
addLog(`{emj_ip_0092} 転生完了!報酬: ${reward}、攻撃力アップあり`);
updateCoinDisplay();
updateSupremacyDisplay();
updateEnemyStatus();
uploadScore();
saveData();
startRebirthCooldownTimer
}
// ---- Quiz Logic ----
function generateQuiz() {
// 選択肢ボタン取得
const options = document.querySelectorAll('.option');
if (!options || options.length === 0) {
alert("選択肢ボタンが見つかりません");
return;
}
// idioms初期化チェック
if (!Array.isArray(idioms) || idioms.length === 0) {
alert("idioms配列が未定義または空です");
return;
}
// idiomQueueが空になったときの制御
if (!Array.isArray(idiomQueue)) idiomQueue = [];
if (!Array.isArray(mistakeQueue)) mistakeQueue = [];
if (idiomQueue.length === 0) {
if (!isReviewMode && mistakeQueue.length > 0) {
idiomQueue = [...mistakeQueue];
mistakeQueue = [];
isReviewMode = true;
shuffleArray(idiomQueue);
} else if (isReviewMode && mistakeQueue.length === 0) {
idiomQueue = [...idioms];
shuffleArray(idiomQueue);
mistakeQueue = [];
isReviewMode = false;
score += 1000000 * donationCount;
todayScore += 1000000 * donationCount;
alert(`キューを完了しました スコア+${1000000 * donationCount}`);
} else if (isReviewMode && mistakeQueue.length > 0) {
idiomQueue = [...mistakeQueue];
mistakeQueue = [];
shuffleArray(idiomQueue);
} else {
idiomQueue = [...idioms];
shuffleArray(idiomQueue);
score += 1000000 * donationCount;
todayScore += 1000000 * donationCount;
alert(`キューを完了しました スコア+${1000000 * donationCount}`);
}
}
if (idiomQueue.length === 0) {
alert("出題キューが空です(エラー)");
return;
}
// 1問取り出し
currentQuestion = idiomQueue.shift();
if (!currentQuestion) {
alert("currentQuestionが空です(エラー)");
return;
}
// 他選択肢
const otherOptions = idioms.filter(i => i !== currentQuestion);
if (otherOptions.length < 3) {
alert("選択肢が3つ未満です(エラー)");
return;
}
const randomDistractors = [];
let guard = 100; // 無限ループ防止
while (randomDistractors.length < 3 && guard-- > 0) {
const rand = otherOptions[Math.floor(Math.random() * otherOptions.length)];
if (!randomDistractors.includes(rand)) {
randomDistractors.push(rand);
}
}
if (randomDistractors.length < 3) {
alert("選択肢数が揃いません(内部エラー)");
return;
}
const choices = [currentQuestion, ...randomDistractors];
choices.sort(() => Math.random() - 0.5);
// 問題の種類決定(例は常にtype 0)
const questionType = 0;
currentQuestionType = questionType;
// 問題・選択肢セット+TTS
if (questionType === 0) {
setQuestion(currentQuestion.english);
options.forEach((button, i) => {
button.innerText = choices[i].japanese;
});
speak(currentQuestion.english, "en-US");
} else {
setQuestion(currentQuestion.japanese);
options.forEach((button, i) => {
button.innerText = choices[i].english;
});
speak(currentQuestion.japanese, "ja-JP");
}
updateRemainingCount();
updateRate();
updateNextDamageDisplay();
updatePromotionUI();
// 全選択肢リセット
options.forEach(option => {
option.classList.remove('correct', 'incorrect');
option.disabled = false;
});
}
function normalize(str) {
return str
.replace(/[\u2019'’]/g, "'") // 全角アポストロフィーなどを半角に
.replace(/\s+/g, ' ') // スペースを1個に
.trim(); // 前後の空白を除去
}
function checkAnswer(button) {
const options = document.querySelectorAll('.option');
options.forEach(opt => opt.disabled = true);
const selectedAnswerText = button.innerText;
let correctAnswerText;
if(currentQuestionType === 0) {
correctAnswerText = currentQuestion.japanese;
} else {
correctAnswerText = currentQuestion.english;
}
if (normalize(selectedAnswerText) !== normalize(correctAnswerText)) {
mistakeQueue.push(currentQuestion);
}
let logMsg = "";
if(normalize(selectedAnswerText) === normalize(correctAnswerText)) {
button.classList.add('correct');
combo++;
currentAnswerCount++;
currentCorrectCount++;
const points = Math.floor(combo ** 3 * donationCount);
const damage = attackEnemy();
score += points;
todayScore += points;
correctAnsCount++;
const prevHP = enemyHP;
attackEnemy(); // enemyHP が減る
logMsg = `{emj_ip_0839}*正解! +${points}pt <br>→${combo}コンボ!, ステージ${currentStage}に${damage * 2}ダメージを与えた`;
logAnswer(true)
currentPlayTime = Math.floor((Date.now() - currentLoadedTime) / 1000);
} else {
button.classList.add('incorrect');
combo = 0;
currentAnswerCount++;
currentPlayTime = Math.floor((Date.now() - currentLoadedTime) / 1000);
incorrectAnsCount++;
options.forEach(opt => {
if(normalize(opt.innerText) === normalize(correctAnswerText)) {
opt.classList.add('correct');
}
});
logMsg = `{emj_ip_0829}*不正解。コンボがリセットされた`;
logAnswer(false)
}
addLog(logMsg);
updateRate();
setTimeout(generateQuiz, 1000);
}
if(loading>=1){
setInterval(updateRate, 10000);
}
// ---- Initialization ----
window.onload = function() {
try {
loadData();
initializeAnswerStats(); // 最初に初期化
initTTS(); // TTS初期化
// idioms の確認
if (!idioms || idioms.length === 0) {
console.error('問題データが読み込まれていません');
return;
}
idiomQueue = shuffleArray([...idioms]);
updateRate();
updateEnemyStatus();
generateQuiz();
updateCoinDisplay();
updateSupremacyDisplay();
updateAnswerLogTable();
// URLパラメータの処理
const params = new URLSearchParams(window.location.search);
const code = params.get("donation");
if (code) {
processDonationCode(code);
}
loading++;
} catch (error) {
console.error('初期化エラー:', error);
alert('ゲームの初期化中にエラーが発生しました。ページを再読み込みしてください。');
}
};
setTimeout(() => {
if (typeof adBlock !== 'undefined' && adBlock === 1) {
const wrapper = document.getElementById('affiliate-wrapper');
if (wrapper) {
// font-sizeを0emにして存在するけど見えない状態に
wrapper.style.fontSize = '0em';
wrapper.style.lineHeight = '0';
wrapper.style.height = '0';
wrapper.style.overflow = 'hidden';
const elems = wrapper.querySelectorAll('img, button, a, input, h1, h2, h3, p, div');
elems.forEach(el => {
el.style.width = '0';
el.style.height = '0';
el.style.margin = '0';
el.style.padding = '0';
});
}
}
}, 2000); // 2000ミリ秒 = 2秒後に実行
</script>
<script>
function adjustScale() {
const wrapper = document.getElementById("question-wrapper");
const textEl = document.getElementById("question");
// 初期状態:拡大縮小なし、1行制限
textEl.style.transform = "scale(1,1)";
textEl.style.transformOrigin = "left center";
textEl.style.whiteSpace = "nowrap"; // 最初は1行
const wrapperWidth = wrapper.clientWidth;
const textWidth = textEl.scrollWidth;
// 条件:2倍を超える長さになったら改行許可
if (textWidth > wrapperWidth * 2.5) {
textEl.style.whiteSpace = "normal"; // 改行許可
} else {
textEl.style.whiteSpace = "nowrap"; // 改行禁止(1行にする)
textEl.style.transform = `scale(${Math.min( wrapperWidth/textWidth,1)},1)`
}
}
</script>
<script>
function formatTime(ms) {
let date = new Date(ms);
return date.toLocaleString("ja-JP", { hour12: false });
}
function formatPlayTime(sec) {
let m = Math.floor(sec / 60);
let s = sec % 60;
return `${m}分${s}秒`;
}
function showSessionData() {
let container = document.getElementById("play-history");
let dataStr = localStorage.getItem("sessionData");
if (!dataStr) {
container.innerText = "プレイ記録はありません。";
return;
}
let sessions = [];
try {
sessions = JSON.parse(dataStr);
} catch (e) {
container.innerText = "データが壊れています。";
return;
}
let html = "<table border='1' cellspacing='0' cellpadding='5'>";
html += "<tr><th>ID</th><th>読み込み時間</th><th>プレイ時間</th><th>正解数(回答数)</th><th>正答率</th></tr>";
sessions.forEach(s => {
let accuracy = (s.answer > 0) ? ((s.correct / s.answer) * 100).toFixed(1) : "0.0";
html += `<tr>
<td>${s.id}</td>
<td>${formatTime(s.loadedTime)}</td>
<td>${formatPlayTime(s.playTime)}</td>
<td>${s.correct} (${s.answer})</td>
<td>${accuracy}%</td>
</tr>`;
});
html += "</table>";
container.innerHTML = html;
}
showSessionData();
</script>
<style>
#donation-banner {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
background-color: #222;
color: white;
text-align: center;
padding: 10px 0;
font-family: sans-serif;
z-index: 9999;
}
.paypay { font-size: 8px; }
.id { color: #ff4444; font-size: 12px; }
.now {
background-color: #ff4444;
color: #ffff88;
display: inline-block;
margin-top: 5px;
padding: 5px 10px;
font-size:12px;
border-radius: 5px;
}
</style>
<div id="donation-banner" style="">
<div class="paypay">NEW!ここに表示するクイズの問題を作れるようになりました</div>
<a class="support-button" href="http://khp.jp/idiomquiz/" target="_blank">
ここからあなたもクイズの問題を作ろう!
</a>
</div>
<style>
.btn {
display: inline-block;
margin: 5px;
padding: 7px 12px;
font-size: 8px;
font-weight: bold;
color: white;
text-decoration: none;
border-radius: 5px;
transition: 0.2s;
}
.btn:hover {
transform: scale(1.05);
}
.twitter {
background-color: #1da1f2;
}
.lineA {
background-color: #00c300;
}
.copy {
background-color: #ff8c00;
}
a.support-button {
display: inline-block;
padding: 10px 20px;
font-size: 10px;
color: white;
text-decoration: none;
border-radius: 7px;
background: linear-gradient(270deg, red, orange, yellow, green, cyan, blue, purple, red);
background-size: 2000% 2000%;
animation: rainbowGlow 1s linear infinite;
box-shadow: 0 0 10px rgba(255, 0, 200, 0.7);
transition: transform 0.1s;
}
a.support-button:hover {
background-color: #e60045;
transform: scale(1.05);
}
@keyframes rainbowGlow {
0% { background-position: 0% 50%; }
100% { background-position: 100% 50%; }
}
</style>
<script>
function copyToClipboard() {
const tempInput = document.createElement("input");
tempInput.value = "http://khp.jp/idiomquiz/";
document.body.appendChild(tempInput);
tempInput.select();
document.execCommand("copy");
document.body.removeChild(tempInput);
document.getElementById("copiedMessage").style.display = "block";
setTimeout(() => {
document.getElementById("copiedMessage").style.display = "none";
}, 2000);
}
</script>
</body>
</html>4択クイズRPG - ゲーム説明
🎮 基本コンセプト
**「クイズで暗記!4択クイズRPG」** は、英語のイディオムや単語を4択クイズで学習しながら、RPG要素で楽しく成長していくブラウザゲームです。
🎯 ゲームの流れ
1. **クイズ解答**
- 4つの選択肢から正しい答えを選ぶ
- 英文→和訳、または和訳→英文の問題が出題
- 正解するとコンボが継続、不正解でコンボリセット
2. 敵とのバトル
💥 正解する → 敵にダメージ
❤️ 敵の体力が0 → ステージクリア
🎯 コンボ数が高いほど大ダメージ
3. **成長システム*
- **コンボボーナス**: 連続正解でスコアとダメージアップ
- **転生**: ステージ20以上で可能、基礎攻撃力向上
- **昇格**: ステージ1000以上で可能、転生効果倍増
⚔️ 主要機能
🔥 攻撃システム
- **通常攻撃**: コンボ数 × 基礎攻撃力
- **クリティカル**: 確率で発動、より大きなダメージ
- **強い一撃**: 高コンボ時により強力な攻撃
- **核攻撃**: 超高ダメージのレア攻撃
🏪 ショップシステム
**一時的強化(コイン)**
- 攻撃力アップ
- 敵体力減少
**恒久的強化(サプレマシー)**
- コイン獲得量増加
- 攻撃力恒久アップ
- 敵体力指数減少
- 転生効果強化
🎁 その他機能
- **ログインボーナス**: 1日1回サプレマシー獲得
- **ハードモード**: 上級者向け高難易度
- **万引き**: ハイリスクハイリターンなギャンブル
- **回答ログ**: 学習進捗の確認
- **音声読み上げ**: 発音の確認(TTS対応ブラウザのみ)
📊 統計管理
- 正答率の追跡
- コンボ記録
- プレイ時間の計測
- セッションごとの成績
📚 学習モード
- 様々な教科・単語帳から選択可能
- 英語イディオム、単語テスト、専門用語など
🎲 エンタメモード
- 元素記号、数学、プログラミングなど
- 一般教養を楽しく学習
💾 データ保存
- ブラウザのローカルストレージに自動保存
- ニックネーム設定可能
- プレイ記録の確認可能
🚀 上達のコツ
1. **コンボ維持**: 連続正解でダメージ倍増!
2. **転生タイミング**: ステージが進んだら転生で強化
3. **昇格戦略**: 攻撃力が十分に高くなったら昇格
4. **ショップ活用**: コインとサプレマシーで効率的に強化
5. **復習機能**: 間違えた問題は自動で再出題
🌟 特徴
- **完全無料**: 課金要素なし
- **レスポンシブ**: スマホ・PCどちらでも快適
- **学習効果**: 繰り返しプレイで自然に暗記
- ゲーム性: RPG要素で楽しく継続
このゲームで、英語学習とゲーム攻略の両方を楽しみながら、効率的に語彙力を向上させましょう!🎯✨
- #ゲーム
- #クイズ
- #プレイ
- #ダメージ
- #CCC
- #コンボ
- #FFFFFF
- #fff
- #333
- #ddd
- #222
- #000000
- #555
- #444
- #321
- #question
- #donation
- #ff4444
- #2c3e50
- #FFE
- #f0f8ff
- #2ecc71
- #27ae60
- #FF8C00
- #34495e
- #ECF0F1
- #007acc
- #bdc3c7
- #AAFFAA
- #1DA1F2
- #fff8f0
- #FFAAAA
- #007700
- #00c300
- #8ff
- #e60045
- #ffff88
- #critRateDisplay
- #nextDamageDisplay
- #0055ff
- #userIdDisplay
- #1c2833
- #4a627a
- #cc002a
- #f280ff
- #670073
- #ffddaa
- #221100
- #f8bdff
- #8e009e
- #774400