ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerSuccess.py
@@ -29,6 +29,7 @@
import ItemControler
import PlayerMagicWeapon
import PlayerFamilyRedPacket
import PlayerGatherSoul
import IpyGameDataPY
import EventShell
import PyGameData
@@ -37,6 +38,14 @@
import datetime
import time
import math
import ChEquip
import PlayerRune
import Operate_EquipStone
import Operate_EquipWash
import PlayerFeastRedPacket
import PlayerDogz
import QuestCommon
import DataRecordPack
## 获取成就字典信息值
@@ -76,7 +85,6 @@
        SetSuccFinish(curPlayer, succID, 0)
        
        Sync_SuccTypeIndexAwardRecord(curPlayer, [succID], True) #设置成未领取的在外层同步
        PlayerMagicWeapon.ActiveMagicWeapon(curPlayer, succID)
        EventShell.EventRespons_SuccessFinish(curPlayer, succID)
        
    return 
@@ -230,26 +238,55 @@
#  @param None
#  @return
def __CheckOldPlayerSuccess(curPlayer):
    ''' 成就版本更新老玩家检查
        正式上线后,成就的修改或者增加,一般是增加新成就,则需要对老玩家成就版本进行校正,检查成就完成情况
        成就版本号递增
    ''' 成就版本更新老玩家检查  每次启动服务后 玩家第一次上线检查成就完成情况
    '''
    Versions = 1 #版本号,往上增加
    #Versions = 2 #版本号,往上增加
    initGameWorldTime = GameWorld.GetGameWorld().GetGameWorldDictByKey(ShareDefine.Def_Notify_WorldKey_InitGameWorldTime)
    # 上线需要检查老玩家成就完成情况类型{成就类型:维护版本号, ...}
    NeedCheckSuccTypeDict = {
                            ShareDefine.SuccType_GetMagicWeapon:1,
                            ShareDefine.SuccType_PassRuneTower:1,
                             }
    NeedCheckSuccTypeList = [
                            ShareDefine.SuccType_GetMagicWeapon,
                            ShareDefine.SuccType_PassRuneTower,
                            ShareDefine.SuccType_GodWeapon,
                            ShareDefine.SuccType_HorseAllLV,
                            #ShareDefine.SuccType_EquipPlusLV,
                            ShareDefine.SuccType_EquipColorItem,
                            ShareDefine.SuccType_EquipArmor,
                            ShareDefine.SuccType_EquipWeapon,
                            ShareDefine.SuccType_InlayRune,
                            ShareDefine.SuccType_RuneLvUp,
                            ShareDefine.SuccType_RealmlvUp,
                            ShareDefine.SuccType_PetClassLV,
                            ShareDefine.SuccType_InlayStone1,
                            ShareDefine.SuccType_InlayStone2,
                            ShareDefine.SuccType_XJMJGetExp,
                            ShareDefine.SuccType_EquipWashLV1,
                            ShareDefine.SuccType_EquipWashLV2,
                            ShareDefine.SuccType_EquipWashLV3,
                            ShareDefine.SuccType_EquipWing,
                            ShareDefine.SuccType_MWSkillUp,
                            ShareDefine.SuccType_EquipSuit,
                            ShareDefine.SuccType_FamilyTechLV,
                            ShareDefine.SuccType_AlchemyLV,
                            ShareDefine.SuccType_VIPLV,
                            ShareDefine.SuccType_StoneTotalLV,
                            ShareDefine.SuccType_XBXZ,
                            ShareDefine.SuccType_DogzBattle,
                            ShareDefine.SuccType_DogzEquipPlus,
                            ShareDefine.SuccType_MainTaskNode,
                            ShareDefine.SuccType_InlayGatherSoul,
                            ShareDefine.SuccType_GatherSoulLvUp,
                            ShareDefine.SuccType_UseStoveBylv,
                             ]
    
    curCheckVersion = GetPDictValue(curPlayer, ChConfig.Def_PDict_Success_CheckVersion)
    if curCheckVersion == initGameWorldTime:
        GameWorld.DebugLog('    本次开启服务器处理过成就检查,不再处理 ', curPlayer.GetID())
        return
    GameWorld.DebugLog("更新老玩家上线检查成就curCheckVersion=%s" % (curCheckVersion))
    for succType, version in NeedCheckSuccTypeDict.items():
        if curCheckVersion >= version:
            continue
    ipyDataMgr = IpyGameDataPY.IPY_Data()
    for succType in NeedCheckSuccTypeList:
        if succType == ShareDefine.SuccType_GetMagicWeapon:
            ipyDataMgr = IpyGameDataPY.IPY_Data()
            for i in xrange(ipyDataMgr.GetTreasureCount()):
                treasureIpyData = ipyDataMgr.GetTreasureByIndex(i)
                magicWeaponID = treasureIpyData.GetID()
@@ -262,10 +299,119 @@
        elif succType == ShareDefine.SuccType_PassRuneTower:
            passlv = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_TrialTower_PassLV)
            DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_PassRuneTower, 1, [passlv])
        elif succType == ShareDefine.SuccType_GodWeapon:
            ResetSuccessByType(curPlayer, succType)
            maxType = ipyDataMgr.GetGodWeaponByIndex(ipyDataMgr.GetGodWeaponCount()-1).GetType()
            for i in xrange(1, maxType + 1):
                weaponLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_GodWeaponLV % i)
                UptateSuccessProgress(curPlayer, succType, weaponLV, [i])
        elif succType == ShareDefine.SuccType_HorseAllLV:
            ResetSuccessByType(curPlayer, succType)
            for i in xrange(ipyDataMgr.GetHorseCount()):
                ipyData = ipyDataMgr.GetHorseByIndex(i)
                index = ipyData.GetHorseID()
                lv = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_Horser_LV % index, 0, ChConfig.Def_PDictType_Horse)
                if not lv:
                    continue
                for rlv in xrange(1, lv+1):
                    DoAddSuccessProgress(curPlayer, succType, 1, [index, rlv])
        elif succType == ShareDefine.SuccType_EquipPlusLV:
            ResetSuccessByType(curPlayer, succType)
            for pType, indexList in ChConfig.Pack_EquipPart_CanPlusStar.items():
                for i in indexList:
                    equipPartStarLV = ChEquip.GetEquipPartPlusLV(curPlayer, pType, i)
                    for pluslv in xrange(1, equipPartStarLV+1):
                        DoAddSuccessProgress(curPlayer, succType, 1, [pluslv])
        elif succType in [ShareDefine.SuccType_EquipColorItem, ShareDefine.SuccType_EquipArmor, ShareDefine.SuccType_EquipWeapon, ShareDefine.SuccType_EquipWing]:
            DoEquipSuccessLogic(curPlayer)
        elif succType in [ShareDefine.SuccType_InlayRune, ShareDefine.SuccType_RuneLvUp]:
            PlayerRune.DoRuneSuccessLogic(curPlayer)
        elif succType in [ShareDefine.SuccType_InlayGatherSoul, ShareDefine.SuccType_GatherSoulLvUp]:
            PlayerGatherSoul.DoGatherSoulSuccessLogic(curPlayer)
        elif succType == ShareDefine.SuccType_RealmlvUp:
            ResetSuccessByType(curPlayer, succType)
            UptateSuccessProgress(curPlayer, succType, curPlayer.GetOfficialRank())
        elif succType == ShareDefine.SuccType_PetClassLV:
            ResetSuccessByType(curPlayer, succType)
            petDataPack = curPlayer.GetItemManager().GetPack(ShareDefine.rptPet)
            for petDataIndex in range(petDataPack.GetCount()):
                petItem = petDataPack.GetAt(petDataIndex)
                if petItem.IsEmpty():
                    continue
                petNPCID = petItem.GetUserAttr(ShareDefine.Def_IudetPet_NPCID)
                classLV = petItem.GetUserAttr(ShareDefine.Def_IudetPet_ClassLV)
                for lv in xrange(classLV+1):
                    DoAddSuccessProgress(curPlayer, succType, 1, [petNPCID, lv+1])
        elif succType in [ShareDefine.SuccType_InlayStone1, ShareDefine.SuccType_InlayStone2, ShareDefine.SuccType_StoneTotalLV]:
            Operate_EquipStone.DoStoneSuccess(curPlayer)
        elif succType == ShareDefine.SuccType_XJMJGetExp:
            expPointRecord = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_BZZD_TotalFightExpPoint)
            DoAddSuccessProgress(curPlayer, succType, 1, [expPointRecord])
        elif succType in [ShareDefine.SuccType_EquipWashLV1,ShareDefine.SuccType_EquipWashLV2,ShareDefine.SuccType_EquipWashLV3]:
            Operate_EquipWash.EquipWashSuccess(curPlayer)
        elif succType == ShareDefine.SuccType_MWSkillUp:
            ResetSuccessByType(curPlayer, succType)
            skillManager = curPlayer.GetSkillManager()
            for i in range(0, skillManager.GetSkillCount()):
                curSkill = skillManager.GetSkillByIndex(i)
                if curSkill.GetFuncType() in [ChConfig.Def_SkillFuncType_FbSkill,ChConfig.Def_SkillFuncType_FbSPSkill]:
                    curSkillLV = curSkill.GetSkillLV()
                    UptateSuccessProgress(curPlayer, succType, curSkillLV, [curSkill.GetSkillTypeID()])
#        elif succType == ShareDefine.SuccType_EquipSuit:
#            Operate_EquipSuitCompose.DoSuiteSuccess(curPlayer)
        elif succType == ShareDefine.SuccType_FamilyTechLV:
            ResetSuccessByType(curPlayer, succType)
            techNeedLVDict = IpyGameDataPY.GetFuncEvalCfg('FamilyTechNeedLV', 1, {})
            techIDList = techNeedLVDict.keys()
            for techID in techIDList:
                techLV = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyTechLV % techID)
                UptateSuccessProgress(curPlayer, succType, techLV, [techID])
        elif succType == ShareDefine.SuccType_AlchemyLV:
            ResetSuccessByType(curPlayer, succType)
            alchemyLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AlchemyLV)
            UptateSuccessProgress(curPlayer, succType, alchemyLV)
        elif succType == ShareDefine.SuccType_VIPLV:
            DoAddSuccessProgress(curPlayer, succType, 1, [curPlayer.GetVIPLv()])
        elif succType == ShareDefine.SuccType_XBXZ:
            ResetSuccessByType(curPlayer, succType)
            for i in xrange(ipyDataMgr.GetXBXZCount()):
                ipyData = ipyDataMgr.GetXBXZByIndex(i)
                if GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_XBXZAwardRecord, ipyData.GetID()):
                    DoAddSuccessProgress(curPlayer, succType, 1, [ipyData.GetMWID()])
    SetPDictValue(curPlayer, ChConfig.Def_PDict_Success_CheckVersion, Versions)
    GameWorld.DebugLog("更新老玩家上线检查成就updCheckVersions=%s" % (Versions))
        elif succType == ShareDefine.SuccType_DogzBattle:
            for i in xrange(ipyDataMgr.GetDogzCount()):
                ipyData = ipyDataMgr.GetDogzByIndex(i)
                if GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_DogzFightState, i):
                    DoAddSuccessProgress(curPlayer, succType, 1, [ipyData.GetDogzID()])
        elif succType == ShareDefine.SuccType_DogzEquipPlus:
            ResetSuccessByType(curPlayer, succType)
            DoAddSuccessProgress(curPlayer, succType, PlayerDogz.GetFightDogzTotalPlusLv(curPlayer))
        elif succType == ShareDefine.SuccType_MainTaskNode: #只能处理主线任务
            succInfoList = GetSuccDataMng().GetSuccDataByType(succType)
            for succData in succInfoList:
                missionID = succData.condition[0]
                if QuestCommon.GetHadFinishMainMission(curPlayer, missionID):
                    DoAddSuccessProgress(curPlayer, succType, 1, [missionID])
        elif succType == ShareDefine.SuccType_UseStoveBylv:
            ResetSuccessByType(curPlayer, succType)
            for i in xrange(ipyDataMgr.GetAttrFruitCount()):
                ipyData = ipyDataMgr.GetAttrFruitByIndex(i)
                fruitItemID = ipyData.GetID()
                hasUseCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_AttrFruitEatCnt % fruitItemID)
                if ipyData.GetFuncID() == ShareDefine.Def_AttrFruitFunc_Stove:
                    itemData = GameWorld.GetGameData().GetItemByTypeID(fruitItemID)
                    if not itemData:
                        continue
                    DoAddSuccessProgress(curPlayer, succType, hasUseCnt, [itemData.GetLV()])
    DataRecordPack.DR_CheckOldPlayerSuccess(curPlayer)
    SetPDictValue(curPlayer, ChConfig.Def_PDict_Success_CheckVersion, initGameWorldTime)
    GameWorld.DebugLog("更新老玩家上线检查成就updCheckVersions=%s" % (initGameWorldTime), curPlayer.GetID())
    return
## 成就OnWeek
@@ -288,6 +434,29 @@
            SetSuccHasGot(curPlayer, succID, False)
            resetList.append(succID)
            GameWorld.DebugLog("    OnWeek 重置成就类型: succID=%s" % (succID))
    if resetList:
        Sync_SuccTypeIndexAwardRecord(curPlayer, resetList, True)
        Sync_SuccessInfo(curPlayer, resetList, True)
    return
def DoResetSuccessIDList(curPlayer, resetSuccIDList):
    ## 重置成就相关数据
    if not resetSuccIDList:
        return
    resetList = []
    for succID in resetSuccIDList:
        succData = GetSuccDataMng().GetSuccessData(succID)
        if not succData:
            continue
        succType = succData.succType
        condition = succData.condition
        #if not GetSuccFinishValue(curPlayer, succType, condition):
        #    continue
        SetSuccFinishValue(curPlayer, succType, condition, 0)
        SetSuccFinish(curPlayer, succID, False)
        SetSuccHasGot(curPlayer, succID, False)
        resetList.append(succID)
        GameWorld.DebugLog("    重置成就类型: succType=%s,succID=%s" % (succType, succID))
    if resetList:
        Sync_SuccTypeIndexAwardRecord(curPlayer, resetList, True)
        Sync_SuccessInfo(curPlayer, resetList, True)
@@ -392,11 +561,11 @@
        
        itemQuality = curEquip.GetItemQuality()
        classLV = ItemCommon.GetItemClassLV(curEquip)
        if equipIndex not in [ShareDefine.retWing,ShareDefine.retGuard,ShareDefine.retHorse]:
        if equipIndex not in [ShareDefine.retWing,ShareDefine.retGuard1,ShareDefine.retGuard2,ShareDefine.retHorse]:
            DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_EquipColorItem, 1, [classLV, itemColor])
        if equipIndex in ChConfig.BaseEquipPlace_Weapon:
        if equipIndex in ChConfig.EquipPlace_BaseWeapon:
            DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_EquipWeapon, 1, [itemColor, itemQuality, classLV])
        elif equipIndex in ChConfig.BaseEquipPlace_Armor:
        elif equipIndex in ChConfig.EquipPlace_BaseArmor:
            DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_EquipArmor, 1, [itemColor, itemQuality, classLV])
        
        elif equipIndex == ShareDefine.retWing:
@@ -412,6 +581,9 @@
def UptateSuccessProgress(curPlayer, successType, newCnt, condition=[]):
    if successType not in ShareDefine.SuccessTypeList:
        return
    if successType in ShareDefine.FeastRedPackSuccessTypeList:
        if not PlayerFeastRedPacket.GetFeastRedPacketState():
            return
    succInfoList = GetSuccDataMng().GetSuccDataByType(successType)
    if not succInfoList:
        return
@@ -433,6 +605,11 @@
    succID = succDataObj.succID
    cond = succDataObj.condition
    
    if successType in ShareDefine.FeastRedPackSuccessTypeList:
        todayFeastSuccIDList = PlayerFeastRedPacket.GetTodayFeastSuccIDList()
        if not todayFeastSuccIDList or succID not in todayFeastSuccIDList:
            #GameWorld.DebugLog("    非今日节日红包成就,不增加进度! succID=%s,todayFeastSuccIDList=%s" % (succID, todayFeastSuccIDList))
            return
    isUnDownCheck = successType in ShareDefine.UnDownCheckSuccessTypeList
    isContain = successType in ShareDefine.ContainSuccessTypeList
    # 已完成的不再检查
@@ -503,7 +680,14 @@
def DoAddSuccessProgress(curPlayer, successType, addCnt, condition=[], delayCalc=True):
    #GameWorld.DebugLog("DoAddSuccessProgress type=%s,addCnt=%s,condition=%s" 
    #                   % (successType, addCnt, condition), curPlayer.GetPlayerID())
    if GameWorld.IsCrossServer():
        return
    if successType in ShareDefine.FeastRedPackSuccessTypeList:
        if not PlayerFeastRedPacket.GetFeastRedPacketState():
            #GameWorld.DebugLog("非节日红包活动时间,不增加成就!successType=%s" % successType)
            return
    playerID = curPlayer.GetID()
    if delayCalc and successType not in ShareDefine.NeedResetSuccessTypeList:
        if playerID not in PyGameData.g_delaySuccessDict:
@@ -826,8 +1010,7 @@
    # 给物品
    if isGiveItem:
        for itemID, itemCnt in itemDict.items():
            isPutIn = ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 1,
                                                   [IPY_GameWorld.rptItem, IPY_GameWorld.rptAnyWhere], True)
            isPutIn = ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [IPY_GameWorld.rptItem, IPY_GameWorld.rptAnyWhere])
       
    #给钱
    for moneyType, value in succData.moneyDict.items():