@@ -360,25 +360,29 @@ async def live_schedule(context: idol.SchoolIdolUserParams) -> LiveScheduleRespo
360360
361361
362362DEBUG_SERVER_SCORE_CALCULATE = False
363- DEBUG_SERVER_CONSUME_LP = True
364363
365364
366365@idol .register ("live" , "partyList" )
367366async def live_partylist (context : idol .SchoolIdolUserParams , request : LivePartyListRequest ) -> LivePartyListResponse :
368367 current_user = await user .get_current (context )
369368
370- # Check LP
369+ # Check live info
371370 live_info = await live .get_live_info_table (context , request .live_difficulty_id )
372371 if live_info is None :
373372 raise idol .error .by_code (idol .error .ERROR_CODE_LIVE_NOT_FOUND )
374- if DEBUG_SERVER_CONSUME_LP :
375- if live_info .capital_type == 2 :
373+
374+ # Check LP
375+ cap_value = live_info .capital_value * request .lp_factor
376+ match live_info .capital_type :
377+ case 1 :
378+ if not user .has_energy (current_user , cap_value ):
379+ if current_user .energy_max < cap_value :
380+ raise idol .error .by_code (idol .error .ERROR_CODE_LIVE_NOT_ENOUGH_MAX_ENERGY )
381+ else :
382+ raise idol .error .by_code (idol .error .ERROR_CODE_LIVE_NOT_ENOUGH_CURRENT_ENERGY )
383+ case _:
376384 # TODO
377385 raise idol .error .by_code (idol .error .ERROR_CODE_LIVE_NOT_ENOUGH_EVENT_POINT )
378- if live_info .capital_type == 1 and not user .has_energy (
379- current_user , live_info .capital_value * request .lp_factor
380- ):
381- raise idol .error .by_code (idol .error .ERROR_CODE_LIVE_NOT_ENOUGH_CURRENT_ENERGY )
382386
383387 live_setting = await live .get_live_setting (context , live_info .live_setting_id )
384388 if live_setting is None :
@@ -488,15 +492,22 @@ async def live_play(context: idol.SchoolIdolUserParams, request: LivePlayRequest
488492 live_info = await live .get_live_info_table (context , request .live_difficulty_id )
489493 if live_info is None :
490494 raise idol .error .by_code (idol .error .ERROR_CODE_LIVE_NOT_FOUND )
491- if DEBUG_SERVER_CONSUME_LP :
492- cap_value = live_info .capital_value * request .lp_factor
493- if live_info .capital_type == 2 :
495+
496+ # Check LP
497+ cap_value = live_info .capital_value * request .lp_factor
498+ match live_info .capital_type :
499+ case 1 :
500+ if not user .has_energy (current_user , cap_value ):
501+ if current_user .energy_max < cap_value :
502+ raise idol .error .by_code (idol .error .ERROR_CODE_LIVE_NOT_ENOUGH_MAX_ENERGY )
503+ else :
504+ raise idol .error .by_code (idol .error .ERROR_CODE_LIVE_NOT_ENOUGH_CURRENT_ENERGY )
505+ case _:
494506 # TODO
495507 raise idol .error .by_code (idol .error .ERROR_CODE_LIVE_NOT_ENOUGH_EVENT_POINT )
496- if live_info .capital_type == 1 and not user .has_energy (current_user , cap_value ):
497- raise idol .error .by_code (idol .error .ERROR_CODE_LIVE_NOT_ENOUGH_CURRENT_ENERGY )
498- # Consume LP
499- user .sub_energy (current_user , cap_value )
508+
509+ # Consume LP
510+ user .sub_energy (current_user , cap_value )
500511
501512 live_setting = await live .get_live_setting_from_difficulty_id (context , request .live_difficulty_id )
502513 if live_setting is None :
0 commit comments