32 lines
847 B
PHP
32 lines
847 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Game\Travel;
|
||
|
|
|
||
|
|
use App\Game\WorldConfig;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* How big a group on the map looks (movement.size_tiers): tiny below the first step,
|
||
|
|
* then small, medium, large and huge. Strangers see the tier, never the units.
|
||
|
|
*/
|
||
|
|
final class GroupSize
|
||
|
|
{
|
||
|
|
public const TIERS = ['tiny', 'small', 'medium', 'large', 'huge'];
|
||
|
|
|
||
|
|
public function __construct(private readonly WorldConfig $config) {}
|
||
|
|
|
||
|
|
/** @param array<string, int> $units */
|
||
|
|
public function tier(array $units): string
|
||
|
|
{
|
||
|
|
$heads = array_sum($units);
|
||
|
|
$steps = $this->config->get('movement.size_tiers', [50, 250, 1000, 5000]);
|
||
|
|
$tier = 0;
|
||
|
|
foreach ($steps as $i => $from) {
|
||
|
|
if ($heads >= $from) {
|
||
|
|
$tier = $i + 1;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return self::TIERS[min($tier, count(self::TIERS) - 1)];
|
||
|
|
}
|
||
|
|
}
|