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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#!/usr/bin/python
# -*- coding: GBK -*-
#
#
##@package PlayerFB.py
#
# @todo:Íæ¼Ò¸±±¾
#
# @author hxp
# @date 2013-08-20
# @version 2.0
# @note:
# @change: "2014-08-01 00:30" hxp Ôö¼ÓÇå³ý¸±±¾Àäȴʱ¼äÂß¼­
# @change: "2014-12-08 17:00" hxp Ôö¼ÓÇ帱±¾CD×êʯÏû·ÑÁ÷Ïò
# @change: "2015-02-10 22:30" hxp Ôö¼Ó×êʯÏûºÄÀàÐÍʼþ»ã±¨
# @change: "2015-06-29 18:00" xdh Ôö¼ÓÍæ¼Ò¸±±¾·­ÅÆÈë¿Ú
# @change: "2016-02-30 17:00" hxp ÁìÖ÷°ÔÒµ¡¢¶ñħÊÔÁ¶
# @change: "2016-03-20 15:30" hxp ¸±±¾¶à±¶½±Àø£»¹«¹²CD¸±±¾É¨µ´
# @change: "2016-04-19 17:30" xdh ¸±±¾É¨µ´Ëã»îÔ¾¶È
# @change: "2016-04-26 15:30" hxp ¶à±¶½±Àø°Ù·Ö±È¸ÄΪ½±ÀøµÈ¼¶£» É¨µ´Ôö¼ÓÇëÇóCD
# @change: "2016-08-15 11:20" xdh ¸±±¾É¨µ´ÏûºÄµÀ¾ß
# @change: "2016-12-02 11:00" xdh ¸±±¾É¨µ´Ôö¼ÓÈËÎïµÈ¼¶ÅжÏ
#------------------------------------------------------------------------------ 
#"""Version = 2016-12-02 11:00"""
#------------------------------------------------------------------------------ 
import IPY_GameWorld
import PlayerControl
import GameWorld
import FBCommon
import ChConfig
import FBLogic
import PlayerSuccess
import ItemCommon
import IpyGameDataPY
import ShareDefine
import GameFuncComm
import NPCCommon
 
#---------------------------------------------------------------------
def OnLogin(curPlayer):
    return
 
## Íæ¼Ò¸±±¾ÐÐΪ·â°ü A5 08
#  @param playerIndex Íæ¼ÒË÷Òý  
#  @param clientData ¿Í»§¶Ë·â°ü  
#  @param tick Ê±¼ä
#  @return None
def OnDoFBAction(playerIndex, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
    actionType = clientData.ActionType # ÐÐΪÀàÐÍ
    actionInfo = clientData.ActionInfo # ÐÐΪÐÅÏ¢
    FBLogic.DoFBAction(curPlayer, actionType, actionInfo, tick)
    return
 
#//A5 05 Íæ¼Ò¿ªÊ¼¸±±¾É¨µ´ #tagCMBeginFBWipeOut
#
#struct    tagCMBeginFBWipeOut
#{
#    tagHead         Head;
#    DWORD        MapID;
#    WORD        LineID;
#    BYTE        Cnt;    // É¨µ´´ÎÊý
#    BYTE        IsFinish;    // ÊÇ·ñÁ¢¼´Íê³É; 0-·ñ£»1-»¨Ç®Á¢¼´Íê³É£»2-¿Í»§¶Ë×ÔÐе¹¼ÆÊ±¼äµ½ºó·¢ËÍ2´ú±íÁìȡɨµ´Íê³É½±Àø
#    DWORD        DataEx;    //¸½´øÐÅÏ¢
#    BYTE        IsLittleHelper;    // ÊÇ·ñСÖúÊÖɨµ´
#};
def OnPlayerFBWipeOut(playerIndex, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
    
    #if not GameWorld.CheckPlayerTick(curPlayer, ChConfig.TYPE_Player_Tick_BeginFBWipeOut, tick):
    #    GameWorld.DebugLog("Íæ¼Ò¸±±¾É¨µ´ÇëÇóCDÖÐ...", curPlayer.GetPlayerID())
    #    return
    
    mapID = clientData.MapID
    lineID = clientData.LineID
    cnt = clientData.Cnt
    #isFinish = clientData.IsFinish
    isFinish = 1 # ÔÝʱĬÈÏ1£¬Ö®ºóÓÐÐèҪɨµ´µÈ´ýµÄÔÙ˵
    dataEx = clientData.DataEx
    isLittleHelper = clientData.IsLittleHelper
    if isLittleHelper:
        if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_LittleHelper):
            GameWorld.DebugLog("Íæ¼ÒûÓÐСÖúÊÖ¹¦ÄÜȨÏÞ£¡", curPlayer.GetPlayerID())
            return
    
    if cnt <= 0:
        return
    
    fbIpyData = FBCommon.GetFBIpyData(mapID)
    if FBCommon.GetRecordMapID(GameWorld.GetMap().GetMapID()) == FBCommon.GetRecordMapID(mapID):
        if fbIpyData and fbIpyData.GetDayTimes():#ûÓÐÏÞÖÆ½øÈë´ÎÊýµÄ²»ÏÞÖÆÔÚÄ¿±êµØÍ¼É¨µ´
            GameWorld.DebugLog("Íæ¼ÒÔÚɨµ´Ä¿±êµØÍ¼ÖУ¬ÎÞ·¨É¨µ´£¡mapID=%s" % mapID)
            return
    
    
    fbLineIpyData = FBCommon.GetFBLineIpyData(mapID, lineID)
    if not fbLineIpyData:
        GameWorld.DebugLog("ÕÒ²»µ½¸Ã¸±±¾Ïß·£¬ÎÞ·¨É¨µ´£¡mapID=%s, lineID=%s" % (mapID, lineID))
        return
    
    if FBCommon.CheckCanEnterFBComm(curPlayer, mapID, lineID, fbIpyData, fbLineIpyData, cnt) != ShareDefine.EntFBAskRet_OK:
        return
    costMoneyList = []
    sweepCostindexList = []
    sweepCostCnt = 0
    itemPack = curPlayer.GetItemManager().GetPack(IPY_GameWorld.rptItem)
    
    if fbLineIpyData:
        #ɨµ´µÈ¼¶ÅжÏ
        sweepLVLimit = fbLineIpyData.GetSweepLVLimit()
        if sweepLVLimit and curPlayer.GetLV() < sweepLVLimit:
            GameWorld.DebugLog('Íæ¼Ò¸±±¾É¨µ´,µÈ¼¶²»×㣡mapID=%s, lineID=%s, playerLV=%s, sweepLVLimit=%s' 
                               % (mapID, lineID, curPlayer.GetLV(), sweepLVLimit), curPlayer.GetPlayerID())
            return
        
        #ɨµ´µÀ¾ßÅжϣ¬Ð¡ÖúÊÖ²»ÏûºÄɨµ´µÀ¾ß
        sweepItemID = fbLineIpyData.GetSweepItemID()
        if sweepItemID and not isLittleHelper:
            sweepItemCnt = fbLineIpyData.GetSweepCostCnt()
            sweepCostCnt = sweepItemCnt * cnt
            #isEnough, sweepCostindexList = ItemCommon.GetItem_FromPack_ByID(sweepItemID, itemPack, sweepCostCnt)
            isEnough, sweepCostindexList, hasBind, lackCnt = ItemCommon.GetItem_FromPack_ByID_ExEx(sweepItemID, itemPack, sweepCostCnt)
            if not isEnough:
                itemPrice = ItemCommon.GetShopItemPrice(sweepItemID, IPY_GameWorld.TYPE_Price_Gold_Money)
                if itemPrice:
                    costMoney = itemPrice * lackCnt
                    costMoneyList = PlayerControl.HaveMoneyEx(curPlayer, ShareDefine.TYPE_Price_Gold_Paper_Money, costMoney)
                if not costMoneyList:
                    GameWorld.DebugLog("ɨµ´ÏûºÄµÀ¾ß²»×ã, mapID=%s,lineID=%s,sweepItemID=%s,sweepCostCnt=%s" 
                                   % (mapID, lineID, sweepItemID, sweepCostCnt), curPlayer.GetPlayerID())
                    return
    
    # ¸±±¾ÊÇ·ñ¿Éɨµ´, ÕâÀïÖ»Åжϸ±±¾×ÔÉíµÄÌØÊâÌõ¼þ, ¹«¹²Ìõ¼þÉÏÃæÒѾ­ÅжÏ
    if not FBLogic.OnPlayerFBSweepAsk(curPlayer, mapID, lineID, cnt, isFinish, dataEx):
        return
    
    PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_FeastRedPack_FBSweep, 1, [mapID])
    
    #¿Û³ýɨµ´µÀ¾ß
    if sweepCostindexList and sweepCostCnt:
        ItemCommon.ReduceItem(curPlayer, itemPack, sweepCostindexList, sweepCostCnt, False, 'FBSweepCostItem')
    if costMoneyList:
        infoDict = {"MapID":mapID, "LineID":lineID, 'SweepCount':cnt}
        for moneyType, moneyNum in costMoneyList:
            if not PlayerControl.PayMoney(curPlayer, moneyType, moneyNum, ChConfig.Def_Cost_FBSweep, infoDict):
                return False, hasBind
    
    #ÐèÏȿ۳ýÃÅÆ±, ÔÙÔö¼Ó´ÎÊý, ·ñÔò¿ÉÄܵ¼Ö¿۳ýµÄÊýÁ¿´íÎó
    FBCommon.DelFBEnterTicket(curPlayer, mapID, lineID, cnt)
        
    #Ôö¼Ó¸±±¾½øÈë´ÎÊý
    if fbIpyData and fbIpyData.GetDayTimes():
        FBCommon.AddEnterFBCount(curPlayer, mapID, cnt)
        
    #ɨµ´½á¹û¸ø½±ÀøµÈ
    FBLogic.OnPlayerFBSweepResult(curPlayer, mapID, lineID, cnt, isFinish, dataEx)
    return
 
#// B1 08 ¿ìËÙÒ»¼ü¹ý¹Ø¸±±¾ #tagCMFBQuickPass
#
#struct    tagCMFBQuickPass
#{
#    tagHead         Head;
#    DWORD        MapID;
#    WORD        LineID;
#};
def OnFBQuickPass(playerIndex, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
    playerID = curPlayer.GetPlayerID()
    mapID = clientData.MapID
    lineID = clientData.LineID
    GameWorld.DebugLog("Íæ¼ÒÇëÇó¿ìËÙÒ»¼ü¹ý¹Ø¸±±¾: mapID=%s,lineID=%s" % (mapID, lineID), playerID)
    
    fbIpyData = FBCommon.GetFBIpyData(mapID)
    fbLineIpyData = FBCommon.GetFBLineIpyData(mapID, lineID)
    if FBCommon.CheckCanEnterFBComm(curPlayer, mapID, lineID, fbIpyData, fbLineIpyData) != ShareDefine.EntFBAskRet_OK:
        return
    
    reqRet = FBLogic.OnPlayerFBQuickPass(curPlayer, mapID, lineID)
    if not reqRet or len(reqRet) != 2:
        GameWorld.DebugLog("ÎÞ·¨Ò»¼ü¹ý¹Ø¸±±¾: mapID=%s,lineID=%s" % (mapID, lineID), playerID)
        return
    bossID, quickCnt = reqRet
    if bossID:
        npcData = GameWorld.GetGameData().FindNPCDataByID(bossID)
        if not npcData:
            return
        npcFightPower = NPCCommon.GetSuppressFightPower(npcData)
        quickNeedRatio = IpyGameDataPY.GetFuncCfg("FBQuickPass", 1)
        quickNeedFightPower = int(npcFightPower * quickNeedRatio)
        curFightPower = PlayerControl.GetFightPower(curPlayer)
        if quickNeedFightPower and curFightPower < quickNeedFightPower:
            GameWorld.DebugLog("ÎÞ·¨Ò»¼ü¹ý¹Ø¸±±¾! Õ½Á¦ÏÞÖÆ: mapID=%s,lineID=%s,bossID=%s,npcFightPower=%s,quickNeedFightPower=%s > %s" 
                               % (mapID, lineID, bossID, npcFightPower, quickNeedFightPower, curFightPower), playerID)
            PlayerControl.NotifyCode(curPlayer, 'TaskFeedback4')
            return
        
    #Ôö¼Ó¸±±¾½øÈë´ÎÊý
    if fbIpyData and fbIpyData.GetDayTimes() and quickCnt:
        # Ìø¹Ø³¬¹ý1¹ØµÄÒªÖØÐÂÑéÖ¤ÏÂ
        if quickCnt > 1 and FBCommon.CheckCanEnterFBComm(curPlayer, mapID, lineID, fbIpyData, fbLineIpyData, quickCnt) != ShareDefine.EntFBAskRet_OK:
            return
        FBCommon.AddEnterFBCount(curPlayer, mapID, quickCnt)
        
    #ɨµ´½á¹û¸ø½±ÀøµÈ
    FBLogic.OnPlayerFBQuickPassResult(curPlayer, mapID, lineID)
    return