11from ...util .linq import flow
22from ...util .ilp_solver import ex_equip_power_max_cost_flow
3- from ...model .common import ExtraEquipChangeSlot , ExtraEquipChangeUnit , InventoryInfoPost , AlcesData
3+ from ...model .common import ExtraEquipChangeSlot , ExtraEquipChangeUnit , InventoryInfoPost , AlcesData , ExtraEquipSubStatus
44from ..modulebase import *
55from ..config import *
66from ...core .pcrclient import pcrclient
1212
1313@name ('彩装究极炼成' )
1414@default (True )
15- @inttype ('ex_equip_rainbow_enhance_pt_hold' , '保留pt数(w)' , 1 , list (range (0 , 1001 )))
15+ @inttype ('ex_equip_rainbow_enhance_pt_hold' , '保留pt数(w)' , 10 , list (range (0 , 1001 )))
1616@ExEquipSubStatusRankConfig ('ex_equip_rainbow_enhance_rank' , '属性优先级' )
1717@inttype ('ex_equip_rainbow_enhance_no_max_num' , '非满属性' , 1 , [0 , 1 , 2 , 3 , 4 ])
1818@ExEquipSubStatusConfig ('ex_equip_rainbow_enchance_sub_status_4' , '炼成属性4' )
1919@ExEquipSubStatusConfig ('ex_equip_rainbow_enchance_sub_status_3' , '炼成属性3' )
2020@ExEquipSubStatusConfig ('ex_equip_rainbow_enchance_sub_status_2' , '炼成属性2' )
2121@ExEquipSubStatusConfig ('ex_equip_rainbow_enchance_sub_status_1' , '炼成属性1' )
22- @booltype ( 'ex_equip_rainbow_enchance_view ' , '看状态 ' , True )
22+ @singlechoice ( 'ex_equip_rainbow_enchance_action ' , '做什么 ' , '看属性' , [ '看属性' , '炼成' , '看概率' ] )
2323@texttype ('ex_equip_rainbow_enchance_id' , '彩装id' , 0 )
24- @description ('看状态指获取彩装id和炼成属性. 非满属性指属性值不必最大,以便手动用光球强化.属性优先级指目标属性值一样时,比较其他属性决定保留或放弃,优先级是按顺序从高到低,目标属性的优先级最高,不受属性优先级影响.满强目标属性会自动锁住.' )
24+ @description ('看属性指获取彩装id和炼成属性,炼成则进行究极炼成,看概率指根据炼成记录统计各属性概率, 非满属性指属性值不必最大,以便手动用光球强化.属性优先级指目标属性值一样时,比较其他属性决定保留或放弃,优先级是按顺序从高到低,目标属性的优先级最高,不受属性优先级影响.满强目标属性会自动锁住.' )
2525class ex_equip_rainbow_enchance (Module ):
2626
2727 async def do_task (self , client : pcrclient ):
28- ex_equip_rainbow_enchance_view = self .get_config ('ex_equip_rainbow_enchance_view ' )
29- if ex_equip_rainbow_enchance_view :
28+ ex_equip_rainbow_enchance_action = self .get_config ('ex_equip_rainbow_enchance_action ' )
29+ if ex_equip_rainbow_enchance_action == '看属性' :
3030 msg = flow (client .data .ex_equips .values ()) \
3131 .where (lambda ex : db .get_ex_equip_rarity (ex .ex_equipment_id ) == 5 ) \
3232 .select (lambda ex : f"{ ex .serial_id } : { db .get_ex_equip_name (ex .ex_equipment_id )} "
@@ -37,7 +37,24 @@ async def do_task(self, client: pcrclient):
3737 raise SkipError ("无彩装" )
3838 msg = '\n ' .join (msg )
3939 self ._log (f"{ cnt } 件彩装:\n { msg } " )
40- else :
40+ elif ex_equip_rainbow_enchance_action == '看概率' :
41+ for equip , data in self .iter_cache ():
42+ total = data .get ('total' , 1 )
43+ equip = int (equip )
44+ self ._log (f"{ db .get_ex_equip_name (equip )} (炼成{ total } 次)" )
45+ info = flow (data .items ()) \
46+ .where (lambda kv : kv [0 ] != 'total' ) \
47+ .select (lambda kv : (list (map (int , kv [0 ].split ('-' ))), kv [1 ])) \
48+ .group_by (lambda kv : kv [0 ][0 ]) \
49+ .to_dict (lambda g : g .key , lambda g : g .to_list ())
50+ for status in sorted (info ):
51+ status_info = info [status ]
52+ status_info .sort (key = lambda x : x [0 ][1 ])
53+ msg = '/' .join ([f"{ db .get_ex_equip_sub_status_str (equip , [ExtraEquipSubStatus (status = k , step = s )])} : { v / total * 100 :.2f} %" for (k , s ), v in status_info ])
54+ self ._log (f" { msg } " )
55+ self ._log ("" )
56+
57+ elif ex_equip_rainbow_enchance_action == '炼成' :
4158 serial_id = self .get_config ('ex_equip_rainbow_enchance_id' )
4259 if not serial_id .isdigit ():
4360 raise AbortError ("彩装id非法" )
@@ -88,6 +105,9 @@ async def do_task(self, client: pcrclient):
88105 f"{ db .get_ex_equip_sub_status_str (client .data .ex_equips [serial_id ].ex_equipment_id , client .data .ex_equips [serial_id ].sub_status or [])} " )
89106
90107 pt_hold = self .get_config ('ex_equip_rainbow_enhance_pt_hold' )
108+ self .cache_info = self .find_cache (client .data .ex_equips [serial_id ].ex_equipment_id )
109+ if not self .cache_info :
110+ self .cache_info = Counter ()
91111
92112 while not stop :
93113 achived_max_cnt , achived_cnt = await self .get_achived_sub_status_cnt (client , serial_id , target_sub_status )
@@ -130,9 +150,12 @@ async def do_task(self, client: pcrclient):
130150 self ._log (f"共进行了{ alces_exec_cnt } 次究极炼成,消耗了:" )
131151 for consume in consume_cnt :
132152 self ._log (f" { db .get_inventory_name_san (consume )} x { consume_cnt [consume ]} " )
153+ self .save_cache (client .data .ex_equips [serial_id ].ex_equipment_id , self .cache_info )
133154 self ._log (f"最终彩装属性 " +
134155 f"{ serial_id } : { db .get_ex_equip_name (client .data .ex_equips [serial_id ].ex_equipment_id )} "
135156 f"{ db .get_ex_equip_sub_status_str (client .data .ex_equips [serial_id ].ex_equipment_id , client .data .ex_equips [serial_id ].sub_status or [])} " )
157+ else :
158+ raise AbortError (f"未知操作{ ex_equip_rainbow_enchance_action } " )
136159
137160 async def do_lock (self , client : pcrclient , serial_id : int , target_sub_status : Counter ):
138161 current_max_sub_status = Counter ()
@@ -149,12 +172,15 @@ async def do_lock(self, client: pcrclient, serial_id: int, target_sub_status: Co
149172
150173 async def decide_alces (self , client : pcrclient , alces_data : AlcesData , target_sub_status : Counter ):
151174 accept = False
152- target_key = target_sub_status .keys ()
153175 current_max_sub_status = Counter ()
176+
177+ self .cache_info ['total' ] += 1
178+
154179 for status in alces_data .sub_status :
155180 if status .is_lock :
156181 current_max_sub_status [status .status ] += 1
157182 continue
183+ self .cache_info [f"{ status .status } -{ status .step } " ] += 1
158184 if current_max_sub_status [status .status ] < target_sub_status [status .status ] and status .step == 5 :
159185 current_max_sub_status [status .status ] += 1
160186 accept = True
0 commit comments