#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#-------------------------------------------------------------------------------
|
#
|
##@package Player.PlayerCharm
|
#
|
# @todo:÷ÈÁ¦
|
# @author hxp
|
# @date 2021-12-03
|
# @version 1.0
|
#
|
# ÏêϸÃèÊö: ÷ÈÁ¦
|
#
|
#-------------------------------------------------------------------------------
|
#"""Version = 2021-12-03 19:00"""
|
#-------------------------------------------------------------------------------
|
|
import ChConfig
|
import PlayerControl
|
import IpyGameDataPY
|
import ItemControler
|
import GameWorld
|
|
def OnPlayerLogin(curPlayer):
|
|
# ÖØÐÂÉèÖ㬴¥·¢ÉÏÏß֪ͨ
|
if PlayerControl.GetCharmLV(curPlayer):
|
PlayerControl.SetCharmLV(curPlayer, PlayerControl.GetCharmLV(curPlayer))
|
|
return
|
|
def GameServer_DoLogic_Charm(curPlayer, msgData):
|
|
msgType = msgData[0]
|
|
## ÷ÈÁ¦µÈ¼¶ÌáÉý
|
if msgType == "CharmLVUp":
|
totalCharm = msgData[1]
|
__DoCharmLVUp(curPlayer, totalCharm)
|
|
return
|
|
def __DoCharmLVUp(curPlayer, totalCharm):
|
|
playerID = curPlayer.GetPlayerID()
|
charmLV = PlayerControl.GetCharmLV(curPlayer)
|
ipyData = IpyGameDataPY.GetIpyGameData("LoveCharm", charmLV)
|
if not ipyData:
|
return
|
|
if not ipyData.GetUpNeedCharm():
|
GameWorld.DebugLog("÷ÈÁ¦µÈ¼¶ÒÑÂú¼¶£¬ÎÞ·¨Éý¼¶! charmLV=%s" % charmLV, playerID)
|
return
|
|
if totalCharm < ipyData.GetUpNeedCharm():
|
GameWorld.DebugLog("÷ÈÁ¦Öµ²»×㣬ÎÞ·¨Éý¼¶! totalCharm=%s < %s, charmLV=%s" % (totalCharm, ipyData.GetUpNeedCharm(), charmLV), playerID)
|
return
|
|
charmLV += 1
|
nextLVIpyData = IpyGameDataPY.GetIpyGameData("LoveCharm", charmLV)
|
if not nextLVIpyData:
|
return
|
awardItemList = nextLVIpyData.GetLVAwardItemInfo()
|
GameWorld.DebugLog("÷ÈÁ¦µÈ¼¶Éý¼¶! charmLV=%s" % charmLV, playerID)
|
PlayerControl.SetCharmLV(curPlayer, charmLV)
|
ItemControler.GivePlayerItemOrMail(curPlayer, awardItemList)
|
RefreshCharmAttr(curPlayer)
|
return
|
|
def RefreshCharmAttr(curPlayer):
|
CalcCharmAttr(curPlayer)
|
PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
|
return
|
|
def CalcCharmAttr(curPlayer):
|
|
allAttrList = [{} for _ in range(4)]
|
|
charmLV = PlayerControl.GetCharmLV(curPlayer)
|
|
ipyData = IpyGameDataPY.GetIpyGameData("LoveCharm", charmLV)
|
if ipyData:
|
lvAttrTypeList = ipyData.GetLVAttrType()
|
lvAttrValueList = ipyData.GetLVAttrValue()
|
for i, attrID in enumerate(lvAttrTypeList):
|
attrValue = lvAttrValueList[i]
|
PlayerControl.CalcAttrDict_Type(attrID, attrValue, allAttrList)
|
|
# ±£´æ¼ÆËãÖµ
|
PlayerControl.SetCalcAttrListValue(curPlayer, ChConfig.Def_CalcAttrFunc_Charm, allAttrList)
|
return
|
|
|