用户:RedDragon/Test2:修订间差异
来自Rizline中文维基
更多操作
小 |
小 |
||
| 第138行: | 第138行: | ||
function generateRandomRestrictions() { | function generateRandomRestrictions() { | ||
const speeds = [...Array( | const speeds = [...Array(40).fill("无限制"), ...Array.from({ length: 91 }, (_, i) => (i + 10) / 10)] | ||
const mods = ["无MOD", "镜像模式", "保护模式", "Bad保护模式", "隐藏计量条"] | const mods = ["无MOD", "镜像模式", "保护模式", "Bad保护模式", "特殊计量条", "隐藏计量条"] | ||
const others = ["无限制"] | const others = ["无限制"] | ||
| 第147行: | 第147行: | ||
let selectedMods = [] | let selectedMods = [] | ||
if (Math.random() < 0.3) { | if (Math.random() < 0.3) { | ||
selectedMods = [mods[Math.floor(Math.random() * mods.length)]] | selectedMods = [mods[Math.floor(Math.random() * mods.length)]] | ||
} else { | } else { | ||
const count = Math.floor(Math.random() * 3) + 2 | const count = Math.floor(Math.random() * 3) + 2 | ||
const shuffled = [... | const availableMods = mods.filter(m => m !== "无MOD") | ||
selectedMods = shuffled.slice(0, count) | const shuffled = [...availableMods].sort(() => Math.random() - 0.5) | ||
selectedMods = shuffled.slice(0, Math.min(count, availableMods.length)) | |||
const hasSpecial = selectedMods.includes("特殊计量条") | |||
if (hasSpecial) { | |||
if ( | |||
const specialRates = ["特殊计量条100%", "特殊计量条110%", "特殊计量条120%"] | const specialRates = ["特殊计量条100%", "特殊计量条110%", "特殊计量条120%"] | ||
selectedMods = selectedMods.filter(m => m !== "特殊计量条") | selectedMods = selectedMods.filter(m => m !== "特殊计量条") | ||
| 第164行: | 第162行: | ||
} | } | ||
} | } | ||
document.getElementById('mod-data').textContent = selectedMods.join( | |||
const modElement = document.getElementById('mod-data') | |||
if (selectedMods.length === 1) { | |||
modElement.textContent = selectedMods[0] | |||
} else { | |||
modElement.innerHTML = selectedMods.map(mod => `<p>${mod}</p>`).join('') | |||
} | |||
let selectedOthers = [] | let selectedOthers = [] | ||
if (Math.random() < 0. | if (Math.random() < 0.5) { | ||
selectedOthers = [others[Math.floor(Math.random() * others.length)]] | selectedOthers = [others[Math.floor(Math.random() * others.length)]] | ||
} else { | } else { | ||
const count = Math.floor(Math.random() * 2) + 2 | const count = Math.floor(Math.random() * 2) + 2 | ||
const shuffled = [... | const availableOthers = others.filter(o => o !== "无限制") | ||
selectedOthers = shuffled.slice(0, count) | const shuffled = [...availableOthers].sort(() => Math.random() - 0.5) | ||
selectedOthers = shuffled.slice(0, Math.min(count, availableOthers.length)) | |||
} | |||
const otherElement = document.getElementById('other-data') | |||
if (selectedOthers.length === 1) { | |||
} | otherElement.textContent = selectedOthers[0] | ||
} else { | |||
otherElement.innerHTML = selectedOthers.map(other => `<p>${other}</p>`).join('') | |||
} | } | ||
} | } | ||