#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#-------------------------------------------------------------------------------
|
#
|
#-------------------------------------------------------------------------------
|
#
|
##@package Event.EventSrc.Operate_EquipPlus
|
#
|
# @todo:²¿Î»ÐǼ¶¹«¹²Ä£Ê½Ç¿»¯
|
# @author hxp
|
# @date 2015-12-15
|
# @version 1.2
|
#
|
# ÏêϸÃèÊö: ²¿Î»ÐǼ¶¹«¹²Ä£Ê½Ç¿»¯
|
#
|
# @change: "2016-06-30 21:30" hxp Ç¿»¯´ïÈË¿ª·þ»î¶¯
|
# @change: "2016-10-08 18:00" hxp ×Ô¶¯¹ºÂòÎïÆ·¼Û¸ñͳһȡÉ̳ÇÎïÆ·¼Û¸ñ
|
#
|
#---------------------------------------------------------------------
|
#"""Version = 2016-10-08 18:00"""
|
#---------------------------------------------------------------------
|
import ItemCommon
|
import ShareDefine
|
import PlayerControl
|
import IPY_GameWorld
|
import OpenServerCampaign
|
import DataRecordPack
|
import PlayerActivity
|
import PlayerSuccess
|
import IpyGameDataPY
|
import GameWorld
|
import ChConfig
|
import ChEquip
|
import EventShell
|
#-------------------------------------------------------------------------------------------
|
|
#===============================================================================
|
# //A3 01 ×°±¸Ç¿»¯ #tagEquipPlus
|
# struct tagEquipPlus
|
# {
|
# tagHead Head;
|
# BYTE PackType; //±³°üÀàÐÍ:rptItem, rptEquip, rptPetEquip1~5
|
# WORD ItemIndex; //ÎïÆ·ÔÚ±³°üÖÐË÷Òý
|
# };
|
#===============================================================================
|
## ×°±¸Ç¿»¯
|
# @param playerIndex: Íæ¼Ò
|
# @param clientData: ·â°ü
|
# @param tick: µ±Ç°Ê±¼ä
|
# @return None
|
def OnEquipMayaPlus(playerIndex, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
|
playerID = curPlayer.GetPlayerID()
|
|
packType = clientData.PackType
|
index = clientData.ItemIndex
|
|
# ÅÐ¶Ï 1.×°±¸ 2.×î¸ßÇ¿»¯µÈ¼¶£¬ 3.ÍÇ®Êý
|
if packType not in ChConfig.Pack_EquipPart_CanPlusStar:
|
GameWorld.DebugLog("packType not in ChConfig.Pack_EquipPart_CanPlusStar", playerID)
|
return
|
|
indexList = ChConfig.Pack_EquipPart_CanPlusStar[packType]
|
if index not in indexList:
|
GameWorld.Log(" index not in ChConfig.Pack_EquipPart_CanPlusStar", playerID)
|
return
|
|
# Ôݲ»ÅжϿªÆôµÈ¼¶Óɿͻ§¶Ë´¦Àí
|
# µ±Ç°×°±¸µÈ¼¶ÊÇ·ñµ½´ï×î¸ßµÈ¼¶
|
curPack = curPlayer.GetItemManager().GetPack(packType)
|
curEquip = curPack.GetAt(index)
|
if not curEquip or curEquip.IsEmpty():
|
GameWorld.DebugLog("OnEquipMayaPlus() equip is empty")
|
return
|
|
maxStarLV = ItemCommon.GetItemMaxStarLV(curEquip)
|
curPartStarLV = ChEquip.GetEquipPartStarLV(curPlayer, packType, index)
|
if curPartStarLV >= maxStarLV:
|
GameWorld.Log("OnEquipMayaPlus:curPartStarLV(%s) >= maxStarLV(%s)" % (curPartStarLV, maxStarLV), playerID)
|
return
|
|
# Ç¿»¯´¦Àí
|
result = DoLogic_EquipMayaPlus(curPlayer, curEquip, packType, index)
|
|
updPartStarLV = ChEquip.GetEquipPartStarLV(curPlayer, packType, index)
|
#GameWorld.Log(" result=%s,curStarLV=%s,updStarLV=%s" % (result, curPartStarLV, updPartStarLV), playerID)
|
if result == ChConfig.Def_ComposeState_None:
|
return
|
|
#===========================================================================
|
# curPlayer.Sync_MakeItemAnswer(ShareDefine.Def_mitEquipMayaPlus, result)
|
|
# ÿÈջ
|
PlayerActivity.AddDailyActionFinishCnt(curPlayer, ShareDefine.DailyActionID_EquipPlus)
|
#===========================================================================
|
|
|
# ÐǼ¶±ä¸üʱ´¦Àí
|
if curPartStarLV != updPartStarLV:
|
DoLogic_OnEquipPartStarLVChange(curPlayer, packType)
|
# Ôö¼ÓÇ¿»¯³É¾Í
|
PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_EquipPlus, 1)
|
EventShell.EventRespons_EquipPlus(curPlayer)
|
return
|
|
|
|
## ¿ªÊ¼×°±¸Ç¿»¯
|
# @param index Ϊװ±¸Î»
|
# @return
|
def DoLogic_EquipMayaPlus(curPlayer, curEquip, packType, index):
|
result = ChConfig.Def_ComposeState_None
|
|
findType = ChEquip.GetEquipPlusType(curEquip)
|
if findType == -1:
|
return result
|
|
curPartStarLV = ChEquip.GetEquipPartStarLV(curPlayer, packType, index)
|
ipyData = IpyGameDataPY.GetIpyGameData("ItemPlus", findType, curPartStarLV)
|
if not ipyData:
|
return
|
costSilver = ipyData.GetCostCount()
|
|
if not PlayerControl.HaveMoney(curPlayer, IPY_GameWorld.TYPE_Price_Silver_Money, costSilver):
|
# ½ð±Ò²»×㣬·µ»Ø
|
return result
|
|
totalExp = ipyData.GetTotalExp()
|
curExp = ChEquip.GetEquipPartProficiency(curPlayer, packType, index) + ipyData.GetAddExp()
|
|
if curExp >= totalExp:
|
#Éý¼¶
|
curPartStarLV = __EquipMayaPlusChange(curPlayer, packType, curEquip, index)
|
curExp = curExp - totalExp
|
|
ChEquip.SetEquipPartProficiency(curPlayer, packType, index, curExp)
|
ChEquip.NotifyEquipPartStarLV(curPlayer, packType, index)
|
# Ö§¸¶½ð±Ò
|
PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Silver_Money, costSilver, isNotify=False)
|
|
DataRecordPack.DR_UpStarLVSuccess(curPlayer, curExp, curPartStarLV)
|
return ChConfig.Def_ComposeState_Sucess
|
|
|
|
## ÂêÑżÓÇ¿µÈ¼¶¸Ä±ä
|
# @param curPlayer: Íæ¼Ò
|
# @param packType: ±³°üÀàÐÍ
|
# @param curEquip: µ±Ç°×°±¸
|
# @param succeedRate: ³É¹¦ÂÊ
|
# @param failStarLV: ʧ°ÜʱµÄÐǼ¶Êý
|
# @return
|
def __EquipMayaPlusChange(curPlayer, packType, curEquip, index):
|
curPlusLV = ChEquip.GetEquipPartStarLV(curPlayer, packType, index)
|
updPlusLV = curPlusLV + 1
|
ChEquip.SetEquipPartStarLV(curPlayer, packType, index, curEquip, updPlusLV)
|
|
broadCastLVList = IpyGameDataPY.GetFuncEvalCfg("StrengthenLevelBroadCast", 1)
|
#GameWorld.DebugLog("PlusLVChange index=%s,updPlusLV=%s,broadCastLVList=%s" % (index, updPlusLV, broadCastLVList))
|
if updPlusLV in broadCastLVList:
|
msgParamList = [curPlayer.GetPlayerName()] + ItemCommon.GetNotifySuperItemInfo(curPlayer, curEquip, index) + [updPlusLV]
|
PlayerControl.WorldNotify(0, "StrengthenCongratulation", msgParamList)
|
|
# ³É¾Í
|
#PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_EquipPlusLV, 1, [updPlusLV])
|
|
|
|
#ÈÎÎñ´¥·¢
|
#EventShell.EventRespons_OnEquipPartStarUp(curPlayer, setLV)
|
# ¿ª·þ»î¶¯Êý¾Ý
|
OpenServerCampaign.UpdOpenServerCampaignRecordData(curPlayer, ShareDefine.Def_Campaign_Type_PlusLV, ChEquip.GetTotalPlusLV(curPlayer))
|
return updPlusLV
|
|
|
def DoLogic_OnEquipPartStarLVChange(curPlayer, packType):
|
#ÏÈË¢×°±¸BUFF ÔÙ¼ÆËãÊôÐÔ
|
curPlayer.SetDict(ChConfig.Def_PlayerKey_AttrActivatyNotify, ChConfig.Def_AttrActivatyNotify_Plus)
|
ChEquip.RefreshPlayerEquipAttribute(curPlayer)
|
|
#Ë¢ÐÂËùÓÐÊôÐÔ
|
playControl = PlayerControl.PlayerControl(curPlayer)
|
playControl.RefreshPlayerAttrState()
|
return
|
|
|
## È«Éí12²¿Î»Ç¿»¯µÈ¼¶×îµÍµÄÒ»¼þÇ¿»¯µÈ¼¶
|
#def GetMinPlusLV(curPlayer):
|
# packType = IPY_GameWorld.rptEquip
|
# minPlusLV = GetMaxEquipPartStarLV()
|
# equipPartIndexList = ChConfig.Pack_EquipPart_CanPlusStar.get(packType, [])
|
# for i in equipPartIndexList:
|
# partStarLV = ChEquip.GetEquipPartStarLV(curPlayer, packType, i)
|
# if partStarLV < minPlusLV:
|
# minPlusLV = partStarLV
|
# return minPlusLV
|