| | |
| | | def __OnEnterFamily(curPlayer, tick):
|
| | | EventShell.EventResponse_OnFamily(curPlayer)
|
| | | __OnFamilyLVBuffChange(curPlayer, tick)
|
| | | __FamilyAffair_CheckReset(curPlayer)
|
| | | PlayerFamilyTech.Sync_PlayerFamilyTechLV(curPlayer)
|
| | | DelAddFamilyRecord(curPlayer)
|
| | | GameLogic_FamilyWar.DoCheckChampionFamilyTitle(curPlayer)
|
| | |
| | | return
|
| | | #每日福利奖励
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyDayAward, 0)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyMoneyDonateCount, 0)
|
| | | Sync_FamilyDayRewardState(curPlayer)
|
| | | __FamilyAffair_Refresh(curPlayer, True)
|
| | | return
|
| | |
|
| | |
|
| | |
| | | PlayerFamilyTech.Sync_PlayerFamilyTechLV(curPlayer)
|
| | | SyncFamilyActivityInfo(curPlayer)
|
| | | Sync_FamilyDayRewardState(curPlayer)
|
| | | __FamilyAffair_CheckReset(curPlayer)
|
| | | return
|
| | |
|
| | | def FamilyPlayerOnLoginCross(curPlayer):
|
| | |
| | | def Sync_FamilyDayRewardState(curPlayer):
|
| | | clientPack = ChPyNetSendPack.tagMCFamilyDayAward()
|
| | | clientPack.GetState = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyDayAward)
|
| | | clientPack.MoneyDonateCount = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyMoneyDonateCount)
|
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|
| | | return
|
| | |
|
| | |
| | | packData.Point = givePoint
|
| | | NetPackCommon.SendFakePack(curPlayer, packData)
|
| | | return
|
| | |
|
| | | #// A6 12 家族捐献货币 #tagCMFamilyMoneyDonate
|
| | | #
|
| | | #struct tagCMFamilyMoneyDonate
|
| | | #{
|
| | | # tagHead Head;
|
| | | # BYTE MoneyType; // 捐献货币类型
|
| | | #};
|
| | | def OnFamilyMoneyDonate(index, clientData, tick):
|
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | moneyType = clientData.MoneyType
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | |
| | | dailyDonateCountMax = IpyGameDataPY.GetFuncCfg('FamilyDonate', 3)
|
| | | donateCount = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyMoneyDonateCount)
|
| | | if dailyDonateCountMax and donateCount >= dailyDonateCountMax:
|
| | | GameWorld.DebugLog("今日货币捐献次数已达上限. donateCount=%s" % donateCount, playerID)
|
| | | return
|
| | | |
| | | donatePrizeInfo = IpyGameDataPY.GetFuncEvalCfg('FamilyDonate', 4, {})
|
| | | if str(moneyType) not in donatePrizeInfo:
|
| | | GameWorld.DebugLog("不存在该货币类型捐献: moneyType=%s" % moneyType, playerID)
|
| | | return
|
| | | needMoney, contribution, familyActivity = donatePrizeInfo[str(moneyType)]
|
| | | if not PlayerControl.HaveMoney(curPlayer, moneyType, needMoney):
|
| | | return
|
| | | |
| | | updDonateCount = donateCount + 1
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyMoneyDonateCount, updDonateCount)
|
| | | Sync_FamilyDayRewardState(curPlayer)
|
| | | GameWorld.DebugLog("货币捐献: moneyType=%s,needMoney=%s,updDonateCount=%s,contribution=%s,familyActivity=%s" |
| | | % (moneyType, needMoney, updDonateCount, contribution, familyActivity), playerID)
|
| | | |
| | | if contribution > 0:
|
| | | AddPlayerFamilyActiveValue(curPlayer, contribution, True, ShareDefine.Def_AddFAVReason_FamilyDonateItem, True)
|
| | | |
| | | if familyActivity > 0:
|
| | | PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_FamilyActivity, familyActivity)
|
| | | |
| | | return
|
| | |
|
| | |
|
| | | ##--------------------------------------- 仙盟事务 --------------------------------------------------
|
| | | AffairState_None = 0 # 无
|
| | | AffairState_Underway = 1 # 进行中
|
| | | AffairState_Finish = 2 # 已完成
|
| | |
|
| | | #// A6 13 家族事务操作 #tagCMFamilyAffairOP
|
| | | #
|
| | | #struct tagCMFamilyAffairOP
|
| | | #{
|
| | | # tagHead Head;
|
| | | # BYTE OPType; // 操作类型:1-刷新事务;2-开始事务;3-领取事务奖励;
|
| | | # WORD AffairID; // 事务ID,可选
|
| | | #};
|
| | | def OnFamilyAffairOP(index, clientData, tick):
|
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | opType = clientData.OPType
|
| | | affairID = clientData.AffairID
|
| | | |
| | | if opType == 1:
|
| | | __FamilyAffair_Refresh(curPlayer)
|
| | | elif opType == 2:
|
| | | __FamilyAffair_Start(curPlayer, affairID)
|
| | | elif opType == 3:
|
| | | __FamilyAffair_GetAward(curPlayer, affairID) |
| | | return
|
| | |
|
| | | def __FamilyAffair_CheckReset(curPlayer):
|
| | | ## 检查任务重置,登录,进入仙盟触发
|
| | | info = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyAffairInfo % 1)
|
| | | if not info:
|
| | | # 任务1还没分配,默认强制重置
|
| | | __FamilyAffair_Refresh(curPlayer, True)
|
| | | else:
|
| | | SyncFamilyAffairInfo(curPlayer)
|
| | | return
|
| | |
|
| | | def __FamilyAffair_Refresh(curPlayer, isReset=False):
|
| | | ## 刷新事务
|
| | | |
| | | playerID = curPlayer.GetPlayerID()
|
| | | moneyType, moneyValue = 0, 0 |
| | | dayRefreshFreeCount = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyAffairRefreshFree)
|
| | | if not isReset:
|
| | | freeCountMax = IpyGameDataPY.GetFuncCfg("FamilyAffair", 2)
|
| | | if freeCountMax and dayRefreshFreeCount >= freeCountMax:
|
| | | moneyType, moneyValue = IpyGameDataPY.GetFuncEvalCfg("FamilyAffair", 3)
|
| | | if not PlayerControl.HaveMoney(curPlayer, moneyType, moneyValue):
|
| | | return
|
| | | |
| | | sendMailAffairList = []
|
| | | refreshAffairIDList = []
|
| | | affairCountMax = IpyGameDataPY.GetFuncCfg("FamilyAffair", 1)
|
| | | affairStarDict = IpyGameDataPY.GetFuncEvalCfg("FamilyAffair", 4)
|
| | | maxStar = 0
|
| | | starWeightList = []
|
| | | for starStr, starInfo in affairStarDict.items():
|
| | | star = int(starStr)
|
| | | if star > maxStar:
|
| | | maxStar = star
|
| | | starWeightList.append([starInfo[0], star])
|
| | | |
| | | for affairID in range(1, affairCountMax + 1):
|
| | | star, state = __GetAffairInfo(curPlayer, affairID)
|
| | | if isReset:
|
| | | # 重置时还在进行中的直接发奖励
|
| | | if state == AffairState_Underway:
|
| | | sendMailAffairList.append([affairID, star])
|
| | | refreshAffairIDList.append(affairID)
|
| | | else:
|
| | | # 非重置只处理没有状态非最高星的
|
| | | if state == AffairState_None and star < maxStar:
|
| | | refreshAffairIDList.append(affairID)
|
| | | |
| | | GameWorld.DebugLog("刷新事务: isReset=%s,moneyType=%s,moneyValue=%s,dayRefreshFreeCount=%s" |
| | | % (isReset, moneyType, moneyValue, dayRefreshFreeCount), playerID)
|
| | | GameWorld.DebugLog(" sendMailAffairList=%s" % sendMailAffairList, playerID)
|
| | | |
| | | for mailInfo in sendMailAffairList:
|
| | | affairID, star = mailInfo
|
| | | if str(star) not in affairStarDict:
|
| | | continue
|
| | | paramList = [affairID, star]
|
| | | addItemList = affairStarDict[str(star)][2]
|
| | | PlayerControl.SendMailByKey("FamilyAffairAward", [playerID], addItemList, paramList)
|
| | | |
| | | if isReset:
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyAffairRefreshFree, 0)
|
| | | for affairID in range(1, affairCountMax + 1):
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyAffairInfo % affairID, 0)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyAffairStartTime % affairID, 0)
|
| | | else:
|
| | | if moneyType and moneyValue:
|
| | | PlayerControl.PayMoney(curPlayer, moneyType, moneyValue, "FamilyAffair")
|
| | | else:
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyAffairRefreshFree, dayRefreshFreeCount + 1)
|
| | | |
| | | GameWorld.DebugLog(" starWeightList=%s" % starWeightList, playerID)
|
| | | GameWorld.DebugLog(" refreshAffairIDList=%s" % refreshAffairIDList, playerID)
|
| | | for affairID in refreshAffairIDList:
|
| | | star = GameWorld.GetResultByWeightList(starWeightList, 1)
|
| | | __SetAffairInfo(curPlayer, affairID, star, AffairState_None)
|
| | | GameWorld.DebugLog(" 随机事务:affairID=%s,star=%s" % (affairID, star), playerID)
|
| | | |
| | | SyncFamilyAffairInfo(curPlayer)
|
| | | return
|
| | |
|
| | | def __FamilyAffair_Start(curPlayer, affairID):
|
| | | ## 开始事务
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | star, state = __GetAffairInfo(curPlayer, affairID)
|
| | | if not star:
|
| | | return
|
| | | if state != AffairState_None:
|
| | | GameWorld.DebugLog("仙盟事务已经进行中或已完成,无法开始: affairID=%s,star=%s,state=%s" % (affairID, star, state), playerID)
|
| | | return
|
| | | startTime = int(time.time())
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyAffairStartTime % affairID, startTime)
|
| | | __SetAffairInfo(curPlayer, affairID, star, AffairState_Underway)
|
| | | GameWorld.DebugLog("仙盟事务开始: affairID=%s,star=%s,startTime=%s" % (affairID, star, startTime), playerID)
|
| | | SyncFamilyAffairInfo(curPlayer, affairID)
|
| | | return
|
| | |
|
| | | def __FamilyAffair_GetAward(curPlayer, affairID):
|
| | | ## 领取事务奖励
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | curTime = int(time.time())
|
| | | affairStarDict = IpyGameDataPY.GetFuncEvalCfg("FamilyAffair", 4)
|
| | | star, state = __GetAffairInfo(curPlayer, affairID)
|
| | | if state != AffairState_Underway:
|
| | | GameWorld.DebugLog("仙盟事务状态非进行中无法领取: affairID=%s,star=%s,state=%s" % (affairID, star, state), playerID)
|
| | | SyncFamilyAffairInfo(curPlayer, affairID)
|
| | | return
|
| | | startTime = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyAffairStartTime % affairID)
|
| | | remainDuration = __GetAffairRemainDuration(curPlayer, affairID, star, curTime, affairStarDict)
|
| | | if remainDuration != 0:
|
| | | GameWorld.DebugLog("仙盟事务当前剩余时长未完成: affairID=%s,remainDuration=%s,startTime=%s" |
| | | % (affairID, remainDuration, startTime), playerID)
|
| | | SyncFamilyAffairInfo(curPlayer, affairID)
|
| | | return
|
| | | if str(star) not in affairStarDict:
|
| | | return
|
| | | addItemList = affairStarDict[str(star)][2]
|
| | | if not ItemCommon.GiveAwardItem(curPlayer, addItemList):
|
| | | return
|
| | | __SetAffairInfo(curPlayer, affairID, star, AffairState_Finish)
|
| | | GameWorld.DebugLog("仙盟事务领奖: affairID=%s,star=%s" % (affairID, star), playerID)
|
| | | SyncFamilyAffairInfo(curPlayer, affairID)
|
| | | return
|
| | |
|
| | | def __GetAffairInfo(curPlayer, affairID):
|
| | | affairInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyAffairInfo % affairID)
|
| | | star, state = affairInfo / 10, affairInfo % 10
|
| | | return star, state
|
| | | def __SetAffairInfo(curPlayer, affairID, star, state):
|
| | | info = star * 10 + state
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_Player_Dict_FamilyAffairInfo % affairID, info)
|
| | | return
|
| | | def __GetAffairRemainDuration(curPlayer, affairID, star, curTime, affairStarDict):
|
| | | ## -1-未开始;>=0-剩余时长
|
| | | startTime = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyAffairStartTime % affairID)
|
| | | if not startTime:
|
| | | return -1
|
| | | starInfo = affairStarDict.get(str(star), [])
|
| | | needDuration = starInfo[1] if len(starInfo) > 1 else 0
|
| | | # 可扩展减时长属性
|
| | | remainDuration = max(needDuration - (curTime - startTime), 0)
|
| | | return remainDuration
|
| | |
|
| | | def SyncFamilyAffairInfo(curPlayer, affairID=None):
|
| | | if affairID == None:
|
| | | affairIDList = []
|
| | | affairCountMax = IpyGameDataPY.GetFuncCfg("FamilyAffair", 1)
|
| | | for affairID in range(1, affairCountMax + 1):
|
| | | affairIDList.append(affairID)
|
| | | else:
|
| | | affairIDList = [affairID]
|
| | | |
| | | curTime = int(time.time())
|
| | | affairStarDict = IpyGameDataPY.GetFuncEvalCfg("FamilyAffair", 4)
|
| | | affairInfoList = []
|
| | | for affairID in affairIDList:
|
| | | star, state = __GetAffairInfo(curPlayer, affairID)
|
| | | remainDuration = __GetAffairRemainDuration(curPlayer, affairID, star, curTime, affairStarDict)
|
| | | affairInfo = ChPyNetSendPack.tagMCFamilyAffair()
|
| | | affairInfo.AffairID = affairID
|
| | | affairInfo.Star = star
|
| | | affairInfo.State = state
|
| | | affairInfo.RemainDuration = max(0, remainDuration)
|
| | | affairInfoList.append(affairInfo)
|
| | | |
| | | if not affairInfoList:
|
| | | return
|
| | | clientPack = ChPyNetSendPack.tagMCFamilyAffairInfo()
|
| | | clientPack.Clear()
|
| | | clientPack.RefreshFreeCount = curPlayer.NomalDictGetProperty(ChConfig.Def_Player_Dict_FamilyAffairRefreshFree)
|
| | | clientPack.AffairInfoList = affairInfoList
|
| | | clientPack.Count = len(clientPack.AffairInfoList)
|
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|
| | | return
|
| | |
|
| | | ##--------------------------------------------------------------------------------------------------
|