#!/usr/bin/python
|
# -*- coding: GBK -*-
|
# -------------------------------------------------------------------------------
|
#
|
##@package Event.EventSrc.Operate_EquipStone
|
#
|
# @todo:×°±¸±¦Ê¯
|
# @author hxp
|
# @date 2017-07-29
|
# @version 1.0
|
#
|
# ÏêϸÃèÊö: ×°±¸±¦Ê¯
|
#
|
# -------------------------------------------------------------------------------
|
# """Version = 2017-07-29 12:00"""
|
# -------------------------------------------------------------------------------
|
|
import GameWorld
|
import ItemCommon
|
import PlayerControl
|
import IPY_GameWorld
|
import ItemControler
|
import IpyGameDataPY
|
import ChConfig
|
import ChEquip
|
import OpenServerCampaign
|
import ChPyNetSendPack
|
import NetPackCommon
|
import DataRecordPack
|
import PlayerSuccess
|
import PlayerWeekParty
|
import ShareDefine
|
import EventShell
|
|
g_stoneCanPlaceList = [] # ¿ÉÏâǶµÄλÖÃ
|
|
|
# def OnLogin(curPlayer):
|
# ###µÇ¼·¢°üͬ²½¿Í»§¶Ë±¦Ê¯ÐÅÏ¢
|
# Sycn_StoneHoleInfo(curPlayer)
|
# return
|
|
def GetAllStoneEquipIndexList():
|
###µÃµ½ËùÓпÉÏâǶ±¦Ê¯×°±¸Î»Áбí
|
global g_stoneCanPlaceList
|
if g_stoneCanPlaceList:
|
return g_stoneCanPlaceList
|
# »ñµÃ±¦Ê¯ÀàÐÍÊýÁ¿
|
GemTypeCount = IpyGameDataPY.GetFuncCfg("GemTypeCount")
|
# »ñµÃËùÓпÉÏâǶ±¦Ê¯×°±¸Î»
|
g_stoneCanPlaceList = []
|
for stoneTypeIndex in xrange(1, GemTypeCount + 1):
|
# Ñ»·±¦Ê¯ÀàÐͶÔÓ¦µÄ×°±¸Î»
|
placeList = IpyGameDataPY.GetFuncEvalCfg("GemType%s" % stoneTypeIndex, 1)
|
for place in placeList:
|
ipyDataList = IpyGameDataPY.GetIpyGameDataByCondition('EquipPlaceIndexMap', {'EquipPlace': place}, True)
|
if not ipyDataList:
|
continue
|
for ipyData in ipyDataList:
|
gridIndex = ipyData.GetGridIndex()
|
if gridIndex not in g_stoneCanPlaceList:
|
g_stoneCanPlaceList.append(gridIndex)
|
return g_stoneCanPlaceList
|
|
|
def GetAllEquipPlaceHoleIndex():
|
### µÃµ½×°±¸Î»ËùÓп×λ
|
gemOpenNeedStarList = IpyGameDataPY.GetFuncEvalCfg("GemOpen", 1)
|
maxEquipHoleCnt = len(gemOpenNeedStarList) # ×î´ó×°±¸½×¼¶¿ª·Å¿×Êý
|
|
gemOpenVipList = IpyGameDataPY.GetFuncEvalCfg("GemOpenVip", 1)
|
maxHoleVipCnt = len(gemOpenVipList) # ×î´óVip¿ª·Å¿×Êý
|
|
return range(maxEquipHoleCnt) + range(ChConfig.Def_Stone_VipHole, ChConfig.Def_Stone_VipHole + maxHoleVipCnt)
|
|
|
def GetEquipIndexStoneIDList(curPlayer, equipIndex):
|
### ×°±¸Î»¿×λ±¦Ê¯IDÁбí
|
|
holeIndexList = GetAllEquipPlaceHoleIndex()
|
holeStoneIDList = []
|
for holeIndex in holeIndexList:
|
stoneID = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)[0]
|
holeStoneIDList.append(stoneID)
|
return holeStoneIDList
|
|
|
def GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex):
|
'''»ñµÃ×°±¸Î»¿×λ±¦Ê¯IDºÍ°ó¶¨ÐÅÏ¢
|
@return: stoneID, stoneIsBind
|
'''
|
# »ñµÃ×°±¸Î»¿×Ë÷Òý±¦Ê¯´æ´¢ÐÅÏ¢
|
stoneInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_EquipPartStoneID % (equipIndex, holeIndex))
|
# »ñȡװ±¸Î»¿×λÉϱ¦Ê¯ID
|
stoneID = stoneInfo / ChConfig.Def_Stone_SaveStoneInfoXNumber
|
# »ñȡװ±¸Î»¿×λÉϱ¦Ê¯ÊÇ·ñ°ó¶¨×´Ì¬
|
stoneIsBind = stoneInfo % ChConfig.Def_Stone_SaveStoneInfoXNumber
|
return stoneID, stoneIsBind
|
|
|
def SetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex, changeStoneID, isBind):
|
### ±£´æ×°±¸Î»¿×λ±¦Ê¯IDºÍ°ó¶¨ÐÅÏ¢
|
befStoneID, befIsBind = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)
|
if befStoneID == changeStoneID and befIsBind == isBind:
|
return
|
|
isBind = 0 # ÏÖ°ó¶¨ÎÞÓã¬Ä¬ÈÏ´æ0
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_EquipPartStoneID % (equipIndex, holeIndex),
|
changeStoneID * ChConfig.Def_Stone_SaveStoneInfoXNumber + isBind)
|
|
# ͬ²½¸üб¦Ê¯×ܵȼ¶
|
gameData = GameWorld.GetGameData()
|
befStoneLV = 0
|
if befStoneID:
|
befGem = gameData.GetItemByTypeID(befStoneID)
|
befStoneLV = 0 if not befGem else befGem.GetEffectByIndex(0).GetEffectValue(1)
|
|
aftStoneLV = 0
|
if changeStoneID:
|
aftGem = gameData.GetItemByTypeID(changeStoneID)
|
aftStoneLV = 0 if not aftGem else aftGem.GetEffectByIndex(0).GetEffectValue(1)
|
|
befTotalStoneLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalStoneLV)
|
updTotalStoneLV = max(0, befTotalStoneLV + aftStoneLV - befStoneLV)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalStoneLV, updTotalStoneLV)
|
GameWorld.DebugLog(
|
"ÉèÖñ¦Ê¯µÈ¼¶: equipIndex=%s,holeIndex=%s,befStoneLV=%s,aftStoneLV=%s,befTotalStoneLV=%s,updTotalStoneLV=%s"
|
% (equipIndex, holeIndex, befStoneLV, aftStoneLV, befTotalStoneLV, updTotalStoneLV))
|
return
|
|
|
def GetPackTypeByEquipPlace(equipPlace):
|
##Ŀǰ֧³ÖÏâǶÆÕͨװ±¸
|
equipPackType = IPY_GameWorld.rptEquip
|
stonePackType = IPY_GameWorld.rptItem
|
placeIndex = equipPlace
|
return equipPackType, stonePackType, placeIndex
|
|
|
# //A3 04 ±¦Ê¯ÏâǶ»òÌæ»» #tagCMEquipEnchase
|
# struct tagCMEquipEnchase
|
# {
|
# tagHead Head;
|
# BYTE EquipIndex; //×°±¸Î»Ë÷Òý
|
# BYTE StoneIndex; //±¦Ê¯ËùÔÚÍæ¼ÒÎïÆ·±³°üË÷Òý
|
# BYTE HoleIndex; //Ñ¡ÔñµÄ¿×Ë÷Òý
|
# };
|
def OnEquipEnchase(playerIndex, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
|
playerID = curPlayer.GetPlayerID()
|
|
# ÑéÖ¤±³°üÀàÐͺϷ¨ÐÔ
|
equipPackIndex = clientData.EquipIndex
|
stoneIndex = clientData.StoneIndex
|
holeIndex = clientData.HoleIndex
|
|
GameWorld.DebugLog("±¦Ê¯ÏâǶ: equipPackIndex=%s,stoneIndex=%s,holeIndex=%s" % (equipPackIndex, stoneIndex, holeIndex),
|
playerID)
|
equipPackType, stonePackType, placeIndex = GetPackTypeByEquipPlace(equipPackIndex)
|
|
# »ñµÃ×°±¸Î»×°±¸ÊµÀý
|
equipPack = curPlayer.GetItemManager().GetPack(equipPackType)
|
curEquip = equipPack.GetAt(placeIndex)
|
|
if not ItemCommon.CheckItemCanUse(curEquip):
|
GameWorld.Log("Ä¿±ê×°±¸Îª¿Õ»ò²»¿ÉÓã¬ÎÞ·¨ÏâǶ£¡", playerID)
|
return
|
|
# »ñµÃ±¦Ê¯ÊµÀý
|
itemPack = curPlayer.GetItemManager().GetPack(stonePackType)
|
curStone = itemPack.GetAt(stoneIndex)
|
|
if not ItemCommon.CheckItemCanUse(curStone):
|
GameWorld.Log("Ä¿±ê±¦Ê¯Îª¿Õ»ò²»¿ÉÓã¬ÎÞ·¨ÏâǶ£¡", playerID)
|
return
|
|
stoneItemID = curStone.GetItemTypeID()
|
isBind = curStone.GetIsBind()
|
curStoneEff = curStone.GetEffectByIndex(0)
|
curEffID = curStoneEff.GetEffectID()
|
if curEffID != ChConfig.Def_Effect_EquipStone:
|
GameWorld.Log("²»ÊDZ¦Ê¯£¬ÎÞ·¨ÏâǶ£¡stoneIndex=%s,stoneItemID=%s,curEffID=%s != %s"
|
% (stoneIndex, stoneItemID, curEffID, ChConfig.Def_Effect_EquipStone), playerID)
|
return
|
|
stoneEffType = curStoneEff.GetEffectValue(0)
|
stoneCanPlaceList = IpyGameDataPY.GetFuncEvalCfg("GemType%s" % stoneEffType, 1)
|
ipyData = IpyGameDataPY.GetIpyGameDataByCondition('EquipPlaceIndexMap', {'GridIndex': equipPackIndex})
|
if not ipyData:
|
return
|
classLV = ipyData.GetClassLV()
|
if ipyData.GetEquipPlace() not in stoneCanPlaceList:
|
GameWorld.Log("¸Ã±¦Ê¯²»¿ÉÏâǶÔÚ¸Ã×°±¸Î»£¡stoneItemID=%s,stoneEffType=%s,stoneCanPlaceList=%s,equipPackIndex=%s"
|
% (stoneItemID, stoneEffType, stoneCanPlaceList, equipPackIndex), playerID)
|
return
|
|
equipStar = ChEquip.GetEquipPartStarByRank(curPlayer, placeIndex, curEquip)
|
if not __CheckStoneHoleCanUse(curPlayer, equipStar, holeIndex, equipPackType):
|
return
|
|
# ¿Û³ý±¦Ê¯
|
ItemCommon.DelItem(curPlayer, curStone, 1, True, ChConfig.ItemDel_EquipEnchase,
|
{"equipPackIndex": equipPackIndex, "HoleIndex": holeIndex})
|
|
isBind = 1 if isBind else 0
|
|
# ±ä¸ü±¦Ê¯¿×±¦Ê¯ÐÅÏ¢
|
__DoChangeEquipHoleStone(curPlayer, equipPackIndex, holeIndex, stoneItemID, isBind, "EquipStone", True)
|
|
# #ÏâǶ³É¹¦
|
# if not curEquip.GetIsBind():
|
# ItemControler.SetItemIsBind(curEquip, True)
|
|
# Ë¢ÐÂÊôÐÔ
|
RefreshAttrByStoneAction(curPlayer, equipPackType, True, classLV)
|
|
# ͬ²½¿Í»§¶Ë
|
Sycn_StoneHoleInfo(curPlayer, [equipPackIndex])
|
# ³É¾Í
|
DoStoneSuccess(curPlayer)
|
|
EventShell.EventRespons_InlayStone(curPlayer)
|
return
|
|
|
def DoStoneSuccess(curPlayer):
|
#PlayerSuccess.ResetSuccessByType(curPlayer, ShareDefine.SuccType_InlayStone1)
|
#PlayerSuccess.ResetSuccessByType(curPlayer, ShareDefine.SuccType_InlayStone2)
|
totalStoneLV = 0
|
holeIndexList = GetAllEquipPlaceHoleIndex()
|
gameData = GameWorld.GetGameData()
|
packType = IPY_GameWorld.rptEquip
|
playerEquip = curPlayer.GetItemManager().GetPack(packType)
|
for equipIndex in xrange(playerEquip.GetCount()):
|
#if equipIndex not in ShareDefine.RoleEquipType:
|
# continue
|
for holeIndex in holeIndexList:
|
|
curGemID = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)[0]
|
if curGemID == 0:
|
continue
|
curGem = gameData.GetItemByTypeID(curGemID)
|
if not curGem:
|
continue
|
|
gemEffect = curGem.GetEffectByIndex(0)
|
gemType, gemLV = gemEffect.GetEffectValue(0), gemEffect.GetEffectValue(1)
|
#if gemType == 1: # ÉúÃü±¦Ê¯
|
# PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_InlayStone1, 1, [gemLV])
|
#elif gemType == 2: # »ÙÃð±¦Ê¯
|
# PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_InlayStone2, 1, [gemLV])
|
|
totalStoneLV += gemLV
|
|
# ¼Ç¼¿ª·þ»î¶¯±¦Ê¯×ܵȼ¶
|
OpenServerCampaign.UpdOpenServerCampaignRecordData(curPlayer, ShareDefine.Def_Campaign_Type_StoneLV, totalStoneLV)
|
PlayerSuccess.UptateSuccessProgress(curPlayer, ShareDefine.SuccType_StoneTotalLV, totalStoneLV)
|
PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_Stone, totalStoneLV, False, True)
|
return
|
|
|
# //A3 05 ±¦Ê¯ÕªÈ¡ #tagCMEquipStonePick
|
# struct tagCMEquipStonePick
|
# {
|
# tagHead Head;
|
# BYTE EquipIndex; //×°±¸Î»ÔÚ±³°üÖÐË÷Òý
|
# BYTE HoleIndex; //×°±¸Î»µÄ¿×Ë÷Òý
|
# };
|
def OnEquipStonePick(playerIndex, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
|
playerID = curPlayer.GetPlayerID()
|
# ÑéÖ¤±³°üÀàÐͺϷ¨ÐÔ
|
equipPackIndex = clientData.EquipIndex
|
holeIndex = clientData.HoleIndex
|
GameWorld.DebugLog("±¦Ê¯Õª³ý: equipPackIndex=%s,holeIndex=%s" % (equipPackIndex, holeIndex), playerID)
|
|
equipPackType, stonePackType, placeIndex = GetPackTypeByEquipPlace(equipPackIndex)
|
# »ñµÃ×°±¸Î»×°±¸ÊµÀý
|
equipPack = curPlayer.GetItemManager().GetPack(equipPackType)
|
curEquip = equipPack.GetAt(placeIndex)
|
|
if not ItemCommon.CheckItemCanUse(curEquip):
|
GameWorld.Log("Ä¿±ê×°±¸Îª¿Õ»ò²»¿ÉÓã¬ÎÞ·¨ÏâǶ£¡", playerID)
|
return
|
|
# ÑéÖ¤±³°ü¿Õ¼ä
|
if not ItemCommon.CheckPackHasSpace(curPlayer, stonePackType, True):
|
return
|
|
# ÑéÖ¤±¦Ê¯
|
stoneID = GetEquipIndexStoneIDAndIsBand(curPlayer, equipPackIndex, holeIndex)[0]
|
|
if not stoneID:
|
GameWorld.DebugLog("¿×Ϊ¿Õ»ò²»´æÔÚ±¦Ê¯!")
|
return
|
|
ipyData = IpyGameDataPY.GetIpyGameDataByCondition('EquipPlaceIndexMap', {'GridIndex': equipPackIndex})
|
if not ipyData:
|
return
|
classLV = ipyData.GetClassLV()
|
|
__DoChangeEquipHoleStone(curPlayer, equipPackIndex, holeIndex, 0, 0, "StonePick", True)
|
|
# Ë¢ÐÂÊôÐÔ
|
RefreshAttrByStoneAction(curPlayer, equipPackType, False, classLV)
|
|
# ͬ²½¿Í»§¶Ë
|
Sycn_StoneHoleInfo(curPlayer, [equipPackIndex])
|
|
totalStoneLV = GetTotalStoneLV(curPlayer)
|
# ¼Ç¼¿ª·þ»î¶¯±¦Ê¯×ܵȼ¶
|
OpenServerCampaign.UpdOpenServerCampaignRecordData(curPlayer, ShareDefine.Def_Campaign_Type_StoneLV, totalStoneLV)
|
PlayerWeekParty.AddWeekPartyActionCnt(curPlayer, ChConfig.Def_WPAct_Stone, totalStoneLV, False, True)
|
return
|
|
|
def GetTotalStoneLV(curPlayer):
|
##±¦Ê¯×ܵȼ¶
|
return curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalStoneLV)
|
|
|
def GetStoneCntByLV(curPlayer, stoneLV):
|
##Ö¸¶¨µÈ¼¶µÄ±¦Ê¯ÊýÁ¿
|
cnt = 0
|
holeIndexList = GetAllEquipPlaceHoleIndex()
|
equipIndexList = GetAllStoneEquipIndexList()
|
gameData = GameWorld.GetGameData()
|
for equipIndex in equipIndexList:
|
for holeIndex in holeIndexList:
|
curGemID = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)[0]
|
if curGemID == 0:
|
continue
|
curGem = gameData.GetItemByTypeID(curGemID)
|
if not curGem:
|
continue
|
gemLV = curGem.GetEffectByIndex(0).GetEffectValue(1)
|
if gemLV >= stoneLV:
|
cnt += 1
|
return cnt
|
|
|
# // A3 06 ±¦Ê¯Éý¼¶ #tagCMEquipStoneUpgrade
|
# struct tagCMEquipStoneUpgrade
|
# {
|
# tagHead Head;
|
# BYTE EquipIndex; //×°±¸Î»ÔÚ×°±¸±³°üÖеÄË÷Òý
|
# BYTE HoleIndex; //×°±¸Î»Öб¦Ê¯¿×Ë÷Òý
|
# BYTE UpWay; //Éý¼¶·½Ê½ 0:ÏÉÓñ 1:±¦Ê¯
|
# };
|
def OnEquipStoneUpgrade(playerIndex, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(playerIndex)
|
playerID = curPlayer.GetPlayerID()
|
|
# ÑéÖ¤±³°üÀàÐͺϷ¨ÐÔ
|
equipPackIndex = clientData.EquipIndex
|
holeIndex = clientData.HoleIndex
|
upWay = clientData.UpWay
|
GameWorld.DebugLog("±¦Ê¯Éý¼¶: equipPackIndex=%s,holeIndex=%s" % (equipPackIndex, holeIndex), playerID)
|
equipPackType, stonePackType, placeIndex = GetPackTypeByEquipPlace(equipPackIndex)
|
# »ñµÃ×°±¸Î»×°±¸ÊµÀý
|
equipPack = curPlayer.GetItemManager().GetPack(equipPackType)
|
curEquip = equipPack.GetAt(placeIndex)
|
|
if not ItemCommon.CheckItemCanUse(curEquip):
|
GameWorld.Log("Ä¿±ê×°±¸Îª¿Õ»ò²»¿ÉÓã¬ÎÞ·¨ÏâǶ£¡", playerID)
|
return
|
|
# Éý¼¶±¦Ê¯ID
|
stoneID, stoneIsBind = GetEquipIndexStoneIDAndIsBand(curPlayer, equipPackIndex, holeIndex)
|
if stoneID == 0:
|
GameWorld.DebugLog("¿×Ϊ¿Õ»ò²»´æÔÚ±¦Ê¯!")
|
return
|
stoneItemData = GameWorld.GetGameData().GetItemByTypeID(stoneID)
|
stoneItemID = stoneItemData.GetItemTypeID()
|
curStoneEff = stoneItemData.GetEffectByIndex(0)
|
curEffID = curStoneEff.GetEffectID()
|
if curEffID != ChConfig.Def_Effect_EquipStone:
|
GameWorld.Log("²»ÊDZ¦Ê¯£¬ÎÞ·¨Éý¼¶£¡stoneIndex=%s,stoneItemID=%s,curEffID=%s"
|
% (holeIndex, stoneItemID, curEffID), playerID)
|
return
|
stoneEffType = curStoneEff.GetEffectValue(0)
|
level = curStoneEff.GetEffectValue(1)
|
upgradeStoneID = curStoneEff.GetEffectValue(2)
|
|
GameWorld.DebugLog("stoneEffType=%s,level=%s,upgradeStoneID=%s" % (stoneEffType, level, upgradeStoneID))
|
|
if not upgradeStoneID:
|
GameWorld.Log("¸Ã±¦Ê¯ÒÑÊÇ×î´ó¼¶,²»ÄÜÉý¼¶£¡stoneIndex=%s,stoneItemID=%s,curEffID=%s,upgradeStoneID=%s"
|
% (holeIndex, stoneItemID, curEffID, upgradeStoneID), playerID)
|
return
|
needCount = IpyGameDataPY.GetFuncCfg("GemUpCostFormula", 2) # ºÏ³ÉÏÂÒ»¼¶ËùÐ豦ʯ¸öÊý
|
if not needCount:
|
return
|
ipyData = IpyGameDataPY.GetIpyGameDataByCondition('EquipPlaceIndexMap', {'GridIndex': equipPackIndex})
|
if not ipyData:
|
return
|
# ¶îÍâ²ÄÁÏ
|
extraItemInfoDict = IpyGameDataPY.GetFuncEvalCfg("GemUpCostFormula", 3, {})
|
classLV = ipyData.GetClassLV()
|
if upWay == 0: # ÏÉÓñ
|
stoneTypeItemIDDict = IpyGameDataPY.GetFuncEvalCfg("GemUpCostFormula", 1)
|
if stoneEffType not in stoneTypeItemIDDict:
|
return
|
stoneTypeItemID = stoneTypeItemIDDict[stoneEffType]
|
unitPrice = ItemCommon.GetShopItemPrice(stoneTypeItemID, IPY_GameWorld.TYPE_Price_Gold_Money)
|
if not unitPrice:
|
return
|
costCount = pow(needCount, level - 1) * (needCount - 1)
|
costGold = costCount * unitPrice
|
# ¶îÍâ²ÄÁÏ
|
costExtraItemDict = {}
|
i, cnt =0, 1
|
for lv in xrange(level+1, 1, -1):
|
cnt =1 if i is 0 else pow(needCount, i-1)
|
i+=1
|
extraItemInfo = extraItemInfoDict.get(str(lv))
|
if extraItemInfo:
|
extraItemID, extraItemCnt = extraItemInfo
|
extraItemPrice = ItemCommon.GetShopItemPrice(extraItemID, IPY_GameWorld.TYPE_Price_Gold_Money)
|
if not extraItemPrice:
|
return
|
costGold += extraItemPrice * extraItemCnt * cnt
|
costExtraItemDict[extraItemID] = costExtraItemDict.get(extraItemID, 0) + extraItemCnt * cnt
|
if costGold <= 0:
|
return
|
infoDict = {"StoneItemID": stoneItemID, "CurStoneIDLV": level, "UpgradeStoneID": upgradeStoneID,
|
"CostCount": costCount, "UnitPrice": unitPrice, 'costExtraItemDict':costExtraItemDict}
|
|
if not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, costGold,
|
ChConfig.Def_Cost_EquipStone, infoDict):
|
GameWorld.DebugLog("ÏÉÓñ²»×ã!costGold=%s" % costGold)
|
return
|
else:
|
costItemDict = {stoneItemID:needCount - 1}
|
if str(level + 1) in extraItemInfoDict:
|
extraItemID, extraItemCnt = extraItemInfoDict[str(level + 1)]
|
costItemDict[extraItemID] = extraItemCnt
|
itemPack = curPlayer.GetItemManager().GetPack(stonePackType)
|
delItemList = []
|
for itemID, itemCnt in costItemDict.items():
|
hasEnough, itemIndexList = ItemCommon.GetItem_FromPack_ByID(itemID, itemPack, itemCnt)
|
if not hasEnough:
|
GameWorld.DebugLog("²ÄÁϲ»×ã itemID=%s!£¬needCnt=%s" % (itemID, itemCnt))
|
return
|
delItemList.append([itemIndexList, itemCnt])
|
for delItemIndexList, delCnt in delItemList:
|
ItemCommon.ReduceItem(curPlayer, itemPack, delItemIndexList, delCnt, False,
|
ChConfig.ItemDel_StoneUpgrade,
|
{"equipPackIndex": equipPackIndex, "HoleIndex": holeIndex})
|
|
|
__DoChangeEquipHoleStone(curPlayer, equipPackIndex, holeIndex, upgradeStoneID, False, "StoneUpgrade", False)
|
|
# Ë¢ÐÂÊôÐÔ
|
RefreshAttrByStoneAction(curPlayer, equipPackType, False, classLV)
|
|
# ͬ²½¿Í»§¶Ë
|
Sycn_StoneHoleInfo(curPlayer, [equipPackIndex])
|
|
DoStoneSuccess(curPlayer)
|
return
|
|
def __CheckStoneHoleCanUse(curPlayer, equipStar, holeIndex, equipPackType):
|
##ÑéÖ¤¿×ºÏ·¨ÐÔ
|
|
holeIndexList = GetAllEquipPlaceHoleIndex()
|
if holeIndex not in holeIndexList:
|
GameWorld.Log("ÏâǶ¿×Ë÷Òý´íÎó!holeIndex=%s, holeIndexList=%s" % (holeIndex, holeIndexList))
|
return False
|
|
openCommHoleCnt = 0 # ÒѾ¿ª·Å×°±¸³£¹æ¿×Êý
|
|
gemOpenNeedStarList = IpyGameDataPY.GetFuncEvalCfg("GemOpen", 1)
|
for holeCnt, openStar in enumerate(gemOpenNeedStarList, 1):
|
if equipStar >= openStar:
|
openCommHoleCnt = holeCnt
|
|
# VIP¿×
|
if holeIndex >= ChConfig.Def_Stone_VipHole:
|
|
if openCommHoleCnt <= 0:
|
GameWorld.Log("×°±¸Î´¿ªÆôÈÎºÎÆÕͨ±¦Ê¯¿×£¬ÎÞ·¨¿ªÆôVIP¿×λ! equipStar=%s,openCommHoleCnt=%s" % (equipStar, openCommHoleCnt))
|
return False
|
gemOpenVipList = IpyGameDataPY.GetFuncEvalCfg("GemOpenVip", 1)
|
|
openVIPHoleCnt = 0 # ÒѾ¿ª·Å×°±¸VIP¿×Êý
|
curVipLV = curPlayer.GetVIPLv()
|
for holeCnt, vipLv in enumerate(gemOpenVipList, 1):
|
if curVipLV >= vipLv:
|
openVIPHoleCnt = holeCnt
|
|
if holeIndex >= openVIPHoleCnt + ChConfig.Def_Stone_VipHole:
|
GameWorld.Log("×°±¸VIP±¦Ê¯¿×먦·Å!curVipLV=%s,holeIndex=%s,openVIPHoleCnt=%s"
|
% (curVipLV, holeIndex, openVIPHoleCnt), curPlayer.GetPlayerID())
|
return False
|
|
# ²»ÏÞÖÆÊÇ·ñ¹ýÆÚ
|
# if not PlayerVip.GetCurVIPTime(curPlayer):
|
# GameWorld.Log("VIPÒѹýÆÚ£¬ÎÞ·¨Ê¹ÓÃVIP±¦Ê¯¿×£¡", curPlayer.GetPlayerID())
|
# return False
|
|
# ³£¹æ¿×
|
elif holeIndex >= openCommHoleCnt:
|
GameWorld.Log("¸Ã×°±¸±¦Ê¯¿×Ϊ¿ª·Å£¡equipStar=%s,holeIndex=%s,openCommHoleCnt=%s"
|
% (equipStar, holeIndex, openCommHoleCnt), curPlayer.GetPlayerID())
|
return False
|
|
return True
|
|
|
def __DoChangeEquipHoleStone(curPlayer, equipPackIndex, holeIndex, changeStoneID, isBind, eventName, isPickoff):
|
## ±ä¸üÍæ¼Ò×°±¸¿×±¦Ê¯
|
|
# »ñµÃ×°±¸Î»¿×Ë÷Òý±¦Ê¯´æ´¢ÐÅÏ¢
|
stoneID, stoneIsBind = GetEquipIndexStoneIDAndIsBand(curPlayer, equipPackIndex, holeIndex)
|
# ±£´æ×°±¸Î»¿×λÉϱ¦Ê¯IDºÍ°ó¶¨×´Ì¬
|
SetEquipIndexStoneIDAndIsBand(curPlayer, equipPackIndex, holeIndex, changeStoneID, isBind)
|
|
if isPickoff and stoneID:
|
equipPackType, stonePackType, placeIndex = GetPackTypeByEquipPlace(equipPackIndex)
|
itemCount = 1
|
# Õª³ýµÄ±¦Ê¯¶¼°ó¶¨
|
if ItemCommon.CheckPackHasSpace(curPlayer, stonePackType):
|
ItemControler.GivePlayerItem(curPlayer, stoneID, itemCount, 0,
|
[stonePackType],
|
event=[ChConfig.ItemGive_StonePickoff, False,
|
{"equipPackIndex": equipPackIndex, "HoleIndex": holeIndex}])
|
else:
|
PlayerControl.SendMailByKey("GemToPlayer", [curPlayer.GetPlayerID()], [[stoneID, 1, stoneIsBind]])
|
|
DataRecordPack.DR_StoneItemChange(curPlayer, eventName,
|
{'equipPackIndex': equipPackIndex, "holeIndex": holeIndex, "stoneID": stoneID,
|
'changeStoneID': changeStoneID})
|
EventShell.EventRespons_StoneChange(curPlayer)
|
return
|
|
|
def RefreshAttrByStoneAction(curPlayer, packType, isNeedNotify, classLV):
|
## ±¦Ê¯Ë¢ÐÂÊôÐÔ
|
# ×°±¸µÈ¼¶¸Ä±ä£¬ÅжÏÊÇ·ñÎªÍæ¼ÒÉíÉϵÄ×°±¸£¬Èç¹ûÊǵĻ°Ë¢ÐÂÍæ¼ÒÊôÐÔ
|
if packType in [IPY_GameWorld.rptEquip]:
|
# ÏÈË¢×°±¸BUFF ÔÙ¼ÆËãÊôÐÔ
|
if isNeedNotify:
|
curPlayer.SetDict(ChConfig.Def_PlayerKey_AttrActivatyNotify, ChConfig.Def_AttrActivatyNotify_Stone)
|
ChEquip.RefreshPlayerEquipAttribute(curPlayer, classLV)
|
|
# Ë¢ÐÂËùÓÐÊôÐÔ
|
playControl = PlayerControl.PlayerControl(curPlayer)
|
playControl.RefreshPlayerAttrState()
|
return
|
|
|
def DoMoveEquipStone(curPlayer, equipPackIndex):
|
###Ìæ»»×°±¸Ê±±¦Ê¯×ªÒÆ
|
equipPackType, stonePackType, placeIndex = GetPackTypeByEquipPlace(equipPackIndex)
|
equipPack = curPlayer.GetItemManager().GetPack(equipPackType)
|
curEquip = equipPack.GetAt(placeIndex)
|
if not ItemCommon.CheckItemCanUse(curEquip):
|
return
|
|
# »ñµÃ×°±¸ÐǼ¶¿×ÐÅÏ¢
|
gemOpenNeedStarList = IpyGameDataPY.GetFuncEvalCfg("GemOpen", 1)
|
maxEquipHoleCnt = len(gemOpenNeedStarList) # ×î´ó×°±¸ÐǼ¶¿ª·Å¿×Êý
|
|
openEquipHoleCnt = 0 # ÒѾ¿ª·Å¿×Êý
|
partStar = ChEquip.GetEquipPartStarByRank(curPlayer, equipPackIndex, curEquip)
|
for holeCnt, openStar in enumerate(gemOpenNeedStarList, 1):
|
if partStar >= openStar:
|
openEquipHoleCnt = holeCnt
|
|
# ÐèÒª²ðж±¦Ê¯µÄ¿×Áбí
|
pickoffHoleList = []
|
|
# ÅжÏ×°±¸½×¼¶±¦Ê¯ÊÇ·ñ²ðж
|
for holeIndex in xrange(maxEquipHoleCnt):
|
if holeIndex < openEquipHoleCnt:
|
continue
|
curGemID = GetEquipIndexStoneIDAndIsBand(curPlayer, equipPackIndex, holeIndex)[0]
|
if curGemID == 0:
|
continue
|
pickoffHoleList.append([equipPackIndex, holeIndex])
|
|
# ûÓпªÆôÆÕͨװ±¸¿×£¬ÐèÕª³ýVIP¿×
|
if not openEquipHoleCnt:
|
# »ñµÃVIPµÈ¼¶¿×ÐÅÏ¢
|
gemOpenVipList = IpyGameDataPY.GetFuncEvalCfg("GemOpenVip", 1)
|
maxVipHoleCnt = len(gemOpenVipList) # ×î´óVIP¿ª·Å¿×Êý
|
# ÅжÏVIPµÈ¼¶¿×ÐÅÏ¢
|
for holeIndex in xrange(ChConfig.Def_Stone_VipHole, ChConfig.Def_Stone_VipHole + maxVipHoleCnt):
|
curGemID = GetEquipIndexStoneIDAndIsBand(curPlayer, equipPackIndex, holeIndex)[0]
|
if curGemID == 0:
|
continue
|
pickoffHoleList.append([equipPackIndex, holeIndex])
|
|
# ÍÑ×°±¸µÄÍâ²ãË¢ÊôÐÔ, ÕâÀﲻˢ
|
__DoSysPickoffEquipStone(curPlayer, equipPackType, stonePackType, pickoffHoleList, "EquipChange", False)
|
return
|
|
|
def OnVIPTimeOut(curPlayer):
|
## VIPµ½ÆÚ´¦Àí
|
# ¹ýÆÚÒ»ÑùÓÐЧ£¬ÆÁ±Î¸ÃÂß¼
|
return
|
|
|
def __DoSysPickoffEquipStone(curPlayer, equipPackType, stonePackType, pickoffHoleList, eventName, isRefreshAttr):
|
## ϵͳժ³ý±¦Ê¯
|
|
if not pickoffHoleList:
|
return
|
|
GameWorld.DebugLog("ϵͳժ³ý±¦Ê¯: %s,pickoffHoleList=%s" % (eventName, pickoffHoleList), curPlayer.GetPlayerID())
|
|
equipIndexList = []
|
stoneCount = len(pickoffHoleList)
|
packSpace = ItemCommon.GetItemPackSpace(curPlayer, stonePackType, stoneCount)
|
if packSpace >= stoneCount:
|
for equipIndex, holeIndex in pickoffHoleList:
|
__DoChangeEquipHoleStone(curPlayer, equipIndex, holeIndex, 0, 0, eventName, True)
|
if equipIndex not in equipIndexList:
|
equipIndexList.append(equipIndex)
|
else:
|
# ÓʼþÎïÆ·ÐÅÏ¢Áбí
|
mailItemInfoList = []
|
for equipIndex, holeIndex in pickoffHoleList:
|
stoneInfo = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)
|
mailItemInfoList.append([stoneInfo[0], 1, stoneInfo[1]])
|
SetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex, 0, 0)
|
DataRecordPack.DR_StoneItemChange(curPlayer, eventName,
|
{'changeStoneID': 0, 'equipIndex': equipIndex, "holeIndex": holeIndex,
|
"stoneID": stoneInfo[0]})
|
if equipIndex not in equipIndexList:
|
equipIndexList.append(equipIndex)
|
PlayerControl.SendMailByKey("GemToPlayer", [curPlayer.GetPlayerID()], mailItemInfoList)
|
|
# ĿǰֻÓÐÍÑ×°±¸»á´¥·¢£¬ÔÝʱÆÁ±Î£¬ÓÉÍÑ×°±¸´¥·¢Ë¢ÊôÐÔ
|
# if isRefreshAttr:
|
# RefreshAttrByStoneAction(curPlayer, equipPackType, False)
|
|
if equipIndexList:
|
Sycn_StoneHoleInfo(curPlayer, equipIndexList)
|
return
|
|
|
def Sycn_StoneHoleInfo(curPlayer, equipIndexList=[]):
|
###ͬ²½¿Í»§¶Ë±¦Ê¯ÐÅÏ¢
|
# ×°±¸Î»ËùÓп×λ
|
holeIndexList = GetAllEquipPlaceHoleIndex()
|
maxHoleCount = len(holeIndexList)
|
if not equipIndexList:
|
equipIndexList = GetAllStoneEquipIndexList()
|
|
sendPack = ChPyNetSendPack.tagMCStoneInfo()
|
sendPack.InfoList = []
|
for equipIndex in equipIndexList:
|
stoneMsg = ChPyNetSendPack.tagMCStoneMsg()
|
stoneMsg.EquipPlace = equipIndex
|
stoneMsg.MaxStoneCount = maxHoleCount
|
stoneMsg.StoneInfo = GetEquipIndexStoneIDList(curPlayer, equipIndex)
|
holeStoneBindList = []
|
for holeIndex in holeIndexList:
|
isBind = GetEquipIndexStoneIDAndIsBand(curPlayer, equipIndex, holeIndex)[1]
|
holeStoneBindList.append(isBind)
|
stoneMsg.StoneBind = holeStoneBindList
|
sendPack.InfoList.append(stoneMsg)
|
sendPack.EquipCount = len(sendPack.InfoList)
|
NetPackCommon.SendFakePack(curPlayer, sendPack)
|
return
|