Add achievement export support
This commit is contained in:
parent
40b44521aa
commit
5fe39b96ae
15 changed files with 197 additions and 55 deletions
|
|
@ -1 +1 @@
|
|||
__version__ = "0.2.1"
|
||||
__version__ = "0.3.0"
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ def print_live_instructions(local_ip: str, backend: str = "windows_raw", detail:
|
|||
print(style(" You can capture more than one board in the same session.", DIM))
|
||||
print()
|
||||
print(style(" Achievements", BOLD))
|
||||
print(" Your completed achievements are captured automatically when")
|
||||
print(" Your tracked achievements are captured automatically when")
|
||||
print(" you log in after following the step above.")
|
||||
print()
|
||||
print(style(" Ready - use the game, then press any key here when finished.", BOLD, GREEN))
|
||||
|
|
@ -106,12 +106,26 @@ def print_page_captured(label: str, page: int | None, *, recaptured: bool = Fals
|
|||
print(style(" + ", GREEN, BOLD) + label + style(f" {action} {page}", DIM))
|
||||
|
||||
|
||||
def print_achievements_captured(total: int, playstation: int) -> None:
|
||||
visible = total - playstation
|
||||
def print_achievements_captured(
|
||||
in_game_completed: int,
|
||||
in_game_in_progress: int,
|
||||
playstation_completed: int,
|
||||
playstation_in_progress: int,
|
||||
) -> None:
|
||||
print(style(" + ", GREEN, BOLD) + "Achievements captured")
|
||||
print(
|
||||
style(" + ", GREEN, BOLD)
|
||||
+ "Achievements"
|
||||
+ style(f" captured {visible} visible + {playstation} PlayStation", DIM)
|
||||
style(
|
||||
f" In-game {in_game_completed} completed, "
|
||||
f"{in_game_in_progress} in progress",
|
||||
DIM,
|
||||
)
|
||||
)
|
||||
print(
|
||||
style(
|
||||
f" PlayStation {playstation_completed} completed, "
|
||||
f"{playstation_in_progress} in progress",
|
||||
DIM,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -184,7 +198,7 @@ def print_problem(text: str) -> None:
|
|||
def print_update_available(current_version: str, latest_version: str, release_url: str) -> None:
|
||||
print()
|
||||
print(style(f" Update available: v{current_version} -> {latest_version}", YELLOW, BOLD))
|
||||
print(style(" Some banner/reward mappings may be incomplete in this version.", YELLOW))
|
||||
print(style(" Some reward or achievement mappings may be incomplete in this version.", YELLOW))
|
||||
print(style(" Updating is recommended for the most accurate export labels.", YELLOW))
|
||||
print(style(f" Download when ready: {release_url}", YELLOW))
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ ARC_BANNER_NAME = "Arc Miracle Box"
|
|||
MYSTERY_BOX_BANNER_ID = "Gashapon_MysteryBox"
|
||||
MYSTERY_BOX_BANNER_NAME = "Mystery Box"
|
||||
EXPORTER_NAME = "nte-history-exporter"
|
||||
EXPORTER_VERSION = "0.2.1"
|
||||
EXPORTER_VERSION = "0.3.0"
|
||||
|
||||
HISTORY_REQUEST_BANNER = 4220
|
||||
HISTORY_REQUEST_LENGTH = 45
|
||||
|
|
|
|||
|
|
@ -27,7 +27,10 @@ class AchievementRecord:
|
|||
def status(self) -> str:
|
||||
if self.completed:
|
||||
return "completed"
|
||||
return "in_progress" if self.progress else "not_started"
|
||||
# Presence in the server response means the achievement has tracked
|
||||
# state. Compound achievements can have hidden checklist progress while
|
||||
# exposing a numeric progress value of zero to the client.
|
||||
return "in_progress"
|
||||
|
||||
@property
|
||||
def completed_at(self) -> str | None:
|
||||
|
|
|
|||
|
|
@ -94,13 +94,11 @@ def build_achievement_export_json(
|
|||
"total_achievements": 0,
|
||||
"completed_achievements": 0,
|
||||
"in_progress_achievements": 0,
|
||||
"not_started_achievements": 0,
|
||||
},
|
||||
"playstation": {
|
||||
"total_achievements": 0,
|
||||
"completed_achievements": 0,
|
||||
"in_progress_achievements": 0,
|
||||
"not_started_achievements": 0,
|
||||
},
|
||||
}
|
||||
for achievement in achievement_records:
|
||||
|
|
@ -110,10 +108,8 @@ def build_achievement_export_json(
|
|||
summary["total_achievements"] += 1
|
||||
if achievement.completed:
|
||||
summary["completed_achievements"] += 1
|
||||
elif achievement.progress:
|
||||
summary["in_progress_achievements"] += 1
|
||||
else:
|
||||
summary["not_started_achievements"] += 1
|
||||
summary["in_progress_achievements"] += 1
|
||||
category, separator, _number = achievement_id.partition("_")
|
||||
category_key = category.casefold() if separator else "uncategorized"
|
||||
record = {
|
||||
|
|
|
|||
|
|
@ -111,12 +111,27 @@ def run_live_capture(
|
|||
reassemble_tcp_segments(tcp_segments[flow])
|
||||
)
|
||||
if achievement_records:
|
||||
completed = [record for record in achievement_records if record.completed]
|
||||
in_game = [
|
||||
record
|
||||
for record in achievement_records
|
||||
if not record.achievement_id.casefold().startswith(
|
||||
"playstation_"
|
||||
)
|
||||
]
|
||||
playstation = [
|
||||
record
|
||||
for record in achievement_records
|
||||
if record.achievement_id.casefold().startswith(
|
||||
"playstation_"
|
||||
)
|
||||
]
|
||||
console.print_achievements_captured(
|
||||
len(completed),
|
||||
sum(record.completed for record in in_game),
|
||||
sum(record.status == "in_progress" for record in in_game),
|
||||
sum(record.completed for record in playstation),
|
||||
sum(
|
||||
record.achievement_id.lower().startswith("playstation_")
|
||||
for record in completed
|
||||
record.status == "in_progress"
|
||||
for record in playstation
|
||||
),
|
||||
)
|
||||
pair_count_before = len(session.pairs)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue