<!DOCTYPE html> <html> <head> <title>Roll Button</title> <style> #results { font-family: Arial, sans-serif; font-size: 14px; margin-top: 20px; } .blue { color: blue; } .purple { color: purple; } .yellow { color: darkgoldenrod; } .bold { font-weight: bold; } #accumulative-results { margin-top: 20px; } #counters { margin-top: 20px; } </style> <script> var results = []; var accumulativeResults = { "Rare": 0, "Epic": 0, "Legendary": 0, "Shimmer Rare": 0, "Shimmer Epic": 0, "Shimmer Legendary": 0 }; var pityCounter = 100; var totalRolls = 0; function rollButton(rolls) { for (var i = 0; i < rolls; i++) { var chances = Math.random(); var prefixChance = Math.random(); var result = ""; if (pityCounter === 1 || chances <= 0.01) { result = "Legendary"; if (prefixChance <= 0.07) { result = "Shimmer " + result; var names = ["Xuan Pin", "Unas", "Tevor", "Feng Nuxi", "Jiang Jiuli", "Raven", "Cecilia"]; var randomName = names[Math.floor(Math.random() * names.length)]; result += " (" + randomName + ")"; result = "<span class='yellow bold'>" + result + "</span>"; accumulativeResults["Shimmer Legendary"]++; } else { result = "<span class='yellow'>" + result + "</span>"; accumulativeResults["Legendary"]++; } pityCounter = 100; } else { if (chances <= 0.9) { result = "Rare"; if (prefixChance <= 0.07) { result = "Shimmer " + result; result = "<span class='blue bold'>" + result + "</span>"; accumulativeResults["Shimmer Rare"]++; } else { result = "<span class='blue'>" + result + "</span>"; accumulativeResults["Rare"]++; } } else if (chances <= 0.99) { result = "Epic"; if (prefixChance <= 0.07) { result = "Shimmer " + result; result = "<span class='purple bold'>" + result + "</span>"; accumulativeResults["Shimmer Epic"]++; } else { result = "<span class='purple'>" + result + "</span>"; accumulativeResults["Epic"]++; } } else { pityCounter--; continue; } pityCounter--; } results.push(result); if (results.length > 10) { results.shift(); } } totalRolls += rolls; document.getElementById("results").innerHTML = results.join("<br>"); document.getElementById("accumulative-results").innerHTML = formatAccumulativeResults(); document.getElementById("pity-counter").innerHTML = "<b>Pity Counter:</b> " + pityCounter; document.getElementById("total-rolls").innerHTML = "<b>Total Rolls:</b> " + totalRolls; } function formatAccumulativeResults() { var formattedResults = []; for (var key in accumulativeResults) { if (accumulativeResults.hasOwnProperty(key)) { var formattedResult = key + ": " + accumulativeResults[key]; formattedResults.push(formattedResult); } } return formattedResults.join("<br>"); } function resetCounters() { results = []; accumulativeResults = { "Rare": 0, "Epic": 0, "Legendary": 0, "Shimmer Rare": 0, "Shimmer Epic": 0, "Shimmer Legendary": 0 }; pityCounter = 100; totalRolls = 0; document.getElementById("results").innerHTML = ""; document.getElementById("accumulative-results").innerHTML = ""; document.getElementById("pity-counter").innerHTML = "<b>Pity Counter:</b> " + pityCounter; document.getElementById("total-rolls").innerHTML = "<b>Total Rolls:</b> " + totalRolls; } </script> </head> <body> <button onclick="rollButton(1)">Roll 1</button> <button onclick="rollButton(10)">Roll 10</button> <button onclick="resetCounters()">Reset</button> <div id="results"></div> <div id="counters"> <div id="pity-counter"><b>Pity Counter:</b> 100</div> <div id="total-rolls"><b>Total Rolls:</b> 0</div> </div> <div id="accumulative-results"></div> </body> </html>
Write, Run & Share HTML code online using OneCompiler's HTML online Code editor for free. It's one of the robust, feature-rich online Code editor for HTML language, running on the latest version HTML5. Getting started with the OneCompiler's HTML compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as HTML
. You can also specify the stylesheet information in styles.css
tab and scripts information in scripts.js
tab and start coding.
HTML(Hyper Text Markup language) is the standard markup language for Web pages, was created by Berners-Lee in the year 1991. Almost every web page over internet might be using HTML.
<!DOCTYPE html>
<html>
and ends with </html>
<h1>
to <h6>
where <h1>
is the highest important heading and <h6>
is the least important sub-heading.<p>..</p>
tag.<a>
tag.
<a href="https://onecompiler.com/html">HTML online compiler</a>
<img>
tag, where src
attribute consists of image name.<button>..</button>
tag<ul>
for unordered/bullet list and <ol>
for ordered/number list, and the list items are defined in <li>
.<a href="https://onecompiler.com/html">HTML online compiler</a>
CSS(cascading style sheets) describes how HTML elements will look on the web page like color, font-style, font-size, background color etc.
Below is a sample style sheet which displays heading in green and in Candara font with padding space of 25px.
body{
padding: 25px;
}
.title {
color: #228B22;
font-family: Candara;
}
<table>
tag.<tr>
tag<th>
tag<td>
tag<caption>
tag<script>
is the tag used to write scripts in HTML<script src="script.js"></script>