-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More tests and started adding faction loyalty
- Loading branch information
Showing
18 changed files
with
294 additions
and
40 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
app/Game/Factions/FactionLoyalty/Controllers/Api/FactionLoyaltyController.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace App\Game\Factions\FactionLoyalty\Controllers\Api; | ||
|
||
use App\Flare\Models\Character; | ||
use App\Game\Factions\FactionLoyalty\Services\FactionLoyaltyService; | ||
use App\Http\Controllers\Controller; | ||
use Illuminate\Http\JsonResponse; | ||
|
||
class FactionLoyaltyController extends Controller { | ||
|
||
/** | ||
* @var FactionLoyaltyService $factionLoyaltyService | ||
*/ | ||
private FactionLoyaltyService $factionLoyaltyService; | ||
|
||
/** | ||
* @param FactionLoyaltyService $factionLoyaltyService | ||
*/ | ||
public function __construct(FactionLoyaltyService $factionLoyaltyService) { | ||
$this->factionLoyaltyService = $factionLoyaltyService; | ||
} | ||
|
||
/** | ||
* @param Character $character | ||
* @return JsonResponse | ||
*/ | ||
public function fetchLoyaltyInfo(Character $character): JsonResponse { | ||
return response()->json($this->factionLoyaltyService->getLoyaltyInfoForPlane($character)); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
app/Game/Factions/FactionLoyalty/Providers/ServiceProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace App\Game\Factions\FactionLoyalty\Providers; | ||
|
||
use Illuminate\Support\ServiceProvider as ApplicationServiceProvider; | ||
use App\Game\Factions\FactionLoyalty\Services\FactionLoyaltyService; | ||
|
||
class ServiceProvider extends ApplicationServiceProvider | ||
{ | ||
/** | ||
* Register any application services. | ||
* | ||
* @return void | ||
*/ | ||
public function register() { | ||
|
||
|
||
$this->app->bind(FactionLoyaltyService::class, function($app) { | ||
return new FactionLoyaltyService( | ||
); | ||
}); | ||
} | ||
|
||
/** | ||
* Bootstrap any application services. | ||
* | ||
* @return void | ||
*/ | ||
public function boot() | ||
{ | ||
|
||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
app/Game/Factions/FactionLoyalty/Services/FactionLoyaltyService.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace App\Game\Factions\FactionLoyalty\Services; | ||
|
||
|
||
use App\Flare\Models\Character; | ||
use App\Flare\Models\Npc; | ||
use App\Game\Core\Traits\ResponseBuilder; | ||
|
||
class FactionLoyaltyService { | ||
|
||
use ResponseBuilder; | ||
|
||
public function getLoyaltyInfoForPlane(Character $character): array { | ||
$gameMap = $character->map->gameMap; | ||
|
||
$npcNames = Npc::where('game_map_id', $gameMap->id)->get()->map(function($npc) { | ||
return [ | ||
'id' => $npc->id, | ||
'name' => $npc->real_name | ||
]; | ||
}); | ||
|
||
return $this->successResult([ | ||
'npcs' => $npcNames, | ||
'map_name' => $gameMap->name, | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
resources/js/game/sections/faction-loyalty/types/faction-loyalty-props.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default interface FactionLoyaltyProps { | ||
character_id: number; | ||
} |
13 changes: 13 additions & 0 deletions
13
resources/js/game/sections/faction-loyalty/types/faction-loyalty-state.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export type FactionLoyaltyNpc = { | ||
name: string; | ||
id: number; | ||
} | ||
|
||
export default interface FactionLoyaltyState { | ||
|
||
is_loading: boolean; | ||
selected_npc: FactionLoyaltyNpc | null; | ||
error_message: string | null; | ||
npcs: FactionLoyaltyNpc[]|[]; | ||
game_map_name: string | null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,7 @@ export default interface ActionTabsProps { | |
|
||
children: React.ReactNode; | ||
|
||
character_id: number; | ||
|
||
use_tabs: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
Route::group(['middleware' => ['is.character.who.they.say.they.are']], function() { | ||
Route::get('/faction-loyalty/{character}', ['uses' => 'Api\FactionLoyaltyController@fetchLoyaltyInfo']); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.