Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
2.4 kB
8
Indexable
Never
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Leveling Time Calculator</title>
    <style>
        .result {
            margin-top: 10px;
            color: green;
        }
    </style>
</head>
<body>

    <h2>Leveling Time Calculator</h2>

    <form id="levelForm">
        <label for="startLevel">Starting Level:</label>
        <input type="number" id="startLevel" name="startLevel" min="1" max="25" required>

        <label for="targetLevel">Target Level:</label>
        <input type="number" id="targetLevel" name="targetLevel" min="1" max="25" required>

        <button type="button" onclick="calculateTime()">Calculate</button>
    </form>

    <div id="result" class="result"></div>

    <script>
        function calculateTime() {
            var startLevel = parseInt(document.getElementById('startLevel').value);
            var targetLevel = parseInt(document.getElementById('targetLevel').value);

            // Define the leveling times for each level
            var levelTimes = {
                1: 15, 2: 15, 3: 20, 4: 20, 5: 25,
                6: 25, 7: 25, 8: 35, 9: 35, 10: 35,
                11: 40, 12: 45, 13: 45, 14: 55, 15: 60,
                16: 65, 17: 70, 18: 75, 19: 75, 20: 80,
                21: 80, 22: 85, 23: 85, 24: 90, 25: 90
            };

            var totalTime = 0;

            // Calculate cumulative time for the first five levels
            for (var level = startLevel; level <= Math.min(targetLevel, 5); level++) {
                totalTime += levelTimes[level];
            }

            // Calculate time for the remaining levels
            for (var level = Math.max(startLevel, 6); level < targetLevel; level++) {
                totalTime += levelTimes[level];
            }

            // Convert total minutes to hours and minutes
            var hours = Math.floor(totalTime / 60);
            var minutes = totalTime % 60;

            // Display the result
            document.getElementById('result').innerHTML = "To level up from level " + startLevel + " to level " + targetLevel + ", it will take approximately " + hours + " hours and " + minutes + " minutes.";
        }
    </script>

</body>
</html>
Leave a Comment