style: clean up whitespace and formatting in files
This commit is contained in:
parent
0bf32b4b93
commit
667e4313d2
3 changed files with 105 additions and 72 deletions
|
@ -19,13 +19,13 @@ function shuffle<T>(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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue