@@ -24,7 +24,7 @@ def __init__(
2424 self .key_price = key_price
2525 self .item_is_not_pure = item_is_not_pure
2626
27- self .__is_possible = False
27+ self ._is_possible = False
2828 self .their_scrap = 0
2929 self .our_scrap = 0
3030 self .their_overview = {}
@@ -74,12 +74,8 @@ def get_pure_in_inventory(self, inventory: list[dict]) -> tuple[int, list[dict]]
7474
7575 return scrap , metal
7676
77- def is_possible (self ) -> bool :
78- return self .__is_possible
79-
80- def __overview_to_items (
81- self , combination : list [str ], inventory : list [dict ]
82- ) -> list [dict ]:
77+ @staticmethod
78+ def _overview_to_items (combination : list [str ], inventory : list [dict ]) -> list [dict ]:
8379 items = []
8480
8581 for metal_name in combination :
@@ -97,12 +93,12 @@ def __overview_to_items(
9793 return items
9894
9995 def get_currencies (self ) -> tuple [list [dict ], list [dict ]]:
100- assert self .__is_possible , "Currencies does not add up"
96+ assert self ._is_possible , "Currencies does not add up"
10197
102- their_items = self .__overview_to_items (
98+ their_items = self ._overview_to_items (
10399 self .their_combination , self .their_inventory
104100 )
105- our_items = self .__overview_to_items (self .our_combination , self .our_inventory )
101+ our_items = self ._overview_to_items (self .our_combination , self .our_inventory )
106102
107103 return their_items , our_items
108104
@@ -125,7 +121,7 @@ def format_overview(pure: list[dict]) -> dict:
125121
126122 return overview
127123
128- def __pick_currencies (self , user : str ) -> tuple [bool , list [str ]]:
124+ def _pick_currencies (self , user : str ) -> tuple [bool , list [str ]]:
129125 """ref, ref, scrap, rec"""
130126 overview = (
131127 self .their_overview .copy () if user == "them" else self .our_overview .copy ()
@@ -166,7 +162,7 @@ def __pick_currencies(self, user: str) -> tuple[bool, list[str]]:
166162
167163 return True , combination
168164
169- def __does_add_up (self ) -> bool :
165+ def _adds_up (self ) -> bool :
170166 their_value = 0
171167 our_value = 0
172168
@@ -184,9 +180,9 @@ def __does_add_up(self) -> bool:
184180
185181 return their_value == our_value
186182
187- def __set_combinations (self ) -> bool :
188- success_our , our_combination = self .__pick_currencies ("us" )
189- success_their , their_combination = self .__pick_currencies ("them" )
183+ def _set_combinations (self ) -> bool :
184+ success_our , our_combination = self ._pick_currencies ("us" )
185+ success_their , their_combination = self ._pick_currencies ("them" )
190186
191187 if not success_our or not success_their :
192188 return False
@@ -196,7 +192,7 @@ def __set_combinations(self) -> bool:
196192
197193 return True
198194
199- def __has_enough (self ) -> bool :
195+ def _has_enough (self ) -> bool :
200196 temp_price = self .scrap_price
201197
202198 if self .item_is_not_pure :
@@ -214,11 +210,11 @@ def calculate(self) -> None:
214210 self .their_overview = self .format_overview (their_pure )
215211 self .our_overview = self .format_overview (our_pure )
216212
217- if not self .__has_enough ():
213+ if not self ._has_enough ():
218214 return
219215
220- while self .__has_enough ():
221- success = self .__set_combinations ()
216+ while self ._has_enough ():
217+ success = self ._set_combinations ()
222218
223219 if success :
224220 break
@@ -227,8 +223,12 @@ def calculate(self) -> None:
227223 # try again, do this till we have either user does not have enough anymore
228224 self .scrap_price += 1
229225
230- if not self .__does_add_up ():
226+ if not self ._adds_up ():
231227 return
232228
233229 # everything adds up and looks good
234- self .__is_possible = True
230+ self ._is_possible = True
231+
232+ @property
233+ def is_possible (self ) -> bool :
234+ return self ._is_possible
0 commit comments