Skip to content

Commit

Permalink
Changes and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamKyle committed Nov 21, 2023
1 parent e3465bc commit 2fb4e7d
Show file tree
Hide file tree
Showing 14 changed files with 101 additions and 52 deletions.
4 changes: 2 additions & 2 deletions app/Flare/Models/GuideQuest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class GuideQuest extends Model {
'unlock_at_level',
'only_during_event',
'be_on_game_map',
'require_event_goal_participation',
'required_event_goal_participation',
'required_holy_stacks',
'required_attached_gems',
];
Expand Down Expand Up @@ -131,7 +131,7 @@ class GuideQuest extends Model {
'unlock_at_level' => 'integer',
'only_during_event' => 'integer',
'be_on_game_map' => 'integer',
'require_event_goal_participation' => 'integer',
'required_event_goal_participation' => 'integer',
'required_holy_stacks' => 'integer',
'required_attached_gems' => 'integer',
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ public function handleGlobalEventParticipation(Character $character, GlobalEvent
'current_kills' => $character->globalEventParticipation->current_kills + 1,
]);

$character->globalEventKills()->create([
$character->globalEventKills()->update([
'kills' => $character->globalEventKills->kills + 1,
]);

$character = $character->refresh();

$globalEventGoal = $globalEventGoal->refresh();

if ($globalEventGoal->total_kills >= $globalEventGoal->next_reward_at) {
Expand All @@ -88,7 +90,7 @@ public function handleGlobalEventParticipation(Character $character, GlobalEvent
$this->rewardCharactersParticipating($globalEventGoal->refresh());
}

event(new UpdateEventGoalProgress($this->eventGoalService->getEventGoalData()));
event(new UpdateEventGoalProgress($this->eventGoalService->getEventGoalData($character)));
}

/**
Expand Down
32 changes: 26 additions & 6 deletions app/Game/Events/Console/Commands/EndScheduledEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Flare\Models\Location;
use App\Flare\Models\Character;
use App\Game\Events\Values\EventType;
use App\Game\Exploration\Services\ExplorationAutomationService;
use Illuminate\Console\Command;
use App\Flare\Models\Announcement;
use App\Flare\Models\ScheduledEvent;
Expand Down Expand Up @@ -52,9 +53,17 @@ public function handle(
UpdateRaidMonsters $updateRaidMonsters,
EventSchedulerService $eventSchedulerService,
KingdomEventService $kingdomEventService,
TraverseService $traverseService
TraverseService $traverseService,
ExplorationAutomationService $explorationAutomationService,
) {
$this->endScheduledEvent($locationService, $updateRaidMonsters, $eventSchedulerService, $kingdomEventService, $traverseService);
$this->endScheduledEvent(
$locationService,
$updateRaidMonsters,
$eventSchedulerService,
$kingdomEventService,
$traverseService,
$explorationAutomationService,
);
}

/**
Expand All @@ -63,14 +72,19 @@ public function handle(
* @param LocationService $locationService
* @param UpdateRaidMonsters $updateRaidMonsters
* @param EventSchedulerService $eventSchedulerService
* @param KingdomEventService $kingdomEventService
* @param TraverseService $traverseService
* @param ExplorationAutomationService $explorationAutomationService
* @return void
* @throws \Exception
*/
protected function endScheduledEvent(
LocationService $locationService,
UpdateRaidMonsters $updateRaidMonsters,
EventSchedulerService $eventSchedulerService,
KingdomEventService $kingdomEventService,
TraverseService $traverseService
TraverseService $traverseService,
ExplorationAutomationService $explorationAutomationService,
): void {

$scheduledEvents = ScheduledEvent::where('end_date', '<=', now())->get();
Expand Down Expand Up @@ -124,7 +138,7 @@ protected function endScheduledEvent(
}

if ($eventType->isWinterEvent()) {
$this->endWinterEvent($kingdomEventService, $traverseService);
$this->endWinterEvent($kingdomEventService, $traverseService, $explorationAutomationService);

$event->update([
'currently_running' => false,
Expand Down Expand Up @@ -234,9 +248,13 @@ protected function endWeeklySpawnEvent() {
* End the winter event.
*
* @param KingdomEventService $kingdomEventService
* @param TraverseService $traverseService
* @param ExplorationAutomationService $explorationAutomationService
* @return void
*/
protected function endWinterEvent(KingdomEventService $kingdomEventService, TraverseService $traverseService) {
protected function endWinterEvent(KingdomEventService $kingdomEventService,
TraverseService $traverseService,
ExplorationAutomationService $explorationAutomationService) {
$event = Event::where('type', EventType::WINTER_EVENT)->first();

$kingdomEventService->handleKingdomRewardsForEvent(MapNameValue::ICE_PLANE);
Expand All @@ -246,8 +264,10 @@ protected function endWinterEvent(KingdomEventService $kingdomEventService, Trav

Character::join('maps', 'maps.character_id', '=', 'characters.id')
->where('maps.game_map_id', $gameMap->id)
->chunk(100, function ($characters) use ($traverseService, $surfaceMap) {
->chunk(100, function ($characters) use ($traverseService, $surfaceMap, $explorationAutomationService) {
foreach ($characters as $character) {
$explorationAutomationService->stopExploration($character);

$traverseService->travel($surfaceMap->id, $character);
}
});
Expand Down
29 changes: 2 additions & 27 deletions app/Game/Exploration/Controllers/Api/ExplorationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,11 @@ class ExplorationController extends Controller {
*/
private ExplorationAutomationService $explorationAutomationService;

/**
* @var CharacterCacheData $characterCacheData
*/
private CharacterCacheData $characterCacheData;

/**
* @param ExplorationAutomationService $explorationAutomationService
* @param CharacterCacheData $characterCacheData
*/
public function __construct(ExplorationAutomationService $explorationAutomationService, CharacterCacheData $characterCacheData) {
public function __construct(ExplorationAutomationService $explorationAutomationService) {
$this->explorationAutomationService = $explorationAutomationService;
$this->characterCacheData = $characterCacheData;
}

/**
Expand Down Expand Up @@ -83,25 +76,7 @@ public function begin(ExplorationRequest $request, Character $character): JsonRe
*/
public function stop(Character $character): JsonResponse {

$characterAutomation = CharacterAutomation::where('character_id', $character->id)->where('type', AutomationType::EXPLORING)->first();

if (is_null($characterAutomation)) {
return response()->json([
'message' => 'Nope. You don\'t own that.'
], 422);
}

$characterAutomation->delete();

$this->characterCacheData->deleteCharacterSheet($character);

$character = $character->refresh();

event(new ExplorationTimeOut($character->user, 0));
event(new ExplorationStatus($character->user, false));
event(new UpdateCharacterStatus($character));

event(new ExplorationLogUpdate($character->user->id, 'Exploration has been stopped at player request.'));
$this->explorationAutomationService->stopExploration($character);

return response()->json();
}
Expand Down
4 changes: 3 additions & 1 deletion app/Game/Exploration/Providers/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Game\Exploration\Providers;


use App\Flare\Builders\Character\CharacterCacheData;
use App\Flare\ServerFight\MonsterPlayerFight;
use App\Game\Battle\Handlers\BattleEventHandler;
use App\Game\Exploration\Middleware\IsCharacterExploring;
Expand All @@ -22,7 +23,8 @@ public function register() {
$this->app->bind(ExplorationAutomationService::class, function($app) {
return new ExplorationAutomationService(
$app->make(MonsterPlayerFight::class),
$app->make(BattleEventHandler::class)
$app->make(BattleEventHandler::class),
$app->make(CharacterCacheData::class)
);
});
}
Expand Down
32 changes: 31 additions & 1 deletion app/Game/Exploration/Services/ExplorationAutomationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

namespace App\Game\Exploration\Services;

use App\Flare\Builders\Character\CharacterCacheData;
use App\Flare\Models\Character;
use App\Flare\Models\CharacterAutomation;
use App\Flare\ServerFight\MonsterPlayerFight;
use App\Flare\Values\AutomationType;
use App\Game\Battle\Events\UpdateCharacterStatus;
use App\Game\Battle\Handlers\BattleEventHandler;
use App\Game\Exploration\Events\ExplorationLogUpdate;
use App\Game\Exploration\Events\ExplorationStatus;
use App\Game\Exploration\Events\ExplorationTimeOut;
use App\Game\Exploration\Jobs\Exploration;
use App\Game\Maps\Events\UpdateDuelAtPosition;
Expand All @@ -19,9 +21,15 @@ class ExplorationAutomationService {

private BattleEventHandler $battleEventHandler;

public function __construct(MonsterPlayerFight $monsterPlayerFight, BattleEventHandler $battleEventHandler) {
private CharacterCacheData $characterCacheData;

public function __construct(MonsterPlayerFight $monsterPlayerFight,
BattleEventHandler $battleEventHandler,
CharacterCacheData $characterCacheData) {

$this->monsterPlayerFight = $monsterPlayerFight;
$this->battleEventHandler = $battleEventHandler;
$this->characterCacheData = $characterCacheData;
}

/**
Expand Down Expand Up @@ -53,6 +61,28 @@ public function beginAutomation(Character $character, array $params) {
$this->startAutomation($character, $automation->id, $params['attack_type']);
}

public function stopExploration(Character $character) {
$characterAutomation = CharacterAutomation::where('character_id', $character->id)->where('type', AutomationType::EXPLORING)->first();

if (is_null($characterAutomation)) {
return response()->json([
'message' => 'Nope. You don\'t own that.'
], 422);
}

$characterAutomation->delete();

$this->characterCacheData->deleteCharacterSheet($character);

$character = $character->refresh();

event(new ExplorationTimeOut($character->user, 0));
event(new ExplorationStatus($character->user, false));
event(new UpdateCharacterStatus($character));

event(new ExplorationLogUpdate($character->user->id, 'Exploration has been stopped at player request.'));
}

protected function startAutomation(Character $character, int $automationId, string $attackType) {
Exploration::dispatch($character, $automationId, $attackType)->delay(now()->addMinutes(5))->onQueue('default_long');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,8 @@ public function requiredGlobalEventKillAmount(Character $character, GuideQuest $
return $this;
}

if ($character->globalEventKills->kills >= $guideQuest->require_event_goal_participation) {
$this->finishedRequirements[] = 'require_event_goal_participation';
if ($character->globalEventKills->kills >= $guideQuest->required_event_goal_participation) {
$this->finishedRequirements[] = 'required_event_goal_participation';
}

return $this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function up(): void
{
Schema::table('guide_quests', function (Blueprint $table) {
$table->unsignedBigInteger('be_on_game_map')->nullable();
$table->bigInteger('require_event_goal_participation')->nullable();
$table->bigInteger('required_event_goal_participation')->nullable();
$table->integer('required_holy_stacks')->nullable();
$table->integer('required_attached_gems')->nullable();
});
Expand Down
Binary file modified resources/data-imports/Admin Section/guide_quests.xlsx
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ const guideQuestLabelBuilder = (
return "Obtain Shards amount";
case "required_gold_bars":
return "Create Gold Bars amount";
case "be_on_game_map":
case "required_to_be_on_game_map_name":
return "Physically be on Plane";
case "require_event_goal_participation":
case "required_event_goal_participation":
return "Kill # of Event Creatures";
default:
return null;
Expand Down Expand Up @@ -180,6 +180,8 @@ const getRequirementKey = (labelKey: string): string => {
return "required_passive_level";
case "required_kingdom_building_id":
return "required_kingdom_building_level";
case "required_to_be_on_game_map_name":
return "be_on_game_map";
default:
return labelKey;
}
Expand Down
22 changes: 20 additions & 2 deletions resources/js/game/sections/guide-quests/modals/guide-quest.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Fragment } from "react";
import React from "react";
import Dialogue from "../../../components/ui/dialogue/dialogue";
import ComponentLoading from "../../../components/ui/loading/component-loading";
import { AxiosError, AxiosResponse } from "axios";
Expand All @@ -15,7 +15,12 @@ import RequiredListItem from "../components/required-list-item";
import { questRewardKeys } from "../lib/guide-quests-rewards";
import RewardListItem from "../components/reward-list-item";
import TabLayout from "../components/tab-labout";
import { viewPortWatcher } from "../../../lib/view-port-watcher";
import InfoAlert from "../../../components/ui/alerts/simple-alerts/info-alert";
import clsx from "clsx";

enum EVENT_TYPE {
WINTER_EVENT = 4,
};

export default class GuideQuest extends React.Component<any, any> {
constructor(props: any) {
Expand Down Expand Up @@ -131,6 +136,8 @@ export default class GuideQuest extends React.Component<any, any> {
buildRequirementsList(): JSX.Element[] | [] {
const requirementsList: JSX.Element[] = [];

console.log(this.state.quest_data);

this.fetchRequiredKeys().forEach((key: string) => {
let label = guideQuestLabelBuilder(key, this.state.quest_data);

Expand Down Expand Up @@ -212,6 +219,17 @@ export default class GuideQuest extends React.Component<any, any> {
</div>
) : (
<div className="overflow-y-auto max-h-[450px] lg:max-h-none lg:overflow-visible">
<InfoAlert additional_css={clsx('my-4', {'hidden': this.state.quest_data.only_during_event === null})}>
<p>
{
this.state.quest_data.only_during_event === EVENT_TYPE.WINTER_EVENT ?
'This is a special event guide quest to get new and existing ' +
'players engaged with the new event content. Once these quests are finished, ' +
'you will be returned to your remaining regular guide quests.'
: null
}
</p>
</InfoAlert>
{this.state.success_message !== null ? (
<SuccessAlert
close_alert={this.closeMessage.bind(this)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<th>unlock_at_level<th>
<th>only_during_event<th>
<th>be_on_game_map</th>
<th>require_event_goal_participation</th>
<th>required_event_goal_participation</th>
<th>required_holy_stacks</th>
<th>required_attached_gems</th>
</tr>
Expand Down Expand Up @@ -115,7 +115,7 @@
<td>{{ $guideQuest->unlock_at_level}}<td>
<td>{{ $guideQuest->only_during_event}}<td>
<td>{{ !is_null($guideQuest->be_on_game_map) ? $guideQuest->required_to_be_on_game_map_name : ''}}</td>
<td>{{ $guideQuest->require_event_goal_participation }}</td>
<td>{{ $guideQuest->required_event_goal_participation }}</td>
<td>{{ $guideQuest->required_holy_stacks }}</td>
<td>{{ $guideQuest->required_attached_gems }}</td>
</tr>
Expand Down
4 changes: 2 additions & 2 deletions resources/views/admin/guide-quests/manage.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@
</div>
<h3 class="mb-3">Event Goal Participation</h3>
<x-core.forms.input :model="$guideQuest" label="Required Event Goal Kills:"
modelKey="require_event_goal_participation"
name="require_event_goal_participation" />
modelKey="required_event_goal_participation"
name="required_event_goal_participation" />
</div>
</div>
</x-core.form-wizard.content>
Expand Down
4 changes: 2 additions & 2 deletions resources/views/admin/guide-quests/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
<dt>Required Player Level</dt>
<dd>{{ $guideQuest->required_level }}</dd>
@endif
@if (!is_null($guideQuest->require_event_goal_participation))
@if (!is_null($guideQuest->required_event_goal_participation))
<dt>Participate in the Event Goal and Kill # of Creatures:</dt>
<dd>{{$guideQuest->require_event_goal_participation}}</dd>
<dd>{{$guideQuest->required_event_goal_participation}}</dd>
@endif
@if (!is_null($guideQuest->required_game_map_id))
<dt>Required Access To Map</dt>
Expand Down

0 comments on commit 2fb4e7d

Please sign in to comment.