Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/RS3/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use RuneStat\RS3\Skills\Ranged;
use RuneStat\RS3\Skills\Summoning;
use RuneStat\RS3\Skills\Constitution;
use RuneStat\RS3\Skills\Necromancy;

class Profile
{
Expand Down Expand Up @@ -64,7 +65,8 @@ public function getCombatLevel(): int
$this->stats->findByClass(Defence::class),
$this->stats->findByClass(Constitution::class),
$this->stats->findByClass(Prayer::class),
$this->stats->findByClass(Summoning::class)
$this->stats->findByClass(Summoning::class),
$this->stats->findByClass(Necromancy::class)
);
}
}
6 changes: 4 additions & 2 deletions src/RS3/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ function combat_level(
Stat $defence,
Stat $constitution,
Stat $prayer,
Stat $summoning
Stat $summoning,
Stat $necromancy
): int {
$highest = max(
$attack->getLevel() + $strength->getLevel(),
2 * $magic->getLevel(),
2 * $ranged->getLevel()
2 * $ranged->getLevel(),
2 * $necromancy->getLevel()
);

$rest = (
Expand Down
69 changes: 58 additions & 11 deletions tests/RS3/CombatLevelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use RuneStat\RS3\Skills\Ranged;
use RuneStat\RS3\Skills\Strength;
use RuneStat\RS3\Skills\Summoning;
use RuneStat\RS3\Skills\Necromancy;
use RuneStat\RS3\Stats\Stat;

use function RuneStat\RS3\combat_level;
Expand All @@ -30,7 +31,8 @@ public function it_calculates_the_minimum_combat_level(): void
new Stat(new Defence(), 1, 1, 1, 1),
new Stat(new Constitution(), 10, 10, 1, 1),
new Stat(new Prayer(), 1, 1, 1, 1),
new Stat(new Summoning(), 1, 1, 1, 1)
new Stat(new Summoning(), 1, 1, 1, 1),
new Stat(new Necromancy(), 1, 1, 1, 1)
);

$this->assertSame(3, $combat);
Expand All @@ -47,10 +49,11 @@ public function it_calculates_the_maximum_combat_level(): void
new Stat(new Defence(), 99, 1, 1, 1),
new Stat(new Constitution(), 99, 99, 1, 1),
new Stat(new Prayer(), 99, 1, 1, 1),
new Stat(new Summoning(), 99, 1, 1, 1)
new Stat(new Summoning(), 99, 1, 1, 1),
new Stat(new Necromancy(), 120, 120, 1, 1)
);

$this->assertSame(138, $combat);
$this->assertSame(152, $combat);
}

/** @test */
Expand All @@ -64,7 +67,8 @@ public function it_calculates_the_combat_level_with_ninety_nine_attack(): void
new Stat(new Defence(), 1, 1, 1, 1),
new Stat(new Constitution(), 10, 10, 1, 1),
new Stat(new Prayer(), 1, 1, 1, 1),
new Stat(new Summoning(), 1, 1, 1, 1)
new Stat(new Summoning(), 1, 1, 1, 1),
new Stat(new Necromancy(), 1, 1, 1, 1)
);

$this->assertSame(35, $combat);
Expand All @@ -81,7 +85,8 @@ public function it_calculates_the_combat_level_with_ninety_nine_strength(): void
new Stat(new Defence(), 1, 1, 1, 1),
new Stat(new Constitution(), 10, 10, 1, 1),
new Stat(new Prayer(), 1, 1, 1, 1),
new Stat(new Summoning(), 1, 1, 1, 1)
new Stat(new Summoning(), 1, 1, 1, 1),
new Stat(new Necromancy(), 1, 1, 1, 1)
);

$this->assertSame(35, $combat);
Expand All @@ -98,7 +103,8 @@ public function it_calculates_the_combat_level_with_ninety_nine_magic(): void
new Stat(new Defence(), 1, 1, 1, 1),
new Stat(new Constitution(), 10, 10, 1, 1),
new Stat(new Prayer(), 1, 1, 1, 1),
new Stat(new Summoning(), 1, 1, 1, 1)
new Stat(new Summoning(), 1, 1, 1, 1),
new Stat(new Necromancy(), 1, 1, 1, 1)
);

$this->assertSame(67, $combat);
Expand All @@ -115,7 +121,8 @@ public function it_calculates_the_combat_level_with_ninety_nine_ranged(): void
new Stat(new Defence(), 1, 1, 1, 1),
new Stat(new Constitution(), 10, 10, 1, 1),
new Stat(new Prayer(), 1, 1, 1, 1),
new Stat(new Summoning(), 1, 1, 1, 1)
new Stat(new Summoning(), 1, 1, 1, 1),
new Stat(new Necromancy(), 1, 1, 1, 1)
);

$this->assertSame(67, $combat);
Expand All @@ -132,7 +139,8 @@ public function it_calculates_the_combat_level_with_ninety_nine_defence(): void
new Stat(new Defence(), 99, 99, 1, 1),
new Stat(new Constitution(), 10, 10, 1, 1),
new Stat(new Prayer(), 1, 1, 1, 1),
new Stat(new Summoning(), 1, 1, 1, 1)
new Stat(new Summoning(), 1, 1, 1, 1),
new Stat(new Necromancy(), 1, 1, 1, 1)
);

$this->assertSame(27, $combat);
Expand All @@ -149,7 +157,8 @@ public function it_calculates_the_combat_level_with_ninety_nine_constitution():
new Stat(new Defence(), 1, 1, 1, 1),
new Stat(new Constitution(), 99, 9, 1, 1),
new Stat(new Prayer(), 1, 1, 1, 1),
new Stat(new Summoning(), 1, 1, 1, 1)
new Stat(new Summoning(), 1, 1, 1, 1),
new Stat(new Necromancy(), 1, 1, 1, 1)
);

$this->assertSame(25, $combat);
Expand All @@ -166,7 +175,8 @@ public function it_calculates_the_combat_level_with_ninety_nine_prayer(): void
new Stat(new Defence(), 1, 1, 1, 1),
new Stat(new Constitution(), 10, 10, 1, 1),
new Stat(new Prayer(), 99, 99, 1, 1),
new Stat(new Summoning(), 1, 1, 1, 1)
new Stat(new Summoning(), 1, 1, 1, 1),
new Stat(new Necromancy(), 1, 1, 1, 1)
);

$this->assertSame(15, $combat);
Expand All @@ -183,9 +193,46 @@ public function it_calculates_the_combat_level_with_ninety_nine_summoning(): voi
new Stat(new Defence(), 1, 1, 1, 1),
new Stat(new Constitution(), 10, 10, 1, 1),
new Stat(new Prayer(), 1, 1, 1, 1),
new Stat(new Summoning(), 99, 99, 1, 1)
new Stat(new Summoning(), 99, 99, 1, 1),
new Stat(new Necromancy(), 1, 1, 1, 1)
);

$this->assertSame(15, $combat);
}

/** @test */
public function it_calculates_the_combat_level_with_ninety_nine_necromancy(): void
{
$combat = combat_level(
new Stat(new Attack(), 1, 1, 1, 1),
new Stat(new Strength(), 1, 1, 1, 1),
new Stat(new Magic(), 1, 1, 1, 1),
new Stat(new Ranged(), 1, 1, 1, 1),
new Stat(new Defence(), 1, 1, 1, 1),
new Stat(new Constitution(), 10, 10, 1, 1),
new Stat(new Prayer(), 1, 1, 1, 1),
new Stat(new Summoning(), 1, 1, 1, 1),
new Stat(new Necromancy(), 99, 99, 1, 1)
);

$this->assertSame(67, $combat);
}

/** @test */
public function it_calculates_the_combat_level_with_one_hundred_twenty_necromancy(): void
{
$combat = combat_level(
new Stat(new Attack(), 1, 1, 1, 1),
new Stat(new Strength(), 1, 1, 1, 1),
new Stat(new Magic(), 1, 1, 1, 1),
new Stat(new Ranged(), 1, 1, 1, 1),
new Stat(new Defence(), 1, 1, 1, 1),
new Stat(new Constitution(), 10, 10, 1, 1),
new Stat(new Prayer(), 1, 1, 1, 1),
new Stat(new Summoning(), 1, 1, 1, 1),
new Stat(new Necromancy(), 120, 120, 1, 1)
);

$this->assertSame(80, $combat);
}
}