Skip to content

Commit

Permalink
Merge pull request #2720 from RaiderIO/development
Browse files Browse the repository at this point in the history
Release v12.1 - Added various new filters for the heatmaps
  • Loading branch information
Wotuu authored Feb 11, 2025
2 parents 7d82487 + 3392a65 commit ac2a07e
Show file tree
Hide file tree
Showing 537 changed files with 96,574 additions and 1,688 deletions.
17 changes: 13 additions & 4 deletions app/Console/Commands/CombatLog/CreateMappingVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CreateMappingVersion extends BaseCombatLogCommand
*
* @var string
*/
protected $signature = 'combatlog:createmappingversion {filePath} {--mappingVersion=} ';
protected $signature = 'combatlog:createmappingversion {filePath} {--enemyConnections} {--mappingVersion=} ';

/**
* The console command description.
Expand All @@ -28,19 +28,28 @@ public function handle(CombatLogMappingVersionServiceInterface $combatLogMapping
{
$filePath = $this->argument('filePath');
$mappingVersionId = $this->option('mappingVersion');
$enemyConnections = (bool)$this->option('enemyConnections');

$mappingVersion = null;
if (is_numeric($mappingVersionId)) {
$mappingVersion = MappingVersion::findOrFail($mappingVersionId);
}

return $this->parseCombatLogRecursively($filePath, fn(string $filePath) => $this->createMappingVersionFromCombatLog($combatLogMappingVersionService, $filePath, $mappingVersion));
return $this->parseCombatLogRecursively($filePath,
fn(string $filePath) => $this->createMappingVersionFromCombatLog(
$combatLogMappingVersionService,
$filePath,
$mappingVersion,
$enemyConnections
)
);
}

private function createMappingVersionFromCombatLog(
CombatLogMappingVersionServiceInterface $combatLogMappingVersionService,
string $filePath,
?MappingVersion $mappingVersion = null): int
?MappingVersion $mappingVersion = null,
bool $enemyConnections = false): int
{
$this->info(sprintf('Parsing file %s', $filePath));

Expand All @@ -52,7 +61,7 @@ private function createMappingVersionFromCombatLog(

$hasMappingVersion = $mappingVersion !== null;

$mappingVersion = $combatLogMappingVersionService->createMappingVersionFromDungeonOrRaid($filePath, $mappingVersion);
$mappingVersion = $combatLogMappingVersionService->createMappingVersionFromDungeonOrRaid($filePath, $mappingVersion, $enemyConnections);
$this->info(
sprintf(
'- %s mapping version %s (%s, %d, %d enemies)',
Expand Down
61 changes: 61 additions & 0 deletions app/Console/Commands/CombatLog/DetermineBounds.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

namespace App\Console\Commands\CombatLog;

use App\Service\CombatLog\CombatLogServiceInterface;

class DetermineBounds extends BaseCombatLogCommand
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'combatlog:determinebounds {filePath}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Finds the min and max coordinates of all combat log events. Useful for determining the size of the map if no coordinates are known.';

/**
* Execute the console command.
*/
public function handle(CombatLogServiceInterface $combatLogService): int
{
ini_set('memory_limit', '2G');

$filePath = $this->argument('filePath');

return $this->parseCombatLogRecursively($filePath, fn(string $filePath) => $this->extractUiMapIds($combatLogService, $filePath));
}

private function extractUiMapIds(CombatLogServiceInterface $combatLogService, string $filePath): int
{
$mapBounds = $combatLogService->getBoundsFromEvents($filePath);

$this->info(
sprintf(
'minX: %.02f, minY: %.02f, maxX: %.02f, maxY: %.02f',
$mapBounds->getMinIngameX(),
$mapBounds->getMinIngameY(),
$mapBounds->getMaxIngameX(),
$mapBounds->getMaxIngameY()
)
);

$this->info(
sprintf(
'Copy me: %.02f, %.02f, %.02f, %.02f',
$mapBounds->getMinIngameX(),
$mapBounds->getMinIngameY(),
$mapBounds->getMaxIngameX(),
$mapBounds->getMaxIngameY()
)
);

return 0;
}
}
19 changes: 18 additions & 1 deletion app/Console/Commands/Mapping/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,21 +135,38 @@ private function saveDungeons(string $dungeonDataDir): void
->with(['floors.floorcouplings', 'floors.dungeonSpeedrunRequiredNpcs10Man', 'floors.dungeonSpeedrunRequiredNpcs25Man'])
->get();

foreach ($dungeons as $dungeon) {
foreach ($dungeon->floors as $floor) {
$floor->makeVisible([
'mdt_sub_level',
'ui_map_id',
'map_name',
'active',
'enemy_engagement_max_range',
'enemy_engagement_max_range_patrols',
]);
}
}

$this->saveDataToJsonFile(
$dungeons->makeVisible([
'id',
'expansion_id',
'game_version_id',
'zone_id',
'map_id',
'instance_id',
'challenge_mode_id',
'mdt_id',
'key',
'name',
'slug',
'raid',
'heatmap_enabled',
'speedrun_enabled',
'speedrun_difficulty_10_man_enabled',
'speedrun_difficulty_25_man_enabled',
])
->makeHidden(['floor_count'])
->toArray(),
$dungeonDataDir,
'dungeons.json'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ class RefreshMembershipStatus extends SchedulerCommand
/**
* Execute the console command.
*/
public function handle(PatreonApiService $patreonApiService, PatreonServiceInterface $patreonService): int
public function handle(PatreonServiceInterface $patreonService): int
{
return $this->trackTime(function () use ($patreonApiService, $patreonService) {
$campaignBenefits = $patreonService->loadCampaignBenefits($patreonApiService);
$campaignTiers = $patreonService->loadCampaignTiers($patreonApiService);
$members = $patreonService->loadCampaignMembers($patreonApiService);
return $this->trackTime(function () use ($patreonService) {
$campaignBenefits = $patreonService->loadCampaignBenefits();
$campaignTiers = $patreonService->loadCampaignTiers();
$members = $patreonService->loadCampaignMembers();

if ($campaignBenefits === null ||
$campaignTiers === null ||
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/Wowhead/FetchDisplayIds.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function handle(WowheadServiceInterface $wowheadService): void
$displayId = $wowheadService->getNpcDisplayId($dungeon->gameVersion, $npc);

if ($displayId === null) {
$this->warn('- Unable to find display ID for npc!');
$this->warn('- Unable to find display ID for npc! Is the game version correct?');
} else {
$npc->update(['display_id' => $displayId]);

Expand Down
2 changes: 2 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Console\Commands\ChallengeModeRunData\ConvertToEvents;
use App\Console\Commands\CombatLog\CreateDungeonRoutes;
use App\Console\Commands\CombatLog\CreateMappingVersion;
use App\Console\Commands\CombatLog\DetermineBounds;
use App\Console\Commands\CombatLog\EnsureChallengeMode;
use App\Console\Commands\CombatLog\ExtractData;
use App\Console\Commands\CombatLog\ExtractUiMapIds;
Expand Down Expand Up @@ -100,6 +101,7 @@ class Kernel extends ConsoleKernel
// CombatLog
CreateDungeonRoutes::class,
CreateMappingVersion::class,
DetermineBounds::class,
EnsureChallengeMode::class,
ExtractData::class,
ExtractUiMapIds::class,
Expand Down
47 changes: 46 additions & 1 deletion app/Helpers/ColorHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function pad($v)
*/
function rgb2hex($r, $g, $b)
{
return '#' . implode('', array_map('dechex', array_map('round', [$r, $g, $b])));
return sprintf('#%02x%02x%02x', round($r), round($g), round($b));
}

/**
Expand All @@ -123,3 +123,48 @@ function randomHexColorNoMapColors(): string

return $result;
}

function pickHexFromHandlers(array $handlers, float $weight): string {
assert(count($handlers) > 1, 'Handlers.length <= 1!');

// If color is before the start or after the end of any gradients, return last known color
if ($handlers[0][0] >= $weight) {
return strtolower($handlers[0][1]);
} elseif ($handlers[count($handlers) - 1][0] <= $weight) {
return strtolower($handlers[count($handlers) - 1][1]);
} else {
// Color is in between gradients, determine which gradient it is
$color1 = null;
$color2 = null;
$scaledWeight = 0.0;

for ($i = 0; $i < count($handlers) - 1; $i++) {
$a = $handlers[$i];
$b = $handlers[$i + 1];

if ($weight >= $a[0] && $weight <= $b[0]) {
$color1 = hex2rgb($a[1]);
$color2 = hex2rgb($b[1]);

$gradientRange = $b[0] - $a[0];
$weightOnGradientRange = $weight - $a[0];
$scaledWeight = $weightOnGradientRange / $gradientRange;

break;
}
}

assert($color1 !== null, 'color1 === null!');
assert($color2 !== null, 'color2 === null!');

$invertedScaledWeight = 1 - $scaledWeight;

return strtolower(
rgb2hex(
round($color2[0] * $scaledWeight + $color1[0] * $invertedScaledWeight),
round($color2[1] * $scaledWeight + $color1[1] * $invertedScaledWeight),
round($color2[2] * $scaledWeight + $color1[2] * $invertedScaledWeight)
)
);
}
}
4 changes: 3 additions & 1 deletion app/Http/Controllers/Ajax/AjaxDungeonRouteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,9 @@ public function store(

$this->dungeonRouteChanged($dungeonRoute, $beforeDungeonRoute, $dungeonRoute);

return $dungeonRoute;
return $dungeonRoute->makeHidden([
'dungeon',
]);
}

/**
Expand Down
6 changes: 5 additions & 1 deletion app/Http/Controllers/Ajax/AjaxEnemyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
class AjaxEnemyController extends AjaxMappingModelBaseController
{
/**
* @param APIEnemyFormRequest $request
* @param CoordinatesServiceInterface $coordinatesService
* @param MappingVersion $mappingVersion
* @param Enemy|null $enemy
* @return Enemy|Model
*
* @throws Throwable
Expand All @@ -38,7 +42,7 @@ public function store(
CoordinatesServiceInterface $coordinatesService,
MappingVersion $mappingVersion,
?Enemy $enemy = null
): Enemy {
): Enemy|Model {
$validated = $request->validated();

$previousFloor = null;
Expand Down
39 changes: 22 additions & 17 deletions app/Http/Controllers/Dungeon/DungeonExploreController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use App\Models\Floor\Floor;
use App\Models\GameServerRegion;
use App\Models\GameVersion\GameVersion;
use App\Models\Season;
use App\Service\CombatLogEvent\CombatLogEventServiceInterface;
use App\Service\MapContext\MapContextServiceInterface;
use App\Service\Season\SeasonServiceInterface;
Expand Down Expand Up @@ -111,26 +112,20 @@ public function viewDungeonFloor(

$heatmapActive = Feature::active(Heatmap::class) && $dungeon->heatmap_enabled;

$dungeon->trackPageView();
$dungeon->trackPageView(Dungeon::PAGE_VIEW_SOURCE_VIEW_DUNGEON);

return view('dungeon.explore.gameversion.view', [
return view('dungeon.explore.gameversion.view', array_merge($this->getFilterSettings($mostRecentSeason), [
'gameVersion' => $gameVersion,
'season' => $mostRecentSeason,
'dungeon' => $dungeon,
'floor' => $floor,
'title' => __($dungeon->name),
'mapContext' => $mapContextService->createMapContextDungeonExplore($dungeon, $floor, $dungeon->currentMappingVersion),
'showHeatmapSearch' => $heatmapActive,
'keyLevelMin' => $mostRecentSeason?->key_level_min ?? config('keystoneguru.keystone.levels.default_min'),
'keyLevelMax' => $mostRecentSeason?->key_level_max ?? config('keystoneguru.keystone.levels.default_max'),
'itemLevelMin' => $mostRecentSeason?->item_level_min ?? 0,
'itemLevelMax' => $mostRecentSeason?->item_level_max ?? 0,
'playerDeathsMin' => 0,
'playerDeathsMax' => 50,
'seasonWeeklyAffixGroups' => $dungeon->gameVersion->has_seasons ?
$seasonService->getWeeklyAffixGroupsSinceStart($mostRecentSeason, GameServerRegion::getUserOrDefaultRegion()) :
collect(),
]);
]));
}
}

Expand Down Expand Up @@ -200,20 +195,16 @@ public function embed(

$heatmapActive = Feature::active(Heatmap::class) && $dungeon->heatmap_enabled;

return view('dungeon.explore.gameversion.embed', [
$dungeon->trackPageView(Dungeon::PAGE_VIEW_SOURCE_VIEW_DUNGEON_EMBED);

return view('dungeon.explore.gameversion.embed', array_merge($this->getFilterSettings($mostRecentSeason), [
'gameVersion' => $gameVersion,
'season' => $mostRecentSeason,
'dungeon' => $dungeon,
'floor' => $floor,
'title' => __($dungeon->name),
'mapContext' => $mapContextService->createMapContextDungeonExplore($dungeon, $floor, $dungeon->currentMappingVersion),
'showHeatmapSearch' => $heatmapActive,
'keyLevelMin' => $mostRecentSeason?->key_level_min ?? config('keystoneguru.keystone.levels.default_min'),
'keyLevelMax' => $mostRecentSeason?->key_level_max ?? config('keystoneguru.keystone.levels.default_max'),
'itemLevelMin' => $mostRecentSeason?->item_level_min ?? 0,
'itemLevelMax' => $mostRecentSeason?->item_level_max ?? 0,
'playerDeathsMin' => 0,
'playerDeathsMax' => 99,
'seasonWeeklyAffixGroups' => $dungeon->gameVersion->has_seasons ?
$seasonService->getWeeklyAffixGroupsSinceStart($mostRecentSeason, GameServerRegion::getUserOrDefaultRegion()) :
collect(),
Expand All @@ -229,6 +220,20 @@ public function embed(
'floorSelection' => true, // Always available, but can be overridden later if there's no floors to select
],
],
]);
]));
}

private function getFilterSettings(?Season $season): array
{
return [
'keyLevelMin' => $season?->key_level_min ?? config('keystoneguru.keystone.levels.default_min'),
'keyLevelMax' => $season?->key_level_max ?? config('keystoneguru.keystone.levels.default_max'),
'itemLevelMin' => $season?->item_level_min ?? 0,
'itemLevelMax' => $season?->item_level_max ?? 0,
'playerDeathsMin' => 0,
'playerDeathsMax' => 99,
'minSamplesRequiredMin' => 1,
'minSamplesRequiredMax' => 100,
];
}
}
Loading

0 comments on commit ac2a07e

Please sign in to comment.