Compare commits
3 Commits
b85cc5db4b
...
32d6ca1891
Author | SHA1 | Date | |
---|---|---|---|
32d6ca1891 | |||
ac5d4c8389 | |||
33a86c1c10 |
@ -2,14 +2,20 @@ from pathlib import Path
|
|||||||
from vollerei import __version__
|
from vollerei import __version__
|
||||||
from vollerei.cli.hsr import HSR
|
from vollerei.cli.hsr import HSR
|
||||||
from vollerei.hsr import PatchType
|
from vollerei.hsr import PatchType
|
||||||
|
from vollerei.cli import utils
|
||||||
|
|
||||||
|
|
||||||
class CLI:
|
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
|
Vollerei CLI
|
||||||
"""
|
"""
|
||||||
print(f"Vollerei v{__version__}")
|
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:
|
if not game_path:
|
||||||
game_path = Path.cwd()
|
game_path = Path.cwd()
|
||||||
game_path = Path(game_path)
|
game_path = Path(game_path)
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
|
from platform import system
|
||||||
|
from vollerei.cli.utils import ask
|
||||||
from vollerei.hsr import Game, Patcher
|
from vollerei.hsr import Game, Patcher
|
||||||
from vollerei.exceptions.patcher import PatcherError, PatchUpdateError
|
from vollerei.exceptions.patcher import PatcherError, PatchUpdateError
|
||||||
from vollerei.hsr.patcher import PatchType
|
from vollerei.hsr.patcher import PatchType
|
||||||
@ -26,7 +28,6 @@ class HSR:
|
|||||||
except PatchUpdateError as e:
|
except PatchUpdateError as e:
|
||||||
print("FAILED")
|
print("FAILED")
|
||||||
print(f"Patch update failed with following error: {e} ({e.__context__})")
|
print(f"Patch update failed with following error: {e} ({e.__context__})")
|
||||||
print_exc()
|
|
||||||
return False
|
return False
|
||||||
print("OK")
|
print("OK")
|
||||||
return True
|
return True
|
||||||
@ -34,18 +35,49 @@ class HSR:
|
|||||||
def update_patch(self):
|
def update_patch(self):
|
||||||
self.__update_patch()
|
self.__update_patch()
|
||||||
|
|
||||||
def patch(self):
|
def __patch_jadeite(self):
|
||||||
if not self.__update_patch():
|
|
||||||
return
|
|
||||||
try:
|
try:
|
||||||
print("Patching game...", end=" ")
|
print("Installing patch...", end=" ")
|
||||||
jadelte_dir = self._patcher.patch_game(game=self._game)
|
jadelte_dir = self._patcher.patch_game(game=self._game)
|
||||||
except PatcherError as e:
|
except PatcherError as e:
|
||||||
print("FAILED")
|
print("FAILED")
|
||||||
print(f"Patching failed with following error: {e}")
|
print(f"Patching failed with following error: {e}")
|
||||||
return
|
return
|
||||||
print("OK")
|
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(
|
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
14
vollerei/cli/utils.py
Normal 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
|
Loading…
Reference in New Issue
Block a user