Skip to content

Commit

Permalink
Fixed failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamKyle committed Oct 11, 2024
1 parent a0d4131 commit 144ecf3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 14 deletions.
7 changes: 3 additions & 4 deletions app/Game/Skills/Services/EnchantingService.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,12 +269,11 @@ protected function attachAffixes(array $affixes, InventorySlot|GlobalEventCrafti
}

if ($enchantingSkill->level > $affix->skill_level_trivial) {
if (! $this->sentToEasyMessage) {
if (!$this->sentToEasyMessage) {
ServerMessageHandler::handleMessage($character->user, 'to_easy_to_craft');

$this->sentToEasyMessage = true;
}

$this->processedEnchant($slot, $affix, $character, $enchantingSkill, true);

$this->wasTooEasy = true;
Expand All @@ -286,8 +285,8 @@ protected function attachAffixes(array $affixes, InventorySlot|GlobalEventCrafti
*
* If we fail to do this then we return from the loop.
*/
if (! $this->wasTooEasy) {
if (! $this->processedEnchant($slot, $affix, $character, $enchantingSkill)) {
if (!$this->wasTooEasy) {
if (!$this->processedEnchant($slot, $affix, $character, $enchantingSkill)) {
return;
}
}
Expand Down
1 change: 0 additions & 1 deletion app/Game/Skills/Services/GemService.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public function generateGem(Character $character, int $tier): array
}

if (!$this->canCraft($characterSkill, (new GemTierValue($tier))->maxForTier()['chance'])) {

ServerMessageHandler::sendBasicMessage($character->user, 'You failed to craft the gem, the item explodes before you into a pile of wasted effort and time.');

return $this->successResult();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public function testEnchantItem()
$mock->shouldReceive('characterRoll')->once()->andReturn(100);
})
);

$item = $this->createItem([
'type' => 'body',
]);
Expand All @@ -204,14 +205,6 @@ public function testEnchantItem()

$slot = $character->inventory->slots()->where('item_id', $item->id)->first();

$this->instance(
SkillCheckService::class,
Mockery::mock(SkillCheckService::class, function (MockInterface $mock) {
$mock->shouldReceive('getDCCheck')->once()->andReturn(1);
$mock->shouldReceive('characterRoll')->once()->andReturn(100);
})
);

$response = $this->actingAs($character->user)
->call('POST', '/api/enchant/' . $character->id, [
'slot_id' => $slot->id,
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Game/Skills/Services/GemServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ public function testCraftTheGemWhenSkillLevelIsMaxed()
{
Event::fake();


$character = $this->character->getCharacter();

$character->skills()->where('game_skill_id', GameSkill::where('name', 'Gem Crafting')->first()->id)->update([
Expand All @@ -211,7 +212,7 @@ public function testCraftTheGemWhenSkillLevelIsMaxed()

$this->assertEquals(200, $result['status']);

Event::assertDispatched(UpdateSkillEvent::class);
Event::assertNotDispatched(UpdateSkillEvent::class);
Event::assertDispatched(ServerMessageEvent::class);
}

Expand Down

0 comments on commit 144ecf3

Please sign in to comment.