Skip to content

Commit

Permalink
Merge branch 'development' of github.com:Wotuu/keystone.guru into dev…
Browse files Browse the repository at this point in the history
…elopment

Conflicts:
 composer.json
 composer.lock
  • Loading branch information
Wotuu committed Mar 13, 2024
2 parents e4fab6e + ecfa5d9 commit 5ab93cf
Show file tree
Hide file tree
Showing 69 changed files with 4,328 additions and 370 deletions.
12 changes: 9 additions & 3 deletions app/Console/Commands/Localization/LocalizationSync.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*/
class LocalizationSync extends Command
{
private const LANG_HODOR = 'ho-HO';

/**
* The name and signature of the console command.
*
Expand Down Expand Up @@ -44,7 +46,7 @@ public function handle(): int
$baseLang = $this->argument('base');
$targetLang = $this->argument('target');

$langDir = resource_path() . DIRECTORY_SEPARATOR . 'lang';
$langDir = base_path() . DIRECTORY_SEPARATOR . 'lang';
$baseDir = $langDir . DIRECTORY_SEPARATOR . $baseLang;
$targetDir = $langDir . DIRECTORY_SEPARATOR . $targetLang;

Expand Down Expand Up @@ -94,7 +96,7 @@ public function scanDir(string $baseLang, string $targetLang, string $baseDir, s
continue;
}

$shortTargetPath = str_replace(resource_path(), '', $targetPath);
$shortTargetPath = str_replace(base_path(), '', $targetPath);
if ($target === false || $target != $result) {
file_put_contents($targetPath, $result);

Expand Down Expand Up @@ -175,7 +177,11 @@ public function parse(string $targetLang, string $content, $lemmas = false): str
$segment = $match[1] . $lemmas[$key] . $match[1];
} // mark value as not specified
else {
$segment = $match[1] . '@todo ' . $targetLang . ': ' . $key . $match[1];
if ($targetLang === self::LANG_HODOR) {
$segment = $match[1] . 'hodor' . $match[1];
} else {
$segment = $match[1] . '@todo ' . $targetLang . ': ' . $key . $match[1];
}
}

array_pop($tree);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AjaxDungeonFloorSwitchMarkerController extends AjaxMappingModelBaseControl
{
use ListsDungeonFloorSwitchMarkers;

public function list(Request $request): Collection
public function get(Request $request): Collection
{
return $this->listDungeonFloorSwitchMarkers($request->get('floor_id'));
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Ajax/AjaxDungeonRouteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class AjaxDungeonRouteController extends Controller
*
* @throws Exception
*/
public function list(Request $request)
public function get(Request $request)
{
// Check if we're filtering based on team or not
$teamPublicKey = $request->get('team_public_key', false);
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Ajax/AjaxNpcController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function delete(Request $request)
/**
* @throws Exception
*/
public function list(Request $request): array
public function get(Request $request): array
{
$npcs = Npc::with(['dungeon', 'type', 'classification', 'enemyForces'])
->selectRaw('npcs.*, COUNT(enemies.id) as enemy_count')
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Ajax/AjaxTagController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function all(Request $request)
/**
* @return Tag[]|Collection
*/
public function list(Request $request, TagCategory $category)
public function get(Request $request, TagCategory $category)
{
return Tag::where('tag_category_id', $category->id)->where('user_id', Auth::id())->get();
}
Expand Down
7 changes: 5 additions & 2 deletions app/Http/Controllers/Ajax/AjaxTeamController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@

class AjaxTeamController extends Controller
{
public function list(Request $request)
public function get(Request $request)
{
return Auth::user()->teams()->get();
/** @var User $user */
$user = Auth::user();

return $user->teams;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Ajax/AjaxUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AjaxUserController
*
* @throws Exception
*/
public function list(Request $request)
public function get(Request $request)
{
$users = User::with(['patreonUserLink', 'roles', 'dungeonroutes'])->selectRaw('users.*');

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/DungeonController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function store(DungeonFormRequest $request, ?Dungeon $dungeon = null)
/**
* @return Factory|View
*/
public function new(): View
public function create(): View
{
$dungeons = Dungeon::all()->keyBy('key');
$availableKeysSelect = collect();
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/DungeonRouteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@

class DungeonRouteController extends Controller
{
public function new(): View
public function create(): View
{
return view('dungeonroute.new');
}

public function newtemporary(): View
public function createTemporary(): View
{
return view('dungeonroute.newtemporary', ['dungeons' => Dungeon::all()]);
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ExpansionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function store(ExpansionFormRequest $request, ?Expansion $expansion = nul
*
* @return Factory|View
*/
public function new(): View
public function create(): View
{
return view('admin.expansion.edit');
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Floor/FloorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function store(FloorFormRequest $request, Dungeon $dungeon, ?Floor $floor
/**
* @return Factory|View
*/
public function new(Request $request, Dungeon $dungeon): View
public function create(Request $request, Dungeon $dungeon): View
{
return view('admin.floor.edit', [
'dungeon' => $dungeon,
Expand Down
13 changes: 8 additions & 5 deletions app/Http/Controllers/NpcController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use App\Models\NpcClassification;
use App\Models\NpcSpell;
use App\Models\Spell;
use App\Models\User;
use App\Service\Npc\NpcServiceInterface;
use Exception;
use Illuminate\Contracts\View\Factory;
Expand Down Expand Up @@ -141,16 +142,18 @@ public function store(NpcFormRequest $request, ?Npc $npc = null)

// Prevent sending multiple messages for the same dungeon
$messagesSentToDungeons = collect();
/** @var User $user */
$user = Auth::user();
if ($npcAllDungeon || $npcBeforeAllDungeon) {
// Broadcast the event for all dungeons
foreach (Dungeon::all() as $dungeon) {
if ($npc->dungeon === null && $messagesSentToDungeons->search($dungeon->id) === false) {
broadcast(new ModelChangedEvent($dungeon, Auth::user(), $npc));
broadcast(new ModelChangedEvent($dungeon, $user, $npc));
$messagesSentToDungeons->push($dungeon->id);
}

if ($npcBefore->dungeon === null && $messagesSentToDungeons->search($dungeon->id) === false) {
broadcast(new ModelChangedEvent($dungeon, Auth::user(), $npcBefore));
broadcast(new ModelChangedEvent($dungeon, $user, $npcBefore));
$messagesSentToDungeons->push($dungeon->id);
}
}
Expand All @@ -161,12 +164,12 @@ public function store(NpcFormRequest $request, ?Npc $npc = null)
if (!$npcAllDungeon) {
// Let previous dungeon know that this NPC is no longer available
if ($messagesSentToDungeons->search($npc->dungeon->id) === false) {
broadcast(new ModelChangedEvent($npc->dungeon, Auth::user(), $npc));
broadcast(new ModelChangedEvent($npc->dungeon, $user, $npc));
$messagesSentToDungeons->push($npc->dungeon->id);
}

if (!$npcBeforeAllDungeon && $messagesSentToDungeons->search($npc->dungeon->id) === false) {
broadcast(new ModelChangedEvent($npcBefore->dungeon, Auth::user(), $npc));
broadcast(new ModelChangedEvent($npcBefore->dungeon, $user, $npc));
$messagesSentToDungeons->push($npc->dungeon->id);
}
}
Expand All @@ -189,7 +192,7 @@ public function store(NpcFormRequest $request, ?Npc $npc = null)
*
* @return Factory|View
*/
public function new()
public function create()
{
return view('admin.npc.edit', [
'classifications' => NpcClassification::all()->pluck('name', 'id')->mapWithKeys(static fn(string $name, int $id) => [$id => __($name)]),
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ReleaseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function store(ReleaseFormRequest $request, ?Release $release = null)
*
* @return Factory|View
*/
public function new(): View
public function create(): View
{
return view('admin.release.edit', [
'categories' => ReleaseChangelogCategory::all(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class DungeonSpeedrunRequiredNpcsController extends Controller
/**
* @return Application|Factory|View
*/
public function new(NpcServiceInterface $npcService, Request $request, Dungeon $dungeon, Floor $floor, int $difficulty): \Illuminate\View\View
public function create(NpcServiceInterface $npcService, Request $request, Dungeon $dungeon, Floor $floor, int $difficulty): \Illuminate\View\View
{
$npcs = $npcService->getNpcsForDropdown($dungeon, true)->toArray();

Expand All @@ -34,7 +34,7 @@ public function new(NpcServiceInterface $npcService, Request $request, Dungeon $
]);
}

public function savenew(DungeonSpeedrunRequiredNpcsFormRequest $request, Dungeon $dungeon, Floor $floor, int $difficulty): RedirectResponse
public function createSave(DungeonSpeedrunRequiredNpcsFormRequest $request, Dungeon $dungeon, Floor $floor, int $difficulty): RedirectResponse
{
$validated = $request->validated();
$validated['npc2_id'] = (int)$validated['npc2_id'] === -1 ? null : $validated['npc2_id'];
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 @@ -75,7 +75,7 @@ public function store(SpellFormRequest $request, ?Spell $spell = null)
*
* @return Factory|View
*/
public function new(): View
public function create(): View
{
return view('admin.spell.edit', [
'dispelTypes' => Spell::ALL_DISPEL_TYPES,
Expand Down
12 changes: 9 additions & 3 deletions app/Http/Controllers/TeamController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use App\Models\Tags\TagCategory;
use App\Models\Team;
use App\Models\TeamUser;
use App\Models\User;
use Exception;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Contracts\Foundation\Application;
Expand Down Expand Up @@ -74,7 +75,9 @@ public function store(TeamFormRequest $request, ?Team $team = null)

if ($new) {
// If saving team + logo was successful, save our own user as its first member
$team->addMember(Auth::user(), TeamUser::ROLE_ADMIN);
/** @var User $user */
$user = Auth::user();
$team->addMember($user, TeamUser::ROLE_ADMIN);
}
}

Expand All @@ -84,7 +87,7 @@ public function store(TeamFormRequest $request, ?Team $team = null)
/**
* @return Factory|View
*/
public function new(): View
public function create(): View
{
return view('team.new');
}
Expand All @@ -98,6 +101,7 @@ public function edit(Request $request, Team $team): View
{
$this->authorize('edit', $team);

/** @var User $user */
$user = Auth::user();

return view('team.edit', [
Expand Down Expand Up @@ -203,7 +207,9 @@ public function inviteaccept(Request $request, string $invitecode)
if ($team->isCurrentUserMember()) {
$result = view('team.invite', ['team' => $team, 'member' => true]);
} else {
$team->addMember(Auth::getUser(), $team->default_role);
/** @var User $user */
$user = Auth::getUser();
$team->addMember($user, $team->default_role);

Session::flash('status', sprintf(__('controller.team.flash.invite_accept_success'), $team->name));
$result = redirect()->route('team.edit', ['team' => $team]);
Expand Down
3 changes: 2 additions & 1 deletion config/language.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
*/

// Only allow DE when debugging, it's still WIP
'allowed' => env('app.debug') ? ['en-US', 'de-DE', 'ru-RU'] : ['en-US', 'ru-RU'],
'allowed' => env('APP_DEBUG') ? ['en-US', 'de-DE', 'ru-RU', 'ho-HO'] : ['en-US', 'ru-RU'],

/*
|--------------------------------------------------------------------------
Expand Down Expand Up @@ -171,6 +171,7 @@
['short' => 'et', 'long' => 'et-EE', 'english' => 'Estonian', 'native' => 'Eesti'],
['short' => 'he', 'long' => 'he-IL', 'english' => 'Hebrew', 'native' => 'עִבְרִית'],
['short' => 'hi', 'long' => 'hi-IN', 'english' => 'Hindi', 'native' => 'हिन्दी'],
['short' => 'ho', 'long' => 'ho-HO', 'english' => 'Hodor', 'native' => 'Hodor'],
['short' => 'hr', 'long' => 'hr-HR', 'english' => 'Croatian', 'native' => 'Hrvatski'],
['short' => 'hu', 'long' => 'hu-HU', 'english' => 'Hungarian', 'native' => 'Magyar'],
['short' => 'hy', 'long' => 'hy-AM', 'english' => 'Armenian', 'native' => 'Հայերեն'],
Expand Down
Loading

0 comments on commit 5ab93cf

Please sign in to comment.