File size: 1,799 Bytes
60c16c9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
document.addEventListener('DOMContentLoaded', () => {
    const rollButton = document.getElementById('rollButton');
    const statusText = document.getElementById('statusText');
    const rewardPopup = document.querySelector('reward-popup');
    
    // Simulate loot box spin
    rollButton.addEventListener('click', () => {
        // Disable button during animation
        rollButton.disabled = true;
        statusText.textContent = "Rolling...";
        
        // Get components
        const lootBoxCarousel = document.querySelector('loot-box-carousel');
        const multiplierTrack = document.querySelector('multiplier-track');
        
        // Start both animations
        lootBoxCarousel.startSpin();
        multiplierTrack.startSpin();
        
        // After animations complete, show reward
        setTimeout(() => {
            const selectedBox = lootBoxCarousel.getSelectedBox();
            const selectedMultiplier = multiplierTrack.getSelectedMultiplier();
            
            // Calculate reward
            const baseReward = selectedBox.value;
            const multiplier = selectedMultiplier.value;
            const finalReward = baseReward * multiplier;
            
            // Update status
            statusText.textContent = `Selected: ${selectedBox.rarity} Loot Box (${baseReward} SC) ×${multiplier}`;
            
            // Show reward popup
            rewardPopup.show({
                baseReward,
                multiplier,
                finalReward,
                rarity: selectedBox.rarity
            });
            
            // Re-enable button
            rollButton.disabled = false;
        }, 5000); // Match this with animation duration
    });
    
    // Initialize reward popup as hidden
    rewardPopup.hide();
});