xdh
2019-05-10 c2a7d0326f1e779bf6ee184e60d04dd7d43b576b
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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package GameWorldLogic.FBProcess.GameLogic_CrossGrassland
#
# @todo:¿ç·þ²ÝÔ°
# @author hxp
# @date 2019-04-15
# @version 1.0
#
# ÏêϸÃèÊö: ¿ç·þ²ÝÔ°
#
#-------------------------------------------------------------------------------
#"""Version = 2019-04-15 16:30"""
#-------------------------------------------------------------------------------
 
import GameWorld
import GameWorldProcess
import PlayerFairyDomain
import NPCCustomRefresh
import IpyGameDataPY
import PyGameData
import NPCCommon
import PlayerControl
import ChConfig
import FBCommon
 
FBDict_SyncFBNPC = 'SyncFBNPC' #ÊÇ·ñÐèҪͬ²½¸±±¾NPC
 
def DoResetCrossGrassland(curPlayer, eventType, fdeventID):
    ## ²ÝÔ°ÖØÖÃ
    
    resetCollectType = 10 + eventType
    NPCCommon.DoResetCollectNPCTimeByType(curPlayer, [resetCollectType])
    
    # ±¦Ïä¹Ö´ÎÊýÖØÖÃ
    if eventType == PlayerFairyDomain.FDEventType_GrasslandXian:
        npcID = IpyGameDataPY.GetFuncCfg("CrossGrasslandCfg", 1)
        if npcID:
            NPCCommon.UpdateNPCAttackCount(curPlayer, npcID, 0)
            
    return
 
## ÊÇ·ñÐèÒª×ö½øÈ븱±¾Í¨Óüì²éÌõ¼þÂß¼­£¬Ä¬ÈÏÐèÒª¼ì²é
def OnNeedCheckCanEnterFBComm(curPlayer, mapID, lineID):
    curState = PlayerFairyDomain.GetFairyDomainFBEventState(curPlayer, mapID, lineID)
    return curState != PlayerFairyDomain.FDEventState_Visiting
 
def OnEnterFBEvent(curPlayer, mapID, lineID, tick):
    curState = PlayerFairyDomain.GetFairyDomainFBEventState(curPlayer, mapID, lineID)
    return curState in [PlayerFairyDomain.FDEventState_CanVisit, PlayerFairyDomain.FDEventState_Visiting]
 
## ½øÈë¿ç·þ¸±±¾×¢²áÊý¾ÝǰÂß¼­
## @return: ÊÇ·ñ¿ÉÒÔ×¢²áǰÍù¿ç·þ¸±±¾£¬´Îº¯ÊýÖпÉÒÔдһЩ¿Û³ýÏûºÄÂß¼­µÈ
def OnRegEnterCrossFB(curPlayer, mapID, lineID):
    curState = PlayerFairyDomain.GetFairyDomainFBEventState(curPlayer, mapID, lineID)
    if curState == PlayerFairyDomain.FDEventState_CanVisit:
        delResult = FBCommon.DelFBEnterTicket(curPlayer, mapID, lineID)
        isOK = delResult[0]
        if not isOK:
            return False
        return PlayerFairyDomain.SetFairyDomainFBEventState(curPlayer, mapID, lineID, PlayerFairyDomain.FDEventState_Visiting)
    
    if curState == PlayerFairyDomain.FDEventState_Visiting:
        return True
    
    return False
 
## ¿ç·þ¹¦ÄÜÏß·Êý¾Ý»º´æ£¬Ï´οªÆôͬÑù¹¦ÄÜÏß·ʱ»áÓøÃÊý¾Ý½øÐл¹Ô­Ö®Ç°µÄ¸±±¾×´Ì¬
def OnGetCrossFuncLineDataCache():
    refreshNPCInfo = NPCCustomRefresh.GetCopyMapRandomRefreshNPCInfo()
    return refreshNPCInfo
 
## ¿ªÆô¸±±¾
def OnOpenFB(tick):
    gameWorld = GameWorld.GetGameWorld()
    realMapID, copyMapID = gameWorld.GetRealMapID(), gameWorld.GetCopyMapID()
    key = (realMapID, copyMapID)
    if key in PyGameData.g_crossFuncLineDataCache:
        refreshNPCInfo = PyGameData.g_crossFuncLineDataCache.pop(key)
        GameWorld.DebugLog("¸±±¾¿ªÆô¸ù¾Ý±£´æµÄÐéÄâÏß·±êÊÔµãË¢¹ÖÐÅϢˢ¹Ö: realMapID=%s,copyMapID=%s,refreshNPCInfo=%s" % (realMapID, copyMapID, refreshNPCInfo))
        NPCCustomRefresh.OnFBOpenSetRandomRefreshNPCInfo(refreshNPCInfo, tick)
        
    return
 
## ½ø¸±±¾
def DoEnterFB(curPlayer, tick):
    playerID = curPlayer.GetPlayerID()
    zoneID = FBCommon.GetCrossDynamicLineMapZoneID()
    funcLineID = FBCommon.GetCrossDynamicLineMapFuncLineID()
    crossMapID = PlayerControl.GetCrossMapID(curPlayer)
    GameWorld.Log("DoEnterFB zoneID=%s,funcLineID=%s,crossMapID=%s" % (zoneID, funcLineID, crossMapID), playerID)
    FBCommon.Sync_FBNPC(curPlayer=curPlayer)
    if crossMapID == ChConfig.Def_FBMapID_CrossGrasslandXian:
        boxNPCID = IpyGameDataPY.GetFuncCfg("CrossGrasslandCfg", 1)
        if boxNPCID:
            NPCCommon.SyncNPCAttackCount(curPlayer, [boxNPCID])
    return
 
## ¸±±¾×ÜÂß¼­¼ÆÊ±Æ÷
def OnProcess(tick):
    gameFB = GameWorld.GetGameFB()
    if gameFB.GetGameFBDictByKey(FBDict_SyncFBNPC):
        gameFB.SetGameFBDict(FBDict_SyncFBNPC, 0)
        FBCommon.Sync_FBNPC()
        
    return
#
### ¹Ø±Õ¸±±¾
#def OnCloseFB(tick):
#    return
#
### Íæ¼ÒÍ˳ö¸±±¾
#def DoExitFB(curPlayer, tick):
#    return
 
##Íæ¼ÒÖ÷¶¯À뿪¸±±¾.
def DoPlayerLeaveFB(curPlayer, tick):
    
    gameWorld = GameWorld.GetGameWorld()
    #×îºóÒ»ÈËÍ˳ö¸±±¾Ôò¹Ø±ÕµØÍ¼
    if gameWorld.GetMapCopyPlayerManager().GetPlayerCount() == 1:
        GameWorldProcess.CloseFB(tick)
        
    return
 
## ¿Í»§¶Ë½øÈë×Ô¶¨Ò峡¾°
def OnEnterCustomScene(curPlayer, mapID, lineID):
    PlayerFairyDomain.SetFairyDomainFBEventState(curPlayer, mapID, lineID, PlayerFairyDomain.FDEventState_Visiting)
    return
 
def DoCheckUpdateGrasslandEnd(curPlayer):
    ## ¼ì²é¸üвÝÔ°ÒѰݷÃÍê³É
    
    grasslandMapIDList = [ChConfig.Def_FBMapID_CrossGrasslandLing, ChConfig.Def_FBMapID_CrossGrasslandXian]
    crossMapID = PlayerControl.GetCrossMapID(curPlayer)
    clientCustomSceneMapID = curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_ClientCustomSceneMapID)
    if crossMapID in grasslandMapIDList:
        mapID = crossMapID
        lineID = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_ReqCrossFBFuncLine)
    elif clientCustomSceneMapID in grasslandMapIDList:
        mapID = clientCustomSceneMapID
        lineID = curPlayer.GetDictByKey(ChConfig.Def_PlayerKey_ClientCustomSceneLineID)
    else:
        return
    
    # ²É¼¯´ÎÊýÊÇ·ñÒÑÓÃÍê
    collNPCIpyDataList = IpyGameDataPY.GetIpyGameDataListNotLog("MapRefreshNPC", mapID)
    if not collNPCIpyDataList:
        return
    
    for collIpyData in collNPCIpyDataList:
        npcIDList = collIpyData.GetNPCIDList()
        for npcID in npcIDList:
            collectNPCIpyData = IpyGameDataPY.GetIpyGameData("CollectNPC", npcID)
            if not collectNPCIpyData:
                return
            limitMaxTime = collectNPCIpyData.GetMaxCollectCount()
            totalCollTime = NPCCommon.GetTodayCollectCount(curPlayer, npcID)
            if totalCollTime < limitMaxTime:
                GameWorld.DebugLog("²ÝÔ°NPC²É¼¯´ÎÊýδÓÃÍê! npcID=%s,totalCollTime=%s < limitMaxTime=%s" % (npcID, totalCollTime, limitMaxTime))
                return
            
    # ±¦Ïä¹Ö¹¥»÷´ÎÊýÊÇ·ñÒÑÓÃÍê
    if mapID == ChConfig.Def_FBMapID_CrossGrasslandXian:
        boxNPCID = IpyGameDataPY.GetFuncCfg("CrossGrasslandCfg", 1)
        boxNPCIpyData = IpyGameDataPY.GetIpyGameDataNotLog("TreasureNPC", boxNPCID)
        if not boxNPCIpyData:
            return
        attackCountDropWeightInfo = boxNPCIpyData.GetAttackCountDropWeightInfo()
        if not attackCountDropWeightInfo:
            return
        maxAttackCount = max(attackCountDropWeightInfo)
        attackCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_NPCAttackCount % boxNPCID)
        if attackCount < maxAttackCount:
            GameWorld.DebugLog("²ÝÔ°±¦Ïä¹Ö¹¥»÷´ÎÊýδÓÃÍê! boxNPCID=%s,attackCount=%s < maxAttackCount=%s" % (boxNPCID, attackCount, maxAttackCount))
            return
        
    PlayerFairyDomain.SetFairyDomainFBEventState(curPlayer, mapID, lineID, PlayerFairyDomain.FDEventState_Visited)
    GameWorld.DebugLog("ÉèÖòÝÔ°ÒÑÍê³É!mapID=%s, lineID=%s" % (mapID, lineID))
    return
 
def DoFB_NPCDead(curNPC):
    #GameWorld.DebugLog("DoFB_NPCDead ÉèÖÃÐèҪͬ²½¸±±¾NPC!")
    GameWorld.GetGameFB().SetGameFBDict(FBDict_SyncFBNPC, 1)
    return
 
def OnNPCRebornInFB(curNPC):
    #GameWorld.DebugLog("OnNPCRebornInFB ÉèÖÃÐèҪͬ²½¸±±¾NPC!")
    GameWorld.GetGameFB().SetGameFBDict(FBDict_SyncFBNPC, 1)
    return