bcsfe-wrapper-python 0.1.3__py3-none-any.whl → 0.1.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
bcsfe_wrapper/wrapper.py CHANGED
@@ -2,29 +2,48 @@ import os
2
2
  import sys
3
3
  from typing import Any, List, Optional, Tuple, Dict, Union
4
4
 
5
- # 内部のbcsfeを優先的にインポート
6
5
  from bcsfe import core
7
6
  from bcsfe.cli import edits
8
7
 
9
8
  class BCSFEWrapper:
10
9
  def __init__(self, save_path_or_data: Union[str, bytes], cc: str = "jp", gv: str = "13.1.0"):
10
+ # パスの初期化
11
+ data_folder = core.Path.get_data_folder()
12
+ core.set_config_path(data_folder.add("config.yaml"))
13
+ core.set_log_path(data_folder.add("log.txt"))
14
+
15
+ # コアデータの初期化
11
16
  core.core_data.init_data()
17
+
18
+ self.cc = core.CountryCode.from_code(cc)
19
+ self.gv = core.GameVersion.from_string(gv)
20
+
12
21
  if isinstance(save_path_or_data, str):
13
22
  self.save_path = core.Path(save_path_or_data)
14
- self.save_file = core.SaveFile(self.save_path.read())
23
+ self.save_file = core.SaveFile(self.save_path.read(), cc=self.cc, gv=self.gv)
15
24
  self.save_file.save_path = self.save_path
16
25
  else:
17
- self.save_file = core.SaveFile(save_path_or_data)
26
+ self.save_file = core.SaveFile(core.Data(save_path_or_data), cc=self.cc, gv=self.gv)
18
27
  self.save_path = None
19
28
 
20
29
  @classmethod
21
- def from_server(cls, transfer_code: str, confirmation_code: str, cc: str = "jp") -> 'BCSFEWrapper':
30
+ def from_server(cls, transfer_code: str, confirmation_code: str, cc: str = "jp", gv: str = "13.1.0") -> 'BCSFEWrapper':
31
+ # サーバーからダウンロードする前に初期化が必要
32
+ data_folder = core.Path.get_data_folder()
33
+ core.set_config_path(data_folder.add("config.yaml"))
34
+ core.core_data.init_data()
35
+
22
36
  country_code = core.CountryCode.from_code(cc)
23
- handler = core.ServerHandler(country_code)
24
- save_data, error = handler.download_save(transfer_code, confirmation_code)
25
- if save_data is None:
26
- raise RuntimeError(f"Download failed: {error}")
27
- return cls(save_data.to_data().get_bytes(), cc=cc)
37
+ game_version = core.GameVersion.from_string(gv)
38
+
39
+ server_handler, result = core.ServerHandler.from_codes(
40
+ transfer_code, confirmation_code, country_code, game_version, print=False
41
+ )
42
+
43
+ if server_handler is None:
44
+ raise RuntimeError(f"Download failed. Check your codes or internet connection.")
45
+
46
+ return cls(server_handler.save_file.to_data().get_bytes(), cc=cc, gv=gv)
28
47
 
29
48
  def save(self, output_path: Optional[str] = None):
30
49
  path = core.Path(output_path) if output_path else self.save_path
@@ -32,9 +51,10 @@ class BCSFEWrapper:
32
51
  self.save_file.to_file(path)
33
52
 
34
53
  def upload_to_server(self) -> Tuple[Optional[str], Optional[str]]:
35
- handler = core.ServerHandler(self.save_file.cc)
36
- response, error = handler.upload_save(self.save_file)
37
- if response: return response.get("transfer_code"), response.get("confirmation_code")
54
+ handler = core.ServerHandler(self.save_file, print=False)
55
+ codes = handler.get_codes()
56
+ if codes:
57
+ return codes
38
58
  return None, None
39
59
 
40
60
  def edit_catfood(self, amount: int): self.save_file.catfood = amount
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bcsfe-wrapper-python
3
- Version: 0.1.3
3
+ Version: 0.1.5
4
4
  Summary: A Python wrapper for BCSFE-Python to easily interact with Battle Cats save files.
5
5
  Home-page: https://github.com/fieryhenry/BCSFE-Python
6
6
  Author: Manus AI
@@ -1,5 +1,5 @@
1
1
  bcsfe_wrapper/__init__.py,sha256=o2LbyVJjuRV1gap8wDbsv39kEUJM1rt8Lq49u1RYYXA,268
2
- bcsfe_wrapper/wrapper.py,sha256=zoFoCdQyNFtE2hDUApkUjPB4F6z4rnSnPtl88xyQYOA,5044
2
+ bcsfe_wrapper/wrapper.py,sha256=Gnpe0vSei-LGaethtL8SkcCnww_iXYSomsFCeAgWmJk,5774
3
3
  bcsfe_wrapper/bcsfe/__init__.py,sha256=vCHjSoJq5u684HLQXahhtA64MZWffNHFdhweP7RM0f4,144
4
4
  bcsfe_wrapper/bcsfe/__main__.py,sha256=Dam14Fv6L-tRRufIkIRpr69dM0b2ybU1eALJxIw_eFI,2091
5
5
  bcsfe_wrapper/bcsfe/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -198,7 +198,7 @@ bcsfe_wrapper/bcsfe/files/locales/vi/edits/treasures.properties,sha256=U9uKsF4y0
198
198
  bcsfe_wrapper/bcsfe/files/locales/vi/edits/user_rank.properties,sha256=FcldhzKM0UmuhmGzI3dGzxstuKcw-t-gkbmKLZT4VKg,603
199
199
  bcsfe_wrapper/bcsfe/files/themes/default.json,sha256=w8eqqd9ATIFwUcvOWTdJjyd1T3LGgUm3iVkJhT5wfEo,392
200
200
  bcsfe_wrapper/bcsfe/files/themes/discord.json,sha256=W1dtEev6tap_waHOxvSqENDcMRA9jfBvjW7t-ssdGs4,370
201
- bcsfe_wrapper_python-0.1.3.dist-info/METADATA,sha256=4rP8MszJlJClcULS6VvPi2MjBo1kKajUqz_Y_C_DhAU,4326
202
- bcsfe_wrapper_python-0.1.3.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
203
- bcsfe_wrapper_python-0.1.3.dist-info/top_level.txt,sha256=kqyMKpAdNg39_kGGtqsxOSLPIb-qx7R1mQj1hReUsYM,14
204
- bcsfe_wrapper_python-0.1.3.dist-info/RECORD,,
201
+ bcsfe_wrapper_python-0.1.5.dist-info/METADATA,sha256=h4sQqByl11oBi84-NzUdouvWbhOUQUEatKWUxdoeKjk,4326
202
+ bcsfe_wrapper_python-0.1.5.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
203
+ bcsfe_wrapper_python-0.1.5.dist-info/top_level.txt,sha256=kqyMKpAdNg39_kGGtqsxOSLPIb-qx7R1mQj1hReUsYM,14
204
+ bcsfe_wrapper_python-0.1.5.dist-info/RECORD,,