Compare commits
5 Commits
e8bba85cd2
...
6d1ff496dd
| Author | SHA1 | Date | |
|---|---|---|---|
| 6d1ff496dd | |||
| c62eef559d | |||
| 6aeb7fd303 | |||
| ca7283d57a | |||
| 36be931e9f |
@@ -38,7 +38,7 @@ def get_nations():
|
|||||||
|
|
||||||
era_match = re.match(r"-+ Era (\d+) -+", line)
|
era_match = re.match(r"-+ Era (\d+) -+", line)
|
||||||
if era_match:
|
if era_match:
|
||||||
current_era = f"Era {era_match.group(1)}"
|
current_era = f"{era_match.group(1)}"
|
||||||
nations[current_era] = {}
|
nations[current_era] = {}
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -89,6 +89,8 @@ def server_command_builder(
|
|||||||
thrones: tuple[int, int, int] = (1, 1, 1),
|
thrones: tuple[int, int, int] = (1, 1, 1),
|
||||||
required_apoints: int = 0,
|
required_apoints: int = 0,
|
||||||
cataclysm: int = 0,
|
cataclysm: int = 0,
|
||||||
|
vwrap: bool = True,
|
||||||
|
hwrap: bool = True,
|
||||||
):
|
):
|
||||||
available_nations = get_nations()
|
available_nations = get_nations()
|
||||||
|
|
||||||
@@ -137,29 +139,29 @@ def server_command_builder(
|
|||||||
return "ERROR_NEWAIS"
|
return "ERROR_NEWAIS"
|
||||||
command = [
|
command = [
|
||||||
SERVER_PATH,
|
SERVER_PATH,
|
||||||
"-TS ",
|
" -TS",
|
||||||
name,
|
name,
|
||||||
"--port ",
|
" --port ",
|
||||||
str(port),
|
str(port),
|
||||||
"--statuspage ",
|
" --statuspage ",
|
||||||
os.getcwd() + "/games/" + name + "/turnstats.html",
|
os.getcwd() + "/games/" + name + "/turnstats.html",
|
||||||
"--era ",
|
" --era ",
|
||||||
era,
|
str(era),
|
||||||
]
|
]
|
||||||
if team_game:
|
if team_game:
|
||||||
for team in teams:
|
for team in teams:
|
||||||
# TODO Can team have more than one disciple and pretender?
|
# TODO Can team have more than one disciple and pretender?
|
||||||
if team[0] not in available_nations[era]:
|
if team[0] not in available_nations[str(era)]:
|
||||||
return "ERROR_INVALID_NATION"
|
return "ERROR_INVALID_NATION"
|
||||||
|
|
||||||
command.append(
|
command.append(
|
||||||
" --team " + str(team[0]) + " " + str(team[1]) + " " + str(team[2])
|
" --team " + str(team[0]) + " " + str(team[1]) + " " + str(team[2])
|
||||||
)
|
)
|
||||||
if clustered_start:
|
if clustered_start:
|
||||||
command.append(" --clustered ")
|
command.append(" --clustered")
|
||||||
|
|
||||||
if not client_start:
|
if not client_start:
|
||||||
command.append(" --noclientstart ")
|
command.append(" --noclientstart")
|
||||||
if cataclysm > 0:
|
if cataclysm > 0:
|
||||||
command.append(" --cataclysm " + str(cataclysm))
|
command.append(" --cataclysm " + str(cataclysm))
|
||||||
if conq_all:
|
if conq_all:
|
||||||
@@ -167,12 +169,83 @@ def server_command_builder(
|
|||||||
if not research_difficulty == 2:
|
if not research_difficulty == 2:
|
||||||
command.append(" --research " + str(research_difficulty))
|
command.append(" --research " + str(research_difficulty))
|
||||||
if not random_start_research:
|
if not random_start_research:
|
||||||
command.append(" --norandres ")
|
command.append(" --norandres")
|
||||||
if not hof_size == 10:
|
if not hof_size == 10:
|
||||||
command.append(" --hof_size " + str(hof_size))
|
command.append(" --hof_size " + str(hof_size))
|
||||||
if not global_slots == 5:
|
if not global_slots == 5:
|
||||||
command.append(" --globals " + str(global_slots))
|
command.append(" --globals " + str(global_slots))
|
||||||
return command
|
if not inde_strength == 5:
|
||||||
|
command.append(" --indepstr " + str(inde_strength))
|
||||||
|
if not magic_sites == 40:
|
||||||
|
command.append(" --magisites " + str(magic_sites))
|
||||||
|
command.append(" --eventrarity " + str(event_rarity))
|
||||||
|
if not richness == 100:
|
||||||
|
command.append(" --richness " + str(richness))
|
||||||
|
if not resources == 100:
|
||||||
|
command.append(" --resources" + str(resources))
|
||||||
|
if not recruitment == 100:
|
||||||
|
command.append(" --recruitment" + str(recruitment))
|
||||||
|
if not supplies == 100:
|
||||||
|
command.append(" --supplies" + str(supplies))
|
||||||
|
if not masterpass == "":
|
||||||
|
command.append(" --masterpass " + masterpass)
|
||||||
|
# i am going insane
|
||||||
|
if not start_prov == 1:
|
||||||
|
command.append(" --startprov " + str(start_prov))
|
||||||
|
if renaming:
|
||||||
|
command.append(" --renaming")
|
||||||
|
if score_graphs:
|
||||||
|
command.append(" --scoregraphs")
|
||||||
|
if no_nation_info:
|
||||||
|
command.append(" --nonationinfo")
|
||||||
|
if no_cheat_det:
|
||||||
|
command.append(" --nocheatdet")
|
||||||
|
if no_artifact_rest:
|
||||||
|
command.append(" --noartrest")
|
||||||
|
if story_events == 1:
|
||||||
|
command.append(" --storyevents")
|
||||||
|
elif story_events == 2:
|
||||||
|
command.append(" --allstoryevents")
|
||||||
|
command.append(" --newailvl " + str(new_ai_lvl))
|
||||||
|
if no_new_ai:
|
||||||
|
command.append(" --nonewai")
|
||||||
|
if conq_all:
|
||||||
|
command.append(" --conqall")
|
||||||
|
command.append(
|
||||||
|
" --thrones " + str(thrones[0]) + " " + str(thrones[1]) + " " + str(thrones[2])
|
||||||
|
)
|
||||||
|
command.append(" --requiredap " + str(required_apoints))
|
||||||
|
if not cataclysm == 0:
|
||||||
|
command.append(" --cataclysm " + str(cataclysm))
|
||||||
|
if vwrap:
|
||||||
|
command.append(" --vwrap")
|
||||||
|
if not hwrap:
|
||||||
|
command.append(" --nohwrap")
|
||||||
|
if ai_slots:
|
||||||
|
added_ais = []
|
||||||
|
for ai in ai_slots:
|
||||||
|
if ai[0] not in available_nations[str(era)]:
|
||||||
|
return "ERROR_INVALID_NATION"
|
||||||
|
if ai[0] in added_ais:
|
||||||
|
return "ERROR_DUPLICATE_AI"
|
||||||
|
match ai[1]:
|
||||||
|
case 1:
|
||||||
|
command.append(" --easyai " + str(ai[0]))
|
||||||
|
case 2:
|
||||||
|
command.append(" --normai " + str(ai[0]))
|
||||||
|
case 3:
|
||||||
|
command.append(" --diffai " + str(ai[0]))
|
||||||
|
case 4:
|
||||||
|
command.append(" --mightyai " + str(ai[0]))
|
||||||
|
case 5:
|
||||||
|
command.append(" --masterai " + str(ai[0]))
|
||||||
|
case 6:
|
||||||
|
command.append(" --impai " + str(ai[0]))
|
||||||
|
case _:
|
||||||
|
return "ERROR_INVALID_AI"
|
||||||
|
added_ais.append(ai[0])
|
||||||
|
|
||||||
|
return "".join(command)
|
||||||
|
|
||||||
|
|
||||||
def is_port_in_use(port: int) -> bool:
|
def is_port_in_use(port: int) -> bool:
|
||||||
|
|||||||
Reference in New Issue
Block a user