-
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.
Added a way to calculate total skill xp in exploration
- Loading branch information
Showing
7 changed files
with
221 additions
and
35 deletions.
There are no files selected for viewing
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
56 changes: 56 additions & 0 deletions
56
app/Game/BattleRewardProcessing/Jobs/ExplorationSkillXpHandler.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,56 @@ | ||
<?php | ||
|
||
namespace App\Game\BattleRewardProcessing\Jobs; | ||
|
||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Foundation\Bus\Dispatchable; | ||
use Illuminate\Queue\InteractsWithQueue; | ||
use Illuminate\Queue\SerializesModels; | ||
use App\Flare\Models\Character; | ||
use App\Flare\Models\Monster; | ||
use App\Flare\Services\CharacterRewardService; | ||
use App\Game\Skills\Services\SkillService; | ||
|
||
class ExplorationSkillXpHandler implements ShouldQueue | ||
{ | ||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | ||
|
||
/** | ||
* @param integer $characterId | ||
* @param integer $numberOfCreatures | ||
* @param integer $xp | ||
*/ | ||
public function __construct(private int $characterId, private int $xp) {} | ||
|
||
/** | ||
* Handle the job | ||
* | ||
* @param CharacterRewardService $characterRewardService | ||
* @return void | ||
*/ | ||
public function handle(SkillService $skillService): void | ||
{ | ||
$character = Character::find($this->characterId); | ||
|
||
if (is_null($character)) { | ||
return; | ||
} | ||
|
||
$this->processSkillXpReward($character, $skillService); | ||
} | ||
|
||
/** | ||
* Process Skill XP Reward | ||
* | ||
* @param Character $character | ||
* @param Monster $monster | ||
* @param CharacterRewardService $characterRewardService | ||
* @return void | ||
*/ | ||
private function processSkillXpReward(Character $character, SkillService $skillService): void | ||
{ | ||
|
||
$skillService->setSkillInTraining($character)->giveXpToTrainingSkill($character, $this->xp); | ||
} | ||
} |
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
Oops, something went wrong.