#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#-------------------------------------------------------------------------------
|
#
|
##@package Player.PlayerTreasure
|
#
|
# @todo:Ñ°±¦
|
# @author hxp
|
# @date 2018-04-28
|
# @version 1.0
|
#
|
# ÏêϸÃèÊö: ÊÖÓÎÑ°±¦, Ö§³Öµ¥³é¡¢Á¬³é
|
#
|
#-------------------------------------------------------------------------------
|
#"""Version = 2018-04-28 16:00"""
|
#-------------------------------------------------------------------------------
|
|
import GameWorld
|
import PlayerRune
|
import ShareDefine
|
import GameFuncComm
|
import IpyGameDataPY
|
import IPY_GameWorld
|
import FormulaControl
|
import ChPyNetSendPack
|
import PlayerControl
|
import ItemControler
|
import NetPackCommon
|
import PlayerBossReborn
|
import PlayerFeastTravel
|
import PlayerFairyCeremony
|
import PlayerNewFairyCeremony
|
import PlayerActLunhuidian
|
import PlayerActYunshi
|
import PlayerActTask
|
import ItemCommon
|
import ChConfig
|
|
import random
|
import time
|
|
# Ñ°±¦ÀàÐÍ£º >=100µÄΪ²ß»®×ÔÐÐÅäÖõÄ×Ô¶¨ÒåÑ°±¦ÀàÐÍ£¬<100µÄÓÃÓÚÖ¸¶¨ÏµÍ³Ñ°±¦¹¦ÄÜ
|
TreasureTypeList = (
|
TreasureType_Jipin, # ¼«Æ·Ñ°±¦ 1
|
TreasureType_Rune, # ·ûÓ¡Ñ°±¦ 2
|
TreasureType_Jueshi, # ¾øÊÀÑ°±¦ 3
|
TreasureType_GatherTheSoul, # ¾Û»êÁÔħ 4
|
TreasureType_Gubao, # ¹Å±¦Ñ°±¦ 5
|
) = range(1, 1 + 5)
|
|
def DoTreasureOpen(curPlayer):
|
## Ñ°±¦¿ªÆô
|
Sync_TreasureInfo(curPlayer)
|
return
|
|
def OnTreasureLogin(curPlayer):
|
#if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_Treasure):
|
# return
|
Sync_TreasureInfo(curPlayer)
|
return
|
|
def OnDay(curPlayer):
|
syncTypeList = []
|
ipyDataMgr = IpyGameDataPY.IPY_Data()
|
for i in xrange(ipyDataMgr.GetTreasureSetCount()):
|
ipyData = ipyDataMgr.GetTreasureSetByIndex(i)
|
treasureType = ipyData.GetTreasureType()
|
if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureFreeCount % (treasureType)):
|
continue
|
syncTypeList.append(treasureType)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TreasureFreeCount % (treasureType), 0)
|
if syncTypeList:
|
Sync_TreasureInfo(curPlayer, syncTypeList)
|
return
|
|
def ResetTreasureType(curPlayer, treasureTypeList):
|
## ÖØÖÃÑ°±¦ÀàÐÍÊý
|
for treasureType in treasureTypeList:
|
setIpyData = IpyGameDataPY.GetIpyGameData("TreasureSet", treasureType)
|
if not setIpyData:
|
continue
|
recycleItemMail = setIpyData.GetRecycleItemMail()
|
costItemID = setIpyData.GetCostItemID()
|
if recycleItemMail and costItemID:
|
ItemControler.RecycleItem(curPlayer, costItemID, recycleItemMail)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TreasureFreeCount % (treasureType), 0)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TreasureCount % (treasureType), 0)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TreasureLuck % (treasureType), 0)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TreasureCntAward % (treasureType), 0)
|
|
gridNumMaxLimitInfo = setIpyData.GetGridNumMaxLimitInfo()
|
for gridNumStr in gridNumMaxLimitInfo.keys():
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TreasureGridCnt % (treasureType, int(gridNumStr)), 0)
|
|
Sync_TreasureInfo(curPlayer, treasureTypeList)
|
return
|
|
def IsActTreasureType(curPlayer, treasureType):
|
## ÊÇ·ñ»î¶¯ÖеÄÑ°±¦ÀàÐÍ
|
if PlayerActYunshi.IsActTreasureType(curPlayer, treasureType):
|
return True
|
return False
|
|
#// A5 68 ÇëÇóÑ°±¦ #tagCMRequestTreasure
|
#
|
#struct tagCMRequestTreasure
|
#{
|
# tagHead Head;
|
# BYTE TreasureType; //Ñ°±¦ÀàÐÍ
|
# BYTE TreasureIndex; //Ñ°±¦Ë÷Òý
|
# BYTE CostType; //ÏûºÄÀàÐÍ£º0-ĬÈÏÏÉÓñ£»1-Ãâ·Ñ´ÎÊý£»2-Ñ°±¦µÀ¾ß
|
#};
|
def OnRequestTreasure(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
playerLV = curPlayer.GetLV()
|
playerID = curPlayer.GetPlayerID()
|
treasureType = clientData.TreasureType
|
treasureIndex = clientData.TreasureIndex
|
costType = clientData.CostType
|
|
GameWorld.DebugLog("Íæ¼ÒÑ°±¦: treasureType=%s,treasureIndex=%s,costType=%s,playerLV=%s"
|
% (treasureType, treasureIndex, costType, playerLV), playerID)
|
|
setIpyData = IpyGameDataPY.GetIpyGameData("TreasureSet", treasureType)
|
if not setIpyData:
|
return
|
if setIpyData.GetIsActType():
|
if not IsActTreasureType(curPlayer, treasureType):
|
GameWorld.ErrLog("¸ÃÑ°±¦ÀàÐͷǻÖУ¬ÎÞ·¨Ñ°±¦! treasureType=%s" % (treasureType), playerID)
|
return
|
treasureCountList = setIpyData.GetTreasureCountList() # Ñ°±¦»ñµÃ¸öÊýÁбí
|
if not treasureCountList:
|
GameWorld.DebugLog("ûÓÐÑ°±¦´ÎÊýÁбíÅäÖÃ!", playerID)
|
return
|
if treasureIndex < 0 or treasureIndex >= len(treasureCountList):
|
GameWorld.ErrLog("Ñ°±¦´ÎÊýË÷Òý²»´æÔÚ!treasureType=%s,treasureIndex=%s" % (treasureType, treasureIndex), playerID)
|
return
|
treasureCount = treasureCountList[treasureIndex]
|
if not treasureCount:
|
GameWorld.DebugLog("ûÓÐÑ°±¦´ÎÊýÅäÖÃ!", playerID)
|
return
|
|
packType = setIpyData.GetPackType()
|
if setIpyData.GetCheckPack():
|
if not ItemCommon.CheckPackHasSpace(curPlayer, packType, True):
|
GameWorld.DebugLog("¶ÔӦѰ±¦±³°üûÓпոñ×Ó!packType=%s" % packType, playerID)
|
return
|
|
# Ãâ·Ñ´ÎÊý
|
if costType == 1:
|
dailyFreeCount = setIpyData.GetDailyFreeCount()
|
if not dailyFreeCount:
|
GameWorld.ErrLog("¸ÃÑ°±¦ÀàÐÍË÷Òý²»Ö§³ÖÃâ·Ñ´ÎÊýÑ°±¦!treasureType=%s,treasureIndex=%s" % (treasureType, treasureIndex), playerID)
|
return
|
freeCountToday = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureFreeCount % (treasureType))
|
updFreeCountToday = freeCountToday + treasureCount
|
if updFreeCountToday > dailyFreeCount:
|
GameWorld.DebugLog("½ñÈÕÃâ·Ñ´ÎÊý²»×㣬ÎÞ·¨Ê¹ÓÃÃâ·ÑÑ°±¦! freeCountToday=%s + %s > %s" % (freeCountToday, treasureCount, dailyFreeCount), playerID)
|
return
|
|
# Ñ°±¦µÀ¾ß, ĿǰĬÈÏÏûºÄ1¸ö
|
elif costType == 2:
|
costItemID = setIpyData.GetCostItemID()
|
costItemList = setIpyData.GetCostItemCountList() # ÏûºÄµÀ¾ßÎïÆ·IDÁбí
|
if not costItemID or not costItemList or treasureIndex >= len(costItemList):
|
GameWorld.ErrLog("¸ÃÑ°±¦ÀàÐÍË÷Òý²»Ö§³ÖÏûºÄµÀ¾ßÑ°±¦!treasureType=%s,treasureIndex=%s" % (treasureType, treasureIndex), playerID)
|
return
|
costItemNeedCount = costItemList[treasureIndex]
|
if not costItemID or not costItemNeedCount:
|
return
|
costItemIndexList, bindCnt, unBindCnt = ItemCommon.GetPackItemBindStateIndexInfo(curPlayer, costItemID)
|
lackCount = max(0, costItemNeedCount - bindCnt - unBindCnt)
|
delCostItemCount = costItemNeedCount - lackCount
|
lackCountCostMoney = 0
|
if lackCount > 0:
|
costGoldList = setIpyData.GetCostMoneyList() # ÏûºÄ»õ±ÒÁбí
|
costGoldType = setIpyData.GetCostMoneyType() # ÏûºÄ»õ±ÒÀàÐÍ
|
if not costGoldType or not costGoldList or treasureIndex >= len(costGoldList) or not costGoldList[treasureIndex]:
|
GameWorld.ErrLog("Ñ°±¦µÀ¾ß²»×㣬¸ÃÑ°±¦ÀàÐͲ»Ö§³ÖÏûºÄ»õ±ÒÑ°±¦! treasureType=%s,treasureIndex=%s" % (treasureType, treasureIndex), playerID)
|
return
|
costGold = costGoldList[treasureIndex]
|
perItemGold = int(costGold / costItemNeedCount) # µÀ¾ßµ¥¼Û
|
lackCountCostMoney = perItemGold * lackCount
|
GameWorld.DebugLog("Ñ°±¦µÀ¾ß²»×㣬ʹÓöÔÓ¦»õ±Ò¿Û³ý: costItemID=%s,perItemGold=%s,lackCount=%s,lackCountCostMoney=%s,costGoldType=%s"
|
% (costItemID, perItemGold, lackCount, lackCountCostMoney, costGoldType), playerID)
|
if lackCountCostMoney:
|
moneyType = costGoldType
|
infoDict = {ChConfig.Def_Cost_Reason_SonKey:costItemID}
|
if not PlayerControl.HaveMoney(curPlayer, moneyType, lackCountCostMoney):
|
return
|
else:
|
GameWorld.DebugLog("Ñ°±¦ÏûºÄµÀ¾ß²»×ã!costItemID=%s,costItemNeedCount=%s,bindCnt=%s,unBindCnt=%s"
|
% (costItemID, costItemNeedCount, bindCnt, unBindCnt), playerID)
|
return
|
|
# ÏÉÓñÑ°±¦
|
else:
|
costGoldList = setIpyData.GetCostMoneyList() # ÏûºÄ»õ±ÒÁбí
|
costGoldType = setIpyData.GetCostMoneyType() # ÏûºÄ»õ±ÒÀàÐÍ
|
if not costGoldType or not costGoldList or treasureIndex >= len(costGoldList):
|
GameWorld.ErrLog("¸ÃÑ°±¦ÀàÐÍË÷Òý²»Ö§³ÖÏûºÄ»õ±ÒÑ°±¦!treasureType=%s,treasureIndex=%s" % (treasureType, treasureIndex), playerID)
|
return
|
costGold = costGoldList[treasureIndex]
|
if not costGold:
|
return
|
|
if not PlayerControl.HaveMoney(curPlayer, costGoldType, costGold):
|
return
|
|
ipyData = IpyGameDataPY.InterpolationSearch("TreasureHouse", "MinLV", playerLV, {"TreasureType":treasureType})
|
if not ipyData:
|
GameWorld.ErrLog("ÕÒ²»µ½¸ÃµÈ¼¶¶ÔӦѰ±¦¿âÅäÖÃ!treasureType=%s,curLV=%s" % (treasureType, curPlayer.GetLV()), playerID)
|
return
|
|
luckyItemRateList = ipyData.GetLuckyItemRateList()
|
luckyGridNumList = []
|
if luckyItemRateList:
|
for _, gridNum in luckyItemRateList:
|
luckyGridNumList.append(gridNum)
|
elif setIpyData.GetLuckyGridNum():
|
luckyGridNumList = [setIpyData.GetLuckyGridNum()]
|
GameWorld.DebugLog("luckyGridNumList=%s, %s" % (luckyGridNumList, luckyItemRateList), playerID)
|
luckFormula = setIpyData.GetLuckyRateFormat() # ÐÒÔËÎïÆ·¸ÅÂʹ«Ê½
|
addLuck = setIpyData.GetOnceLucky() # Ôö¼ÓÐÒÔËÖµ
|
maxLuck = setIpyData.GetFullLucky() # ÂúÐÒÔËÖµ
|
curLuck = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureLuck % (treasureType)) # µ±Ç°ÐÒÔËÖµ
|
updLuck = curLuck
|
|
curTreasureCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureCount % (treasureType)) # µ±Ç°ÒÑÑ°±¦´ÎÊý
|
updTreasureCount = curTreasureCount
|
|
beSureCountDict = ipyData.GetGridItemRateList3() # µÚx´Î±Ø³ö²ú³ö¸ñ×Ó±àºÅ±ýͼ
|
ensureCount = setIpyData.GetEnsureCount() # ÿ¶àÉٴδ¥·¢±£µ×²ú³ö¿â
|
ensureRateList = ipyData.GetGridItemRateList2()
|
GameWorld.DebugLog("beSureCountDict=%s" % beSureCountDict, playerID)
|
GameWorld.DebugLog("ensureCount=%s, %s" % (ensureCount, ensureRateList), playerID)
|
notifyGridNumList = setIpyData.GetNotifyGridNumList() # ¶îÍâÐèÒª¹ã²¥µÄ¸ñ×Ó£¬ÐÒÔ˱سö¡¢´ÎÊý±Ø³ö¿É²»ÅäÖÃ
|
gridNumMaxLimitInfo = setIpyData.GetGridNumMaxLimitInfo() # {"¸ñ×Ó":×î´ó¿É²ú³ö´ÎÊý, ...}
|
gridNumCountInfo = {} # ÓÐÏÞÖƲú³ö´ÎÊýµÄ¸ñ×ÓÒѾ²ú³öÊý
|
for gridNumStr in gridNumMaxLimitInfo.keys():
|
gridNumCountInfo[int(gridNumStr)] = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureGridCnt % (treasureType, gridNumStr))
|
GameWorld.DebugLog("gridNumMaxLimitInfo=%s,gridNumCountInfo=%s" % (gridNumMaxLimitInfo, gridNumCountInfo), playerID)
|
|
# µ¥³é²ú³öÓÅÏȼ¶£º ÐÒÔËÎïÆ· > ±Ø³ö > ±£µ× > ÆÕͨ
|
# Á¬³éûÓÐÓÅÏȼ¶ÏÞÖÆ£¬Ö»ÒªÂú×ãÌõ¼þ¼´¿É²ú³ö
|
getGridResult = []
|
for tIndex in range(treasureCount):
|
updLuck = min(updLuck + addLuck, maxLuck)
|
updTreasureCount += 1
|
GameWorld.DebugLog("%s,ÀۼƴÎÊý=%s,ÐÒÔË=%s" % (tIndex + 1, updTreasureCount, updLuck), playerID)
|
if gridNumMaxLimitInfo:
|
GameWorld.DebugLog(" gridNumMaxLimitInfo=%s,gridNumCountInfo=%s" % (gridNumMaxLimitInfo, gridNumCountInfo), playerID)
|
baseRateList, commItemRateList = GetUpdLuckyItemRateList(ipyData, luckyGridNumList, updLuck, luckFormula, costType) # ³£¹æ²ú³öÎïÆ·¸ñ×Ó±ýͼ£¬ÐÒÔËÎïÆ·¸ÅÂÊÒѱä¸ü
|
commItemRateList = GetRemoveLimitGridRateList(commItemRateList, gridNumCountInfo, gridNumMaxLimitInfo)
|
GameWorld.DebugLog(" »ù´¡±ýͼ=%s" % baseRateList, playerID)
|
GameWorld.DebugLog(" ³£¹æ±ýͼ=%s" % commItemRateList, playerID)
|
|
curRateList = [] # ¿ÉÄÜ»á¸Ä±ä±ýͼ£¬Ã¿´Î³é½±Ê¹ÓÃеıýͼ¶ÔÏ󣬲»Òª¸Ä±äÅäÖõıýͼ¸ÅÂÊ
|
|
# ÂúÐÒÔ˱سö
|
if updLuck >= maxLuck and luckyGridNumList:
|
if luckyItemRateList:
|
curRateList = GetRemoveLimitGridRateList(luckyItemRateList, gridNumCountInfo, gridNumMaxLimitInfo)
|
else:
|
curRateList = GetRemoveLimitGridRateList([(10000, luckyGridNumList[0])], gridNumCountInfo, gridNumMaxLimitInfo)
|
GameWorld.DebugLog(" ¡¾ÂúÐÒÔ˱ýͼ¡¿: %s" % curRateList)
|
|
# ´ÎÊý±Ø³ö
|
if not curRateList and updTreasureCount in beSureCountDict:
|
besureGridRateList = beSureCountDict[updTreasureCount]
|
curRateList = GetRemoveLimitGridRateList(besureGridRateList, gridNumCountInfo, gridNumMaxLimitInfo)
|
GameWorld.DebugLog(" ¡¾µÚ%s´ÎÊý±Ø³ö±ýͼ¡¿: %s" % (updTreasureCount, curRateList))
|
|
# Âú´ÎÊý±Ø³ö
|
if not curRateList and ensureCount and updTreasureCount % ensureCount == 0 and ensureRateList:
|
curRateList = GetRemoveLimitGridRateList(ensureRateList, gridNumCountInfo, gridNumMaxLimitInfo)
|
GameWorld.DebugLog(" ¡¾Âú%s´ÎÊý±Ø³ö±ýͼ¡¿: %s" % (ensureCount, curRateList))
|
|
doCount = 0
|
while doCount <= 50: # ÏÞÖÆ×î´ó´ÎÊý
|
doCount += 1
|
if doCount > 1 or not curRateList: # ÖØÐÂËæ»úµÄĬÈÏʹÓó£¹æ±ýͼ
|
curRateList = commItemRateList
|
|
gridNum = GameWorld.GetResultByRandomList(curRateList)
|
if gridNum in luckyGridNumList and gridNum in getGridResult:
|
GameWorld.DebugLog(" ÐÒÔËÎïÆ·ÒѾ³ö¹ý£¬²»ÔÙÖظ´²ú³ö£¡ gridNum=%s in %s" % (gridNum, getGridResult))
|
continue
|
|
# ÆäËû²ú³öÏÞÖÆ...
|
|
if not gridNum:
|
continue
|
|
getGridResult.append(gridNum)
|
GameWorld.DebugLog(" ±¾´Î²ú³ö: gridNum=%s, %s" % (gridNum, getGridResult), playerID)
|
if gridNum in luckyGridNumList:
|
updLuck = 0
|
GameWorld.DebugLog(" ¡¾²ú³öÐÒÔ˸ñ×Ó¡¿: gridNum=%s" % (gridNum), playerID)
|
if gridNum in gridNumCountInfo:
|
gridNumCountInfo[gridNum] = gridNumCountInfo[gridNum] + 1
|
GameWorld.DebugLog(" ¡¾¸üвú³ö´ÎÊý¡¿: gridNum=%s, %s" % (gridNum, gridNumCountInfo), playerID)
|
break
|
|
GameWorld.DebugLog("Ñ°±¦¸ñ×Ó½á¹û: getGridResult=%s" % getGridResult, playerID)
|
if len(getGridResult) != treasureCount:
|
GameWorld.ErrLog("Ñ°±¦Òì³££¬Êµ¼Ê»ñµÃÊýÁ¿ÓëÑ°±¦ÇëÇóÊý²»Í¬£¡treasureType=%s,treasureIndex=%s" % (treasureType, treasureIndex), playerID)
|
return
|
|
isBind = 0 # ÔÝʱĬÈϲ»°ó¶¨
|
job = curPlayer.GetJob()
|
gridItemInfoDict = ipyData.GetGridItemInfo() # ¸ñ×Ó¶ÔÓ¦ÎïÆ·ÐÅÏ¢ {"¸ñ×Ó±àºÅ":[ÎïÆ·ID, ÊýÁ¿], ...}
|
gridLibInfoDict = ipyData.GetGridLibInfo() # ¸ñ×Ó±àºÅ¶ÔÓ¦¿âID {"±àºÅ":ÎïÆ·¿âID, ...}
|
jobItemList = ipyData.GetJobItemList()
|
treasureResult = []
|
randItemIDDict = IpyGameDataPY.GetFuncEvalCfg("TreasureSet", 2)
|
|
for gridNum in getGridResult:
|
gridNum = str(gridNum)
|
if gridNum in gridItemInfoDict:
|
itemID, itemCount = gridItemInfoDict[gridNum]
|
itemID = GetJobItem(job, itemID, jobItemList)
|
if not itemID:
|
GameWorld.ErrLog("Ñ°±¦¸ñ×ÓÎïÆ·IDÒì³£!treasureType=%s,gridNum=%s" % (treasureType, gridNum), playerID)
|
return
|
|
# Ëæ»ú²ú³öÎïÆ·
|
if itemID in randItemIDDict:
|
canRandItemList = []
|
randItemIDList = randItemIDDict[itemID]
|
for randItemID in randItemIDList:
|
itemData = GameWorld.GetGameData().GetItemByTypeID(randItemID)
|
if itemData.GetType() == ChConfig.Def_ItemType_Rune and not PlayerRune.GetIsOpenByRuneID(curPlayer, randItemID):
|
GameWorld.DebugLog("δ½âËøµÄ·ûÓ¡²»²ú³ö£¡itemID=%s,randItemID=%s" % (itemID, randItemID), playerID)
|
continue
|
canRandItemList.append(randItemID)
|
if not canRandItemList:
|
GameWorld.ErrLog("Ñ°±¦Ëæ»ú¸ñ×ÓûÓпÉËæ»úµÄÎïÆ·!treasureType=%s,treasureIndex=%s,gridNum=%s,itemID=%s"
|
% (treasureType, treasureIndex, gridNum, itemID), playerID)
|
return
|
itemID = random.choice(canRandItemList)
|
# ¸ù¾ÝÎïÆ·¿âÀ´Ëæ»ú
|
elif gridNum in gridLibInfoDict:
|
libID = gridLibInfoDict[gridNum]
|
libItemList = IpyGameDataPY.GetIpyGameDataList("TreasureItemLib", libID)
|
if not libItemList:
|
return
|
itemWeightList = []
|
for libItem in libItemList:
|
itemWeight, itemID, itemCount = libItem.GetItemWeight(), libItem.GetItemID(), libItem.GetItemCount()
|
itemData = GameWorld.GetGameData().GetItemByTypeID(itemID)
|
if not itemData:
|
continue
|
itemWeightList.append([itemWeight, [itemID, itemCount]])
|
if not itemWeightList:
|
GameWorld.ErrLog("Ñ°±¦Ëæ»ú¸ñ×ÓûÓпÉËæ»úµÄÎïÆ·!treasureType=%s,treasureIndex=%s,gridNum=%s,libID=%s"
|
% (treasureType, treasureIndex, gridNum, libID), playerID)
|
return
|
itemID, itemCount = GameWorld.GetResultByWeightList(itemWeightList)
|
else:
|
GameWorld.ErrLog("Ñ°±¦¸ñ×Ó²»´æÔÚ!treasureType=%s,gridNum=%s" % (treasureType, gridNum), playerID)
|
return
|
|
treasureResult.append([gridNum, itemID, itemCount, isBind])
|
|
# ¿ÛÏûºÄ
|
if costType == 1:
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TreasureFreeCount % (treasureType), updFreeCountToday)
|
GameWorld.DebugLog("ÏûºÄÃâ·Ñ´ÎÊý£¬¸üнñÈÕÒÑʹÓÃÃâ·Ñ´ÎÊý: %s" % updFreeCountToday, playerID)
|
elif costType == 2:
|
ItemCommon.DelCostItemByBind(curPlayer, costItemIndexList, bindCnt, unBindCnt, delCostItemCount, ChConfig.ItemDel_Treasure)
|
GameWorld.DebugLog("¿Û³ýÑ°±¦µÀ¾ß,costItemID=%s,delCostItemCount=%s" % (costItemID, delCostItemCount), playerID)
|
if lackCountCostMoney:
|
infoDict = {"TreasureType":treasureType, "TreasureIndex":treasureIndex, "CostItemID":costItemID, "LackCount":lackCount}
|
PlayerControl.PayMoney(curPlayer, moneyType, lackCountCostMoney, ChConfig.Def_Cost_Treasure, infoDict, lackCount)
|
else:
|
infoDict = {"TreasureType":treasureType, "TreasureIndex":treasureIndex}
|
PlayerControl.PayMoney(curPlayer, costGoldType, costGold, ChConfig.Def_Cost_Treasure, infoDict)
|
GameWorld.DebugLog("¿Û³ý»õ±Ò,costGoldType=%s,costGold=%s" % (costGoldType, costGold), playerID)
|
|
# ¼ÓÊý¾Ý
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TreasureCount % (treasureType), updTreasureCount)
|
for luckyGridNum in luckyGridNumList:
|
if luckyGridNum in getGridResult:
|
updLuck = 0
|
break
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TreasureLuck % (treasureType), updLuck)
|
for gridNum, updCount in gridNumCountInfo.items():
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TreasureGridCnt % (treasureType, gridNum), updCount)
|
|
addScoreType = setIpyData.GetAwardMoneyType() # ¶îÍâ½±Àø»õ±ÒÀàÐÍ
|
addScore = setIpyData.GetAwardMoneyValue() # µ¥´Î½±Àø»õ±ÒÊý
|
if addScoreType and addScore:
|
PlayerControl.GiveMoney(curPlayer, addScoreType, addScore)
|
|
if treasureType == TreasureType_Rune:
|
PlayerFairyCeremony.AddFCPartyActionCnt(curPlayer, ChConfig.Def_PPAct_RuneTreasure, treasureCount)
|
PlayerFeastTravel.AddFeastTravelTaskValue(curPlayer, ChConfig.Def_FeastTravel_RuneTreasure, treasureCount)
|
PlayerBossReborn.AddBossRebornActionCnt(curPlayer, ChConfig.Def_BRAct_RuneTreasure, treasureCount)
|
PlayerActTask.AddActTaskValue(curPlayer, ChConfig.ActTaskType_TreasureRune, treasureCount)
|
elif treasureType == TreasureType_Jipin:
|
PlayerFairyCeremony.AddFCPartyActionCnt(curPlayer, ChConfig.Def_PPAct_Treasure, treasureCount)
|
PlayerFeastTravel.AddFeastTravelTaskValue(curPlayer, ChConfig.Def_FeastTravel_Treasure, treasureCount)
|
PlayerBossReborn.AddBossRebornActionCnt(curPlayer, ChConfig.Def_BRAct_Treasure, treasureCount)
|
PlayerActTask.AddActTaskValue(curPlayer, ChConfig.ActTaskType_TreasureJipin, treasureCount)
|
elif treasureType == TreasureType_Jueshi:
|
PlayerFairyCeremony.AddFCPartyActionCnt(curPlayer, ChConfig.Def_PPAct_JSTreasure, treasureCount)
|
PlayerFeastTravel.AddFeastTravelTaskValue(curPlayer, ChConfig.Def_FeastTravel_JSTreasure, treasureCount)
|
PlayerBossReborn.AddBossRebornActionCnt(curPlayer, ChConfig.Def_BRAct_JSTreasure, treasureCount)
|
PlayerActTask.AddActTaskValue(curPlayer, ChConfig.ActTaskType_TreasureJueshi, treasureCount)
|
elif treasureType == TreasureType_GatherTheSoul:
|
PlayerActTask.AddActTaskValue(curPlayer, ChConfig.ActTaskType_TreasureGatherTheSoul, treasureCount)
|
elif treasureType == TreasureType_Gubao:
|
PlayerActTask.AddActTaskValue(curPlayer, ChConfig.ActTaskType_TreasureGubao, treasureCount)
|
|
PlayerActLunhuidian.AddLunhuidianValue(curPlayer, PlayerActLunhuidian.AwardType_Treasure, treasureType, treasureCount)
|
|
# ¸øÎïÆ·
|
mailItemList = []
|
itemControl = ItemControler.PlayerItemControler(curPlayer)
|
for gridNum, itemID, itemCount, isBind in treasureResult:
|
itemObj = ItemControler.GetOutPutItemObj(itemID, itemCount, False, curPlayer=curPlayer)
|
mailItemDict = ItemCommon.GetMailItemDict(itemObj)
|
|
if int(gridNum) in notifyGridNumList:
|
PlayerControl.WorldNotify(0, "HappyXB", [curPlayer.GetPlayerName(), itemID, itemObj.GetUserData(), itemCount])
|
|
if mailItemList or not itemControl.PutInItem(packType, itemObj, event=[ChConfig.ItemGive_Treasure, False, {}]):
|
mailItemList.append(mailItemDict)
|
itemObj.Clear()
|
|
if mailItemList:
|
PlayerControl.SendMailByKey("HappyXBUnEnough", [playerID], mailItemList)
|
|
GameWorld.DebugLog("Ñ°±¦³É¹¦: treasureType=%s,updTreasureCount=%s,updLuck=%s,addScoreType=%s,addScore=%s,gridNumCountInfo=%s"
|
% (treasureType, updTreasureCount, updLuck, addScoreType, addScore, gridNumCountInfo), playerID)
|
GameWorld.DebugLog(" treasureResult=%s" % (treasureResult), playerID)
|
GameWorld.DebugLog(" mailItemList=%s" % (mailItemList), playerID)
|
|
# ֪ͨǰ¶Ë
|
sendPack = ChPyNetSendPack.tagMCTreasureResult()
|
sendPack.Clear()
|
sendPack.AddMoneyType = addScoreType
|
sendPack.AddMoneyValue = addScore
|
sendPack.AddTreasureLuck = addLuck
|
sendPack.TreasureResult = str(treasureResult)
|
sendPack.TreasureResultLen = len(sendPack.TreasureResult)
|
NetPackCommon.SendFakePack(curPlayer, sendPack)
|
|
Sync_TreasureInfo(curPlayer, [treasureType])
|
return
|
|
def GetRemoveLimitGridRateList(srcGridNumRateList, gridNumCountInfo, gridNumMaxLimitInfo):
|
## »ñÈ¡ÒƳýÏÞÖƲú³öµÄ¸ñ×ÓºóµÄ±ýͼÁбí
|
# @param srcGridNumRateList: Ôʼ¸ÅÂÊ [(¸ÅÂÊ, ¸ñ×Ó±àºÅ), ...]
|
# @param gridNumCountInfo: ÓÐÏÞÖƲú³öÊýµÄ¸ñ×ÓÒѾ²ú³öÊýÁ¿ÐÅÏ¢ {gridNum:count, ...}
|
# @param gridNumMaxLimitInfo: ÓÐÏÞÖƲú³öÊýµÄ¸ñ×Ó×î´ó²ú³öÊýÁ¿ÐÅÏ¢ {"gridNum":countLimit, ...}
|
newRateList = []
|
if not gridNumMaxLimitInfo:
|
return newRateList + srcGridNumRateList # ²»Ê¹ÓÃÔÅäÖñýͼ£¬²»È»¿ÉÄܵ¼ÖÂÐ޸ĵôÔʼÅäÖñýͼµ¼ÖÂbug
|
for i, rateInfo in enumerate(srcGridNumRateList):
|
rate, gridNum = rateInfo
|
if str(gridNum) in gridNumMaxLimitInfo:
|
limitCount = gridNumMaxLimitInfo[str(gridNum)]
|
if limitCount and gridNumCountInfo.get(gridNum, 0) >= limitCount:
|
# ÒÑ´ïµ½ÏÞÖƲú³öÊý£¬²»ÔÙ²ú³ö
|
continue
|
srcRate = rate if i == 0 else (rate - srcGridNumRateList[i - 1][0]) # Ô¸ÅÂÊ
|
newRate = srcRate if not newRateList else (newRateList[-1][0] + srcRate)
|
newRateList.append((newRate, gridNum))
|
return newRateList
|
|
def GetUpdLuckyItemRateList(ipyData, luckyGridNumList, curLuck, luckFormula, costType):
|
# »ñÈ¡ÐÒÔËÎïÆ·ÌáÉý¸ÅÂʺóµÄ±ýͼ
|
treasureType = ipyData.GetTreasureType()
|
srcPieList = ipyData.GetGridItemRateListFree() if costType == 1 else ipyData.GetGridItemRateList1()
|
if not srcPieList:
|
srcPieList = ipyData.GetGridItemRateList1()
|
|
updRateList = []
|
for i, rateInfo in enumerate(srcPieList):
|
rate, gridNum = rateInfo
|
baseRate = rate if i == 0 else (rate - srcPieList[i - 1][0]) # Ô¸ÅÂÊ
|
|
if gridNum in luckyGridNumList:
|
newRate = eval(FormulaControl.GetCompileFormula("TreasureLuckyRate%s" % treasureType, luckFormula))
|
else:
|
newRate = baseRate
|
|
specRate = newRate if not updRateList else (updRateList[-1][0] + newRate) # ÌáÉýºó¶ÔÓ¦±ýͼ¸ÅÂÊ
|
updRateList.append((specRate, gridNum))
|
|
return srcPieList, updRateList
|
|
def GetJobItem(job, itemID, jobItemList):
|
## »ñÈ¡±¦ÏäÎïÆ·½±Àø¶ÔÓ¦µÄÖ°ÒµÎïÆ·£¬ Ö°Òµ´Ó1¿ªÊ¼
|
for jobItemIDList in jobItemList:
|
if type(jobItemIDList) not in [list, tuple]:
|
GameWorld.ErrLog("Ö°ÒµÎïÆ·×é¸ñʽ´íÎó!jobItemList=%s" % (jobItemList))
|
return 0
|
if itemID in jobItemIDList:
|
if job <= 0 or job > len(jobItemIDList):
|
GameWorld.ErrLog("Ö°ÒµÎïÆ·ÅäÖôíÎó,ûÓиÃÖ°Òµ¶ÔÓ¦ÎïÆ·ID!job=%s,itemID=%s" % (job, itemID))
|
return 0
|
return jobItemIDList[job - 1]
|
return itemID
|
|
def GetTreasureCntAward(curPlayer, treasureType, needTreasureCnt):
|
## ÁìÈ¡Ñ°±¦ÀۼƴÎÊý½±Àø
|
needTreasureCnt = GameWorld.ToIntDef(needTreasureCnt, 0)
|
playerID = curPlayer.GetPlayerID()
|
ipyData = IpyGameDataPY.GetIpyGameData("TreasureCntAward", treasureType, needTreasureCnt)
|
if not ipyData:
|
return
|
awardIndex = ipyData.GetAwardIndex()
|
awardItemList = ipyData.GetAwardItemList()
|
|
awardState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureCntAward % (treasureType))
|
if awardState&pow(2, awardIndex):
|
GameWorld.DebugLog("¸ÃÑ°±¦´ÎÊý½±ÀøÒÑÁì½±! treasureType=%s,needTreasureCnt=%s,awardIndex=%s"
|
% (treasureType, needTreasureCnt, awardIndex), playerID)
|
return
|
|
treasureCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureCount % (treasureType))
|
if treasureCount < needTreasureCnt:
|
GameWorld.DebugLog("¸ÃÑ°±¦´ÎÊý²»×㣬ÎÞ·¨Áì½±! treasureType=%s,treasureCount=%s < %s"
|
% (treasureType, treasureCount, needTreasureCnt), playerID)
|
return
|
|
updState = awardState|pow(2, awardIndex)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TreasureCntAward % (treasureType), updState)
|
GameWorld.DebugLog("ÁìÈ¡Ñ°±¦´ÎÊý½±Àø! treasureType=%s,needTreasureCnt=%s,awardIndex=%s,awardState=%s,updState=%s"
|
% (treasureType, needTreasureCnt, awardIndex, awardState, updState), playerID)
|
|
ItemControler.GivePlayerItemOrMail(curPlayer, awardItemList, event=["TreasureCntAward", False, {}])
|
Sync_TreasureInfo(curPlayer, [treasureType])
|
return
|
|
def Sync_TreasureInfo(curPlayer, syncTypeList=None):
|
if syncTypeList == None:
|
syncTypeList = []
|
ipyDataMgr = IpyGameDataPY.IPY_Data()
|
for i in xrange(ipyDataMgr.GetTreasureSetCount()):
|
ipyData = ipyDataMgr.GetTreasureSetByIndex(i)
|
syncTypeList.append(ipyData.GetTreasureType())
|
|
treasureInfoPack = ChPyNetSendPack.tagMCTreasureInfo()
|
treasureInfoPack.Clear()
|
treasureInfoPack.TreasuerInfoList = []
|
for tType in syncTypeList:
|
setIpyData = IpyGameDataPY.GetIpyGameData("TreasureSet", tType)
|
if not setIpyData:
|
continue
|
if setIpyData.GetIsActType():
|
if not IsActTreasureType(curPlayer, tType):
|
continue
|
gridNumMaxLimitInfo = setIpyData.GetGridNumMaxLimitInfo()
|
tTypeInfo = ChPyNetSendPack.tagMCTreasureTypeInfo()
|
tTypeInfo.Clear()
|
tTypeInfo.TreasureType = tType
|
tTypeInfo.LuckValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureLuck % (tType))
|
tTypeInfo.TreasureCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureCount % (tType))
|
tTypeInfo.FreeCountToday = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureFreeCount % (tType))
|
tTypeInfo.TreasureCntAward = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureCntAward % (tType))
|
for gridNumStr in gridNumMaxLimitInfo.keys():
|
gridNum = int(gridNumStr)
|
gridLimit = ChPyNetSendPack.tagMCTreasureGridLimit()
|
gridLimit.GridNum = gridNum
|
gridLimit.GridCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TreasureGridCnt % (tType, gridNum))
|
tTypeInfo.GridLimitCntList.append(gridLimit)
|
tTypeInfo.GridLimitCnt = len(tTypeInfo.GridLimitCntList)
|
treasureInfoPack.TreasuerInfoList.append(tTypeInfo)
|
treasureInfoPack.InfoCount = len(treasureInfoPack.TreasuerInfoList)
|
NetPackCommon.SendFakePack(curPlayer, treasureInfoPack)
|
return
|
|