bcsfe-wrapper-python 0.1.21__py3-none-any.whl → 0.1.22__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
@@ -64,7 +64,13 @@ class BCSFEWrapper:
64
64
  codes = handler.get_codes()
65
65
  return codes if codes else (None, None)
66
66
 
67
- def _set_val(self, attr: str, amount: int): setattr(self.save_file, attr, amount)
67
+ def _check_save(self):
68
+ if self.save_file is None:
69
+ raise RuntimeError("セーブデータが読み込まれていません。先に from_server() などでデータをロードしてください。")
70
+
71
+ def _set_val(self, attr: str, amount: int):
72
+ self._check_save()
73
+ setattr(self.save_file, attr, amount)
68
74
  def edit_catfood(self, amount: int): self._set_val("catfood", amount)
69
75
  def edit_xp(self, amount: int): self._set_val("xp", amount)
70
76
  def edit_normal_tickets(self, amount: int): self._set_val("normal_tickets", amount)
@@ -75,52 +81,63 @@ class BCSFEWrapper:
75
81
  def edit_leadership(self, amount: int): self._set_val("leadership", amount)
76
82
 
77
83
  def edit_battle_items(self, amount: int):
84
+ self._check_save()
78
85
  for item in self.save_file.battle_items.items: item.amount = amount
79
86
  def edit_catseyes(self, amount: int):
87
+ self._check_save()
80
88
  for i in range(len(self.save_file.catseyes)): self.save_file.catseyes[i] = amount
81
89
  def edit_catfruit(self, amount: int):
90
+ self._check_save()
82
91
  for i in range(len(self.save_file.catfruit)): self.save_file.catfruit[i] = amount
83
92
 
84
93
  def unlock_cats(self, cat_ids: List[int]):
94
+ self._check_save()
85
95
  for cid in cat_ids:
86
- # ユーザーが指定したIDから1を引いて内部IDに変換
87
96
  internal_id = cid - 1
88
97
  cat = self.save_file.cats.get_cat_by_id(internal_id)
89
98
  if cat: cat.unlock(self.save_file)
90
99
  def unlock_all_cats(self):
100
+ self._check_save()
91
101
  for cat in self.save_file.cats.cats: cat.unlock(self.save_file)
92
102
 
93
- # 新機能: 指定キャラ削除(未解放に戻す)
94
103
  def remove_cats(self, cat_ids: List[int]):
104
+ self._check_save()
95
105
  for cid in cat_ids:
96
106
  internal_id = cid - 1
97
107
  cat = self.save_file.cats.get_cat_by_id(internal_id)
98
108
  if cat: cat.set_unlocked(False)
99
109
 
100
110
  def upgrade_cats(self, cat_ids: List[int], base: int = 19, plus: int = 0):
111
+ self._check_save()
101
112
  for cid in cat_ids:
102
113
  internal_id = cid - 1
103
114
  cat = self.save_file.cats.get_cat_by_id(internal_id)
104
115
  if cat: cat.upgrade.base, cat.upgrade.plus = base, plus
105
116
  def upgrade_all_cats(self, base: Optional[int] = None, plus: Optional[int] = None):
117
+ self._check_save()
106
118
  for cat in self.save_file.cats.cats:
107
119
  if not cat.is_unlocked(self.save_file): continue
108
120
  power_up = core.PowerUpHelper(cat, self.save_file)
109
121
  cat.upgrade.base = (base if base is not None else power_up.get_max_possible_base()) - 1
110
122
  cat.upgrade.plus = plus if plus is not None else power_up.get_max_possible_plus()
111
123
  def set_cat_form(self, cat_ids: List[int], form: int = 2):
124
+ self._check_save()
112
125
  for cid in cat_ids:
113
126
  internal_id = cid - 1
114
127
  cat = self.save_file.cats.get_cat_by_id(internal_id)
115
128
  if cat: cat.set_form(form)
116
129
  def true_form_all_cats(self):
130
+ self._check_save()
117
131
  cats = self.save_file.cats.get_unlocked_cats()
118
132
  self.save_file.cats.true_form_cats(self.save_file, cats, True, True)
119
133
  self.save_file.cats.fourth_form_cats(self.save_file, cats, True, True)
120
134
 
121
- def clear_tutorial(self): edits.clear_tutorial.clear_tutorial(self.save_file, False)
135
+ def clear_tutorial(self):
136
+ self._check_save()
137
+ edits.clear_tutorial.clear_tutorial(self.save_file, False)
122
138
 
123
139
  def _clear_chapter_group(self, chapters_obj, chapters_to_clear: List[int]):
140
+ self._check_save()
124
141
  for c_id in chapters_to_clear:
125
142
  if c_id < len(chapters_obj.chapters):
126
143
  chapter = chapters_obj.chapters[c_id]
@@ -128,13 +145,17 @@ class BCSFEWrapper:
128
145
  for stage in chapter.stages: stage.treasure = 3
129
146
 
130
147
  def clear_empire_of_cats(self, chapters: List[int] = [0, 1, 2]):
148
+ self._check_save()
131
149
  self._clear_chapter_group(self.save_file.story.chapters, chapters)
132
150
  def clear_into_the_future(self, chapters: List[int] = [0, 1, 2]):
151
+ self._check_save()
133
152
  self._clear_chapter_group(self.save_file.story.chapters, [c + 3 for c in chapters])
134
153
  def clear_cats_of_the_cosmos(self, chapters: List[int] = [0, 1, 2]):
154
+ self._check_save()
135
155
  self._clear_chapter_group(self.save_file.story.chapters, [c + 6 for c in chapters])
136
156
 
137
157
  def _clear_legend_group(self, legend_obj, max_star: int = 1):
158
+ self._check_save()
138
159
  for map_id in range(len(legend_obj.chapters)):
139
160
  for star in range(min(max_star, legend_obj.get_total_stars(map_id))):
140
161
  for stage_id in range(legend_obj.get_total_stages(map_id, star)):
@@ -145,22 +166,28 @@ class BCSFEWrapper:
145
166
  def clear_zero_legends(self, max_star: int = 1): self._clear_legend_group(self.save_file.zero_legends, max_star)
146
167
 
147
168
  def clear_zombie_outbreaks(self, chapters: List[int] = [0, 1, 2, 3, 4, 5, 6, 7, 8]):
169
+ self._check_save()
148
170
  for chapter_id in chapters:
149
171
  for stage_id in range(48):
150
172
  self.save_file.outbreaks.clear_outbreak(chapter_id, stage_id, True)
151
173
 
152
- def unlock_aku_realm(self): edits.aku_realm.unlock_aku_realm(self.save_file)
174
+ def unlock_aku_realm(self):
175
+ self._check_save()
176
+ edits.aku_realm.unlock_aku_realm(self.save_file)
153
177
 
154
178
  def unlock_all_medals(self):
179
+ self._check_save()
155
180
  for i in range(len(self.save_file.medals.medals)):
156
181
  self.save_file.medals.medals[i] = True
157
182
 
158
183
  def claim_all_stamps(self):
184
+ self._check_save()
159
185
  for stamp in self.save_file.stamps.stamps:
160
186
  stamp.received = True
161
187
  stamp.current_stamp = stamp.total_stamps
162
188
 
163
189
  def legend_all_gamatoto_members(self):
190
+ self._check_save()
164
191
  members_name = core.core_data.get_gamatoto_members_name(self.save_file)
165
192
  legend_ids = [m.member_id for m in members_name.members if m.rarity == 2]
166
193
  if not legend_ids: return
@@ -168,6 +195,7 @@ class BCSFEWrapper:
168
195
  helper.id = random.choice(legend_ids)
169
196
 
170
197
  def complete_all_treasures(self, groups: List[int] = [0, 1, 2]):
198
+ self._check_save()
171
199
  for group_id in groups:
172
200
  start, end = group_id * 3, (group_id + 1) * 3
173
201
  for c_id in range(start, end):
@@ -176,30 +204,32 @@ class BCSFEWrapper:
176
204
  for stage in chapter.stages: stage.treasure = 3
177
205
 
178
206
  def max_all_upgrades(self):
207
+ self._check_save()
179
208
  for upgrade in self.save_file.upgrades.upgrades:
180
209
  upgrade.base = upgrade.max_base
181
210
  upgrade.plus = upgrade.max_plus
182
211
 
183
- # 新機能: 施設レベルの個別指定
184
212
  def edit_upgrade_level(self, upgrade_id: int, base: Optional[int] = None, plus: Optional[int] = None):
185
- """
186
- 0:にゃんこ砲攻撃力, 1:射程, 2:チャージ, 3:働きネコ効率, 4:お財布, 5:お城体力, 6:研究, 7:会計, 8:勉強, 9:統率力
187
- """
213
+ self._check_save()
188
214
  if upgrade_id < len(self.save_file.upgrades.upgrades):
189
215
  upgrade = self.save_file.upgrades.upgrades[upgrade_id]
190
216
  if base is not None: upgrade.base = base
191
217
  if plus is not None: upgrade.plus = plus
192
218
 
193
219
  def instant_complete_activities(self):
220
+ self._check_save()
194
221
  self.save_file.gamatoto.expedition.remaining_time = 0
195
222
  self.save_file.ototo.developing_remaining_time = 0
196
223
 
197
224
  def max_all_talents(self):
225
+ self._check_save()
198
226
  for cat in self.save_file.cats.get_unlocked_cats():
199
227
  for talent in cat.talents:
200
228
  talent.level = talent.max_level
201
229
 
202
- def unban(self): self.save_file.show_ban_message = self.save_file.banned = False
230
+ def unban(self):
231
+ self._check_save()
232
+ self.save_file.show_ban_message = self.save_file.banned = False
203
233
  def get_inquiry_code(self) -> str: return self.save_file.inquiry_code
204
234
  def edit_inquiry_code(self, new_code: str): self.save_file.inquiry_code = new_code
205
235
  def get_save_file(self) -> core.SaveFile: return self.save_file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bcsfe-wrapper-python
3
- Version: 0.1.21
3
+ Version: 0.1.22
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=zzd0OXdHHR7XmKipc24h7Hciyq2Koijilm4D1pRhjg0,10439
2
+ bcsfe_wrapper/wrapper.py,sha256=nffE7JI7jasWAm_-NVWnpLgjCqXi6LVlxHWX6_xhBAc,11081
3
3
  bcsfe_wrapper/__pycache__/__init__.cpython-311.pyc,sha256=svMfcdHfIa6yhFBxIuraz6iCJ0ZuMsDRaOFR2NWWC6A,567
4
4
  bcsfe_wrapper/__pycache__/wrapper.cpython-311.pyc,sha256=ij4a4EzzZlilVhzc-SB8LHaQKWO3truExx2aGn-coMg,21944
5
5
  bcsfe_wrapper/bcsfe/__init__.py,sha256=vCHjSoJq5u684HLQXahhtA64MZWffNHFdhweP7RM0f4,144
@@ -310,7 +310,7 @@ bcsfe_wrapper/bcsfe/files/locales/vi/edits/treasures.properties,sha256=U9uKsF4y0
310
310
  bcsfe_wrapper/bcsfe/files/locales/vi/edits/user_rank.properties,sha256=FcldhzKM0UmuhmGzI3dGzxstuKcw-t-gkbmKLZT4VKg,603
311
311
  bcsfe_wrapper/bcsfe/files/themes/default.json,sha256=w8eqqd9ATIFwUcvOWTdJjyd1T3LGgUm3iVkJhT5wfEo,392
312
312
  bcsfe_wrapper/bcsfe/files/themes/discord.json,sha256=W1dtEev6tap_waHOxvSqENDcMRA9jfBvjW7t-ssdGs4,370
313
- bcsfe_wrapper_python-0.1.21.dist-info/METADATA,sha256=8bK_yvwx0Yv852ND7rlF-uwsRl0lQNbe-GrFv2bcux0,4518
314
- bcsfe_wrapper_python-0.1.21.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
315
- bcsfe_wrapper_python-0.1.21.dist-info/top_level.txt,sha256=kqyMKpAdNg39_kGGtqsxOSLPIb-qx7R1mQj1hReUsYM,14
316
- bcsfe_wrapper_python-0.1.21.dist-info/RECORD,,
313
+ bcsfe_wrapper_python-0.1.22.dist-info/METADATA,sha256=WxJ5vOUn3IxTetHnSr0_5MIkxkumbgQY2OkxSmuTK2A,4518
314
+ bcsfe_wrapper_python-0.1.22.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
315
+ bcsfe_wrapper_python-0.1.22.dist-info/top_level.txt,sha256=kqyMKpAdNg39_kGGtqsxOSLPIb-qx7R1mQj1hReUsYM,14
316
+ bcsfe_wrapper_python-0.1.22.dist-info/RECORD,,