Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
a9a0cdc6d5 | |||
1c102488b6 | |||
c38acef2a0 | |||
48b5e473aa |
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
__author__ = """Eriks Karls"""
|
__author__ = """Eriks Karls"""
|
||||||
__email__ = 'eriks@72.lv'
|
__email__ = 'eriks@72.lv'
|
||||||
__version__ = '0.21.4'
|
__version__ = '0.21.4.2'
|
||||||
|
|
||||||
from erepublik import classes, utils, constants
|
from erepublik import classes, utils, constants
|
||||||
from erepublik.citizen import Citizen
|
from erepublik.citizen import Citizen
|
||||||
|
@ -12,8 +12,8 @@ __all__ = ['SlowRequests', 'CitizenAPI']
|
|||||||
|
|
||||||
class SlowRequests(Session):
|
class SlowRequests(Session):
|
||||||
last_time: datetime.datetime
|
last_time: datetime.datetime
|
||||||
timeout = datetime.timedelta(milliseconds=500)
|
timeout: datetime.timedelta = datetime.timedelta(milliseconds=500)
|
||||||
uas = [
|
uas: List[str] = [
|
||||||
# Chrome
|
# Chrome
|
||||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36', # noqa
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36', # noqa
|
||||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36', # noqa
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36', # noqa
|
||||||
@ -36,7 +36,7 @@ class SlowRequests(Session):
|
|||||||
'Mozilla/5.0 (X11; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0',
|
'Mozilla/5.0 (X11; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0',
|
||||||
'Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0',
|
'Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0',
|
||||||
]
|
]
|
||||||
debug = False
|
debug: bool = False
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
@ -1615,7 +1615,7 @@ class CitizenMilitary(CitizenTravel):
|
|||||||
:param battle: Battle battle to fight in
|
:param battle: Battle battle to fight in
|
||||||
:type battle: Battle
|
:type battle: Battle
|
||||||
:param side: BattleSide or None. Battle side to fight in, If side not == invader id or not in invader deployed
|
:param side: BattleSide or None. Battle side to fight in, If side not == invader id or not in invader deployed
|
||||||
allies list, then defender's side is chosen
|
allies list, then defender's side is chosen
|
||||||
:type side: BattleSide
|
:type side: BattleSide
|
||||||
:param count: How many hits to do, if not specified self.should_fight() is called.
|
:param count: How many hits to do, if not specified self.should_fight() is called.
|
||||||
:type count: int
|
:type count: int
|
||||||
|
@ -629,7 +629,7 @@ class Reporter:
|
|||||||
except: # noqa
|
except: # noqa
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def fetch_tasks(self) -> List[str, Tuple[Any]]:
|
def fetch_tasks(self) -> List[Union[str, Tuple[Any]]]:
|
||||||
try:
|
try:
|
||||||
task_response = self._req.get(f'{self.url}/api/v1/command',
|
task_response = self._req.get(f'{self.url}/api/v1/command',
|
||||||
params=dict(citizen=self.citizen_id, key=self.key))
|
params=dict(citizen=self.citizen_id, key=self.key))
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
[bumpversion]
|
[bumpversion]
|
||||||
current_version = 0.21.4
|
current_version = 0.21.4.2
|
||||||
commit = True
|
commit = True
|
||||||
tag = True
|
tag = True
|
||||||
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)\.?(?P<dev>\d+)?
|
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)\.?(?P<dev>\d+)?
|
||||||
|
2
setup.py
2
setup.py
@ -43,6 +43,6 @@ setup(
|
|||||||
test_suite='tests',
|
test_suite='tests',
|
||||||
tests_require=test_requirements,
|
tests_require=test_requirements,
|
||||||
url='https://github.com/eeriks/erepublik/',
|
url='https://github.com/eeriks/erepublik/',
|
||||||
version='0.21.4',
|
version='0.21.4.2',
|
||||||
zip_safe=False,
|
zip_safe=False,
|
||||||
)
|
)
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
"""Tests for `erepublik` package."""
|
"""Tests for `erepublik` package."""
|
||||||
|
from typing import Callable
|
||||||
|
|
||||||
from erepublik import Citizen
|
from erepublik import Citizen
|
||||||
|
|
||||||
@ -65,6 +66,7 @@ class TestErepublik(unittest.TestCase):
|
|||||||
self.assertEqual(self.citizen.next_reachable_energy, 0)
|
self.assertEqual(self.citizen.next_reachable_energy, 0)
|
||||||
|
|
||||||
def test_should_fight(self):
|
def test_should_fight(self):
|
||||||
|
is_wc_close: Callable[[], bool] = lambda: self.citizen.max_time_till_full_ff > self.citizen.time_till_week_change
|
||||||
self.citizen.config.fight = False
|
self.citizen.config.fight = False
|
||||||
self.assertEqual(self.citizen.should_fight(), (0, "Fighting not allowed!", False))
|
self.assertEqual(self.citizen.should_fight(), (0, "Fighting not allowed!", False))
|
||||||
|
|
||||||
@ -73,62 +75,63 @@ class TestErepublik(unittest.TestCase):
|
|||||||
# Level up
|
# Level up
|
||||||
self.citizen.energy.limit = 3000
|
self.citizen.energy.limit = 3000
|
||||||
self.citizen.details.xp = 24705
|
self.citizen.details.xp = 24705
|
||||||
self.assertEqual(self.citizen.should_fight(), (0, 'Level up', False))
|
if not is_wc_close:
|
||||||
|
self.assertEqual(self.citizen.should_fight(), (0, 'Level up', False))
|
||||||
|
|
||||||
self.citizen.energy.recovered = 3000
|
self.citizen.energy.recovered = 3000
|
||||||
self.citizen.energy.recoverable = 2950
|
self.citizen.energy.recoverable = 2950
|
||||||
self.citizen.energy.interval = 30
|
self.citizen.energy.interval = 30
|
||||||
self.assertEqual(self.citizen.should_fight(), (900, 'Level up', True))
|
self.assertEqual(self.citizen.should_fight(), (900, 'Level up', True))
|
||||||
self.citizen.my_companies.ff_lockdown = 160
|
self.citizen.my_companies.ff_lockdown = 160
|
||||||
self.assertEqual(self.citizen.should_fight(), (900, 'Level up', True))
|
self.assertEqual(self.citizen.should_fight(), (900, 'Level up', True))
|
||||||
self.citizen.my_companies.ff_lockdown = 0
|
self.citizen.my_companies.ff_lockdown = 0
|
||||||
|
|
||||||
# Level up reachable
|
# Level up reachable
|
||||||
self.citizen.details.xp = 24400
|
self.citizen.details.xp = 24400
|
||||||
self.assertEqual(self.citizen.should_fight(), (305, 'Fighting for close Levelup. Doing 305 hits', True))
|
self.assertEqual(self.citizen.should_fight(), (305, 'Fighting for close Levelup. Doing 305 hits', True))
|
||||||
self.citizen.my_companies.ff_lockdown = 160
|
self.citizen.my_companies.ff_lockdown = 160
|
||||||
self.assertEqual(self.citizen.should_fight(), (305, 'Fighting for close Levelup. Doing 305 hits', True))
|
self.assertEqual(self.citizen.should_fight(), (305, 'Fighting for close Levelup. Doing 305 hits', True))
|
||||||
self.citizen.my_companies.ff_lockdown = 0
|
self.citizen.my_companies.ff_lockdown = 0
|
||||||
|
|
||||||
self.citizen.details.xp = 21000
|
self.citizen.details.xp = 21000
|
||||||
self.assertEqual(self.citizen.should_fight(), (75, 'Obligatory fighting for at least 75pp', True))
|
self.assertEqual(self.citizen.should_fight(), (75, 'Obligatory fighting for at least 75pp', True))
|
||||||
self.citizen.my_companies.ff_lockdown = 160
|
self.citizen.my_companies.ff_lockdown = 160
|
||||||
self.assertEqual(self.citizen.should_fight(), (75, 'Obligatory fighting for at least 75pp', True))
|
self.assertEqual(self.citizen.should_fight(), (75, 'Obligatory fighting for at least 75pp', True))
|
||||||
self.citizen.my_companies.ff_lockdown = 0
|
self.citizen.my_companies.ff_lockdown = 0
|
||||||
self.citizen.details.pp = 80
|
self.citizen.details.pp = 80
|
||||||
|
|
||||||
# All-in (type = all-in and full ff)
|
# All-in (type = all-in and full ff)
|
||||||
self.citizen.config.all_in = True
|
self.citizen.config.all_in = True
|
||||||
self.assertEqual(self.citizen.should_fight(), (595, 'Fighting all-in. Doing 595 hits', False))
|
self.assertEqual(self.citizen.should_fight(), (595, 'Fighting all-in. Doing 595 hits', False))
|
||||||
self.citizen.my_companies.ff_lockdown = 160
|
self.citizen.my_companies.ff_lockdown = 160
|
||||||
self.assertEqual(self.citizen.should_fight(), (
|
self.assertEqual(self.citizen.should_fight(), (
|
||||||
435, 'Fight count modified (old count: 595 | FF: 595 | WAM ff_lockdown: 160 | New count: 435)', False
|
435, 'Fight count modified (old count: 595 | FF: 595 | WAM ff_lockdown: 160 | New count: 435)', False
|
||||||
))
|
))
|
||||||
self.citizen.my_companies.ff_lockdown = 0
|
self.citizen.my_companies.ff_lockdown = 0
|
||||||
|
|
||||||
self.citizen.config.air = True
|
self.citizen.config.air = True
|
||||||
self.citizen.energy.recoverable = 1000
|
self.citizen.energy.recoverable = 1000
|
||||||
self.assertEqual(self.citizen.should_fight(), (400, 'Fighting all-in in AIR. Doing 400 hits', False))
|
self.assertEqual(self.citizen.should_fight(), (400, 'Fighting all-in in AIR. Doing 400 hits', False))
|
||||||
self.citizen.my_companies.ff_lockdown = 160
|
self.citizen.my_companies.ff_lockdown = 160
|
||||||
self.assertEqual(self.citizen.should_fight(), (
|
self.assertEqual(self.citizen.should_fight(), (
|
||||||
240, 'Fight count modified (old count: 400 | FF: 400 | WAM ff_lockdown: 160 | New count: 240)', False
|
240, 'Fight count modified (old count: 400 | FF: 400 | WAM ff_lockdown: 160 | New count: 240)', False
|
||||||
))
|
))
|
||||||
self.citizen.my_companies.ff_lockdown = 0
|
self.citizen.my_companies.ff_lockdown = 0
|
||||||
self.citizen.config.all_in = False
|
self.citizen.config.all_in = False
|
||||||
|
|
||||||
self.citizen.config.next_energy = True
|
self.citizen.config.next_energy = True
|
||||||
self.citizen.energy.limit = 5000
|
self.citizen.energy.limit = 5000
|
||||||
self.citizen.details.next_pp = [100, 150, 250, 400, 500]
|
self.citizen.details.next_pp = [100, 150, 250, 400, 500]
|
||||||
self.assertEqual(self.citizen.should_fight(), (320, 'Fighting for +1 energy. Doing 320 hits', False))
|
self.assertEqual(self.citizen.should_fight(), (320, 'Fighting for +1 energy. Doing 320 hits', False))
|
||||||
self.citizen.my_companies.ff_lockdown = 160
|
self.citizen.my_companies.ff_lockdown = 160
|
||||||
self.assertEqual(self.citizen.should_fight(), (
|
self.assertEqual(self.citizen.should_fight(), (
|
||||||
160, 'Fight count modified (old count: 320 | FF: 400 | WAM ff_lockdown: 160 | New count: 160)', False
|
160, 'Fight count modified (old count: 320 | FF: 400 | WAM ff_lockdown: 160 | New count: 160)', False
|
||||||
))
|
))
|
||||||
self.citizen.my_companies.ff_lockdown = 0
|
self.citizen.my_companies.ff_lockdown = 0
|
||||||
self.citizen.energy.limit = 3000
|
self.citizen.energy.limit = 3000
|
||||||
self.citizen.details.next_pp = [19250, 20000]
|
self.citizen.details.next_pp = [19250, 20000]
|
||||||
self.citizen.config.next_energy = False
|
self.citizen.config.next_energy = False
|
||||||
|
|
||||||
# 1h worth of energy
|
# 1h worth of energy
|
||||||
self.citizen.energy.recoverable = 2910
|
self.citizen.energy.recoverable = 2910
|
||||||
self.assertEqual(self.citizen.should_fight(), (30, 'Fighting for 1h energy. Doing 30 hits', True))
|
self.assertEqual(self.citizen.should_fight(), (30, 'Fighting for 1h energy. Doing 30 hits', True))
|
||||||
|
Reference in New Issue
Block a user