#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#-------------------------------------------------------------------------------
|
#
|
##@package Player.PlayerLove
|
#
|
# @todo:ÇéԵϵͳ
|
# @author hxp
|
# @date 2021-11-09
|
# @version 1.0
|
#
|
# ÏêϸÃèÊö: ÇéԵϵͳ
|
#
|
#-------------------------------------------------------------------------------
|
#"""Version = 2021-11-09 20:00"""
|
#-------------------------------------------------------------------------------
|
|
import GameWorld
|
import ItemCommon
|
import PlayerControl
|
import IpyGameDataPY
|
import ChPyNetSendPack
|
import PlayerBillboard
|
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)
|
|
return
|
|
def DoPlayerLogin(curPlayer):
|
Sync_CharmInfo(curPlayer)
|
Sync_CoupleInfo(curPlayer)
|
Sync_LoveRingInfo(curPlayer)
|
return
|
|
#// B3 10 ËÍ»¨ #tagCMSendFlowers
|
#
|
#struct tagCMSendFlowers
|
#{
|
# tagHead Head;
|
# DWORD TagPlayerID; // Ä¿±êÍæ¼ÒID
|
# DWORD FlowerCount; // ÔùËÍ»¨ÊýÁ¿
|
#};
|
def OnSendFlowers(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
tagPlayerID = clientData.TagPlayerID
|
flowerCount = clientData.FlowerCount
|
|
if flowerCount <= 0:
|
return
|
|
flowerCountInfoDict = IpyGameDataPY.GetFuncEvalCfg("LoveFlower", 2, {})
|
if str(flowerCount) not in flowerCountInfoDict:
|
return
|
addCharm, addCharmTag, addIntimacy = flowerCountInfoDict[str(flowerCount)]
|
flowerID = IpyGameDataPY.GetFuncCfg("LoveFlower", 1)
|
|
_, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, flowerID, flowerCount)
|
lackCnt = flowerCount - 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 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)
|
return
|
|
#// B3 11 ÌáÇ× #tagCMMarryReq
|
#
|
#struct tagCMMarryReq
|
#{
|
# tagHead Head;
|
# DWORD TagPlayerID; // Ä¿±êÍæ¼ÒID
|
# BYTE BridePriceID; // ƸÀñID
|
#};
|
def OnMarryReq(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
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
|
moneyType, moneyValue = costMoneyInfo
|
|
if not PlayerControl.HaveMoney(curPlayer, moneyType, moneyValue):
|
return
|
|
if not GameWorld.SetPlayerTickTime(curPlayer, ChConfig.TYPE_Player_Tick_Love, tick):
|
PlayerControl.NotifyCode(curPlayer, "RequestLater")
|
return
|
|
dataMsg = [tagPlayerID, bridePriceID]
|
SendToGameServer_Love(curPlayer, "MarryReq", dataMsg)
|
return
|
|
#// B3 13 ³ÔϲÌÇ #tagCMMarryEatCandy
|
#
|
#struct tagCMMarryEatCandy
|
#{
|
# tagHead Head;
|
# DWORD PlayerIDA; // ϲÌÇËùÊôÍæ¼ÒIDA
|
# DWORD PlayerIDB; // ϲÌÇËùÊôÍæ¼ÒIDB
|
#};
|
def OnMarryEatCandy(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
|
playerIDA = clientData.PlayerIDA
|
playerIDB = clientData.PlayerIDB
|
|
playerID = curPlayer.GetPlayerID()
|
|
if not GameWorld.SetPlayerTickTime(curPlayer, ChConfig.TYPE_Player_Tick_Love, tick):
|
PlayerControl.NotifyCode(curPlayer, "RequestLater")
|
return
|
|
costMoneyType, costMoneyValue = IpyGameDataPY.GetFuncEvalCfg("LoveCandy", 2)
|
playerMoneyValue = PlayerControl.GetMoney(curPlayer, costMoneyType)
|
|
dataMsg = [playerIDA, playerIDB, playerID, costMoneyType, costMoneyValue, playerMoneyValue]
|
SendToGameServer_Love(curPlayer, "MarryEatCandy", dataMsg)
|
return
|
|
|
#// B3 14 ¹ºÂò»éÀñÑÌ»¨ #tagCMMarryBuyFireworks
|
#
|
#struct tagCMMarryBuyFireworks
|
#{
|
# tagHead Head;
|
# DWORD PlayerIDA; // ϲÌÇËùÊôÍæ¼ÒIDA
|
# DWORD PlayerIDB; // ϲÌÇËùÊôÍæ¼ÒIDB
|
#};
|
def OnMarryBuyFireworks(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
|
playerIDA = clientData.PlayerIDA
|
playerIDB = clientData.PlayerIDB
|
|
playerID = curPlayer.GetPlayerID()
|
|
costMoneyType, costMoneyValue = IpyGameDataPY.GetFuncEvalCfg("LoveCandyFire", 2)
|
if not PlayerControl.HaveMoney(curPlayer, costMoneyType, costMoneyValue):
|
return
|
playerMoneyValue = PlayerControl.GetMoney(curPlayer, costMoneyType)
|
|
if not GameWorld.SetPlayerTickTime(curPlayer, ChConfig.TYPE_Player_Tick_Love, tick):
|
PlayerControl.NotifyCode(curPlayer, "RequestLater")
|
return
|
|
dataMsg = [playerIDA, playerIDB, playerID, costMoneyType, costMoneyValue, playerMoneyValue]
|
SendToGameServer_Love(curPlayer, "MarryBuyFireworks", dataMsg)
|
return
|
|
#// B3 15 ˑȎ #tagCMMarryBreak
|
#
|
#struct tagCMMarryBreak
|
#{
|
# tagHead Head;
|
# BYTE BreakType; // 0-ºÍƽÀë»é£»1-Ç¿ÖÆÀë»é
|
#};
|
def OnMarryBreak(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
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)
|
if len(costMoneyInfo) != 2:
|
return
|
moneyType, moneyValue = costMoneyInfo
|
|
if not PlayerControl.HaveMoney(curPlayer, moneyType, moneyValue):
|
return
|
|
if not GameWorld.SetPlayerTickTime(curPlayer, ChConfig.TYPE_Player_Tick_Love, tick):
|
PlayerControl.NotifyCode(curPlayer, "RequestLater")
|
return
|
|
dataMsg = [playerID, coupleID, breakType, moneyType, moneyValue]
|
SendToGameServer_Love(curPlayer, "MarryBreakReq", dataMsg)
|
return
|
|
def SendToGameServer_Love(curPlayer, msgType, dataMsg):
|
## ·¢ËÍÐÅÏ¢µ½¿ç·þ·þÎñÆ÷
|
msgList = str([msgType, dataMsg])
|
GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(curPlayer.GetPlayerID(), 0, 0, "Love", msgList, len(msgList))
|
GameWorld.Log("ÇéÔµ·¢ËÍGameServer: %s, %s" % (msgType, dataMsg), curPlayer.GetPlayerID())
|
return
|
|
def GameServer_Love_DoLogic(curPlayer, msgData):
|
|
msgType, dataMsg = msgData[:2]
|
|
## Ôö¼Ó÷ÈÁ¦Öµ
|
if msgType == "AddCharm":
|
addCharmTag = dataMsg[0]
|
__DoAddCharm(curPlayer, addCharmTag)
|
return
|
|
## ½á»é³É¹¦
|
elif msgType == "MarrySuccess":
|
__DoMarrySuccess(curPlayer, dataMsg)
|
|
## Àë»é³É¹¦
|
elif msgType == "ClearCoupleSocial":
|
__ClearCoupleSocial(curPlayer, dataMsg)
|
|
return
|
|
def GameServer_Love_DoResult(curPlayer, msgData):
|
|
msgType, dataMsg, ret = msgData
|
|
## ËÍ»¨ÇëÇó·µ»Ø
|
if msgType == "SendFlowersReq":
|
if not ret:
|
return
|
__DoSendFlowers(curPlayer, dataMsg)
|
|
## ³ÔϲÌÇ·µ»Ø
|
elif msgType == "MarryEatCandy":
|
if not ret:
|
return
|
__DoMarryEatCandy(curPlayer, ret)
|
|
## ¹ºÂò»éÀñÑÌ»¨·µ»Ø
|
elif msgType == "MarryBuyFireworks":
|
if not ret:
|
return
|
__DoMarryBuyFireworks(curPlayer, ret)
|
|
## Àë»éÇëÇó·µ»Ø
|
elif msgType == "MarryBreakReq":
|
if not ret:
|
return
|
__DoMarryBreakReq(curPlayer, ret)
|
|
return
|
|
def __DoSendFlowers(curPlayer, dataMsg):
|
## ËÍ»¨·½´¦Àí
|
|
playerID = curPlayer.GetPlayerID()
|
tagPlayerID, flowerID, flowerCount, addCharm = dataMsg[:4]
|
|
costItemIndexList, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, flowerID, flowerCount)
|
lackCnt = flowerCount - bindCnt - unBindCnt
|
if lackCnt > 0:
|
GameWorld.ErrLog("µØÍ¼ÏÊ»¨µÀ¾ß²»×㣬ÎÞ·¨ÔùËÍ! tagPlayerID=%s,flowerID=%s,flowerCount=%s,lackCnt=%s"
|
% (tagPlayerID, flowerID, flowerCount, lackCnt), playerID)
|
return
|
|
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)
|
return
|
|
def __DoMarryEatCandy(curPlayer, retInfo):
|
## Ö´ÐгÔϲÌǽá¹û
|
|
canBuy, isFree, costMoneyType, costMoneyValue, candyItemInfo = retInfo
|
|
if not isFree:
|
if not PlayerControl.HaveMoney(curPlayer, costMoneyType, costMoneyValue):
|
return
|
|
if not canBuy:
|
return
|
|
GameWorld.Log("³ÔϲÌǽá¹û: isFree=%s" % (isFree), curPlayer.GetPlayerID())
|
|
if not isFree:
|
infoDict = {ChConfig.Def_Cost_Reason_SonKey:"EatCandy"}
|
PlayerControl.PayMoney(curPlayer, costMoneyType, costMoneyValue, ChConfig.Def_Cost_Love, infoDict, isMinus=True)
|
|
ItemControler.GivePlayerItemOrMail(curPlayer, candyItemInfo)
|
return
|
|
def __DoMarryBuyFireworks(curPlayer, retInfo):
|
## Ö´ÐйºÂò»éÀñÑÌ»¨½á¹û
|
|
costMoneyType, costMoneyValue = retInfo
|
GameWorld.Log("Ö´ÐйºÂò»éÀñÑÌ»¨½á¹û: costMoneyType=%s, costMoneyValue=%s" % (costMoneyType, costMoneyValue), curPlayer.GetPlayerID())
|
|
infoDict = {ChConfig.Def_Cost_Reason_SonKey:"MarryBuyFireworks"}
|
PlayerControl.PayMoney(curPlayer, costMoneyType, costMoneyValue, ChConfig.Def_Cost_Love, infoDict, isMinus=True)
|
return
|
|
def __DoMarryBreakReq(curPlayer, retInfo):
|
## Àë»éÇëÇó½á¹û·µ»Ø
|
|
costMoneyType, costMoneyValue = retInfo
|
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) # ÊÇ·ñлé
|
playerID = curPlayer.GetPlayerID()
|
|
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)
|
|
if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveRingClassLV) == 0:
|
GameWorld.DebugLog("¼¤»îÇé½ä!")
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveRingClassLV, 1)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveRingStarLV, 1)
|
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)
|
if ipyData:
|
moneyType, moneyValue = ipyData.GetCostMoneyInfo()
|
infoDict = {ChConfig.Def_Cost_Reason_SonKey:"MarrySuccess", "bridePriceID":bridePriceID}
|
PlayerControl.PayMoney(curPlayer, moneyType, moneyValue, ChConfig.Def_Cost_Love, infoDict, isMinus=True)
|
|
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)
|
|
GameWorld.Log("Çå³ý°é¹ØÏµ³É¹¦! coupleID=%s" % (coupleID), playerID)
|
RefreshLoveAttr(curPlayer)
|
return
|
|
#// B3 17 Çé½ä½âËø #tagCMLoveRingUnlock
|
#
|
#struct tagCMLoveRingUnlock
|
#{
|
# tagHead Head;
|
#};
|
def OnLoveRingUnlock(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
playerID = curPlayer.GetPlayerID()
|
unlockItemID = IpyGameDataPY.GetFuncCfg("LoveRing", 1)
|
|
unlockItem = ItemCommon.FindItemInPackByItemID(curPlayer, unlockItemID, IPY_GameWorld.rptItem)
|
if not ItemCommon.CheckItemCanUse(unlockItem):
|
GameWorld.DebugLog("ÎïÆ·½âËøÇé½äȱÉÙµÀ¾ß! unlockItemID=%s" % unlockItemID, playerID)
|
return
|
ItemCommon.DelItem(curPlayer, unlockItem, 1)
|
|
classLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveRingClassLV)
|
if classLV < 1:
|
GameWorld.DebugLog("ÎïÆ·½âËøÇé½ä!", playerID)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveRingClassLV, 1)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveRingStarLV, 1)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveRingEatCount, 0)
|
Sync_LoveRingInfo(curPlayer)
|
RefreshLoveAttr(curPlayer)
|
|
NetPackCommon.SendFakePack(curPlayer, ChPyNetSendPack.tagMCLoveRingUnlockOK())
|
return
|
|
#// B3 18 Çé½äÉý¼¶ #tagCMLoveRingUp
|
#
|
#struct tagCMLoveRingUp
|
#{
|
# tagHead Head;
|
# DWORD UseItemCnt; //ÏûºÄ²ÄÁϸöÊý
|
#};
|
def OnLoveRingUp(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
costItemCount = clientData.UseItemCnt # ÏûºÄ²ÄÁϸöÊý
|
#isAutoBuy = False # ±¾¹¦ÄÜÔݲ»Ìṩ×Ô¶¯¹ºÂò
|
playerID = curPlayer.GetPlayerID()
|
|
classLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveRingClassLV)
|
if not classLV:
|
GameWorld.DebugLog("Çé½äδ½âËø!", playerID)
|
return
|
|
starLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveRingStarLV)
|
curEatItemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveRingEatCount)
|
|
ringIpyData = IpyGameDataPY.GetIpyGameData("LoveRing", classLV, starLV)
|
if not ringIpyData:
|
return
|
needEatCount = ringIpyData.GetNeedEatCount()
|
|
if not needEatCount:
|
GameWorld.DebugLog("Çé½äÒÑÂú¼¶£¡classLV=%s,starLV=%s" % (classLV, starLV), playerID)
|
return
|
|
costItemID = IpyGameDataPY.GetFuncCfg("LoveRing", 2)
|
if not costItemID or costItemCount <= 0:
|
return
|
|
costItemIndexList, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, costItemID, costItemCount)
|
lackCnt = costItemCount - bindCnt - unBindCnt
|
if lackCnt > 0:
|
GameWorld.DebugLog("ÏûºÄµÀ¾ß²»×㣬ÎÞ·¨Éý¼¶Çé½ä! costItemID=%s,costItemCount=%s,bindCnt=%s,unBindCnt=%s,lackCnt=%s"
|
% (costItemID, costItemCount, bindCnt, unBindCnt, lackCnt), playerID)
|
return
|
delCnt = costItemCount
|
|
updClassLV, updStarLV = classLV, starLV
|
updEatItemCount = curEatItemCount + costItemCount
|
GameWorld.DebugLog("Çé½äÉý¼¶: classLV=%s,starLV=%s,curEatItemCount=%s,costItemCount=%s,updEatItemCount=%s,needEatCount=%s"
|
% (classLV, starLV, curEatItemCount, costItemCount, updEatItemCount, needEatCount), playerID)
|
|
ringUpType = ""
|
if updEatItemCount >= needEatCount:
|
ringUpType = "starUp"
|
updStarLV += 1
|
nextRingIpyData = IpyGameDataPY.GetIpyGameDataNotLog("LoveRing", updClassLV, updStarLV)
|
if not nextRingIpyData:
|
updClassLV += 1
|
updStarLV = 1
|
nextRingIpyData = IpyGameDataPY.GetIpyGameData("LoveRing", updClassLV, updStarLV)
|
if not nextRingIpyData:
|
GameWorld.ErrLog("Çé½äÉý¼¶Êý¾ÝÒì³£: classLV=%s,starLV=%s,curEatItemCount=%s,costItemCount=%s,updEatItemCount=%s,needEatCount=%s"
|
% (classLV, starLV, curEatItemCount, costItemCount, updEatItemCount, needEatCount), playerID)
|
return
|
ringUpType = "classUp"
|
updEatItemCount -= needEatCount
|
|
# ¿Û³ýÏûºÄ
|
if delCnt:
|
ItemCommon.DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, delCnt, "LoveRing")
|
|
# ÉýÐÇ
|
if ringUpType == "starUp":
|
GameWorld.DebugLog(" ÉýÐÇ: updClassLV=%s,updStarLV=%s,updEatItemCount=%s" % (updClassLV, updStarLV, updEatItemCount), playerID)
|
|
# Éý½×
|
elif ringUpType == "classUp":
|
GameWorld.DebugLog(" Éý½×: updClassLV=%s,updStarLV=%s,updEatItemCount=%s" % (updClassLV, updStarLV, updEatItemCount), playerID)
|
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveRingClassLV, updClassLV)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveRingStarLV, updStarLV)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_LoveRingEatCount, updEatItemCount)
|
|
Sync_LoveRingInfo(curPlayer)
|
RefreshLoveAttr(curPlayer)
|
return
|
|
def RefreshLoveAttr(curPlayer):
|
CalcLoveAttr(curPlayer)
|
PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
|
return
|
|
def CalcLoveAttr(curPlayer):
|
|
classLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveRingClassLV)
|
starLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveRingStarLV)
|
|
coupleID = PlayerControl.GetCoupleID(curPlayer)
|
|
allAttrList = [{} for _ in range(4)]
|
allAttrListCouple = [{} for _ in range(4)]
|
|
ipyDataMgr = IpyGameDataPY.IPY_Data()
|
for index in xrange(ipyDataMgr.GetLoveRingCount()):
|
ringIpyData = ipyDataMgr.GetLoveRingByIndex(index)
|
dataClassLV = ringIpyData.GetRingClassLV()
|
dataStarLV = ringIpyData.GetRingStarLV()
|
if dataClassLV > classLV or (dataClassLV == classLV and dataStarLV > starLV):
|
break
|
elif dataClassLV == classLV and dataStarLV == starLV:
|
upItemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveRingEatCount)
|
else:
|
upItemCount = ringIpyData.GetNeedEatCount()
|
|
# ½×ÐÇÊôÐÔ
|
starAttrTypeList = ringIpyData.GetStarAttrType()
|
starAttrValueList = ringIpyData.GetStarAttrValue()
|
for i, attrID in enumerate(starAttrTypeList):
|
attrValue = starAttrValueList[i]
|
PlayerControl.CalcAttrDict_Type(attrID, attrValue, allAttrList)
|
|
# Éý¼¶¸öÊýÊôÐÔ
|
upItemPerCount = ringIpyData.GetUpEatItemPerCount()
|
if upItemCount and upItemPerCount:
|
upItemAttrTypeList = ringIpyData.GetUpItemAttrType()
|
upItemAttrValueList = ringIpyData.GetUpItemAttrValue()
|
attrMultiple = upItemCount / upItemPerCount
|
for i, attrID in enumerate(upItemAttrTypeList):
|
attrValue = upItemAttrValueList[i]
|
PlayerControl.CalcAttrDict_Type(attrID, attrValue * attrMultiple, allAttrList)
|
|
# ÏÉÂÂÊôÐÔ
|
if coupleID:
|
coupleAttrTypeList = ringIpyData.GetCoupleAttrType()
|
coupleAttrValueList = ringIpyData.GetCoupleAttrValue()
|
for i, attrID in enumerate(coupleAttrTypeList):
|
attrValue = coupleAttrValueList[i]
|
PlayerControl.CalcAttrDict_Type(attrID, attrValue, allAttrListCouple)
|
|
#GameWorld.DebugLog("Çé½ä»ù´¡ÊôÐÔ: classLV=%s,starLV=%s,allAttrList=%s" % (classLV, starLV, allAttrList))
|
#GameWorld.DebugLog("Çé½äÏÉÂÂÊôÐÔ: classLV=%s,starLV=%s,allAttrListCouple=%s" % (classLV, starLV, allAttrListCouple))
|
|
# ±£´æ¼ÆËãÖµ
|
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):
|
## ͬ²½Çé½äÐÅÏ¢
|
clientPack = ChPyNetSendPack.tagMCLoveRingInfo()
|
clientPack.ClassLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveRingClassLV)
|
clientPack.StarLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveRingStarLV)
|
clientPack.EatCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_LoveRingEatCount)
|
NetPackCommon.SendFakePack(curPlayer, clientPack)
|
return
|
|