1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package GameWorldLogic.FBProcess.GameLogic_MainLevelBoss
#
# @todo:Ö÷Ï߹ؿ¨boss
# @author hxp
# @date 2025-9-2
# @version 1.0
#
# ÏêϸÃèÊö: Ö÷Ï߹ؿ¨boss
#
#-------------------------------------------------------------------------------
#"""Version = 2025-9-2 ÏÂÎç5:07:12"""
#-------------------------------------------------------------------------------
 
import GameWorld
import IpyGameDataPY
import PlayerControl
import ItemControler
 
import FBCommon
 
def OnTurnFightRequest(curPlayer, mapID, funcLineID, tagType, tagID, valueList):
    ## »ØºÏÕ½¶·ÇëÇó 
    playerID = curPlayer.GetPlayerID()
    chapterID, levelNum, wave = PlayerControl.GetMainLevelPassInfo(curPlayer)
    #levelID = chapterID * 100 + levelNum
    #if funcLineID != levelID:
    #    return
    GameWorld.DebugLog("ÇëÇóÌôÕ½¹Ø¿¨Boss! passInfo: chapterID=%s,levelNum=%s,wave=%s" % (chapterID, levelNum, wave), playerID)
    chapterIpyData = IpyGameDataPY.GetIpyGameData("MainChapter", chapterID)
    if not chapterIpyData:
        return
    levelIpyData = IpyGameDataPY.GetIpyGameData("MainLevel", chapterID, levelNum)
    if not levelIpyData:
        return
    
    nowChapterID, nowLevelNum, _ = PlayerControl.GetMainLevelNowInfo(curPlayer)
    if chapterID != nowChapterID or levelNum != nowLevelNum:
        '''Ò»°ãÓÐÁ½ÖÖÇé¿ö»áµ¼ÖÂ
        1. ÀíÂÛÉÏÍæ¼Òµ±Ç°Ë¢¹ÖµÄÕ½ڹؿ¨Ò»¶¨ÊÇÓë¹ý¹ØµÄÕ½ڹؿ¨ÊÇÒ»Öµģ¬³ýÁËÈ«²¿Õ½ÚÒÑͨ¹Ø
                                µ±Í¨¹ØÊ±£¬Òѹý¹ØµÄ¼Ç¼»á±»ÉèÖÃΪÏÂÒ»Õ½ڵÚ1¹Ø£¨°æ±¾¹Ø¿¨±íʵ¼Ê²»´æÔڸùؿ¨£©
                                µ«Êǵ±Ç°Ë¢¹ÖµÄ»¹Êǰ汾µÄ×îºóÒ»¹Ø£¬¹Ì»á³öÏÖ²»Ò»ÖµÄÇé¿ö
                                ÔÚÔö¼ÓÕ½ڹؿ¨Ð°汾¸üкóÍæ¼ÒÖØµÇ»á×Ô¶¯½øÐÐÐÞ¸´µ±Ç°Ë¢¹Ö½ø¶ÈΪ×îÐÂÕ½ڵÚ1¹Ø
        2. ÕæµÄ³öÏÖÎÊÌâÁË£¬¿ÉÄÜÊÇbugÒýÆð£¬ÕâÖÖÇé¿öÖ»ÄܽøÐÐbugÐÞ¸´¼°Õë¶ÔÒì³£Õ˺ÅÌØÊâ´¦Àí£¬»òÕßÖØµÇºóÒ²»á×Ô¶¯½øÐÐÐÞÕý
        '''
        GameWorld.ErrLog("µ±Ç°Ë¢¹ÖÕ½ڹؿ¨ÓëÌôÕ½µÄbossÕ½ڹؿ¨²»Ò»Ö£¬ÎÞ·¨ÌôÕ½! chapterID=%s,levelNum=%s,nowChapterID=%s,nowLevelNum=%s" 
                         % (chapterID, levelNum, nowChapterID, nowLevelNum), playerID)
        return
    
    # ±¾¹Ø¿¨×î´ó²¨Êý
    waveMax = 6
    while waveMax >= 1 and (not hasattr(levelIpyData, "GetWaveLineupIDList%s" % waveMax) or not getattr(levelIpyData, "GetWaveLineupIDList%s" % waveMax)()):
        waveMax -= 1
        
    if wave < waveMax:
        GameWorld.DebugLog("×îºóÒ»²¨Î´Í¨¹ý£¬ÎÞ·¨ÌôÕ½±¾¹Øboss! passWave=%s < %s" % (wave, waveMax))
        return
    
    return True
 
def GetFBNPCLineupInfo(curPlayer, mapID, funcLineID):
    ## »ñÈ¡NPCÕóÈÝÏà¹Ø
    # @return: npcLineupIDList, strongerLV, difficulty
    
    chapterID, levelNum, _ = PlayerControl.GetMainLevelPassInfo(curPlayer)
    levelIpyData = IpyGameDataPY.GetIpyGameData("MainLevel", chapterID, levelNum)
    if not levelIpyData:
        return
    
    npcLineupIDList = levelIpyData.GetBossLineupIDList() # Boss²¨ÕóÈÝIDÁÐ±í£¬Ð¡¶Ó1ÕóÈÝID|С¶Ó2ÕóÈÝID|...
    strongerLV = levelIpyData.GetNPCLV()
    difficulty = levelIpyData.GetDifficulty()
    
    return npcLineupIDList, strongerLV, difficulty
 
def OnTurnFightOver(curPlayer, turnFight, mapID, funcLineID, overMsg):
    ## »ØºÏÕ½¶·½áÊø
    if not curPlayer:
        return
    
    playerID = curPlayer.GetPlayerID()
    #winFaction = turnFight.winFaction
    isWin = turnFight.isWin
    
    chapterID, levelNum, _ = PlayerControl.GetMainLevelPassInfo(curPlayer)
    if not isWin:
        nowValue = PlayerControl.GetMainLevelNowValue(curPlayer)
        GameWorld.DebugLog("Ö÷ÏßbossÕ½¶·Ê§°Ü£¡±£³Öµ±Ç°Ë¢¹Ö²¨½ø¶È²»±ä! nowValue=%s" % nowValue, playerID)
        return
    
    if turnFight.haveNextLineup():
        GameWorld.DebugLog("Ö÷ÏßbossС¶ÓÕ½¶·Ê¤Àû£¬ÓÐÏÂһС¶Ó! chapterID=%s,levelNum=%s,lineupIndex=%s,lineupIDList=%s" 
                           % (chapterID, levelNum, turnFight.lineupIndex, turnFight.lineupIDList), playerID)
        return
    
    isAllPass = False # ÊÇ·ñͨ¹Ø
    if IpyGameDataPY.GetIpyGameDataNotLog("MainLevel", chapterID, levelNum + 1):
        nextChapterID, nextLevelNum = chapterID, levelNum + 1
        GameWorld.DebugLog("Ö÷Ïßboss²¨Õ½¶·Ê¤Àû£¡ÏÂÒ»¹Ø! chapterID=%s,levelNum=%s,nextLevelNum=%s" 
                           % (chapterID, levelNum, nextLevelNum), playerID)
    elif IpyGameDataPY.GetIpyGameDataNotLog("MainLevel", chapterID + 1, 1):
        nextChapterID, nextLevelNum = chapterID + 1, 1
        GameWorld.DebugLog("Ö÷Ïßboss²¨Õ½¶·Ê¤Àû£¡ÏÂÒ»ÕÂ! chapterID=%s,levelNum=%s,nextChapterID=%s,nextLevelNum=%s" 
                           % (chapterID, levelNum, nextChapterID, nextLevelNum), playerID)
    else:
        # ÒÑͨ¹ØµÄÔÝʱÏȱ£³Ö²»±ä
        # ×¢Òâ·À·¶×îºóÒ»¹Ø½±ÀøÖظ´»ñµÃ
        nextChapterID, nextLevelNum = chapterID + 1, 1
        GameWorld.DebugLog("Ö÷Ïßboss²¨Õ½¶·Ê¤Àû£¡ÒÑͨ¹Ø! chapterID=%s,levelNum=%s,nextChapterID=%s,nextLevelNum=%s" 
                            % (chapterID, levelNum, nextChapterID, nextLevelNum), playerID)
        isAllPass = True
        
    updPassValue = PlayerControl.SetMainLevelPassInfo(curPlayer, nextChapterID, nextLevelNum, 0)
    if isAllPass:
        # ÒÑͨ¹ØµÄË¢¹Ö½ø¶È±£³Ö²»±ä
        updNowValue = PlayerControl.GetMainLevelNowValue(curPlayer)
        GameWorld.DebugLog("ÒÑͨ¹ØµÄË¢¹Ö½ø¶È±£³Ö²»±ä: updNowValue=%s" % updNowValue, playerID)
    else:
        updNowValue = PlayerControl.SetMainLevelNowInfo(curPlayer, nextChapterID, nextLevelNum, 1)
        GameWorld.DebugLog("Ϊͨ¹ØµÄË¢¹Ö½ø¶ÈÉèÖÃΪÏÂÒ»¹ØµÄµÚ1²¨: updNowValue=%s" % updNowValue, playerID)
    GameWorld.DebugLog("updPassValue=%s,updNowValue=%s" % (updPassValue, updNowValue), playerID)
    
    # ·¢·Å¹ý¹Ø½±Àø
    levelIpyData = IpyGameDataPY.GetIpyGameData("MainLevel", chapterID, levelNum)
    if not levelIpyData:
        return
    itemList = levelIpyData.GetAwardItemList()
    GameWorld.DebugLog("¹ý¹Ø½±Àø: chapterID=%s,levelNum=%s,itemList=%s" % (chapterID, levelNum, itemList), playerID)
    
    ItemControler.GivePlayerItemOrMail(curPlayer, itemList, event=["MainLevelBoss", False, {}], isNotifyAward=False)
    
    overMsg.update({FBCommon.Over_itemInfo:FBCommon.GetJsonItemList(itemList)})
    return