1テイオー
2オグリ3マック4ウララ👑 的中 👑おめでとうございます!let funds = 1000;let raceInterval;const baseHorsesData = [{ name: "トウカイテイオー", speed: 85, stamina: 70 },{ name: "オグリキャップ", speed: 75, stamina: 85 },{ name: "メジロマックイーン", speed: 65, stamina: 95 },{ name: "ハルウララ", speed: 45, stamina: 40 }];let activeHorses = [];function setBet(amount) { document.getElementById("bet-input").value = amount; }function setBet500() { document.getElementById("bet-input").value = 500; }function setBetAll() { document.getElementById("bet-input").value = funds; }function prepareNextRace() {activeHorses = baseHorsesData.map(horse => {const condition = Math.floor(Math.random() * 41) - 20;const totalPower = horse.speed + horse.stamina + condition;return { ...horse, condition: condition, totalPower: totalPower, currentOdds: 0 };});const totalPowerSum = activeHorses.reduce((sum, h) => sum + h.totalPower, 0);activeHorses.forEach(h => {let calculatedOdds = (totalPowerSum / h.totalPower) * 1.2;h.currentOdds = Math.max(1.2, Math.round(calculatedOdds * 10) / 10);});const sortedByPower = [...activeHorses].sort((a, b) => b.totalPower - a.totalPower);const aiMarks = ["◎ 本命", "○ 对抗", "▲ 单穴", "△ 连下"];const aiBadges = ["ai-tip-1", "ai-tip-2", "ai-tip-3", "ai-tip-4"];sortedByPower.forEach((sh, index) => {const target = activeHorses.find(h => h.name === sh.name);target.aiMark = aiMarks[index];target.aiBadge = aiBadges[index];});renderRaceCard();}function renderRaceCard() {const tbody = document.getElementById("race-card-body");const select = document.getElementById("horse-select");tbody.innerHTML = "";select.innerHTML = "";activeHorses.forEach((h, i) => {let condText = "🛑 絶不調";if (h.condition > 10) condText = "🔥 絶好調";else if (h.condition > 2) condText = "🧡 好調";else if (h.condition >= -10) condText = "🟢 普通";const row = document.createElement("tr");row.innerHTML =
${i + 1} | ${h.name} | | | ${condText} | ${h.aiMark} | ${h.currentOdds}倍 | ;tbody.appendChild(row);const opt = document.createElement("option");opt.value = i;opt.innerText = ${i + 1}番: ${h.name} (${h.currentOdds}倍);select.appendChild(opt);});}function startRace() {const betInput = document.getElementById("bet-input");const betAmount = parseInt(betInput.value);const selectedHorse = parseInt(document.getElementById("horse-select").value);if (isNaN(betAmount) || betAmount <= 0 || betAmount > funds) {alert("賭け金が正しくないか、所持金が足りません。");return;}funds -= betAmount;document.getElementById("money").innerText = funds;document.getElementById("start-btn").disabled = true;document.getElementById("refresh-btn").disabled = true;document.getElementById("result").innerHTML = "スタートしました!";const horses = activeHorses.map((h, i) => {return {id: horse${i},pos: 5,minMove: (h.speed * 0.02) + (h.condition * 0.03),maxMove: (h.speed * 0.06) + (h.condition * 0.05) + (h.stamina * 0.01)};});const trackWidth = document.getElementById("track").clientWidth - 75;raceInterval = setInterval(() => {let winner = null;horses.forEach((h, index) => {const move = Math.random() * (h.maxMove - h.minMove) + h.minMove;h.pos += Math.max(0.3, move);document.getElementById(h.id).style.left = h.pos + "px";if (h.pos >= trackWidth && winner === null) {winner = index;}});if (winner !== null) {clearInterval(raceInterval);endRace(winner, selectedHorse, betAmount);}}, 40);}function endRace(winner, selectedHorse, betAmount) {document.getElementById("start-btn").disabled = false;document.getElementById("refresh-btn").disabled = false;const winHorse = activeHorses[winner];let resultText = 1着:
${winHorse.name};if (winner === selectedHorse) {const payout = Math.floor(betAmount * winHorse.currentOdds);funds += payout;resultText +=
的中!払戻金 ¥${payout};triggerCelebration();} else {resultText +=
はずれ;}document.getElementById("money").innerText = funds;document.getElementById("result").innerHTML = resultText;if (funds <= 0) {funds = 1000;document.getElementById("money").innerText = funds;}prepareNextRace();}function triggerCelebration() {const overlay = document.getElementById("celebration");overlay.style.display = "flex";for (let i = 0; i < 60; i++) {const confetti = document.createElement("div");confetti.classList.add("confetti");confetti.style.left = Math.random() * 100 + "vw";confetti.style.backgroundColor = hsl(${Math.random() * 360}, 100%, 60%);confetti.style.animationDelay = Math.random() * 1.5 + "s";overlay.appendChild(confetti);}setTimeout(() => {overlay.style.display = "none";const elements = document.getElementsByClassName("confetti");while(elements.length > 0){ elements[0].remove(); }}, 3000);}prepareNextRace();