Skip to content

Commit

Permalink
Merge pull request #1898 from Wotuu/development
Browse files Browse the repository at this point in the history
Release v6.9.2
  • Loading branch information
Wotuu authored Jul 27, 2023
2 parents a62789f + 1262064 commit 38069d0
Show file tree
Hide file tree
Showing 71 changed files with 16,457 additions and 433 deletions.
36 changes: 10 additions & 26 deletions app/Console/Commands/CombatLog/CreateDungeonRoutes.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
namespace App\Console\Commands\CombatLog;

use App\Service\CombatLog\ResultEventDungeonRouteServiceInterface;
use Illuminate\Console\Command;

class CreateDungeonRoutes extends Command
class CreateDungeonRoutes extends BaseCombatLogCommand
{
/**
* The name and signature of the console command.
Expand All @@ -19,7 +18,7 @@ class CreateDungeonRoutes extends Command
*
* @var string
*/
protected $description = 'Ensures that a filepath\'s combat logs contain just one challenge mode. If more are found, the combat log is split up.';
protected $description = 'Creates dungeon routes for all _events.txt files found in the given directory.';

/**
* Execute the console command.
Expand All @@ -31,47 +30,32 @@ class CreateDungeonRoutes extends Command
public function handle(ResultEventDungeonRouteServiceInterface $combatLogDungeonRouteService): int
{
$filePath = $this->argument('filePath');
// Assume error
$result = -1;

if (is_dir($filePath)) {
$this->info(sprintf('%s is a dir, parsing all files in the dir..', $filePath));
$files = glob(sprintf('%s/*', $filePath));
foreach ($files as $filePath) {
$this->createDungeonRouteFromCombatLog($combatLogDungeonRouteService, $filePath);
}
} else {
$this->createDungeonRouteFromCombatLog($combatLogDungeonRouteService, $filePath);
}

return $result;
return $this->parseCombatLogRecursively($filePath, function (string $filePath) use ($combatLogDungeonRouteService) {
return $this->createDungeonRouteFromCombatLog($combatLogDungeonRouteService, $filePath);
});
}

/**
* @param ResultEventDungeonRouteServiceInterface $combatLogDungeonRouteService
* @param string $filePath
*
* @return void
* @return int
*/
private function createDungeonRouteFromCombatLog(ResultEventDungeonRouteServiceInterface $combatLogDungeonRouteService, string $filePath): void
private function createDungeonRouteFromCombatLog(ResultEventDungeonRouteServiceInterface $combatLogDungeonRouteService, string $filePath): int
{
$this->info(sprintf('Parsing file %s', $filePath));

// While have a successful result, keep parsing
if (!is_file($filePath)) {
$this->warn('- Is a dir - cannot parse');

return;
}

if (!str_contains($filePath, '_events.txt')) {
$this->comment(sprintf('- Skipping non-events file %s', $filePath));
return;
return -1;
}

$dungeonRoutes = $combatLogDungeonRouteService->convertCombatLogToDungeonRoutes($filePath);
foreach ($dungeonRoutes as $dungeonRoute) {
$this->info(sprintf('- Created dungeon route %s (%s)', $dungeonRoute->public_key, __($dungeonRoute->dungeon->name)));
}

return 0;
}
}
2 changes: 1 addition & 1 deletion app/Console/Commands/CombatLog/OutputCreateRouteJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private function outputCreateRouteJson(CreateRouteDungeonRouteServiceInterface $
$resultingFile = str_replace(['.txt', '.zip'], '.json', $filePath);

$result = file_put_contents(
base_path($resultingFile),
$resultingFile,
json_encode($createRouteBodyDungeonRouteService->getCreateRouteBody($filePath), JSON_PRETTY_PRINT)
);

Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/CombatLog/OutputResultEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private function outputResultEvents(CombatLogServiceInterface $combatLogService,

$resultingFile = str_replace(['.txt', '.zip'], '_events.txt', $filePath);

$result = file_put_contents(base_path($resultingFile), $resultEvents->map(function (BaseResultEvent $resultEvent) {
$result = file_put_contents($resultingFile, $resultEvents->map(function (BaseResultEvent $resultEvent) {
// Trim to remove CRLF, implode with PHP_EOL to convert to (most likely) linux line endings
return trim($resultEvent->getBaseEvent()->getRawEvent());
})->implode(PHP_EOL));
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/CombatLog/SplitChallengeMode.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use App\Service\CombatLog\CombatLogSplitServiceInterface;
use Illuminate\Console\Command;

class SplitChallengeMode extends Command
class SplitChallengeMode extends BaseCombatLogCommand
{
/**
* The name and signature of the console command.
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function update(Request $request, User $user, EchoServerHttpApiServiceInt
/** @var DungeonRoute $context */
$context = DungeonRoute::where('public_key', $routeKey)->first();
} else if (strpos($name, 'live-session') !== false) {
$routeKey = str_replace(sprintf('presence-%s-live-session.', env('APP_TYPE')), '', $name);
$routeKey = str_replace(sprintf('presence-%s-live-session.', config('app.type')), '', $name);
/** @var LiveSession $context */
$context = LiveSession::where('public_key', $routeKey)->first();
}
Expand Down
38 changes: 21 additions & 17 deletions app/Http/Controllers/ReleaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ReleaseController extends Controller
{
/**
* @param ReleaseFormRequest $request
* @param Release|null $release
* @param Release|null $release
* @return mixed
*/
public function store(ReleaseFormRequest $request, Release $release = null)
Expand All @@ -45,18 +45,21 @@ public function store(ReleaseFormRequest $request, Release $release = null)
$changelog->changes()->delete();
// Unset the relation so it's reloaded
$changelog->unsetRelation('changes');

$releaseChangelogChangesAttributes = [];
for ($i = 0; $i < count($tickets); $i++) {
// Only filled in rows, but tickets may be null
if (/*strlen($tickets[$i]) > 0 && */ (int)$categories[$i] !== -1 && strlen($categories[$i]) > 0 && strlen($changes[$i]) > 0) {
// Add new changes
$changelogChange = new ReleaseChangelogChange();
$changelogChange->release_changelog_id = $changelog->id;
$changelogChange->release_changelog_category_id = $categories[$i];
$changelogChange->ticket_id = is_null($tickets[$i]) ? null : intval(str_replace('#', '', $tickets[$i]));
$changelogChange->change = $changes[$i];
$changelogChange->save();
if ((int)$categories[$i] !== -1 && strlen($categories[$i]) > 0 && strlen($changes[$i]) > 0) {
$releaseChangelogChangesAttributes[] = [
'release_changelog_id' => $changelog->id,
'release_changelog_category_id' => $categories[$i],
'ticket_id' => is_null($tickets[$i]) ? null : intval(str_replace('#', '', $tickets[$i])),
'change' => $changes[$i],
];
}
}
ReleaseChangelogChange::insert($releaseChangelogChangesAttributes);

$changelog->load('changes');


Expand All @@ -72,13 +75,14 @@ public function store(ReleaseFormRequest $request, Release $release = null)
$changelog->release_id = $release->id;
$changelog->save();

if (Artisan::call('release:save') === 0) {
try {
Artisan::call(sprintf('make:githubreleaseticket %s', $release->version));
Artisan::call(sprintf('make:githubreleasepullrequest %s', $release->version));
} catch (Exception $exception) {
Session::flash('status', sprintf(__('controller.release.flash.github_exception'), $exception->getMessage()));
}
$release->setRelation('changelog', $changelog);
$changelog->setRelation('release', $release);

try {
Artisan::call(sprintf('make:githubreleaseticket %s', $release->version));
Artisan::call(sprintf('make:githubreleasepullrequest %s', $release->version));
} catch (Exception $exception) {
Session::flash('status', sprintf(__('controller.release.flash.github_exception'), $exception->getMessage()));
}
} // Something went wrong with saving
else {
Expand Down Expand Up @@ -115,7 +119,7 @@ public function edit(Request $request, Release $release)

/**
* @param ReleaseFormRequest $request
* @param Release $release
* @param Release $release
* @return Factory|View
* @throws Exception
*/
Expand Down
25 changes: 15 additions & 10 deletions app/Logic/CombatLog/CombatEvents/Prefixes/Prefix.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ abstract class Prefix implements HasParameters
{
use ValidatesParameterCount;

public const PREFIX_SWING = 'SWING';
public const PREFIX_RANGE = 'RANGE';
public const PREFIX_SPELL_PERIODIC = 'SPELL_PERIODIC';
public const PREFIX_SPELL_BUILDING = 'SPELL_BUILDING';
public const PREFIX_SPELL = 'SPELL';
// Bit of a special one, SWING_DAMAGE_LANDED_SUPPORT is actually a spell and not a swing.
// We have to include the full name here so it doesn't collide with anything else
public const PREFIX_SWING_DAMAGE_LANDED_SUPPORT = 'SWING_DAMAGE_LANDED_SUPPORT';
public const PREFIX_SWING = 'SWING';
public const PREFIX_RANGE = 'RANGE';
public const PREFIX_SPELL_PERIODIC = 'SPELL_PERIODIC';
public const PREFIX_SPELL_BUILDING = 'SPELL_BUILDING';
public const PREFIX_SPELL = 'SPELL';

public const PREFIX_ALL = [
self::PREFIX_SWING_DAMAGE_LANDED_SUPPORT,
self::PREFIX_SWING,
self::PREFIX_RANGE,
self::PREFIX_SPELL_PERIODIC,
Expand All @@ -26,11 +30,12 @@ abstract class Prefix implements HasParameters
];

private const PREFIX_CLASS_MAPPING = [
self::PREFIX_SWING => Swing::class,
self::PREFIX_RANGE => Range::class,
self::PREFIX_SPELL => Spell::class,
self::PREFIX_SPELL_PERIODIC => SpellPeriodic::class,
self::PREFIX_SPELL_BUILDING => SpellBuilding::class,
self::PREFIX_SWING_DAMAGE_LANDED_SUPPORT => SwingDamageLandedSupport::class,
self::PREFIX_SWING => Swing::class,
self::PREFIX_RANGE => Range::class,
self::PREFIX_SPELL => Spell::class,
self::PREFIX_SPELL_PERIODIC => SpellPeriodic::class,
self::PREFIX_SPELL_BUILDING => SpellBuilding::class,
];

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace App\Logic\CombatLog\CombatEvents\Prefixes;

class SwingDamageLandedSupport extends Range
{
}
9 changes: 3 additions & 6 deletions app/Logic/CombatLog/CombatEvents/Suffixes/Damage.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ public function isCrushing(): bool
return $this->crushing;
}


/**
* @param array $parameters
* @return HasParameters
Expand All @@ -120,18 +119,16 @@ public function setParameters(array $parameters): HasParameters
$this->rawAmount = $parameters[1];
$this->overKill = $parameters[2];
$this->school = $parameters[3];
$this->resisted = $parameters[4];
$this->blocked = $parameters[5];
$this->absorbed = $parameters[6];
$this->resisted = $parameters[4] === 'nil' ? 0 : $parameters[4];
$this->blocked = $parameters[5] === 'nil' ? 0 : $parameters[5];
$this->absorbed = $parameters[6] === 'nil' ? 0 : $parameters[6];
$this->critical = $parameters[7] !== 'nil';
$this->glancing = $parameters[8] !== 'nil';
$this->crushing = $parameters[9] !== 'nil';


return $this;
}


/**
* @return int
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace App\Logic\CombatLog\CombatEvents\Suffixes;

class DamageLandedSupport extends DamageSupport
{

}
41 changes: 41 additions & 0 deletions app/Logic/CombatLog/CombatEvents/Suffixes/DamageSupport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace App\Logic\CombatLog\CombatEvents\Suffixes;

use App\Logic\CombatLog\CombatEvents\Interfaces\HasParameters;
use App\Logic\CombatLog\Guid\Guid;

class DamageSupport extends Damage
{
private Guid $supportGuid;

/**
* @return Guid|null
*/
public function getSupportGuid(): ?Guid
{
return $this->supportGuid;
}

/**
* @param array $parameters
* @return HasParameters
*/
public function setParameters(array $parameters): HasParameters
{
parent::setParameters($parameters);

$this->supportGuid = Guid::createFromGuidString($parameters[10]);

return $this;
}


/**
* @return int
*/
public function getParameterCount(): int
{
return 11;
}
}
41 changes: 41 additions & 0 deletions app/Logic/CombatLog/CombatEvents/Suffixes/HealSupport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace App\Logic\CombatLog\CombatEvents\Suffixes;

use App\Logic\CombatLog\CombatEvents\Interfaces\HasParameters;
use App\Logic\CombatLog\Guid\Guid;

class HealSupport extends Heal
{
private Guid $supportGuid;

/**
* @return Guid|null
*/
public function getSupportGuid(): ?Guid
{
return $this->supportGuid;
}

/**
* @param array $parameters
* @return HasParameters
*/
public function setParameters(array $parameters): HasParameters
{
parent::setParameters($parameters);

$this->supportGuid = Guid::createFromGuidString($parameters[5]);

return $this;
}


/**
* @return int
*/
public function getParameterCount(): int
{
return 6;
}
}
9 changes: 9 additions & 0 deletions app/Logic/CombatLog/CombatEvents/Suffixes/Suffix.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ abstract class Suffix implements HasParameters
{
use ValidatesParameterCount;

public const SUFFIX_DAMAGE_LANDED_SUPPORT = 'DAMAGE_LANDED_SUPPORT';
public const SUFFIX_DAMAGE_LANDED = 'DAMAGE_LANDED';
public const SUFFIX_DAMAGE_SUPPORT = 'DAMAGE_SUPPORT';
public const SUFFIX_DAMAGE = 'DAMAGE';
public const SUFFIX_MISSED = 'MISSED';
public const SUFFIX_HEAL_ABSORBED = 'HEAL_ABSORBED';
public const SUFFIX_HEAL_SUPPORT = 'HEAL_SUPPORT';
public const SUFFIX_HEAL = 'HEAL';
public const SUFFIX_ABSORBED = 'ABSORBED';
public const SUFFIX_ENERGIZE = 'ENERGIZE';
Expand Down Expand Up @@ -47,10 +50,13 @@ abstract class Suffix implements HasParameters
public const SUFFIX_EMPOWER_END = 'EMPOWER_END';

public const SUFFIX_ALL = [
self::SUFFIX_DAMAGE_LANDED_SUPPORT,
self::SUFFIX_DAMAGE_LANDED,
self::SUFFIX_DAMAGE_SUPPORT,
self::SUFFIX_DAMAGE,
self::SUFFIX_MISSED,
self::SUFFIX_HEAL_ABSORBED,
self::SUFFIX_HEAL_SUPPORT,
self::SUFFIX_HEAL,
self::SUFFIX_ABSORBED,
self::SUFFIX_ENERGIZE,
Expand Down Expand Up @@ -83,10 +89,13 @@ abstract class Suffix implements HasParameters
];

private const SUFFIX_CLASS_MAPPING = [
self::SUFFIX_DAMAGE_LANDED_SUPPORT => DamageLandedSupport::class,
self::SUFFIX_DAMAGE_LANDED => DamageLanded::class,
self::SUFFIX_DAMAGE_SUPPORT => DamageSupport::class,
self::SUFFIX_DAMAGE => Damage::class,
self::SUFFIX_MISSED => Missed::class,
self::SUFFIX_HEAL_ABSORBED => HealAbsorbed::class,
self::SUFFIX_HEAL_SUPPORT => HealSupport::class,
self::SUFFIX_HEAL => Heal::class,
self::SUFFIX_ABSORBED => Absorbed::class,
self::SUFFIX_ENERGIZE => Energize::class,
Expand Down
Loading

0 comments on commit 38069d0

Please sign in to comment.