Skip to content

Commit 3540c76

Browse files
committed
Fix experience earned value, adding round function and cast the result to int
1 parent 633ccfc commit 3540c76

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

app/Timongo/Battle/PvE.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ public function battle($creatureId)
7272
protected function battleWin($hero, $opponent)
7373
{
7474
$goldDrop = $opponent->getGoldDrop();
75-
$expEarned = ceil(($opponent->experience) + ($opponent->experience * 0.04 * $hero->learning_level));
75+
76+
$expEarned = $this->expEarned($opponent->experience, $hero->learning_level);
7677

7778
if ($hero->level >= ($opponent->level + 5)) {
7879
$expEarned /= 3;
@@ -102,6 +103,13 @@ protected function battleLoss($hero, $opponent)
102103
];
103104
}
104105

106+
private function expEarned($expEarned, $learningLevel)
107+
{
108+
return (int)round(
109+
ceil(($expEarned) + ($expEarned * 0.05 * $learningLevel))
110+
);
111+
}
112+
105113
protected function getCreature($creatureId)
106114
{
107115
return $this->creatures->find($creatureId);

0 commit comments

Comments
 (0)