@if (!empty($rapidfire_against) || !empty($rapidfire_from))
@foreach ($rapidfire_from as $from => $rapidfire_data)
-
Rapidfire from
{{ $rapidfire_data['object']->title }}:
@php
$chance = $rapidfire_data['rapidfire']->getChance();
// Determine the correct number of decimal places
if (floor($chance) === $chance) {
// It's a whole number, no need for decimals
$formattedChance = number_format($chance, 0);
} else {
// It's a decimal number, check for how many significant digits are needed
$roundedChance = round($chance, 2);
if (round($roundedChance, 1) === $roundedChance) {
// If rounding to 1 decimal gives the same result, we need only 1 decimal
$formattedChance = number_format($roundedChance, 1);
} else {
// Otherwise, use 2 decimals
$formattedChance = number_format($roundedChance, 2);
}
}
// Format the amount normally since it's likely an integer
$formattedAmount = number_format($rapidfire_data['rapidfire']->amount);
@endphp
{{ $formattedChance }}% ({{ $formattedAmount }})
@endforeach
@foreach ($rapidfire_against as $target => $rapidfire_data)
-
Rapidfire against
{{ $rapidfire_data['object']->title }}:
@php
$chance = $rapidfire_data['rapidfire']->getChance();
// Determine the correct number of decimal places
if (floor($chance) === $chance) {
// It's a whole number, no need for decimals
$formattedChance = number_format($chance, 0);
} else {
// It's a decimal number, check for how many significant digits are needed
$roundedChance = round($chance, 2);
if (round($roundedChance, 1) === $roundedChance) {
// If rounding to 1 decimal gives the same result, we need only 1 decimal
$formattedChance = number_format($roundedChance, 1);
} else {
// Otherwise, use 2 decimals
$formattedChance = number_format($roundedChance, 2);
}
}
// Format the amount normally since it's likely an integer
$formattedAmount = number_format($rapidfire_data['rapidfire']->amount);
@endphp
{{ $formattedChance }}% ({{ $formattedAmount }})
@endforeach
@endif