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 sys
sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath(".."))
import erepublik
import edx_theme
@ -33,24 +34,24 @@ import edx_theme
# Add any Sphinx extension module names here, as strings. They can be
# 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.
templates_path = ['_templates']
templates_path = ["_templates"]
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"
# The master toctree document.
master_doc = 'index'
master_doc = "index"
# General information about the project.
project = u'eRepublik script'
copyright = u"2019, Eriks Karls"
author = u"Eriks Karls"
project = "eRepublik script"
copyright = "2019, Eriks Karls"
author = "Eriks Karls"
# The version info for the project you're documenting, acts as replacement
# 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
# directories to ignore when looking for source files.
# 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.
pygments_style = 'sphinx'
pygments_style = "sphinx"
# If true, `todo` and `todoList` produce output, else they produce nothing.
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
# a list of builtin themes.
#
html_theme = 'edx_theme'
html_theme = "edx_theme"
html_theme_path = [edx_theme.get_html_theme_path()]
# 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,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]
# -- Options for HTMLHelp output ---------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'erepublikdoc'
htmlhelp_basename = "erepublikdoc"
# -- Options for LaTeX output ------------------------------------------
@ -112,15 +113,12 @@ latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
@ -130,9 +128,7 @@ latex_elements = {
# (source start file, target name, title, author, documentclass
# [howto, manual, or own class]).
latex_documents = [
(master_doc, 'erepublik.tex',
u'eRepublik script Documentation',
u'Eriks Karls', 'manual'),
(master_doc, "erepublik.tex", "eRepublik script Documentation", "Eriks Karls", "manual"),
]
@ -140,11 +136,7 @@ latex_documents = [
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'erepublik',
u'eRepublik script Documentation',
[author], 1)
]
man_pages = [(master_doc, "erepublik", "eRepublik script Documentation", [author], 1)]
# -- Options for Texinfo output ----------------------------------------
@ -153,10 +145,5 @@ man_pages = [
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'erepublik',
u'eRepublik script Documentation',
author,
'erepublik',
'One line description of project.',
'Miscellaneous'),
(master_doc, "erepublik", "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
CONFIG = {
'email': 'player@email.com',
'password': 'Pa$5w0rd!',
'interactive': True,
'fight': True,
'debug': True,
'battle_launcher': {
"email": "player@email.com",
"password": "Pa$5w0rd!",
"interactive": True,
"fight": True,
"debug": True,
"battle_launcher": {
# War id: {auto_attack: bool (attack asap when region is available), regions: [region_ids allowed to attack]}
121672: {"auto_attack": False, "regions": [661]},
125530: {"auto_attack": False, "regions": [259]},
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
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()}
next_attack_time = player.now
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()}
for war_id in war_ids - finished_war_ids - running_wars:
war = war_data[war_id]
war_regions = set(war.get('regions'))
auto_attack = war.get('auto_attack')
war_regions = set(war.get("regions"))
auto_attack = war.get("auto_attack")
status = player.get_war_status(war_id)
if status.get('ended', False):
CONFIG['battle_launcher'].pop(war_id, None)
if status.get("ended", False):
CONFIG["battle_launcher"].pop(war_id, None)
finished_war_ids.add(war_id)
continue
elif not status.get('can_attack'):
elif not status.get("can_attack"):
continue
if auto_attack or (player.now.hour > 20 or player.now.hour < 2):
for reg in war_regions:
if attacked:
break
if reg in status.get('regions', {}).keys():
player.launch_attack(war_id, reg, status.get('regions', {}).get(reg))
if reg in status.get("regions", {}).keys():
player.launch_attack(war_id, reg, status.get("regions", {}).get(reg))
attacked = True
hits = 100
if player.energy.food_fights >= hits and player.config.fight:
@ -91,12 +91,12 @@ def _battle_launcher(player: Citizen):
# noinspection DuplicatedCode
def main():
player = Citizen(email=CONFIG['email'], password=CONFIG['password'], auto_login=False)
player.config.interactive = CONFIG['interactive']
player.config.fight = CONFIG['fight']
player.set_debug(CONFIG.get('debug', False))
player = Citizen(email=CONFIG["email"], password=CONFIG["password"], auto_login=False)
player.config.interactive = CONFIG["interactive"]
player.config.fight = CONFIG["fight"]
player.set_debug(CONFIG.get("debug", False))
player.login()
if CONFIG.get('battle_launcher'):
if CONFIG.get("battle_launcher"):
name = f"{player.name}-battle_launcher-{threading.active_count() - 1}"
state_thread = threading.Thread(target=_battle_launcher, args=(player,), name=name)
state_thread.start()

View File

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

View File

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