style: format code for better readability and consistency
All checks were successful
CI / Get Changed Files (pull_request) Successful in 10s
CI / Docker backend validation (pull_request) Successful in 17s
CI / Docker frontend validation (pull_request) Successful in 48s
CI / Checkstyle Main (pull_request) Has been skipped
CI / oxlint (pull_request) Successful in 27s
CI / eslint (pull_request) Successful in 31s
CI / prettier (pull_request) Successful in 36s
CI / test-build (pull_request) Successful in 1m1s

This commit is contained in:
Jan-Marlon Leibl 2025-05-07 14:57:24 +02:00
commit c7f26c4df3
Signed by: jleibl
GPG key ID: 300B2F906DC6F1D5
9 changed files with 175 additions and 135 deletions

View file

@ -11,7 +11,7 @@ import { timeout } from 'rxjs';
standalone: true,
imports: [CommonModule, NavbarComponent],
templateUrl: './lootbox-selection.component.html',
styleUrls: ['./lootbox-selection.component.css']
styleUrls: ['./lootbox-selection.component.css'],
})
export default class LootboxSelectionComponent implements OnInit {
lootboxes: LootBox[] = [];
@ -22,68 +22,72 @@ export default class LootboxSelectionComponent implements OnInit {
fallbackLootboxes: LootBox[] = [
{
id: 1,
name: "Basic LootBox",
price: 2.00,
name: 'Basic LootBox',
price: 2.0,
rewards: [
{
id: 1,
value: 0.50,
probability: 0.70
value: 0.5,
probability: 0.7,
},
{
id: 5,
value: 5.00,
probability: 0.30
}
]
value: 5.0,
probability: 0.3,
},
],
},
{
id: 2,
name: "Premium LootBox",
price: 5.00,
name: 'Premium LootBox',
price: 5.0,
rewards: [
{
id: 4,
value: 2.00,
probability: 0.60
value: 2.0,
probability: 0.6,
},
{
id: 5,
value: 5.00,
probability: 0.30
value: 5.0,
probability: 0.3,
},
{
id: 6,
value: 15.00,
probability: 0.10
}
]
value: 15.0,
probability: 0.1,
},
],
},
{
id: 3,
name: "Legendäre LootBox",
price: 15.00,
name: 'Legendäre LootBox',
price: 15.0,
rewards: [
{
id: 4,
value: 2.00,
probability: 0.60
value: 2.0,
probability: 0.6,
},
{
id: 5,
value: 5.00,
probability: 0.30
value: 5.0,
probability: 0.3,
},
{
id: 6,
value: 15.00,
probability: 0.10
}
]
}
value: 15.0,
probability: 0.1,
},
],
},
];
constructor(private lootboxService: LootboxService, private router: Router, private cdr: ChangeDetectorRef) {}
constructor(
private lootboxService: LootboxService,
private router: Router,
private cdr: ChangeDetectorRef
) {}
ngOnInit(): void {
this.loadLootboxes();
@ -91,23 +95,24 @@ export default class LootboxSelectionComponent implements OnInit {
loadLootboxes(): void {
this.isLoading = true;
this.lootboxService.getAllLootBoxes().pipe(
timeout(5000)
).subscribe({
next: (data) => {
console.log('Received lootboxes:', data);
this.lootboxes = data;
this.isLoading = false;
this.cdr.detectChanges();
},
error: (err) => {
this.error = 'Konnte keine Verbindung zum Backend herstellen. Zeige Demo-Daten.';
this.lootboxes = this.fallbackLootboxes;
this.isLoading = false;
this.cdr.detectChanges();
console.error('Failed to load lootboxes:', err);
}
});
this.lootboxService
.getAllLootBoxes()
.pipe(timeout(5000))
.subscribe({
next: (data) => {
console.log('Received lootboxes:', data);
this.lootboxes = data;
this.isLoading = false;
this.cdr.detectChanges();
},
error: (err) => {
this.error = 'Konnte keine Verbindung zum Backend herstellen. Zeige Demo-Daten.';
this.lootboxes = this.fallbackLootboxes;
this.isLoading = false;
this.cdr.detectChanges();
console.error('Failed to load lootboxes:', err);
},
});
}
getBoxImage(id: number): string {
@ -131,4 +136,4 @@ export default class LootboxSelectionComponent implements OnInit {
formatProbability(probability: number): string {
return (probability * 100).toFixed(0) + '%';
}
}
}