diff --git a/frontend/src/app/feature/lootboxes/lootbox-opening/lootbox-opening.component.css b/frontend/src/app/feature/lootboxes/lootbox-opening/lootbox-opening.component.css index 5684ca3..28fd570 100644 --- a/frontend/src/app/feature/lootboxes/lootbox-opening/lootbox-opening.component.css +++ b/frontend/src/app/feature/lootboxes/lootbox-opening/lootbox-opening.component.css @@ -172,12 +172,6 @@ body { animation: highlight-winner 1s ease-out 10s forwards; } -.case-item-won .case-item-inner { - box-shadow: 0 0 15px rgba(255, 255, 255, 0.3); - background: linear-gradient(to right, #232c43, #2a3354, #232c43); - border: 2px solid #facc15; /* Gold border for winning item */ -} - /* Specific ID for the winning item to ensure it's visible */ #winning-item { z-index: 5; /* Higher than indicator */ diff --git a/frontend/src/app/feature/lootboxes/lootbox-opening/lootbox-opening.component.html b/frontend/src/app/feature/lootboxes/lootbox-opening/lootbox-opening.component.html index fef38af..c85802d 100644 --- a/frontend/src/app/feature/lootboxes/lootbox-opening/lootbox-opening.component.html +++ b/frontend/src/app/feature/lootboxes/lootbox-opening/lootbox-opening.component.html @@ -1,5 +1,7 @@ -
+
Lade Lootbox...
@@ -7,24 +9,37 @@

{{ lootbox.name }}

-
Preis: {{ lootbox.price | currency:'EUR' }}
+
Preis: {{ lootbox.price | currency: 'EUR' }}
-
+

Mögliche Gewinne:

-
-
- {{ reward.value | currency:'EUR' }} +
+
+ {{ reward.value | currency: 'EUR' }} +
+
+ Chance: {{ reward.probability * 100 | number: '1.0-0' }}%
-
Chance: {{ (reward.probability * 100) | number:'1.0-0' }}%
- +
@@ -36,59 +51,86 @@
-
+
Dein Gewinn:
-
{{ wonReward?.value | currency:'EUR' }}
+
+ {{ wonReward?.value | currency: 'EUR' }} +
- + - +
- +
-
- -
-
-
{{ reward.value | currency:'EUR' }}
-
{{ (reward.probability * 100) | number:'1.0-0' }}%
+
+ +
+
+
{{ reward.value | currency: 'EUR' }}
+
{{ reward.probability * 100 | number: '1.0-0' }}%
- + -
+
- + -
- - +
+ +
-
\ No newline at end of file +
diff --git a/frontend/src/app/feature/lootboxes/lootbox-opening/lootbox-opening.component.ts b/frontend/src/app/feature/lootboxes/lootbox-opening/lootbox-opening.component.ts index 556dedc..39a23a9 100644 --- a/frontend/src/app/feature/lootboxes/lootbox-opening/lootbox-opening.component.ts +++ b/frontend/src/app/feature/lootboxes/lootbox-opening/lootbox-opening.component.ts @@ -19,13 +19,13 @@ function shuffle(array: T[]): T[] { standalone: true, imports: [CommonModule, NavbarComponent], templateUrl: './lootbox-opening.component.html', - styleUrls: ['./lootbox-opening.component.css'] + styleUrls: ['./lootbox-opening.component.css'], }) export default class LootboxOpeningComponent { lootbox: LootBox | null = null; isLoading = true; error = ''; - + // UI State isOpening = false; isOpen = false; @@ -47,7 +47,7 @@ export default class LootboxOpeningComponent { const lootboxId = parseInt(idParam, 10); this.lootboxService.getAllLootBoxes().subscribe({ next: (lootboxes) => { - this.lootbox = lootboxes.find(box => box.id === lootboxId) || null; + this.lootbox = lootboxes.find((box) => box.id === lootboxId) || null; this.isLoading = false; this.cdr.detectChanges(); }, @@ -55,7 +55,7 @@ export default class LootboxOpeningComponent { this.error = 'Failed to load lootbox data'; this.isLoading = false; this.cdr.detectChanges(); - } + }, }); } @@ -66,7 +66,7 @@ export default class LootboxOpeningComponent { this.wonReward = null; this.prizeList = []; // Clear previous prizes this.cdr.detectChanges(); - + // Short delay to ensure animation plays from the beginning setTimeout(() => { this.lootboxService.purchaseLootBox(this.lootbox!.id).subscribe({ @@ -86,21 +86,21 @@ export default class LootboxOpeningComponent { this.isOpening = false; this.isOpen = true; this.cdr.detectChanges(); - } + }, }); }, 100); } generateCasePrizes(wonReward: Reward) { if (!this.lootbox) return; - + // Create a case opening display with an extremely large number of prizes for a massive scrolling animation const prizeCount = 200; // Set to 200 for an extremely long scrolling animation const winningPosition = Math.floor(prizeCount / 2); // Position of the winning prize (middle) - + // Get possible rewards from the lootbox const possibleRewards = this.lootbox.rewards; - + // Generate an array of random rewards let items: Reward[] = []; for (let i = 0; i < prizeCount; i++) { @@ -114,15 +114,15 @@ export default class LootboxOpeningComponent { items.push(randomReward); } } - + this.prizeList = items; } - + getWeightedRandomReward(rewards: Reward[]): Reward { // Create a weighted distribution based on probabilities const totalProbability = rewards.reduce((sum, reward) => sum + reward.probability, 0); const randomValue = Math.random() * totalProbability; - + let cumulativeProbability = 0; for (const reward of rewards) { cumulativeProbability += reward.probability; @@ -130,7 +130,7 @@ export default class LootboxOpeningComponent { return { ...reward }; // Return a copy of the reward } } - + // Fallback, should never reach here return { ...rewards[0] }; } @@ -151,29 +151,26 @@ export default class LootboxOpeningComponent { this.router.navigate(['/game/lootboxes']); } - getRarityClass(prob: number): string { - if (prob <= 0.1) return 'text-yellow-400 border-yellow-400'; - if (prob <= 0.3) return 'text-purple-400 border-purple-400'; - return 'text-blue-400 border-blue-400'; - } - isWonReward(reward: Reward): boolean { if (!this.wonReward) { return false; } - - return reward.id === this.wonReward.id && - reward.value === this.wonReward.value && - reward.probability === this.wonReward.probability; + + return ( + reward.id === this.wonReward.id && + reward.value === this.wonReward.value && + reward.probability === this.wonReward.probability + ); } - + // Calculate the center position for better alignment getCenterOffset(): string { return '0px'; // No additional offset - using animation transform instead } - + // Check if item is at center position (100th item) isCenterItem(index: number): boolean { return index === Math.floor(200 / 2); // Center item at index 100 (0-indexed) } -} \ No newline at end of file +} +