Skip to content

Commit

Permalink
eecs: add difficulty
Browse files Browse the repository at this point in the history
  • Loading branch information
Pithlit committed Aug 20, 2024
1 parent b6d8579 commit d9c8cd3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
38 changes: 25 additions & 13 deletions deploy/campaign/eecs/campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,23 @@ def scenario_event(scenario: models.scenario.Scenario, crew: models.crew.Crew, e
# update score and get progress
progress = None
rep_factor = SCENARIO_REPUTATION_FACTOR.get(s, 1.0)
difficulty = 1
if "current" in crew.score:
difficulty = crew.score["current"].get("difficulty",1)
if event_topic == "score":
details = json.loads(details)
if "progress" in details:
progress = details["progress"]
details["reputation"] = progress * rep_factor
difficulty = details.get("difficulty",difficulty)
details["reputation"] = progress * rep_factor * difficulty
crew.updateScore(s, details)
elif event_topic == "victory":
progress = 100
elif event_topic == "progress":
assert isinstance(details, dict)
progress = details["progress"]
crew.updateScore(s, {"progress": progress, "reputation": progress*rep_factor})
elif event_topic == "victory":
progress = 100
crew.updateScore(s, {"progress": progress, "reputation": progress*rep_factor})
if event_topic in ["victory", "progress"]:
crew.updateScore(s, {"progress": progress, "reputation": progress * rep_factor * difficulty})

# for all scenarios
if event_topic == "started":
Expand All @@ -68,26 +72,34 @@ def scenario_event(scenario: models.scenario.Scenario, crew: models.crew.Crew, e
# scenario specific
if s == "20_training1":
if progress is not None and progress >= 75:
crew.unlockScenarios(["00_basic", "21_training2"])
crew.unlockScenario("00_basic", settings={"Time": ["30Min"], "Enemies": ["Normal"]})
crew.unlockScenario("21_training2")
crew.setBriefing("""Glückwunsch, {crew_name}.
Euch stehen weitere Missionen zur Auswahl:
In 'Basic Battle'
In 'Skirmish' könnt ihr euer Können gegen angreifende Gegner testen.
In 'Frigates Testing Ground' könnt ihr andere (spezialisierte) Schiffe ausprobieren.
Ihr könnt euch nun euren Punklestand bei der gerade abgeschlossenen Missionen ansehen.
Ihr könnt euch nun euren Punktestand bei der gerade abgeschlossenen Missionen ansehen.
""")
if s == "21_training2":
if event_topic == "unlockShip":
ship = details["ship"]
if not crew.hasShip(ship):
crew.unlockShip(ship)
crew.setBriefing("""Glückwunsch, {crew_name}.
Die in dieser Mission von euch verwendeten Schiffstypen stehen euch nun auch in den kampfbasierten Missionen zur Verfügung.
crew.setBriefing("""Willkommen zurück, {crew_name}.
Die in dieser Mission von euch verwendeten Schiffstypen stehen euch nun auch im 'Skirmish'-Szenario zur Verfügung.
""")

if s == "00_basic":
if progress is not None and progress >= 75:
crew.unlockScenario("03_waves")
crew.setBriefing("""Glückwunsch, {crew_name}.
if progress is not None and progress > 0:
# crew.unlockScenario("03_waves")
crew.unlockScenario("00_basic", settings={"Enemies": ["Easy", "Normal", "Hard", "Extreme"]})
crew.setBriefing("""Willkommen zurück, {crew_name}.
Die aktuelle Mission 'Skirmish' kann auf verschiedenen Schwierigkeitsgraden wiederholt werden.
Je höher der Schwierigkeitsgrad ist, desto höher wird eurer Reputations-Bonus ausfallen.
Der Reputations-Bonus ergibt sich aus dem Schwierigkeitsgrad und dem erreichten Missionsfortschritt.
""")

Expand Down
2 changes: 2 additions & 0 deletions deploy/campaign/eecs/models/crew.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ def getRecentScore(self):
ret["best_artifacts"] = str(int(ss["artifacts"]))
ret["fleet_artifacts"] = str(int(hi["artifacts"][0]))
ret["fleet_artifacts_name"] = "" if len(hi["artifacts"][1]) != 1 else " (" + str(list(hi["artifacts"][1])[0]) + ")"
if "difficulty" in current:
ret["current_difficulty"] = str(int(current["difficulty"]))
if "reputation" in current:
ret["reputation"] = str(int(ss["reputation"]))
return ret
Expand Down

0 comments on commit d9c8cd3

Please sign in to comment.