Compare commits

...

3 Commits

Author SHA1 Message Date
32d6ca1891 chore: some improvement to cli 2023-06-18 00:05:02 +07:00
ac5d4c8389 fmt: black
I forgor to install pre-commit to my tuxtux
2023-06-17 23:08:35 +07:00
33a86c1c10 fix: wrong file name
why i always type jadelte instead of jadeite
2023-06-17 23:07:59 +07:00
3 changed files with 60 additions and 8 deletions

View File

@ -2,14 +2,20 @@ from pathlib import Path
from vollerei import __version__
from vollerei.cli.hsr import HSR
from vollerei.hsr import PatchType
from vollerei.cli import utils
class CLI:
def __init__(self, game_path: str = None, patch_type=None) -> None:
def __init__(
self, game_path: str = None, patch_type=None, noconfirm: bool = False
) -> None:
"""
Vollerei CLI
"""
print(f"Vollerei v{__version__}")
if noconfirm:
print("User requested to automatically answer yes to all questions.")
utils.no_confirm = noconfirm
if not game_path:
game_path = Path.cwd()
game_path = Path(game_path)

View File

@ -1,4 +1,6 @@
from traceback import print_exc
from platform import system
from vollerei.cli.utils import ask
from vollerei.hsr import Game, Patcher
from vollerei.exceptions.patcher import PatcherError, PatchUpdateError
from vollerei.hsr.patcher import PatchType
@ -26,7 +28,6 @@ class HSR:
except PatchUpdateError as e:
print("FAILED")
print(f"Patch update failed with following error: {e} ({e.__context__})")
print_exc()
return False
print("OK")
return True
@ -34,18 +35,49 @@ class HSR:
def update_patch(self):
self.__update_patch()
def patch(self):
if not self.__update_patch():
return
def __patch_jadeite(self):
try:
print("Patching game...", end=" ")
print("Installing patch...", end=" ")
jadelte_dir = self._patcher.patch_game(game=self._game)
except PatcherError as e:
print("FAILED")
print(f"Patching failed with following error: {e}")
return
print("OK")
print("Jadelte executable is located at:", jadelte_dir.joinpath("jadelte.exe"))
exe_path = jadelte_dir.joinpath("jadeite.exe")
print("Jadelte executable is located at:", exe_path)
print(
"Patching succeeded, but note that you need to run the game using Jadelte to use the patch."
"Installation succeeded, but note that you need to run the game using "
+ "Jadeite to use the patch."
)
print(f'E.g: I_WANT_A_BAN=1 {exe_path} "{self._game.path}"')
print(
"And for your own sake, please only use testing accounts, as there is an "
+ "extremely high risk of getting banned."
)
def __patch_astra(self):
try:
print("Patching game...", end=" ")
self._patcher.patch_game(game=self._game)
except PatcherError as e:
print("FAILED")
print(f"Patching failed with following error: {e}")
return
print("OK")
def patch(self):
if system() == "Windows":
print(
"Windows is supported officialy by the game, so no patching is needed."
)
if not ask("Do you still want to patch?"):
print("Patching aborted.")
return
if not self.__update_patch():
return
match self._patcher.patch_type:
case PatchType.Jadeite:
self.__patch_jadeite()
case PatchType.Astra:
self.__patch_astra()

14
vollerei/cli/utils.py Normal file
View File

@ -0,0 +1,14 @@
no_confirm = False
def ask(question: str):
if no_confirm:
print(question + " [Y/n] Y")
return True
while True:
answer = input(question + " [y/n] ")
if answer.lower() in ["y", "yes"]:
return True
# Pacman way, treat all other answers as no
else:
return False