Skip to content

Commit

Permalink
#2447 Spells moved namespace. Added mechanic for Spells along with th…
Browse files Browse the repository at this point in the history
…e relevant constant.
  • Loading branch information
Wotuu committed Aug 4, 2024
1 parent 5e15d2b commit 8b07297
Show file tree
Hide file tree
Showing 38 changed files with 275 additions and 158 deletions.
2 changes: 1 addition & 1 deletion app/Console/Commands/CombatLog/ExtractSpellAurasToCsv.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use App\Logic\CombatLog\CombatEvents\CombatLogEvent;
use App\Logic\CombatLog\Guid\Creature;
use App\Models\Dungeon;
use App\Models\Spell;
use App\Models\Spell\Spell;
use App\Service\CombatLog\CombatLogDataExtractionServiceInterface;
use App\Service\Wowhead\WowheadServiceInterface;
use Illuminate\Support\Collection;
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/Mapping/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use App\Models\Mapping\MappingCommitLog;
use App\Models\Mapping\MappingVersion;
use App\Models\Npc\Npc;
use App\Models\Spell;
use App\Models\Spell\Spell;
use App\Traits\SavesArrayToJsonFile;
use Illuminate\Console\Command;
use Illuminate\Database\Eloquent\Model;
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/Wowhead/FetchSpellData.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Console\Commands\Wowhead;

use App\Models\Spell;
use App\Models\Spell\Spell;
use App\Service\Wowhead\WowheadServiceInterface;
use Exception;
use Illuminate\Console\Command;
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/AdminToolsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use App\Models\Npc\NpcClassification;
use App\Models\Npc\NpcEnemyForces;
use App\Models\Npc\NpcType;
use App\Models\Spell;
use App\Models\Spell\Spell;
use App\Service\Cache\CacheServiceInterface;
use App\Service\CombatLog\ResultEventDungeonRouteServiceInterface;
use App\Service\Coordinates\CoordinatesServiceInterface;
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Ajax/AjaxEnemyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use App\Models\EnemyActiveAura;
use App\Models\Mapping\MappingVersion;
use App\Models\RaidMarker;
use App\Models\Spell;
use App\Models\Spell\Spell;
use App\Models\User;
use App\Service\Coordinates\CoordinatesServiceInterface;
use DB;
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Ajax/AjaxSpellController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use App\Http\Controllers\Controller;
use App\Http\Requests\Spell\AjaxSpellUpdateFormRequest;
use App\Models\Spell;
use App\Models\Spell\Spell;

class AjaxSpellController extends Controller
{
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/NpcController.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use App\Models\Npc\NpcClassification;
use App\Models\Npc\NpcEnemyForces;
use App\Models\Npc\NpcSpell;
use App\Models\Spell;
use App\Models\Spell\Spell;
use App\Models\User;
use App\Service\Npc\NpcServiceInterface;
use Exception;
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/SpellController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use App\Http\Controllers\Traits\ChangesMapping;
use App\Http\Requests\SpellFormRequest;
use App\Models\Spell;
use App\Models\Spell\Spell;
use Exception;
use Illuminate\Contracts\View\Factory;
use Illuminate\Http\RedirectResponse;
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/KillZone/APIKillZoneFormRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Http\Requests\KillZone;

use App\Models\Floor\Floor;
use App\Models\Spell;
use App\Models\Spell\Spell;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/Spell/AjaxSpellUpdateFormRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Http\Requests\Spell;

use App\Models\Laratrust\Role;
use App\Models\Spell;
use App\Models\Spell\Spell;
use Auth;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/SpellFormRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Http\Requests;

use App\Models\Laratrust\Role;
use App\Models\Spell;
use App\Models\Spell\Spell;
use Auth;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
Expand Down
2 changes: 1 addition & 1 deletion app/Logic/MapContext/MapContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use App\Models\Mapping\MappingVersion;
use App\Models\PublishedState;
use App\Models\RaidMarker;
use App\Models\Spell;
use App\Models\Spell\Spell;
use App\Models\User;
use App\Service\Cache\CacheServiceInterface;
use App\Service\Coordinates\CoordinatesServiceInterface;
Expand Down
1 change: 1 addition & 0 deletions app/Models/EnemyActiveAura.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Models;

use App\Models\Spell\Spell;
use App\Models\Traits\SeederModel;
use Eloquent;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
Expand Down
2 changes: 1 addition & 1 deletion app/Models/KillZone/KillZone.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use App\Models\DungeonRoute\DungeonRoute;
use App\Models\Enemy;
use App\Models\Floor\Floor;
use App\Models\Spell;
use App\Models\Spell\Spell;
use App\Models\Traits\HasLatLng;
use Eloquent;
use Illuminate\Database\Eloquent\Model;
Expand Down
2 changes: 1 addition & 1 deletion app/Models/KillZone/KillZoneSpell.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Models\KillZone;

use App\Models\Spell;
use App\Models\Spell\Spell;
use Eloquent;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Npc/Npc.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use App\Models\Enemy;
use App\Models\Mapping\MappingModelInterface;
use App\Models\Mapping\MappingVersion;
use App\Models\Spell;
use App\Models\Spell\Spell;
use App\Models\Traits\SeederModel;
use Eloquent;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Npc/NpcSpell.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Models\Npc;

use App\Models\CacheModel;
use App\Models\Spell;
use App\Models\Spell\Spell;
use App\Models\Traits\SeederModel;
use Eloquent;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
Expand Down
112 changes: 112 additions & 0 deletions app/Models/Spell/Spell.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?php

namespace App\Models\Spell;

use App\Models\CacheModel;
use App\Models\Mapping\MappingModelInterface;
use App\Models\Traits\SeederModel;
use Eloquent;
use Illuminate\Database\Eloquent\Builder;
use Str;

/**
* @property int $id
* @property string $category
* @property string $cooldown_group
* @property string $dispel_type
* @property string $icon_name
* @property string $name
* @property int $schools_mask
* @property bool $aura
* @property bool $selectable
* @property bool $hidden_on_map
*
* @property string $icon_url
*
* @method static Builder visible()
*
* @mixin Eloquent
*/
class Spell extends CacheModel implements MappingModelInterface
{
use SeederModel;
use SpellConstants;

public $incrementing = false;

public $timestamps = false;

public $hidden = ['pivot'];

protected $appends = ['icon_url'];

protected $fillable = [
'id',
'category',
'cooldown_group',
'dispel_type',
'icon_name',
'name',
'schools_mask',
'aura',
'selectable',
'hidden_on_map',
'icon_url',
];

protected $casts = [
'id' => 'integer',
'schools_mask' => 'integer',
'aura' => 'boolean',
'selectable' => 'boolean',
'hidden_on_map' => 'boolean',
];

public function getSchoolsAsArray(): array
{
$result = [];

foreach (self::ALL_SCHOOLS as $school) {
$result[$school] = $this->schools_mask & $school;
}

return $result;
}

public function scopeVisible(): Builder
{
return $this->where('hidden_on_map', false);
}

/**
* @return string
*/
public function getIconUrlAttribute(): string
{
return url(sprintf('/images/spells/%s.jpg', $this->icon_name));
}

public function getDungeonId(): ?int
{
// Spells aren't tied to a specific dungeon, but they're part of the mapping
return 0;
}

public function getWowheadLink(): string
{
return sprintf('https://wowhead.com/spell=%d/%s', $this->id, Str::slug($this->name));
}

public static function maskToReadableString(int $spellSchoolMask): string
{
$result = [];

foreach (self::ALL_SCHOOLS as $schoolName => $schoolMask) {
if ($spellSchoolMask & $schoolMask) {
$result[] = $schoolName;
}
}

return implode(', ', $result);
}
}
Loading

0 comments on commit 8b07297

Please sign in to comment.