| | |
| | | import PlayerControl
|
| | | import IpyGameDataPY
|
| | | import ChPyNetSendPack
|
| | | import PlayerBillboard
|
| | | import FunctionNPCCommon
|
| | | import IPY_GameWorld
|
| | | import ItemControler
|
| | | import NetPackCommon
|
| | | import ShareDefine
|
| | | import ChConfig
|
| | |
|
| | | import time
|
| | |
|
| | | def DoPlayerOnDay(curPlayer):
|
| | | |
| | | # 重置每日魅力
|
| | | if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveCharmToday):
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveCharmToday, 0)
|
| | | Sync_CharmInfo(curPlayer)
|
| | | |
| | | # 重置每日聘礼
|
| | | bridePriceState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveBridePriceState)
|
| | | if bridePriceState:
|
| | | updBridePriceState = bridePriceState
|
| | | ipyDataMgr = IpyGameDataPY.IPY_Data()
|
| | | for index in range(ipyDataMgr.GetMarryCount()):
|
| | | ipyData = ipyDataMgr.GetMarryByIndex(index)
|
| | | if not ipyData.GetIsDayReset():
|
| | | continue
|
| | | bridePriceID = ipyData.GetBridePriceID()
|
| | | dataIndex = bridePriceID - 1
|
| | | buyCount = GameWorld.GetDataByDigitPlace(updBridePriceState, dataIndex)
|
| | | if not buyCount:
|
| | | continue
|
| | | updBridePriceState = GameWorld.ChangeDataByDigitPlace(updBridePriceState, dataIndex, 0)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveBridePriceState, updBridePriceState)
|
| | | GameWorld.DebugLog("重置每日聘礼次数: bridePriceState=%s,bridePriceID=%s,updBridePriceState=%s" |
| | | % (bridePriceState, bridePriceID, updBridePriceState), curPlayer.GetPlayerID())
|
| | | |
| | | if bridePriceState != updBridePriceState:
|
| | | Sync_CoupleInfo(curPlayer)
|
| | | |
| | | def DoPlayerOnDay(curPlayer): |
| | | return
|
| | |
|
| | | def DoPlayerLogin(curPlayer):
|
| | | Sync_CharmInfo(curPlayer)
|
| | | Sync_CoupleInfo(curPlayer)
|
| | | Sync_LoveRingInfo(curPlayer)
|
| | | return
|
| | |
|
| | | #// B3 10 送花 #tagCMSendFlowers
|
| | | #// B3 10 送礼物 #tagCMSendGifts
|
| | | #
|
| | | #struct tagCMSendFlowers
|
| | | #struct tagCMSendGifts
|
| | | #{
|
| | | # tagHead Head;
|
| | | # DWORD TagPlayerID; // 目标玩家ID
|
| | | # DWORD FlowerCount; // 赠送花数量
|
| | | # WORD GiftNum; // 赠送礼物编号
|
| | | # DWORD GiftCount; // 赠送礼物数量
|
| | | # BYTE IsAutoBuy; // 是否自动购买
|
| | | #};
|
| | | def OnSendFlowers(index, clientData, tick):
|
| | | def OnSendGifts(index, clientData, tick):
|
| | | curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
| | | tagPlayerID = clientData.TagPlayerID
|
| | | flowerCount = clientData.FlowerCount
|
| | | giftNum = clientData.GiftNum
|
| | | giftCount = clientData.GiftCount
|
| | | isAutoBuy = clientData.IsAutoBuy
|
| | |
|
| | | if flowerCount <= 0:
|
| | | if giftNum <= 0 or giftCount <= 0:
|
| | | return
|
| | |
|
| | | flowerCountInfoDict = IpyGameDataPY.GetFuncEvalCfg("LoveFlower", 2, {})
|
| | | if str(flowerCount) not in flowerCountInfoDict:
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("LoveGift", giftNum)
|
| | | if not ipyData:
|
| | | return
|
| | | addCharm, addCharmTag, addIntimacy = flowerCountInfoDict[str(flowerCount)]
|
| | | flowerID = IpyGameDataPY.GetFuncCfg("LoveFlower", 1)
|
| | |
|
| | | _, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, flowerID, flowerCount)
|
| | | lackCnt = flowerCount - bindCnt - unBindCnt
|
| | | giftItemID = ipyData.GetGiftItemID()
|
| | | if not ipyData.GetAllowBatch():
|
| | | giftCount = 1 # 不允许批量赠送的默认赠送1个
|
| | | |
| | | _, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, giftItemID, giftCount)
|
| | | lackCnt = giftCount - bindCnt - unBindCnt
|
| | | if lackCnt > 0:
|
| | | GameWorld.DebugLog("鲜花道具不足,无法赠送! flowerID=%s,flowerCount=%s,bindCnt=%s,unBindCnt=%s,lackCnt=%s" |
| | | % (flowerID, flowerCount, bindCnt, unBindCnt, lackCnt))
|
| | | return
|
| | | |
| | | if not isAutoBuy:
|
| | | GameWorld.DebugLog("礼物道具不足,无法赠送! giftItemID=%s,giftCount=%s,bindCnt=%s,unBindCnt=%s,lackCnt=%s" |
| | | % (giftItemID, giftCount, bindCnt, unBindCnt, lackCnt))
|
| | | return
|
| | | |
| | | moneyType = IpyGameDataPY.GetFuncCfg("LoveGift", 1)
|
| | | infoDict = {ChConfig.Def_Cost_Reason_SonKey:giftItemID}
|
| | | if not FunctionNPCCommon.PayAutoBuyItem(curPlayer, {giftItemID:lackCnt}, moneyType, ChConfig.Def_Cost_Love, infoDict, isCheck=True):
|
| | | return
|
| | | |
| | | if not GameWorld.SetPlayerTickTime(curPlayer, ChConfig.TYPE_Player_Tick_Love, tick):
|
| | | PlayerControl.NotifyCode(curPlayer, "RequestLater")
|
| | | return
|
| | |
|
| | | isWorldNotify = (flowerCount in IpyGameDataPY.GetFuncEvalCfg("LoveFlower", 3))
|
| | | dataMsg = [tagPlayerID, flowerID, flowerCount, addCharm, addCharmTag, addIntimacy, isWorldNotify]
|
| | | SendToGameServer_Love(curPlayer, "SendFlowersReq", dataMsg)
|
| | | dataMsg = [tagPlayerID, giftNum, giftItemID, giftCount, isAutoBuy]
|
| | | SendToGameServer_Love(curPlayer, "SendGiftsReq", dataMsg)
|
| | | return
|
| | |
|
| | | #// B3 11 提亲 #tagCMMarryReq
|
| | |
| | | tagPlayerID = clientData.TagPlayerID
|
| | | bridePriceID = clientData.BridePriceID
|
| | |
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | coupleID = PlayerControl.GetCoupleID(curPlayer)
|
| | | if coupleID and coupleID != tagPlayerID:
|
| | | GameWorld.DebugLog("已成亲伴侣ID不一致,无法提亲! tagPlayerID(%s) != coupleID(%s)" % (tagPlayerID, coupleID), playerID)
|
| | | return
|
| | | |
| | | ipyData = IpyGameDataPY.GetIpyGameData("Marry", bridePriceID)
|
| | | if not ipyData:
|
| | | return
|
| | | |
| | | canBuyMax = ipyData.GetCanBuyCount()
|
| | | |
| | | dataIndex = bridePriceID - 1
|
| | | bridePriceState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveBridePriceState)
|
| | | buyCount = GameWorld.GetDataByDigitPlace(bridePriceState, dataIndex)
|
| | | if canBuyMax and buyCount >= canBuyMax:
|
| | | GameWorld.DebugLog("聘礼提亲次数不足,无法提亲! bridePriceID=%s,buyCount(%s) >= canBuyMax(%s)" |
| | | % (bridePriceID, buyCount, canBuyMax), playerID)
|
| | | return
|
| | | |
| | | costMoneyInfo = ipyData.GetCostMoneyInfo()
|
| | | if len(costMoneyInfo) != 2:
|
| | | return
|
| | |
| | | breakType = clientData.BreakType
|
| | | playerID = curPlayer.GetPlayerID()
|
| | |
|
| | | coupleID = PlayerControl.GetCoupleID(curPlayer)
|
| | | if not coupleID:
|
| | | GameWorld.DebugLog("没有伴侣,不需要离婚!", playerID)
|
| | | return
|
| | | |
| | | curTime = int(time.time())
|
| | | marryTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveMarryTime)
|
| | | passTime = curTime - marryTime
|
| | | breakCD = IpyGameDataPY.GetFuncCfg("LoveMarryBreak", 1)
|
| | | if breakCD and passTime < breakCD:
|
| | | GameWorld.Log("离婚等待时间未到,无法离婚! marryTime=%s,passTime(%s) < %s" |
| | | % (GameWorld.ChangeTimeNumToStr(marryTime), passTime, breakCD), playerID)
|
| | | return
|
| | | |
| | | moneyType, moneyValue = 0, 0
|
| | | if breakType == 1:
|
| | | costMoneyInfo = IpyGameDataPY.GetFuncEvalCfg("LoveMarryBreak", 2)
|
| | | costMoneyInfo = IpyGameDataPY.GetFuncEvalCfg("LoveMarryBreak", 3)
|
| | | if len(costMoneyInfo) != 2:
|
| | | return
|
| | | moneyType, moneyValue = costMoneyInfo
|
| | |
| | | PlayerControl.NotifyCode(curPlayer, "RequestLater")
|
| | | return
|
| | |
|
| | | dataMsg = [playerID, coupleID, breakType, moneyType, moneyValue]
|
| | | dataMsg = [playerID, breakType, moneyType, moneyValue]
|
| | | SendToGameServer_Love(curPlayer, "MarryBreakReq", dataMsg)
|
| | | return
|
| | |
|
| | |
| | |
|
| | | msgType, dataMsg = msgData[:2]
|
| | |
|
| | | ## 增加魅力值
|
| | | if msgType == "AddCharm":
|
| | | addCharmTag = dataMsg[0]
|
| | | __DoAddCharm(curPlayer, addCharmTag)
|
| | | return
|
| | | |
| | | ## 结婚成功
|
| | | elif msgType == "MarrySuccess":
|
| | | if msgType == "MarrySuccess":
|
| | | __DoMarrySuccess(curPlayer, dataMsg)
|
| | |
|
| | | ## 离婚成功
|
| | |
| | |
|
| | | msgType, dataMsg, ret = msgData
|
| | |
|
| | | ## 送花请求返回
|
| | | if msgType == "SendFlowersReq":
|
| | | ## 送礼物请求返回
|
| | | if msgType == "SendGiftsReq":
|
| | | if not ret:
|
| | | return
|
| | | __DoSendFlowers(curPlayer, dataMsg)
|
| | | __DoSendGiftsReq(curPlayer, dataMsg)
|
| | |
|
| | | ## 吃喜糖返回
|
| | | elif msgType == "MarryEatCandy":
|
| | |
| | |
|
| | | return
|
| | |
|
| | | def __DoSendFlowers(curPlayer, dataMsg):
|
| | | ## 送花方处理
|
| | | def __DoSendGiftsReq(curPlayer, dataMsg):
|
| | | ## 送礼物方处理
|
| | |
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | tagPlayerID, flowerID, flowerCount, addCharm = dataMsg[:4]
|
| | | tagPlayerID, giftNum, giftItemID, giftCount, isAutoBuy = dataMsg
|
| | |
|
| | | costItemIndexList, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, flowerID, flowerCount)
|
| | | lackCnt = flowerCount - bindCnt - unBindCnt
|
| | | costItemIndexList, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, giftItemID, giftCount)
|
| | | lackCnt = giftCount - bindCnt - unBindCnt
|
| | | delCnt = giftCount
|
| | | if lackCnt > 0:
|
| | | GameWorld.ErrLog("地图鲜花道具不足,无法赠送! tagPlayerID=%s,flowerID=%s,flowerCount=%s,lackCnt=%s" |
| | | % (tagPlayerID, flowerID, flowerCount, lackCnt), playerID)
|
| | | return
|
| | | if not isAutoBuy:
|
| | | GameWorld.ErrLog("礼物道具不足,无法赠送! giftItemID=%s,giftCount=%s,bindCnt=%s,unBindCnt=%s,lackCnt=%s" |
| | | % (giftItemID, giftCount, bindCnt, unBindCnt, lackCnt))
|
| | | return
|
| | | |
| | | moneyType = IpyGameDataPY.GetFuncCfg("LoveGift", 1)
|
| | | infoDict = {ChConfig.Def_Cost_Reason_SonKey:giftItemID}
|
| | | if not FunctionNPCCommon.PayAutoBuyItem(curPlayer, {giftItemID:lackCnt}, moneyType, ChConfig.Def_Cost_Love, infoDict):
|
| | | return
|
| | | delCnt -= lackCnt
|
| | | |
| | | GameWorld.Log("赠送礼物: tagPlayerID=%s,giftNum=%s,giftItemID=%s,giftCount=%s,isAutoBuy=%s" |
| | | % (tagPlayerID, giftNum, giftItemID, giftCount, isAutoBuy), playerID)
|
| | |
|
| | | GameWorld.Log("赠送鲜花: tagPlayerID=%s,flowerID=%s,flowerCount=%s,addCharm=%s" % (tagPlayerID, flowerID, flowerCount, addCharm), playerID)
|
| | | |
| | | saveDataDict = {"tagPlayerID":tagPlayerID}
|
| | | ItemCommon.DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, flowerCount, "Love", saveDataDict)
|
| | | |
| | | __DoAddCharm(curPlayer, addCharm)
|
| | | |
| | | SendToGameServer_Love(curPlayer, "SendFlowersOK", dataMsg)
|
| | | # 扣除消耗
|
| | | if delCnt > 0:
|
| | | ItemCommon.DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, delCnt, "Love")
|
| | | |
| | | SendToGameServer_Love(curPlayer, "SendGiftsOK", dataMsg)
|
| | | return
|
| | |
|
| | | def __DoMarryEatCandy(curPlayer, retInfo):
|
| | |
| | | ## 离婚请求结果返回
|
| | |
|
| | | costMoneyType, costMoneyValue = retInfo
|
| | | GameWorld.Log("执行离婚请求结果: costMoneyType=%s, costMoneyValue=%s" % (costMoneyType, costMoneyValue), curPlayer.GetPlayerID())
|
| | | GameWorld.Log("执行强制离婚请求结果: costMoneyType=%s, costMoneyValue=%s" % (costMoneyType, costMoneyValue), curPlayer.GetPlayerID())
|
| | |
|
| | | infoDict = {ChConfig.Def_Cost_Reason_SonKey:"MarryBreak"}
|
| | | PlayerControl.PayMoney(curPlayer, costMoneyType, costMoneyValue, ChConfig.Def_Cost_Love, infoDict, isMinus=True)
|
| | | return
|
| | |
|
| | | def __DoAddCharm(curPlayer, addValue):
|
| | | ## 增加魅力值
|
| | | charmTotal = min(curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveCharmTotal) + addValue, ShareDefine.Def_UpperLimit_DWord)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveCharmTotal, charmTotal)
|
| | | |
| | | charmToday = min(curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveCharmToday) + addValue, ShareDefine.Def_UpperLimit_DWord)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveCharmToday, charmToday)
|
| | | |
| | | GameWorld.Log("增加魅力: addValue=%s,charmTotal=%s,charmToday=%s" % (addValue, charmTotal, charmToday), curPlayer.GetPlayerID())
|
| | | |
| | | PlayerControl.NotifyCode(curPlayer, "AddCharm", [addValue])
|
| | | |
| | | PlayerBillboard.UpdatePlayerBillboard(curPlayer, ShareDefine.Def_BT_Charm, charmTotal)
|
| | | PlayerBillboard.UpdatePlayerBillboard(curPlayer, ShareDefine.Def_BT_CharmDay, charmToday)
|
| | | |
| | | Sync_CharmInfo(curPlayer)
|
| | | return
|
| | |
|
| | | def __DoMarrySuccess(curPlayer, dataMsg):
|
| | | ## 执行成亲成功
|
| | | reqPlayerID, coupleID, curTime, bridePriceID = dataMsg
|
| | | isNewlyMarried = (PlayerControl.GetCoupleID(curPlayer) != coupleID) # 是否新婚
|
| | | reqPlayerID, bridePriceID, mapServerCoupleInfo = dataMsg
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | PlayerControl.SetCoupleInfo(playerID, mapServerCoupleInfo)
|
| | |
|
| | | if isNewlyMarried:
|
| | | PlayerControl.SetCoupleID(curPlayer, coupleID)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveNewMarryTime, curTime)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveBridePriceState, 0)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveBridePriceMaxID, 0)
|
| | | |
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveMarryTime, curTime)
|
| | | |
| | | dataIndex = bridePriceID - 1
|
| | | bridePriceState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveBridePriceState)
|
| | | buyCount = GameWorld.GetDataByDigitPlace(bridePriceState, dataIndex)
|
| | | updBuyCount = min(9, buyCount + 1)
|
| | | updBridePriceState = GameWorld.ChangeDataByDigitPlace(bridePriceState, dataIndex, updBuyCount)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveBridePriceState, updBridePriceState)
|
| | | |
| | | bridePriceMaxID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveBridePriceMaxID)
|
| | | if bridePriceID > bridePriceMaxID:
|
| | | bridePriceMaxID = bridePriceID
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveBridePriceMaxID, bridePriceMaxID)
|
| | | |
| | | Sync_CoupleInfo(curPlayer)
|
| | | GameWorld.Log("执行成亲成功! reqPlayerID=%s,bridePriceID=%s" % (reqPlayerID, bridePriceID), playerID)
|
| | |
|
| | | if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveRingClassLV) == 0:
|
| | | GameWorld.DebugLog("激活情戒!")
|
| | |
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveRingEatCount, 0)
|
| | | Sync_LoveRingInfo(curPlayer)
|
| | |
|
| | | GameWorld.Log("执行成亲成功! coupleID=%s,curTime=%s,bridePriceID=%s,isNewlyMarried=%s,bridePriceState=%s,buyCount=%s,updBuyCount=%s,updBridePriceState=%s,bridePriceMaxID=%s" |
| | | % (coupleID, curTime, bridePriceID, isNewlyMarried, bridePriceState, buyCount, updBuyCount, updBridePriceState, bridePriceMaxID), playerID)
|
| | | |
| | | # 提亲的玩家扣除消耗
|
| | | if playerID == reqPlayerID:
|
| | | ipyData = IpyGameDataPY.GetIpyGameData("Marry", bridePriceID)
|
| | |
| | | RefreshLoveAttr(curPlayer)
|
| | | return
|
| | |
|
| | | def GetBridePriceMaxID(curPlayer):
|
| | | ## 获取结婚聘礼的最高ID
|
| | | return curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveBridePriceMaxID)
|
| | |
|
| | | def __ClearCoupleSocial(curPlayer, dataMsg):
|
| | | ## 离婚 - 清除伴侣关系
|
| | |
|
| | | playerID = curPlayer.GetPlayerID()
|
| | |
|
| | | coupleID = PlayerControl.GetCoupleID(curPlayer)
|
| | | PlayerControl.SetCoupleID(curPlayer, 0)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveBridePriceState, 0) |
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveBridePriceMaxID, 0) |
| | | Sync_CoupleInfo(curPlayer)
|
| | | PlayerControl.SetCoupleInfo(playerID, None)
|
| | |
|
| | | GameWorld.Log("清除伴侣关系成功! coupleID=%s" % (coupleID), playerID)
|
| | | RefreshLoveAttr(curPlayer)
|
| | |
| | |
|
| | | # 扣除消耗
|
| | | if delCnt:
|
| | | ItemCommon.DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, delCnt, "LoveRing")
|
| | | ItemCommon.DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, delCnt, "Love")
|
| | |
|
| | | # 升星
|
| | | if ringUpType == "starUp":
|
| | |
| | | # 保存计算值
|
| | | PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_LoveRing, allAttrList)
|
| | | PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_LoveRingCouple, allAttrListCouple)
|
| | | return
|
| | |
|
| | | def Sync_CharmInfo(curPlayer):
|
| | | ## 同步魅力信息
|
| | | clientPack = ChPyNetSendPack.tagMCCharmInfo()
|
| | | clientPack.CharmTotal = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveCharmTotal)
|
| | | clientPack.CharmToday = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveCharmToday)
|
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|
| | | return
|
| | |
|
| | | def Sync_CoupleInfo(curPlayer):
|
| | | ## 同步伴侣信息
|
| | | clientPack = ChPyNetSendPack.tagMCCoupleInfo()
|
| | | clientPack.CoupleID = PlayerControl.GetCoupleID(curPlayer)
|
| | | clientPack.NewMarryTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveNewMarryTime)
|
| | | clientPack.MarryTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveMarryTime)
|
| | | clientPack.BridePriceState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveBridePriceState)
|
| | | NetPackCommon.SendFakePack(curPlayer, clientPack)
|
| | | return
|
| | |
|
| | | def Sync_LoveRingInfo(curPlayer):
|