Licence changes

This commit is contained in:
KEriks 2021-08-27 19:29:52 +03:00
parent 68f40fd4ab
commit 421b6fa919
4 changed files with 70 additions and 85 deletions

View File

@ -20,7 +20,8 @@
# #
import os import os
import sys import sys
sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath(".."))
import erepublik import erepublik
import edx_theme import edx_theme
@ -33,24 +34,24 @@ import edx_theme
# Add any Sphinx extension module names here, as strings. They can be # Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'edx_theme'] extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode", "edx_theme"]
# Add any paths that contain templates here, relative to this directory. # Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates'] templates_path = ["_templates"]
# The suffix(es) of source filenames. # The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string: # You can specify multiple suffix as a list of string:
# #
# source_suffix = ['.rst', '.md'] # source_suffix = ['.rst', '.md']
source_suffix = '.rst' source_suffix = ".rst"
# The master toctree document. # The master toctree document.
master_doc = 'index' master_doc = "index"
# General information about the project. # General information about the project.
project = u'eRepublik script' project = "eRepublik script"
copyright = u"2019, Eriks Karls" copyright = "2019, Eriks Karls"
author = u"Eriks Karls" author = "Eriks Karls"
# The version info for the project you're documenting, acts as replacement # The version info for the project you're documenting, acts as replacement
# for |version| and |release|, also used in various other places throughout # for |version| and |release|, also used in various other places throughout
@ -71,10 +72,10 @@ language = None
# List of patterns, relative to source directory, that match files and # List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files. # directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path # This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
# The name of the Pygments (syntax highlighting) style to use. # The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx' pygments_style = "sphinx"
# If true, `todo` and `todoList` produce output, else they produce nothing. # If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False todo_include_todos = False
@ -85,7 +86,7 @@ todo_include_todos = False
# The theme to use for HTML and HTML Help pages. See the documentation for # The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes. # a list of builtin themes.
# #
html_theme = 'edx_theme' html_theme = "edx_theme"
html_theme_path = [edx_theme.get_html_theme_path()] html_theme_path = [edx_theme.get_html_theme_path()]
# Theme options are theme-specific and customize the look and feel of a # Theme options are theme-specific and customize the look and feel of a
@ -97,13 +98,13 @@ html_theme_path = [edx_theme.get_html_theme_path()]
# Add any paths that contain custom static files (such as style sheets) here, # Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files, # relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css". # so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static'] html_static_path = ["_static"]
# -- Options for HTMLHelp output --------------------------------------- # -- Options for HTMLHelp output ---------------------------------------
# Output file base name for HTML help builder. # Output file base name for HTML help builder.
htmlhelp_basename = 'erepublikdoc' htmlhelp_basename = "erepublikdoc"
# -- Options for LaTeX output ------------------------------------------ # -- Options for LaTeX output ------------------------------------------
@ -112,15 +113,12 @@ latex_elements = {
# The paper size ('letterpaper' or 'a4paper'). # The paper size ('letterpaper' or 'a4paper').
# #
# 'papersize': 'letterpaper', # 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt'). # The font size ('10pt', '11pt' or '12pt').
# #
# 'pointsize': '10pt', # 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble. # Additional stuff for the LaTeX preamble.
# #
# 'preamble': '', # 'preamble': '',
# Latex figure (float) alignment # Latex figure (float) alignment
# #
# 'figure_align': 'htbp', # 'figure_align': 'htbp',
@ -130,9 +128,7 @@ latex_elements = {
# (source start file, target name, title, author, documentclass # (source start file, target name, title, author, documentclass
# [howto, manual, or own class]). # [howto, manual, or own class]).
latex_documents = [ latex_documents = [
(master_doc, 'erepublik.tex', (master_doc, "erepublik.tex", "eRepublik script Documentation", "Eriks Karls", "manual"),
u'eRepublik script Documentation',
u'Eriks Karls', 'manual'),
] ]
@ -140,11 +136,7 @@ latex_documents = [
# One entry per manual page. List of tuples # One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section). # (source start file, name, description, authors, manual section).
man_pages = [ man_pages = [(master_doc, "erepublik", "eRepublik script Documentation", [author], 1)]
(master_doc, 'erepublik',
u'eRepublik script Documentation',
[author], 1)
]
# -- Options for Texinfo output ---------------------------------------- # -- Options for Texinfo output ----------------------------------------
@ -153,10 +145,5 @@ man_pages = [
# (source start file, target name, title, author, # (source start file, target name, title, author,
# dir menu entry, description, category) # dir menu entry, description, category)
texinfo_documents = [ texinfo_documents = [
(master_doc, 'erepublik', (master_doc, "erepublik", "eRepublik script Documentation", author, "erepublik", "One line description of project.", "Miscellaneous"),
u'eRepublik script Documentation',
author,
'erepublik',
'One line description of project.',
'Miscellaneous'),
] ]

View File

@ -4,18 +4,18 @@ from datetime import timedelta
from erepublik import Citizen, utils from erepublik import Citizen, utils
CONFIG = { CONFIG = {
'email': 'player@email.com', "email": "player@email.com",
'password': 'Pa$5w0rd!', "password": "Pa$5w0rd!",
'interactive': True, "interactive": True,
'fight': True, "fight": True,
'debug': True, "debug": True,
'battle_launcher': { "battle_launcher": {
# War id: {auto_attack: bool (attack asap when region is available), regions: [region_ids allowed to attack]} # War id: {auto_attack: bool (attack asap when region is available), regions: [region_ids allowed to attack]}
121672: {"auto_attack": False, "regions": [661]}, 121672: {"auto_attack": False, "regions": [661]},
125530: {"auto_attack": False, "regions": [259]}, 125530: {"auto_attack": False, "regions": [259]},
125226: {"auto_attack": True, "regions": [549]}, 125226: {"auto_attack": True, "regions": [549]},
124559: {"auto_attack": True, "regions": [176]} 124559: {"auto_attack": True, "regions": [176]},
} },
} }
@ -29,7 +29,7 @@ def _battle_launcher(player: Citizen):
""" """
global CONFIG global CONFIG
finished_war_ids = {*[]} finished_war_ids = {*[]}
war_data = CONFIG.get('battle_launcher', {}) war_data = CONFIG.get("battle_launcher", {})
war_ids = {int(war_id) for war_id in war_data.keys()} war_ids = {int(war_id) for war_id in war_data.keys()}
next_attack_time = player.now next_attack_time = player.now
next_attack_time = next_attack_time.replace(minute=next_attack_time.minute // 5 * 5, second=0) next_attack_time = next_attack_time.replace(minute=next_attack_time.minute // 5 * 5, second=0)
@ -40,23 +40,23 @@ def _battle_launcher(player: Citizen):
running_wars = {b.war_id for b in player.all_battles.values()} running_wars = {b.war_id for b in player.all_battles.values()}
for war_id in war_ids - finished_war_ids - running_wars: for war_id in war_ids - finished_war_ids - running_wars:
war = war_data[war_id] war = war_data[war_id]
war_regions = set(war.get('regions')) war_regions = set(war.get("regions"))
auto_attack = war.get('auto_attack') auto_attack = war.get("auto_attack")
status = player.get_war_status(war_id) status = player.get_war_status(war_id)
if status.get('ended', False): if status.get("ended", False):
CONFIG['battle_launcher'].pop(war_id, None) CONFIG["battle_launcher"].pop(war_id, None)
finished_war_ids.add(war_id) finished_war_ids.add(war_id)
continue continue
elif not status.get('can_attack'): elif not status.get("can_attack"):
continue continue
if auto_attack or (player.now.hour > 20 or player.now.hour < 2): if auto_attack or (player.now.hour > 20 or player.now.hour < 2):
for reg in war_regions: for reg in war_regions:
if attacked: if attacked:
break break
if reg in status.get('regions', {}).keys(): if reg in status.get("regions", {}).keys():
player.launch_attack(war_id, reg, status.get('regions', {}).get(reg)) player.launch_attack(war_id, reg, status.get("regions", {}).get(reg))
attacked = True attacked = True
hits = 100 hits = 100
if player.energy.food_fights >= hits and player.config.fight: if player.energy.food_fights >= hits and player.config.fight:
@ -91,12 +91,12 @@ def _battle_launcher(player: Citizen):
# noinspection DuplicatedCode # noinspection DuplicatedCode
def main(): def main():
player = Citizen(email=CONFIG['email'], password=CONFIG['password'], auto_login=False) player = Citizen(email=CONFIG["email"], password=CONFIG["password"], auto_login=False)
player.config.interactive = CONFIG['interactive'] player.config.interactive = CONFIG["interactive"]
player.config.fight = CONFIG['fight'] player.config.fight = CONFIG["fight"]
player.set_debug(CONFIG.get('debug', False)) player.set_debug(CONFIG.get("debug", False))
player.login() player.login()
if CONFIG.get('battle_launcher'): if CONFIG.get("battle_launcher"):
name = f"{player.name}-battle_launcher-{threading.active_count() - 1}" name = f"{player.name}-battle_launcher-{threading.active_count() - 1}"
state_thread = threading.Thread(target=_battle_launcher, args=(player,), name=name) state_thread = threading.Thread(target=_battle_launcher, args=(player,), name=name)
state_thread.start() state_thread.start()

View File

@ -3,71 +3,70 @@ from datetime import timedelta
from erepublik import Citizen, constants, utils from erepublik import Citizen, constants, utils
CONFIG = { CONFIG = {
'email': 'player@email.com', "email": "player@email.com",
'password': 'Pa$5w0rd!', "password": "Pa$5w0rd!",
'interactive': True, "interactive": True,
'debug': True, "debug": True,
'work': True, "work": True,
'ot': True, # Work OverTime "ot": True, # Work OverTime
'wam': True, # WorkAsManager "wam": True, # WorkAsManager
'train': True "train": True,
} }
# noinspection DuplicatedCode # noinspection DuplicatedCode
def main(): def main():
player = Citizen(email=CONFIG['email'], password=CONFIG['password'], auto_login=False) player = Citizen(email=CONFIG["email"], password=CONFIG["password"], auto_login=False)
player.config.interactive = CONFIG['interactive'] player.config.interactive = CONFIG["interactive"]
player.config.work = CONFIG['work'] player.config.work = CONFIG["work"]
player.config.train = CONFIG['train'] player.config.train = CONFIG["train"]
player.config.ot = CONFIG['ot'] player.config.ot = CONFIG["ot"]
player.config.wam = CONFIG['wam'] player.config.wam = CONFIG["wam"]
player.set_debug(CONFIG.get('debug', False)) player.set_debug(CONFIG.get("debug", False))
player.login() player.login()
now = player.now.replace(second=0, microsecond=0) now = player.now.replace(second=0, microsecond=0)
dt_max = constants.max_datetime dt_max = constants.max_datetime
tasks = {} tasks = {}
if player.config.work: if player.config.work:
tasks.update({'work': now}) tasks.update({"work": now})
if player.config.train: if player.config.train:
tasks.update({'train': now}) tasks.update({"train": now})
if player.config.ot: if player.config.ot:
tasks.update({'ot': now}) tasks.update({"ot": now})
if player.config.wam: if player.config.wam:
tasks.update({'wam': now.replace(hour=14, minute=0)}) tasks.update({"wam": now.replace(hour=14, minute=0)})
while True: while True:
try: try:
player.update_all() player.update_all()
if tasks.get('work', dt_max) <= now: if tasks.get("work", dt_max) <= now:
player.write_log("Doing task: work") player.write_log("Doing task: work")
player.update_citizen_info() player.update_citizen_info()
player.work() player.work()
if player.config.ot: if player.config.ot:
tasks['ot'] = now tasks["ot"] = now
player.collect_daily_task() player.collect_daily_task()
next_time = utils.good_timedelta(now.replace(hour=0, minute=0, second=0), timedelta(days=1)) next_time = utils.good_timedelta(now.replace(hour=0, minute=0, second=0), timedelta(days=1))
tasks.update({'work': next_time}) tasks.update({"work": next_time})
if tasks.get('train', dt_max) <= now: if tasks.get("train", dt_max) <= now:
player.write_log("Doing task: train") player.write_log("Doing task: train")
player.update_citizen_info() player.update_citizen_info()
player.train() player.train()
player.collect_daily_task() player.collect_daily_task()
next_time = utils.good_timedelta(now.replace(hour=0, minute=0, second=0), timedelta(days=1)) next_time = utils.good_timedelta(now.replace(hour=0, minute=0, second=0), timedelta(days=1))
tasks.update({'train': next_time}) tasks.update({"train": next_time})
if tasks.get('wam', dt_max) <= now: if tasks.get("wam", dt_max) <= now:
player.write_log("Doing task: Work as manager") player.write_log("Doing task: Work as manager")
success = player.work_as_manager() success = player.work_as_manager()
if success: if success:
next_time = utils.good_timedelta(now.replace(hour=14, minute=0, second=0, microsecond=0), next_time = utils.good_timedelta(now.replace(hour=14, minute=0, second=0, microsecond=0), timedelta(days=1))
timedelta(days=1))
else: else:
next_time = utils.good_timedelta(now.replace(second=0, microsecond=0), timedelta(minutes=30)) next_time = utils.good_timedelta(now.replace(second=0, microsecond=0), timedelta(minutes=30))
tasks.update({'wam': next_time}) tasks.update({"wam": next_time})
if tasks.get('ot', dt_max) <= now: if tasks.get("ot", dt_max) <= now:
player.update_job_info() player.update_job_info()
player.write_log("Doing task: work overtime") player.write_log("Doing task: work overtime")
if now > player.my_companies.next_ot_time: if now > player.my_companies.next_ot_time:
@ -75,7 +74,7 @@ def main():
next_time = now + timedelta(minutes=60) next_time = now + timedelta(minutes=60)
else: else:
next_time = player.my_companies.next_ot_time next_time = player.my_companies.next_ot_time
tasks.update({'ot': next_time}) tasks.update({"ot": next_time})
closest_next_time = dt_max closest_next_time = dt_max
next_tasks = [] next_tasks = []
@ -87,8 +86,7 @@ def main():
if sleep_seconds <= 0: if sleep_seconds <= 0:
player.write_log(f"Loop detected! Offending task: '{next_tasks[0]}'") player.write_log(f"Loop detected! Offending task: '{next_tasks[0]}'")
player.write_log("My next Tasks and there time:\n" + "\n".join(sorted(next_tasks))) player.write_log("My next Tasks and there time:\n" + "\n".join(sorted(next_tasks)))
player.write_log(f"Sleeping until (eRep): {closest_next_time.strftime('%F %T')}" player.write_log(f"Sleeping until (eRep): {closest_next_time.strftime('%F %T')}" f" (sleeping for {sleep_seconds}s)")
f" (sleeping for {sleep_seconds}s)")
seconds_to_sleep = sleep_seconds if sleep_seconds > 0 else 0 seconds_to_sleep = sleep_seconds if sleep_seconds > 0 else 0
player.sleep(seconds_to_sleep) player.sleep(seconds_to_sleep)
except Exception as e: except Exception as e:

View File

@ -30,7 +30,7 @@ setup(
classifiers=[ classifiers=[
"Development Status :: 4 - Beta", "Development Status :: 4 - Beta",
"Intended Audience :: Developers", "Intended Audience :: Developers",
"License :: OSI Approved :: MIT License", "License :: OSI Approved :: GPLv3 License",
"Natural Language :: English", "Natural Language :: English",
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.8",
@ -39,7 +39,7 @@ setup(
description="Python package for automated eRepublik playing", description="Python package for automated eRepublik playing",
entry_points={}, entry_points={},
install_requires=requirements, install_requires=requirements,
license="MIT license", license="GPLv3 license",
long_description=readme + "\n\n" + history, long_description=readme + "\n\n" + history,
include_package_data=True, include_package_data=True,
keywords="erepublik", keywords="erepublik",