Compare commits

..

5 Commits

Author SHA1 Message Date
6d1ff496dd Added duplicate Ai check. 2026-05-03 01:35:34 +02:00
c62eef559d Minor fixes. 2026-05-03 01:32:02 +02:00
6aeb7fd303 Forgor to actually add ai. 2026-05-03 01:23:01 +02:00
ca7283d57a Fixed command formatting having too many spaces. 2026-05-03 01:12:35 +02:00
36be931e9f Added all (for now) features to the command builder 2026-05-03 00:59:25 +02:00

View File

@@ -38,7 +38,7 @@ def get_nations():
era_match = re.match(r"-+ Era (\d+) -+", line)
if era_match:
current_era = f"Era {era_match.group(1)}"
current_era = f"{era_match.group(1)}"
nations[current_era] = {}
continue
@@ -89,6 +89,8 @@ def server_command_builder(
thrones: tuple[int, int, int] = (1, 1, 1),
required_apoints: int = 0,
cataclysm: int = 0,
vwrap: bool = True,
hwrap: bool = True,
):
available_nations = get_nations()
@@ -137,29 +139,29 @@ def server_command_builder(
return "ERROR_NEWAIS"
command = [
SERVER_PATH,
"-TS ",
" -TS",
name,
"--port ",
" --port ",
str(port),
"--statuspage ",
" --statuspage ",
os.getcwd() + "/games/" + name + "/turnstats.html",
"--era ",
era,
" --era ",
str(era),
]
if team_game:
for team in teams:
# 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"
command.append(
" --team " + str(team[0]) + " " + str(team[1]) + " " + str(team[2])
)
if clustered_start:
command.append(" --clustered ")
command.append(" --clustered")
if not client_start:
command.append(" --noclientstart ")
command.append(" --noclientstart")
if cataclysm > 0:
command.append(" --cataclysm " + str(cataclysm))
if conq_all:
@@ -167,12 +169,83 @@ def server_command_builder(
if not research_difficulty == 2:
command.append(" --research " + str(research_difficulty))
if not random_start_research:
command.append(" --norandres ")
command.append(" --norandres")
if not hof_size == 10:
command.append(" --hof_size " + str(hof_size))
if not global_slots == 5:
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: