@@ -491,10 +491,20 @@ init 5 python:
491491
492492 def is_mail_waiting_reply ():
493493 for i in persistent._maica_send_or_received_mpostals:
494- if i[" responsed_status" ] in (" received" , " failed" ):
494+ if i[" responsed_status" ] in (" received" , " failed" , " newfatal " ):
495495 return True
496496 return False
497497
498+ def maica_retry_mpostal (postal , reset_count = False ):
499+ """ Delay the next attempt without changing the original letter time."""
500+ import time
501+ postal[" retry_after" ] = (
502+ time .time () + persistent.maica_setting_dict[" mpostal_default_reply_time" ] * 60
503+ )
504+ postal[" responsed_status" ] = " delaying"
505+ if reset_count:
506+ postal[" failed_count" ] = 0
507+
498508 @ store.mas_submod_utils.functionplugin (" ch30_loop" , priority = - 100 )
499509 def push_mpostal_reply ():
500510 if (
@@ -516,6 +526,12 @@ init 5 python:
516526 if wait_replying_count > 3 :
517527 min_response_time *= 2
518528 if i[" responsed_status" ] == " delaying" :
529+ # Retries wait a full interval after the failure is acknowledged.
530+ if i.get(" retry_after" ) is not None :
531+ if time .time () >= i[" retry_after" ]:
532+ i[" responsed_status" ] = " notupload"
533+ i.pop(" retry_after" , None )
534+ continue
519535 # 时间计算
520536 last_sesh_ed = persistent.sessions.get(" last_session_end" , datetime.datetime.now())
521537
@@ -530,7 +546,7 @@ init 5 python:
530546 if time .time () - float (i[' time' ]) > min_response_time:
531547 i[" responsed_status" ] = " notupload"
532548
533- elif i[" responsed_status" ] in (" received" , " failed" ):
549+ elif i[" responsed_status" ] in (" received" , " failed" , " newfatal " ):
534550 wait_replying_count += 1
535551
536552 return
@@ -1070,9 +1086,9 @@ label .talking_start:
10701086 call clear_all
10711087 return
10721088
1073- label maica_connection_failure_dialogue (from_mspire = False , status_code = None ):
1089+ label maica_connection_failure_dialogue (from_mspire = False , status_code = None , fallback_to_current = True ):
10741090 $ ai = store.maica.maica_instance
1075- $ failure_status = ai.status if status_code is None else status_code
1091+ $ failure_status = ai.status if ( status_code is None and fallback_to_current) else status_code
10761092
10771093 if failure_status == ai.MaicaAiStatus.TOKEN_MISSING:
10781094 m 2 rusdlb " ...It seems you haven't got a token yet."
@@ -1467,35 +1483,33 @@ label maica_mpostal_received:
14671483# 在重启后加入事件队列等待推送,随机对话频率设置为0将永远不推送
14681484label maica_mpostal_replyed :
14691485 $ ev = mas_getEV(" maica_mpostal_replyed" )
1470- python :
1471-
1472- def _curr_count ():
1473- curr_queue_count = 0
1474- for i in persistent._maica_send_or_received_mpostals:
1475- if i[" responsed_status" ] == " received" :
1476- curr_queue_count += 1
1477- return curr_queue_count
1478-
14791486 $ seq = 0
1487+ $ all_seq = 0
1488+ $ mpostal_shown_count = 0
14801489
14811490 # 这里是生成结果
1482- label maica_mpostal_replyed .select_letter(is_repeat = False ):
1491+ label maica_mpostal_replyed .select_letter:
1492+ $ is_repeat = False
14831493 $ current = None
14841494 python :
14851495 for letter in persistent._maica_send_or_received_mpostals:
1486- if letter[" responsed_status" ] in [" received" , " failed" , " notupload" ]:
1496+ all_seq += 1
1497+ # If there's "notupload" in queue, we generate them together to make game experience smoother
1498+ # Though those don't actively trigger mpostal_replyed
1499+ if letter[" responsed_status" ] in [" received" , " failed" , " newfatal" , " notupload" ]:
14871500 current = letter
14881501 break
14891502 if current is None :
14901503 jump maica_mpostal_replyed.end
1491-
1492- label maica_mpostal_replyed .start:
14931504 $ seq += 1
14941505
1506+ label maica_mpostal_replyed .start:
14951507 # This method iters over ALL history letters.
14961508 # That means we cannot include "fatal"s in, because they'd come up every time before manually handled.
14971509 # So we only write reactions for non-stale status.
1498- if current[" responsed_status" ] in (" failed" ):
1510+
1511+ # newfatal is acknowledged once, then kept as fatal for manual handling.
1512+ if current[" responsed_status" ] in (" failed" , " newfatal" ):
14991513 if not is_repeat:
15001514 if seq <= 1 :
15011515 m 2l ksdlb " Uh, [player] , {w=0.5} about your last letter." # 担心
@@ -1506,12 +1520,17 @@ label maica_mpostal_replyed.start:
15061520 m 2l ksdlb " Uh, [player] , I'm really sorry but the Heaven Forest seems not working now."
15071521 m 2 ekc " Let me see..."
15081522
1509- call maica_connection_failure_dialogue(status_code = current.get(" failure_status" ))
1523+ $ failure_status = current.get(" failure_status" )
1524+ $ fallback_to_current = " failure_status" not in current
1525+ call maica_connection_failure_dialogue(status_code = failure_status, fallback_to_current = fallback_to_current)
15101526 if current[" responsed_status" ] == " failed" :
15111527 m 1 eua " It's okay, I'll remember to write you back as soon as you address that issue."
1512- $ current[" responsed_status" ] = " notupload"
1528+ $ maica_retry_mpostal(current)
1529+ elif current[" responsed_status" ] == " newfatal" :
1530+ m 1 eksdla " I tried several times on this one but without success. But you can still use the 'Resend mail' button in 'Reread MPostal letters' menu, to let me try again."
1531+ $ current[" responsed_status" ] = " fatal"
15131532
1514- elif current[" responsed_status" ] in ( " received" ) :
1533+ elif current[" responsed_status" ] == " received" :
15151534 if seq <= 1 :
15161535 m 7 hub " Oh, [player] ! {w=0.5} I've finished writing you my reply!"
15171536 else :
@@ -1522,8 +1541,9 @@ label maica_mpostal_replyed.start:
15221541
15231542 call maica_mpostal_show(current[" responsed_content" ])
15241543 $ current[" responsed_status" ] = " readed"
1544+ $ mpostal_shown_count += 1
15251545
1526- elif current[" responsed_status" ] in ( " notupload" ) :
1546+ elif current[" responsed_status" ] == " notupload" :
15271547 if seq <= 1 :
15281548 m 3 eksdlb " Oh, your letter [player] ! I was kind of in a hurry so it's not completely ready yet." # 尴尬
15291549 else :
@@ -1533,26 +1553,29 @@ label maica_mpostal_replyed.start:
15331553 show black with dissolve
15341554 call maica_mpostal_read
15351555
1536- if _return == " failed " :
1556+ if current[ " responsed_status " ] != " received " :
15371557 hide black with dissolve
1538- # 直接重新开始, 失败的信会提示失败, 理论应与current一致
1539- jump maica_mpostal_replyed.select_letter(is_repeat = True )
1558+ # The batch result belongs to all letters; inspect this letter only.
1559+ $ is_repeat = True
1560+ jump maica_mpostal_replyed.start
15401561
15411562 m " Okay, here it is!"
15421563 hide black with dissolve
15431564 call maica_mpostal_show(current[" responsed_content" ])
15441565 $ current[" responsed_status" ] = " readed"
1566+ $ mpostal_shown_count += 1
15451567
15461568 jump maica_mpostal_replyed.select_letter
15471569
15481570label maica_mpostal_replyed .end:
1571+ if not mpostal_shown_count:
1572+ return " no_unlock"
15491573 if ev.shown_count <= 2 :
15501574 m 2l ksdlb " I have to admit that I'm not quite used to writing here, but I hope it's not too bad!"
15511575 elif ev.shown_count <= 4 :
15521576 m 2l ksdlb " May not as good as my former poems though, but I really tried. Hope you like it!"
15531577 else :
1554- $ it = renpy.substitute(_(" it" ) if seq <= 1 else _(" these" ))
1555- m 2 tublu " I have to assume you're loving {it} now, since you did write to me a lot!"
1578+ m 2 tublu " I have to assume you're loving these now, since you did write to me a lot!"
15561579 m 5 ekbsa " And welcome writing to me again anytime you like!"
15571580 return " no_unlock"
15581581
0 commit comments