Skip to content

Commit 9e92b47

Browse files
committed
Merge branch 'FeatDeathMatch' of https://github.com/PrettyNeet/AccurateHerbChecker into FeatDeathMatch
2 parents 16a6c1a + 9fe5f5f commit 9e92b47

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

bot/utils/helpers.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ def generate_estimated_yield(farming_level, low_cts, high_cts, harvest_lives, it
1818
high_cts_final = math.floor(high_cts_final * (1 + attas_bonus))
1919

2020
chance_to_save = skill_interp(low_cts_final, high_cts_final, farming_level)
21-
return harvest_lives / (1 - chance_to_save)
21+
if chance_to_save == 1:
22+
return "Error: No yield calculated"
23+
else:
24+
return harvest_lives / (1 - chance_to_save)
2225

2326

2427
# Format the profit results into a markdown table

tests/test_utils.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,41 @@
11
# TODO create some unit tests
2+
import unittest
3+
from bot.utils.helpers import skill_interp, generate_estimated_yield
4+
5+
class TestHelpers(unittest.TestCase):
6+
def test_skill_interp(self):
7+
# Test 1: Level 10-50
8+
level = 20
9+
low_cts = 1000
10+
high_cts = 2000
11+
self.assertAlmostEqual(skill_interp(low_cts, high_cts, level), 1, places=7)
12+
13+
# Test 2: Level 51-99
14+
level = 70
15+
low_cts = 1500
16+
high_cts = 2500
17+
self.assertAlmostEqual(skill_interp(low_cts, high_cts, level), 1, places=7)
18+
19+
def test_generate_estimated_yield(self):
20+
# Test 1: Low CTs, High Yield
21+
farming_level = 60
22+
low_cts = 1000
23+
high_cts = 2000
24+
harvest_lives = 10
25+
item_bonus = 0.05
26+
diary_bonus = 5
27+
attas_bonus = 0.1
28+
self.assertAlmostEqual(generate_estimated_yield(farming_level, low_cts, high_cts, harvest_lives, item_bonus, diary_bonus, attas_bonus), "Error: No yield calculated")
29+
30+
# Test 2: High CTs, Low Yield
31+
farming_level = 60
32+
low_cts = 2000
33+
high_cts = 3000
34+
harvest_lives = 5
35+
item_bonus = 0.05
36+
diary_bonus = 5
37+
attas_bonus = 0.1
38+
self.assertAlmostEqual(generate_estimated_yield(farming_level, low_cts, high_cts, harvest_lives, item_bonus, diary_bonus, attas_bonus), "Error: No yield calculated")
39+
40+
if __name__ == "__main__":
41+
unittest.main()

0 commit comments

Comments
 (0)