全站通知:
Widget:Ewallet
刷
历
编
跳到导航
跳到搜索
<!DOCTYPE html> <html lang="zh-CN"> <head>
<meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>幻塔意志卡池模拟器</title> <style> .gacha-simulator { font-family: Arial, sans-serif; background-color: #2C3E50; color: white; padding: 20px; border-radius: 10px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); width: 90%; max-width: 600px; margin: 20px auto; text-align: center; } .gacha-simulator h1 { font-size: 24px; margin-bottom: 20px; } .gacha-simulator label { display: block; margin: 10px 0; font-size: 16px; } .gacha-simulator input[type="number"], .gacha-simulator select { padding: 10px; width: 80%; max-width: 300px; border: none; border-radius: 5px; background-color: #34495E; color: white; } .gacha-simulator button { padding: 10px 20px; background-color: #3498DB; color: white; border: none; border-radius: 5px; cursor: pointer; margin: 10px 0; } .gacha-simulator button:hover { background-color: #2980B9; } .gacha-simulator .result { margin-top: 20px; font-size: 16px; background-color: #34495E; padding: 15px; border-radius: 5px; text-align: left; } .gacha-simulator .checkbox-group { margin: 10px 0; } </style>
</head> <body>
🌸 幻塔意志卡池模拟器 🌸
<label for="targetStar">目标星级:</label> <select id="targetStar"> <option value="0">0星</option> <option value="1">1星</option> <option value="2">2星</option> <option value="3">3星</option> </select> <label for="currency">持有货币:</label> <input id="currency" type="number" placeholder="请输入你拥有的货币数量">
<label> <input type="checkbox" id="exchangeCustom" onchange="toggleCustomExchange()"> 兑换自定义位置铸币(仅差一个时生效) </label>
<button onclick="startSimulation()">开始模拟</button>
<script> const POSITIONS = ['左上', '右上', '左下', '右下']; const STAR_REQUIRE = [1, 2, 3, 4]; // 各星级需要数量 let allowCustomExchange = false; // 是否允许兑换自定义位置铸币
class GachaSimulator { constructor() { this.inventory = POSITIONS.reduce((acc, pos) => { acc[pos] = { count: 0, locked: false }; return acc; }, {}); this.currency = 0; this.targetStar = 3; }
// 核心抽卡逻辑 singlePull() { let result = null;
// 保底机制 if (this.currency % 40 === 0) { result = this.generateWill(true); } else if (Math.random() < 0.0075) { result = this.generateWill(Math.random() < 0.5); }
this.currency--; return result; }
generateWill(isLimited) { const availablePositions = POSITIONS.filter(pos => !this.inventory[pos].locked && this.inventory[pos].count < STAR_REQUIRE[this.targetStar] );
if (availablePositions.length === 0) return null;
const position = availablePositions[Math.floor(Math.random() * availablePositions.length)]; this.inventory[position].count++;
// 自动锁定逻辑 if (this.inventory[position].count >= STAR_REQUIRE[this.targetStar]) { this.inventory[position].locked = true; }
return { position, isLimited }; }
// 兑换功能 exchange(position) { if (this.currency >= 80 && !this.inventory[position].locked) { this.currency -= 80; this.inventory[position].count++; if (this.inventory[position].count >= STAR_REQUIRE[this.targetStar]) { this.inventory[position].locked = true; } return true; } return false; }
// 自定义兑换功能(仅差一个时生效) customExchange() { if (!allowCustomExchange) return false;
const positionsNeeded = POSITIONS.filter(pos => this.inventory[pos].count === STAR_REQUIRE[this.targetStar] - 1 );
if (positionsNeeded.length === 1 && this.currency >= 80) { const position = positionsNeeded[0]; this.currency -= 80; this.inventory[position].count++; if (this.inventory[position].count >= STAR_REQUIRE[this.targetStar]) { this.inventory[position].locked = true; } return true; } return false; }
// 完整模拟流程 simulate(initialCurrency, targetStar) { this.currency = initialCurrency; this.targetStar = targetStar; let attempts = 0; const maxAttempts = 10000;
while (this.currency > 0 && attempts < maxAttempts) { this.singlePull(); attempts++;
// 优先兑换最缺的部位 const weakestPosition = POSITIONS.reduce((minPos, pos) => { return this.inventory[pos].count < this.inventory[minPos].count ? pos : minPos; }, POSITIONS[0]);
if (this.currency >= 80) this.exchange(weakestPosition);
// 自定义兑换(仅差一个时生效) if (allowCustomExchange) this.customExchange(); }
return this.getCurrentProgress(); }
getCurrentProgress() { return POSITIONS.map(pos => ({ position: pos, count: this.inventory[pos].count, star: Math.min(3, Math.floor(this.inventory[pos].count / STAR_REQUIRE[this.targetStar])) })); } }
function toggleCustomExchange() { allowCustomExchange = document.getElementById('exchangeCustom').checked; }
function calculateSuccessRate(currency, targetStar) { let successCount = 0; const totalSimulations = 1000;
for (let i = 0; i < totalSimulations; i++) { const simulator = new GachaSimulator(); const result = simulator.simulate(currency, targetStar); if (result.every(item => item.star >= targetStar)) { successCount++; } }
return (successCount / totalSimulations * 100).toFixed(1); }
function startSimulation() { const target = parseInt(document.getElementById('targetStar').value); const currency = parseInt(document.getElementById('currency').value);
if (isNaN(target) || isNaN(currency)) { alert("请输入完整信息!"); return; }
const successRate = calculateSuccessRate(currency, target); let recommendation = `当前目标:${target} 星(综合成功率:${successRate}%)`;
// 降档推荐逻辑 if (successRate < 50) { let lowerTarget = target - 1; while (lowerTarget >= 0) { const lowerSuccessRate = calculateSuccessRate(currency, lowerTarget); if (lowerSuccessRate >= 50) { recommendation += `
建议降档目标:${lowerTarget} 星(成功率:${lowerSuccessRate}%)`; break; } lowerTarget--; } }
document.getElementById('result').innerHTML = `
模拟结果 (1000轮)
${recommendation}
`; } </script>
</body> </html>