Skip to content

Commit

Permalink
Merge commit '524b51a0ce372820831f39bb4f78b053149aadeb' into gdb
Browse files Browse the repository at this point in the history
  • Loading branch information
KT-Yeh committed Apr 27, 2024
2 parents c989ea6 + 524b51a commit b5944de
Show file tree
Hide file tree
Showing 31 changed files with 945 additions and 143 deletions.
14 changes: 1 addition & 13 deletions genshin-dev/lint-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1 @@
flake8

flake8-annotations-complexity # complex annotation
flake8-black # runs black
flake8-builtins # builtin shadowing
flake8-docstrings # proper formatting and grammar in docstrings
flake8-isort # runs isort
flake8-mutable # mutable default argument detection
flake8-pep3101 # new-style format strings only
flake8-print # complain about print statements in code
flake8-pytest-style # pytest checks
flake8-raise # exception raising
flake8-requirements # requirements.txt check
ruff
4 changes: 2 additions & 2 deletions genshin-dev/reformat-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
black
isort
sort-all
ruff
sort-all
29 changes: 29 additions & 0 deletions genshin/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ async def accounts(client: genshin.Client) -> None:

genshin_group: click.Group = click.Group("genshin", help="Genshin-related commands.")
honkai_group: click.Group = click.Group("honkai", help="Honkai-related commands.")
starrail_group: click.Group = click.Group("starrail", help="StarRail-related commands.")
cli.add_command(genshin_group)
cli.add_command(honkai_group)
cli.add_command(starrail_group)


@honkai_group.command("stats")
Expand Down Expand Up @@ -199,6 +201,33 @@ async def genshin_notes(client: genshin.Client, uid: typing.Optional[int]) -> No
click.echo(f" - {expedition.status}")


@starrail_group.command("notes")
@click.argument("uid", type=int, default=None, required=False)
@client_command
async def starrail_notes(client: genshin.Client, uid: typing.Optional[int]) -> None:
"""Show real-Time starrail notes."""
click.echo("Real-Time notes.")

data = await client.get_starrail_notes(uid)

click.echo(f"{click.style('TB power:', bold=True)} {data.current_stamina}/{data.max_stamina}", nl=False)
click.echo(f" (Full in {data.stamina_recover_time})" if data.stamina_recover_time > datetime.timedelta(0) else "")
click.echo(f"{click.style('Reserved TB power:', bold=True)} {data.current_reserve_stamina}/2400")
click.echo(f"{click.style('Daily training:', bold=True)} {data.current_train_score}/{data.max_train_score}")
click.echo(f"{click.style('Simulated Universe:', bold=True)} {data.current_rogue_score}/{data.max_rogue_score}")
click.echo(
f"{click.style('Echo of War:', bold=True)} {data.remaining_weekly_discounts}/{data.max_weekly_discounts}"
)

click.echo(f"\n{click.style('Assignments:', bold=True)} {data.accepted_epedition_num}/{data.total_expedition_num}")
for expedition in data.expeditions:
if expedition.remaining_time > datetime.timedelta(0):
remaining = f"{expedition.remaining_time} remaining"
click.echo(f" - {expedition.name} | {remaining}")
else:
click.echo(f" - {expedition.name} | Finished")


@cli.command()
@click.option("--scenario", help="Scenario ID or name to use (eg '12-3').", type=str, default=None)
@client_command
Expand Down
13 changes: 10 additions & 3 deletions genshin/client/components/gacha.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ async def _get_banner_details(
server = "prod_official_asia" if game == types.Game.STARRAIL else "os_asia"

data = await self.request_webstatic(
f"/{region}/gacha_info/{server}/{banner_id}/{lang}.json",
f"/gacha_info/{region}/{server}/{banner_id}/{lang}.json",
cache=client_cache.cache_key("banner", endpoint="details", banner=banner_id, lang=lang),
)
return models.BannerDetails(**data, banner_id=banner_id)
Expand All @@ -240,12 +240,19 @@ async def get_genshin_banner_ids(self) -> typing.Sequence[str]:
Uses the current cn banners.
"""

def process_gacha(data: typing.Mapping[str, typing.Any]) -> str:
# Temporary fix for 4.5 chronicled wish
if data["gacha_type"] == 500:
return "8b10b48c52dd6870f92d72e9963b44bb8968ed2f"
return data["gacha_id"]

data = await self.request_webstatic(
"hk4e/gacha_info/cn_gf01/gacha/list.json",
"gacha_info/hk4e/cn_gf01/gacha/list.json",
region=types.Region.CHINESE,
cache=client_cache.cache_key("banner", endpoint="ids"),
)
return [i["gacha_id"] for i in data["data"]["list"]]
return list(map(process_gacha, data["data"]["list"]))

async def get_banner_details(
self,
Expand Down
Loading

0 comments on commit b5944de

Please sign in to comment.