@@ -102,135 +102,55 @@ def load_data() -> Tuple[Dict, Dict, Dict]:
102102 return divination_data , currency_data , unique_items
103103
104104 @staticmethod
105- def process_card (
106- name : str ,
107- chaos_value : float ,
108- stack_size : int ,
109- explicit_modifiers : List [Dict ],
110- currency : Dict [str , float ],
111- unique_items : Dict [str , float ],
112- divination_data : Dict
113- ) -> Optional [Dict ]:
114- """Process divination card data and calculate profit.
115-
116- Args:
117- name: Card name
118- chaos_value: Value in chaos orbs
119- stack_size: Number of cards in a full set
120- explicit_modifiers: Card reward modifiers
121- currency: Currency data dictionary
122- unique_items: Unique items data dictionary
123- divination_data: Divination card data dictionary
124-
125- Returns:
126- Dictionary with processed card data or None if processing fails
127- """
128- if not explicit_modifiers :
129- return None
130-
131- type_info = explicit_modifiers [0 ]["text" ]
132- match = re .match (r"<(.*?)>{(.*?)}" , type_info )
133- if not match :
134- return None
135-
136- reward_type , reward_content = match .groups ()
105+ def process_card (name , chaos_value , stack_size , explicit_modifiers , currency , unique_items , divination_data ):
137106 total_cost = chaos_value * stack_size
138-
139- # Handle special name cases
140- reward_content = Utils ._handle_special_names (name , reward_content )
141-
142- try :
143- if reward_type == "currencyitem" :
144- return Utils ._process_currency_reward (
145- name , reward_content , currency , total_cost , chaos_value , stack_size
146- )
147- elif reward_type == "uniqueitem" :
148- return Utils ._process_unique_reward (
149- name , reward_content , unique_items , total_cost , chaos_value , stack_size
150- )
107+ type_info = explicit_modifiers [0 ]["text" ]
108+ match = re .match ("<(.*)>{(.*)}" , type_info )
109+ if match :
110+ if match .group (1 ) == "currencyitem" :
111+ reward_type = "Currency"
112+ items = match .group (2 ).split ("x " )
113+ if len (items ) == 1 :
114+ items .insert (0 , "1" )
115+ if items [1 ] == "Master Cartographer's Sextant" :
116+ items [1 ] = "Awakened Sextant"
117+ try :
118+ reward_value = currency .get (items [1 ], 0 ) * float (items [0 ])
119+ except KeyError :
120+ print (f"KeyError: Item '{ items [1 ]} ' not found in currency data for card '{ name } '" )
121+ return None
122+ elif match .group (1 ) == "uniqueitem" :
123+ reward_type = "Unique"
124+ item_reward = match .group (2 )
125+ if item_reward == "Charan's Sword" :
126+ item_reward = "Oni-Goroshi"
127+ if name == "Azyran's Reward" :
128+ item_reward = "The Anima Stone"
129+ try :
130+ reward_value = unique_items .get (item_reward , 0 )
131+ except KeyError :
132+ print (f"KeyError: Item '{ item_reward } ' not found in unique items data for card '{ name } '" )
133+ return None
151134 else :
152- return Utils ._process_divination_reward (
153- name , reward_content , divination_data , total_cost , chaos_value , stack_size
154- )
155- except KeyError as e :
156- print (f"KeyError: Item '{ e .args [0 ]} ' not found in data for card '{ name } '" )
157- return None
158-
159- @staticmethod
160- def _process_currency_reward (
161- name : str ,
162- reward_content : str ,
163- currency : Dict [str , float ],
164- total_cost : float ,
165- chaos_value : float ,
166- stack_size : int
167- ) -> Dict :
168- """Process currency-type rewards."""
169- parts = reward_content .split ("x " )
170- quantity = float (parts [0 ]) if len (parts ) > 1 else 1.0
171- item_name = parts [1 ] if len (parts ) > 1 else parts [0 ]
172-
173- item_name = Utils .ITEM_NAME_MAPPINGS .get (item_name , item_name )
174- reward_value = currency [item_name ] * quantity
175-
176- return Utils ._build_card_data (
177- name , "Currency" , reward_value , total_cost , chaos_value , stack_size
178- )
179-
180- @staticmethod
181- def _process_unique_reward (
182- name : str ,
183- reward_content : str ,
184- unique_items : Dict [str , float ],
185- total_cost : float ,
186- chaos_value : float ,
187- stack_size : int
188- ) -> Dict :
189- """Process unique-item rewards."""
190- reward_content = Utils .ITEM_NAME_MAPPINGS .get (reward_content , reward_content )
191- reward_value = unique_items [reward_content ]
192-
193- return Utils ._build_card_data (
194- name , "Unique" , reward_value , total_cost , chaos_value , stack_size
195- )
196-
197- @staticmethod
198- def _process_divination_reward (
199- name : str ,
200- reward_content : str ,
201- divination_data : Dict ,
202- total_cost : float ,
203- chaos_value : float ,
204- stack_size : int
205- ) -> Dict :
206- """Process divination-card rewards."""
207- reward_value = divination_data [reward_content ]
208-
209- return Utils ._build_card_data (
210- name , "Divination" , reward_value , total_cost , chaos_value , stack_size
211- )
212-
213- @staticmethod
214- def _build_card_data (
215- name : str ,
216- reward_type : str ,
217- reward_value : float ,
218- total_cost : float ,
219- chaos_value : float ,
220- stack_size : int
221- ) -> Dict :
222- """Build the card data dictionary."""
223- profit = round ((reward_value - total_cost ), 2 )
224- return {
225- "Name" : name ,
226- "Type" : reward_type ,
227- "Profit" : profit ,
228- "Cost" : chaos_value ,
229- "Stack" : stack_size ,
230- "Profitpercard" : round (profit / stack_size , 2 ),
231- "Total" : total_cost ,
232- "Sellprice" : reward_value ,
233- }
135+ reward_type = "Divination"
136+ item_reward = match .group (2 )
137+ try :
138+ reward_value = divination_data .get (item_reward , 0 )
139+ except KeyError :
140+ print (f"KeyError: Item '{ item_reward } ' not found in divination data for card '{ name } '" )
141+ return None
142+ profit = round ((reward_value - total_cost ), 2 )
143+ return {
144+ "Name" : name ,
145+ "Type" : reward_type ,
146+ "Profit" : profit ,
147+ "Cost" : chaos_value ,
148+ "Stack" : stack_size ,
149+ "Profitpercard" : round (profit / stack_size , 2 ),
150+ "Total" : total_cost ,
151+ "Sellprice" : reward_value
152+ }
153+ return None
234154
235155 @staticmethod
236156 def _handle_special_names (card_name : str , reward_content : str ) -> str :
0 commit comments