Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
c874247335 | |||
6e9def4394 | |||
d6fbaa7945 | |||
eb740c60c7 | |||
240c409739 | |||
f348a315c5 | |||
7a09eea2b4 | |||
81b1069cf0 | |||
429d43df15 | |||
c81986d65e | |||
7bb988f716 |
@ -4,7 +4,7 @@
|
||||
|
||||
__author__ = """Eriks Karls"""
|
||||
__email__ = 'eriks@72.lv'
|
||||
__version__ = '0.22.3'
|
||||
__version__ = '0.23.0'
|
||||
|
||||
from erepublik import classes, utils, constants
|
||||
from erepublik.citizen import Citizen
|
||||
|
@ -161,8 +161,10 @@ class ErepublikAnniversaryAPI(CitizenBaseAPI):
|
||||
data = {'nodeId': node_id, '_token': self.token, "currencyCost": currency_amount}
|
||||
return self.post(f"{self.url}/main/map-rewards-speedup", data=data)
|
||||
|
||||
def _post_map_rewards_claim(self, node_id: int) -> Response:
|
||||
def _post_map_rewards_claim(self, node_id: int, extra: bool = False) -> Response:
|
||||
data = {'nodeId': node_id, '_token': self.token}
|
||||
if extra:
|
||||
data['claimExtra'] = 1
|
||||
return self.post(f"{self.url}/main/map-rewards-claim", data=data)
|
||||
|
||||
def _post_main_wheel_of_fortune_spin(self, cost) -> Response:
|
||||
@ -176,6 +178,9 @@ class ErepublikArticleAPI(CitizenBaseAPI):
|
||||
def _get_main_article_json(self, article_id: int) -> Response:
|
||||
return self.get(f"{self.url}/main/articleJson/{article_id}")
|
||||
|
||||
def _get_main_delete_article(self, article_id: int) -> Response:
|
||||
return self.get(f"{self.url}/main/delete-article/{article_id}/1")
|
||||
|
||||
def _post_main_article_comments(self, article_id: int, page: int = 1) -> Response:
|
||||
data = dict(_token=self.token, articleId=article_id, page=page)
|
||||
if page:
|
||||
|
@ -731,8 +731,8 @@ class CitizenAnniversary(BaseCitizen):
|
||||
def start_unlocking_map_quest_node(self, node_id: int):
|
||||
return self._post_map_rewards_unlock(node_id)
|
||||
|
||||
def collect_map_quest_node(self, node_id: int):
|
||||
return self._post_map_rewards_claim(node_id)
|
||||
def collect_map_quest_node(self, node_id: int, extra: bool = False):
|
||||
return self._post_map_rewards_claim(node_id, extra)
|
||||
|
||||
def speedup_map_quest_node(self, node_id: int):
|
||||
node = self.get_anniversary_quest_data().get('cities', {}).get(str(node_id), {})
|
||||
@ -808,7 +808,14 @@ class CitizenTravel(BaseCitizen):
|
||||
if data.get('alreadyInRegion'):
|
||||
return True
|
||||
else:
|
||||
country = constants.COUNTRIES[data.get('preselectCountryId')]
|
||||
country = None
|
||||
for country_data in data.get('countries').values():
|
||||
if region_id in country_data.get('regions'):
|
||||
country = constants.COUNTRIES[country_data.get('id')]
|
||||
break
|
||||
|
||||
if country is None:
|
||||
raise classes.ErepublikException('Region not found!')
|
||||
|
||||
if self._travel(country, region_id):
|
||||
self._report_action("TRAVEL", "Traveled to region")
|
||||
@ -1120,14 +1127,16 @@ class CitizenEconomy(CitizenTravel):
|
||||
if not constants.INDUSTRIES[industry]:
|
||||
self.write_log(f"Trying to sell unsupported industry {industry}")
|
||||
|
||||
final = industry in [1, 2, 4, 23]
|
||||
items = self.inventory['final' if final else 'raw'][constants.INDUSTRIES[industry]]
|
||||
if items[quality if final else 0]['amount'] < amount:
|
||||
self.update_inventory()
|
||||
items = self.inventory['final' if final else 'raw'][constants.INDUSTRIES[industry]]
|
||||
if items[quality if final else 0]['amount'] < amount:
|
||||
_inv_qlt = quality if industry in [1, 2, 3, 4, 23] else 0
|
||||
_kind = 'final' if industry in [1, 2, 4, 4, 23] else 'raw'
|
||||
inventory = self.get_inventory()
|
||||
items = inventory[_kind].get(constants.INDUSTRIES[industry], {_inv_qlt: {'amount': 0}})
|
||||
if items[_inv_qlt]['amount'] < amount:
|
||||
inventory = self.get_inventory(True)
|
||||
items = inventory[_kind].get(constants.INDUSTRIES[industry], {_inv_qlt: {'amount': 0}})
|
||||
if items[_inv_qlt]['amount'] < amount:
|
||||
self._report_action("ECONOMY_SELL_PRODUCTS", "Unable to sell! Not enough items in storage!",
|
||||
kwargs=dict(inventory=items[quality if final else 0], amount=amount))
|
||||
kwargs=dict(inventory=items[_inv_qlt], amount=amount))
|
||||
return False
|
||||
|
||||
data = {
|
||||
@ -1435,6 +1444,19 @@ class CitizenMedia(BaseCitizen):
|
||||
"\n".join(["{}: {}".format(k, v) for k, v in kinds.items()]), kind
|
||||
))
|
||||
|
||||
def get_article(self, article_id: int) -> Dict[str, Any]:
|
||||
return self._get_main_article_json(article_id).json()
|
||||
|
||||
def delete_article(self, article_id: int) -> NoReturn:
|
||||
article_data = self.get_article(article_id)
|
||||
if article_data and article_data['articleData']['canDelete']:
|
||||
self._report_action("ARTICLE_DELETE",
|
||||
f"Attempting to delete article '{article_data['article']['title']}' (#{article_id})",
|
||||
kwargs=article_data)
|
||||
self._get_main_delete_article(article_id)
|
||||
else:
|
||||
self.write_log(f"Unable to delete article (#{article_id})!")
|
||||
|
||||
|
||||
class CitizenMilitary(CitizenTravel):
|
||||
all_battles: Dict[int, classes.Battle] = None
|
||||
@ -1606,6 +1628,7 @@ class CitizenMilitary(CitizenTravel):
|
||||
def get_cheap_tp_divisions(self) -> Dict[str, List[Tuple[int, classes.BattleDivision]]]:
|
||||
air_divs: List[Tuple[int, classes.BattleDivision]] = []
|
||||
ground_divs: List[Tuple[int, classes.BattleDivision]] = []
|
||||
check_maverick = self.maverick and self.config.maverick
|
||||
for battle in reversed(self.sorted_battles(True, True)):
|
||||
for division in battle.div.values():
|
||||
is_start_ok = utils.good_timedelta(division.battle.start, timedelta(minutes=-1)) < self.now
|
||||
@ -1618,7 +1641,7 @@ class CitizenMilitary(CitizenTravel):
|
||||
else:
|
||||
air_divs.append((medal.get('1').get('raw_value'), division))
|
||||
elif not division.is_air and self.config.ground:
|
||||
if not division.div == self.division and not self.maverick:
|
||||
if not division.div == self.division and not check_maverick:
|
||||
continue
|
||||
division_medals = self.get_battle_round_data(division)
|
||||
medal = division_medals[self.details.citizenship == division.battle.defender.country]
|
||||
@ -1972,13 +1995,8 @@ class CitizenMilitary(CitizenTravel):
|
||||
count = self.energy.food_fights
|
||||
msg = "Fighting all-in. Doing %i hits" % count
|
||||
|
||||
# All-in for AIR battles
|
||||
elif all([self.config.air, self.config.all_in, self.energy.available >= self.energy.limit]):
|
||||
count = self.energy.food_fights
|
||||
msg = "Fighting all-in in AIR. Doing %i hits" % count
|
||||
|
||||
# Get to next Energy +1
|
||||
elif self.next_reachable_energy and self.config.next_energy:
|
||||
elif self.config.next_energy and self.next_reachable_energy:
|
||||
count = self.next_reachable_energy
|
||||
msg = "Fighting for +1 energy. Doing %i hits" % count
|
||||
|
||||
@ -2219,7 +2237,8 @@ class CitizenTasks(BaseCitizen):
|
||||
js = response.json()
|
||||
good_msg = ["already_worked", "captcha"]
|
||||
if not js.get("status") and not js.get("message") in good_msg:
|
||||
if js.get('message') == 'employee':
|
||||
if js.get('message') in ['employee', 'money']:
|
||||
self.resign_from_employer()
|
||||
self.find_new_job()
|
||||
self.update_citizen_info()
|
||||
self.work()
|
||||
|
@ -357,6 +357,7 @@ class Config:
|
||||
telegram = True
|
||||
telegram_chat_id = 0
|
||||
telegram_token = ""
|
||||
maverick = False
|
||||
|
||||
def __init__(self):
|
||||
self.auto_sell = []
|
||||
@ -389,6 +390,7 @@ class Config:
|
||||
self.telegram = True
|
||||
self.telegram_chat_id = 0
|
||||
self.telegram_token = ""
|
||||
self.maverick = False
|
||||
|
||||
@property
|
||||
def as_dict(self):
|
||||
@ -397,7 +399,7 @@ class Config:
|
||||
fight=self.fight, air=self.air, ground=self.ground, all_in=self.all_in,
|
||||
next_energy=self.next_energy, boosters=self.boosters, travel_to_fight=self.travel_to_fight,
|
||||
always_travel=self.always_travel, epic_hunt=self.epic_hunt, epic_hunt_ebs=self.epic_hunt_ebs,
|
||||
rw_def_side=self.rw_def_side, interactive=self.interactive,
|
||||
rw_def_side=self.rw_def_side, interactive=self.interactive, maverick=self.maverick,
|
||||
continuous_fighting=self.continuous_fighting, auto_buy_raw=self.auto_buy_raw,
|
||||
force_wam=self.force_wam, sort_battles_time=self.sort_battles_time, force_travel=self.force_travel,
|
||||
telegram=self.telegram, telegram_chat_id=self.telegram_chat_id, telegram_token=self.telegram_token)
|
||||
|
@ -53,7 +53,7 @@ class Country:
|
||||
|
||||
|
||||
class Industries:
|
||||
__by_name = {'food': 1, 'weapon': 2, 'ticket':3, 'house': 4, 'aircraft': 23,
|
||||
__by_name = {'food': 1, 'weapon': 2, 'ticket': 3, 'house': 4, 'aircraft': 23,
|
||||
'foodraw': 7, 'weaponraw': 12, 'houseraw': 18, 'aircraftraw': 24, 'airplaneraw': 24,
|
||||
'frm': 7, 'wrm': 12, 'hrm': 18, 'arm': 24,
|
||||
'frm q1': 7, 'frm q2': 8, 'frm q3': 9, 'frm q4': 10, 'frm q5': 11,
|
||||
|
@ -1,5 +1,5 @@
|
||||
[bumpversion]
|
||||
current_version = 0.22.3
|
||||
current_version = 0.23.0
|
||||
commit = True
|
||||
tag = True
|
||||
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)\.?(?P<dev>\d+)?
|
||||
|
Reference in New Issue
Block a user