#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#-------------------------------------------------------------------------------
|
#
|
##@package Player.PlayerActTurntable
|
#
|
# @todo:תÅ̻
|
# @author hxp
|
# @date 2021-05-06
|
# @version 1.0
|
#
|
# ÏêϸÃèÊö: תÅ̻
|
#
|
#-------------------------------------------------------------------------------
|
#"""Version = 2021-05-06 16:30"""
|
#-------------------------------------------------------------------------------
|
|
|
import PyGameData
|
import ShareDefine
|
import PlayerControl
|
import IpyGameDataPY
|
import ItemControler
|
import ChPyNetSendPack
|
import IPY_GameWorld
|
import NetPackCommon
|
import GameWorld
|
import ChConfig
|
import CommFunc
|
|
import random
|
|
# ÎïÆ·¿âÀàÐÍ
|
(
|
ItemLibType_Comm, # ³£¹æÎïÆ·
|
ItemLibType_Good, # ¼«Æ·ÎïÆ·
|
ItemLibType_Super, # ÖÕ¼«ÎïÆ·
|
) = range(1, 3 + 1)
|
|
def OnPlayerLogin(curPlayer):
|
|
for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_Turntable, {}).values():
|
actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)
|
isReset = __CheckPlayerTurntableAction(curPlayer, actNum)
|
if not isReset:
|
# »î¶¯ÖÐͬ²½»î¶¯ÐÅÏ¢
|
if actInfo.get(ShareDefine.ActKey_State):
|
AddTurntableUseCountByLogin(curPlayer, actNum)
|
Sync_TurntableActionInfo(curPlayer, actNum)
|
Sync_TurntablePlayerInfo(curPlayer, actNum)
|
|
return
|
|
def PlayerOnDay(curPlayer):
|
|
for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_Turntable, {}).values():
|
actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)
|
if not actInfo.get(ShareDefine.ActKey_State):
|
continue
|
|
# ¹ýÌìÖØÖÃ
|
AddTurntableUseCountByLogin(curPlayer, actNum)
|
Sync_TurntablePlayerInfo(curPlayer, actNum)
|
|
return
|
|
def RefreshTurntableActionInfo(actNum):
|
## ÊÕµ½GameServerͬ²½µÄ»î¶¯ÐÅÏ¢£¬Ë¢Ð»ÐÅÏ¢
|
playerManager = GameWorld.GetPlayerManager()
|
for index in xrange(playerManager.GetPlayerCount()):
|
curPlayer = playerManager.GetPlayerByIndex(index)
|
if curPlayer.GetID() == 0:
|
continue
|
__CheckPlayerTurntableAction(curPlayer, actNum)
|
return
|
|
def __CheckPlayerTurntableAction(curPlayer, actNum):
|
## ¼ì²éÍæ¼Ò»î¶¯Êý¾ÝÐÅÏ¢
|
|
playerID = curPlayer.GetPlayerID()
|
actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_Turntable, actNum)
|
actID = actInfo.get(ShareDefine.ActKey_ID, 0)
|
state = actInfo.get(ShareDefine.ActKey_State, 0)
|
|
playerActID = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TurntableID % actNum) # Íæ¼ÒÉíÉϵĻID
|
|
# »î¶¯ID ÏàͬµÄ»°²»´¦Àí
|
if actID == playerActID:
|
GameWorld.DebugLog("תÅ̻ID²»±ä£¬²»´¦Àí£¡actNum=%s,actID=%s" % (actNum, actID), playerID)
|
return
|
|
cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0)
|
actWorldLV = actInfo.get(ShareDefine.ActKey_WorldLV, 0)
|
|
GameWorld.DebugLog("תÅ̻ÖØÖÃ! cfgID=%s,actNum=%s,actID=%s,playerActID=%s,state=%s" % (cfgID, actNum, actID, playerActID, state), playerID)
|
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TurntableID % actNum, actID)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TurntableWorldLV % actNum, actWorldLV)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TurntableLoginState % actNum, 0)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TurntableCTGValue % actNum, 0)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TurntableUseGold % actNum, 0)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TurntableCanUseCount % actNum, 0)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TurntableItemState % actNum, 0)
|
|
ipyData = None if not cfgID else IpyGameDataPY.GetIpyGameData("ActTurntable", cfgID)
|
if ipyData:
|
numCountList = ipyData.GetLibChooseCountList()
|
numCountTotal = sum([numCount for numCount in numCountList])
|
for num in xrange(1, numCountTotal + 1):
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TurntableItemID % (actNum, num), 0)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TurntableItemCount % (actNum, num), 0)
|
|
if state:
|
# Ëæ»úÉú³É³£¹æÎïÆ·
|
commItemCount = numCountList[0]
|
commItemLib = GameWorld.GetDictValueByRangeKey(ipyData.GetCommItemLib(), actWorldLV, [])
|
random.shuffle(commItemLib) # ´òÂÒÏÂ˳Ðò
|
commItemList = commItemLib[:commItemCount]
|
GameWorld.DebugLog(" Ëæ»úÉú³É³£¹æÎïÆ·: %s, %s" % (commItemCount, commItemList))
|
for num, itemInfo in enumerate(commItemList, 1):
|
itemID, itemCount, _ = itemInfo
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TurntableItemID % (actNum, num), itemID * 10 + ItemLibType_Comm)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TurntableItemCount % (actNum, num), itemCount)
|
|
# Ôö¼ÓµÇ¼½±ÀøתÅÌ´ÎÊý
|
AddTurntableUseCountByLogin(curPlayer, actNum)
|
|
Sync_TurntableActionInfo(curPlayer, actNum)
|
Sync_TurntablePlayerInfo(curPlayer, actNum)
|
return True
|
|
def AddTurntableUseCountByLogin(curPlayer, actNum):
|
## µÇ¼Ôö¼ÓתÅÌ´ÎÊý
|
todayTime = GameWorld.GetTodayTime()
|
loginState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TurntableLoginState % actNum)
|
if loginState == todayTime:
|
GameWorld.DebugLog("µÇ¼Ôö¼ÓתÅÌ´ÎÊý£¬ÒѾÔö¼Ó¹ý: actNum=%s,todayTime=%s" % (actNum, todayTime))
|
return
|
GameWorld.DebugLog("µÇ¼Ôö¼ÓתÅÌ´ÎÊý: actNum=%s,todayTime=%s" % (actNum, todayTime))
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TurntableLoginState % actNum, todayTime)
|
AddTurntableUseCount(curPlayer, actNum, 1)
|
return
|
|
def AddTurntableUseCount(curPlayer, actNum, addCount):
|
## Ôö¼ÓתÅÌ´ÎÊý
|
canUseCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TurntableCanUseCount % actNum) + addCount
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TurntableCanUseCount % actNum, canUseCount)
|
GameWorld.DebugLog(" Ôö¼ÓתÅ̻´ÎÊý: actNum=%s,addCount=%s,canUseCount=%s" % (actNum, addCount, canUseCount))
|
return
|
|
def OnPlayerRecharge(curPlayer, curRechargeValue, coinType):
|
## Íæ¼Ò³äÖµ
|
if curRechargeValue <= 0:
|
return
|
|
for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_Turntable, {}).values():
|
actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)
|
if not actInfo.get(ShareDefine.ActKey_State):
|
GameWorld.DebugLog("תÅ̵±Ç°Î´¿ªÆô! actNum=%s" % actNum)
|
continue
|
|
cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0)
|
if not cfgID:
|
continue
|
|
ipyData = IpyGameDataPY.GetIpyGameData("ActTurntable", cfgID)
|
if not ipyData:
|
continue
|
|
ctgTypeEffValue = ipyData.GetCTGTypeEffValue()
|
if not ctgTypeEffValue & pow(2, coinType):
|
GameWorld.DebugLog("תÅ̻³äÖµÀàÐͶԸûÎÞЧ! actNum=%s,coinType=%s,ctgTypeEffValue=%s"
|
% (actNum, coinType, ctgTypeEffValue), curPlayer.GetPlayerID())
|
continue
|
|
ctgPrizeList = [CommFunc.RMBToCoin(floatRMB) for floatRMB in ipyData.GetCTGPrizeList()]
|
nowCTGValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TurntableCTGValue % actNum)
|
if nowCTGValue >= max(ctgPrizeList):
|
GameWorld.DebugLog("תÅ̻³äÖµÒÑ´ï×î´ó¼Ç¼£¬actNum=%s,nowCTGValue=%s,maxCTGValue=%s"
|
% (actNum, nowCTGValue, max(ctgPrizeList)))
|
continue
|
|
updCTGValue = nowCTGValue + curRechargeValue
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TurntableCTGValue % actNum, updCTGValue)
|
GameWorld.DebugLog("תÅ̻³äÖµ£¬actNum=%s,nowCTGValue=%s,updCTGValue=%s,curRechargeValue=%s"
|
% (actNum, nowCTGValue, updCTGValue, curRechargeValue))
|
|
addTurntableCount = 0
|
for ctgValue in ctgPrizeList:
|
if updCTGValue < ctgValue:
|
break
|
|
if nowCTGValue < ctgValue and updCTGValue >= ctgValue:
|
addTurntableCount += 1
|
GameWorld.DebugLog(" ctgValue=%s,addTurntableCount=%s" % (ctgValue, addTurntableCount))
|
|
if addTurntableCount > 0:
|
AddTurntableUseCount(curPlayer, actNum, addTurntableCount)
|
Sync_TurntablePlayerInfo(curPlayer, actNum)
|
|
return
|
|
def OnPlayerUseGold(curPlayer, moneyType, addUseGold):
|
## Íæ¼ÒÏûºÄ»õ±Ò
|
|
if addUseGold <= 0:
|
return
|
|
for actInfo in PyGameData.g_operationActionDict.get(ShareDefine.OperationActionName_Turntable, {}).values():
|
actNum = actInfo.get(ShareDefine.ActKey_ActNum, 0)
|
if not actInfo.get(ShareDefine.ActKey_State):
|
GameWorld.DebugLog("תÅ̵±Ç°Î´¿ªÆô! actNum=%s" % actNum)
|
continue
|
|
cfgID = actInfo.get(ShareDefine.ActKey_CfgID, 0)
|
if not cfgID:
|
continue
|
|
ipyData = IpyGameDataPY.GetIpyGameData("ActTurntable", cfgID)
|
if not ipyData:
|
continue
|
|
if moneyType != ipyData.GetUseMoneyType():
|
continue
|
|
useMoneyPrizeList = ipyData.GetUseMoneyPrizeList()
|
nowUseGold = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TurntableUseGold % actNum)
|
if nowUseGold >= max(useMoneyPrizeList):
|
GameWorld.DebugLog("תÅ̻ÏûºÄ»õ±ÒÒÑ´ï×î´ó¼Ç¼£¬actNum=%s,moneyType=%s,nowUseGold=%s,maxUseMoneyValue=%s"
|
% (actNum, moneyType, nowUseGold, max(useMoneyPrizeList)))
|
continue
|
|
updUseGold = nowUseGold + addUseGold
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TurntableUseGold % actNum, updUseGold)
|
GameWorld.DebugLog("תÅ̻ÏûºÄ»õ±Ò£¬actNum=%s,moneyType=%s,nowUseGold=%s,updUseGold=%s,addUseGold=%s"
|
% (actNum, moneyType, nowUseGold, updUseGold, addUseGold))
|
|
addTurntableCount = 0
|
for useGold in useMoneyPrizeList:
|
if updUseGold < useGold:
|
break
|
|
if nowUseGold < useGold and updUseGold >= useGold:
|
addTurntableCount += 1
|
GameWorld.DebugLog(" useGold=%s,addTurntableCount=%s" % (useGold, addTurntableCount))
|
|
if addTurntableCount > 0:
|
AddTurntableUseCount(curPlayer, actNum, addTurntableCount)
|
Sync_TurntablePlayerInfo(curPlayer, actNum)
|
|
return
|
|
#// AA 12 Ñ¡ÔñתÅ̻ÎïÆ· #tagCMActTurntableChooseItem
|
#
|
#struct tagCMActTurntableChooseItem
|
#{
|
# tagHead Head;
|
# BYTE ActNum; // »î¶¯±àºÅ
|
# BYTE GoodItemNumCount;
|
# BYTE GoodItemNumList[GoodItemNumCount]; // Ñ¡ÔñµÄ¼«Æ·ÎïÆ·±àºÅÁбí
|
# BYTE SuperItemNumCount;
|
# BYTE SuperItemNumList[SuperItemNumCount]; // Ñ¡ÔñµÄÖÕ¼«ÎïÆ·±àºÅÁбí
|
#};
|
def OnTurntableChooseItem(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
actNum = clientData.ActNum
|
|
actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_Turntable, actNum)
|
if not actInfo.get(ShareDefine.ActKey_State):
|
return
|
|
cfgID = actInfo.get(ShareDefine.ActKey_CfgID)
|
if not cfgID:
|
return
|
|
ipyData = IpyGameDataPY.GetIpyGameData("ActTurntable", cfgID)
|
if not ipyData:
|
return
|
|
numCountList = ipyData.GetLibChooseCountList()
|
numCountTotal = sum([numCount for numCount in numCountList])
|
if len(numCountList) != 3:
|
return
|
commCount, goodCount, superCount = numCountList
|
|
canChoose = True
|
for num in xrange(1, numCountTotal + 1):
|
itemIDInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TurntableItemID % (actNum, num))
|
itemID, itemLibType = itemIDInfo / 10, itemIDInfo % 10
|
if itemID and itemLibType != ItemLibType_Comm:
|
canChoose = False
|
GameWorld.DebugLog(" ÒѾѡÔñ¹ýÁËתÅÌÎïÆ·ÁË£¬ÎÞ·¨Öظ´Ñ¡Ôñ!")
|
break
|
|
if not canChoose:
|
return
|
|
actWorldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TurntableWorldLV % actNum)
|
goodItemLib = GameWorld.GetDictValueByRangeKey(ipyData.GetGoodItemLib(), actWorldLV, [])
|
chooseGoodItemNumList = clientData.GoodItemNumList
|
if not chooseGoodItemNumList or len(chooseGoodItemNumList) != goodCount or min(chooseGoodItemNumList) <= 0 or max(chooseGoodItemNumList) > len(goodItemLib):
|
GameWorld.ErrLog(" תÅ̻¼«Æ·ÎïÆ·Ñ¡Ôñ´íÎó!actNum=%s,chooseGoodItemNumList=%s,goodCount=%s,goodItemLibLen=%s"
|
% (actNum, chooseGoodItemNumList, goodCount, len(goodItemLib)))
|
return
|
|
superItemLib = GameWorld.GetDictValueByRangeKey(ipyData.GetSuperItemLib(), actWorldLV, [])
|
chooseSuperItemNumList = clientData.SuperItemNumList
|
if not chooseSuperItemNumList or len(chooseSuperItemNumList) != superCount or min(chooseSuperItemNumList) <= 0 or max(chooseSuperItemNumList) > len(superItemLib):
|
GameWorld.ErrLog(" תÅ̻ÖÕ¼«ÎïÆ·Ñ¡Ôñ´íÎó!actNum=%s,chooseSuperItemNumList=%s,superCount=%s,superItemLibLen=%s"
|
% (actNum, chooseSuperItemNumList, superCount, len(superItemLib)))
|
return
|
|
useNum = commCount # ÒÔÆÕͨÎïÆ·¸öÊýΪ±àºÅ£¬µÝÔö
|
GameWorld.DebugLog("תÅ̻ѡÔñÎïÆ·: actNum=%s,chooseGoodItemNumList=%s,chooseSuperItemNumList=%s" % (actNum, chooseGoodItemNumList, chooseSuperItemNumList))
|
for chooseGoodNum in chooseGoodItemNumList:
|
useNum += 1
|
itemID, itemCount, _ = goodItemLib[chooseGoodNum - 1]
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TurntableItemID % (actNum, useNum), itemID * 10 + ItemLibType_Good)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TurntableItemCount % (actNum, useNum), itemCount)
|
GameWorld.DebugLog(" ´æ´¢Ñ¡Ôñ¼«Æ·ÎïÆ·: useNum=%s,itemID=%s,itemCount=%s" % (useNum, itemID, itemCount))
|
|
for chooseSuperNum in chooseSuperItemNumList:
|
useNum += 1
|
itemID, itemCount, _ = superItemLib[chooseSuperNum - 1]
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TurntableItemID % (actNum, useNum), itemID * 10 + ItemLibType_Super)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TurntableItemCount % (actNum, useNum), itemCount)
|
GameWorld.DebugLog(" ´æ´¢Ñ¡ÔñÖÕ¼«ÎïÆ·: useNum=%s,itemID=%s,itemCount=%s" % (useNum, itemID, itemCount))
|
|
Sync_TurntableActionInfo(curPlayer, actNum)
|
return
|
|
#// AA 13 Æô¶¯×ªÅÌ #tagCMActTurntableStart
|
#
|
#struct tagCMActTurntableStart
|
#{
|
# tagHead Head;
|
# BYTE ActNum; // »î¶¯±àºÅ
|
#};
|
def OnTurntableStart(index, clientData, tick):
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
actNum = clientData.ActNum
|
|
actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_Turntable, actNum)
|
if not actInfo.get(ShareDefine.ActKey_State):
|
return
|
|
cfgID = actInfo.get(ShareDefine.ActKey_CfgID)
|
if not cfgID:
|
return
|
|
ipyData = IpyGameDataPY.GetIpyGameData("ActTurntable", cfgID)
|
if not ipyData:
|
return
|
|
canUseCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TurntableCanUseCount % actNum)
|
if canUseCount <= 0:
|
GameWorld.DebugLog("ûÓÐתÅ̻´ÎÊý!actNum=%s" % actNum)
|
return
|
|
itemState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TurntableItemState % actNum)
|
|
numCountList = ipyData.GetLibChooseCountList()
|
numCountTotal = sum([numCount for numCount in numCountList])
|
|
canStart = False
|
hadGetCount = 0
|
isAuctionItem = 0 # ĬÈÏ·ÇÅÄÆ·
|
canGetItemInfoDict = {} # »¹¿ÉÒÔ»ñµÃµÄÎïÆ·ÐÅÏ¢ {itemLibType:{num:itemInfo, ...}, ...}
|
for num in xrange(1, numCountTotal + 1):
|
itemIDInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TurntableItemID % (actNum, num))
|
itemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TurntableItemCount % (actNum, num))
|
itemID, itemLibType = itemIDInfo / 10, itemIDInfo % 10
|
if not itemID or not itemCount:
|
continue
|
|
if itemLibType != ItemLibType_Comm:
|
canStart = True
|
|
if itemState & pow(2, num):
|
hadGetCount += 1
|
continue
|
|
if itemLibType not in canGetItemInfoDict:
|
canGetItemInfoDict[itemLibType] = {}
|
canGetItemInfoDict[itemLibType][num] = [itemID, itemCount, isAuctionItem]
|
|
if not canStart:
|
GameWorld.DebugLog("δѡÔñתÅ̻¼«Æ·ÖÕ¼«ÎïÆ·£¬ÎÞ·¨Æô¶¯×ªÅÌ£¡")
|
return
|
|
if not ItemControler.CheckPackHasSpace(curPlayer, isNotify=True):
|
return
|
|
superRate, superLimitTurnCount = ipyData.GetSuperItemLimitRule() # ÖÕ¼«¿â²ú³öÍò·ÖÂÊ|ÖÁÉÙX´Îºó¿É²ú³ö
|
|
GameWorld.DebugLog("Æô¶¯×ªÅ̻! actNum=%s,itemState=%s,hadGetCount=%s, superLimitTurnCount=%s,superRate=%s"
|
% (actNum, itemState, hadGetCount, superLimitTurnCount, superRate))
|
GameWorld.DebugLog(" canGetItemInfoDict=%s" % canGetItemInfoDict)
|
|
if not canGetItemInfoDict:
|
return
|
|
randNum = 0
|
worldNotifyKey = ""
|
giveItemInfo = []
|
canGetCommNumList = canGetItemInfoDict.get(ItemLibType_Comm, {}).keys()
|
canGetGoodNumList = canGetItemInfoDict.get(ItemLibType_Good, {}).keys()
|
randNumWithoutSuperList = canGetCommNumList + canGetGoodNumList
|
GameWorld.DebugLog(" ²»º¬ÖÕ¼«ÎïÆ·µÄ±àºÅ: %s" % (randNumWithoutSuperList))
|
|
if hadGetCount >= superLimitTurnCount and ItemLibType_Super in canGetItemInfoDict:
|
GameWorld.DebugLog(" Óлú»á»ñµÃÖÕ¼«ÎïÆ·: superRate=%s" % superRate)
|
if not randNumWithoutSuperList or GameWorld.CanHappen(superRate): # ûÓÐÆäËûÎïÆ·Á˱سöÖÕ¼«
|
randNum = random.choice(canGetItemInfoDict[ItemLibType_Super].keys())
|
giveItemInfo = canGetItemInfoDict[ItemLibType_Super][randNum]
|
GameWorld.DebugLog(" »ñµÃÖÕ¼«ÎïÆ·! randNum=%s,giveItemInfo=%s" % (randNum, giveItemInfo))
|
worldNotifyKey = ipyData.GetWorldNotifyKey()
|
|
if not giveItemInfo and randNumWithoutSuperList:
|
randNum = random.choice(randNumWithoutSuperList)
|
|
if randNum in canGetGoodNumList:
|
giveItemInfo = canGetItemInfoDict[ItemLibType_Good][randNum]
|
GameWorld.DebugLog(" »ñµÃ¼«Æ·ÎïÆ·! randNum=%s,giveItemInfo=%s" % (randNum, giveItemInfo))
|
worldNotifyKey = ipyData.GetWorldNotifyKey()
|
else:
|
giveItemInfo = canGetItemInfoDict[ItemLibType_Comm][randNum]
|
GameWorld.DebugLog(" »ñµÃ³£¹æÎïÆ·! randNum=%s,giveItemInfo=%s" % (randNum, giveItemInfo))
|
|
if not giveItemInfo or not randNum:
|
return
|
|
updItemState = itemState | pow(2, randNum)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TurntableItemState % actNum, updItemState)
|
updCanUseCount = canUseCount - 1
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TurntableCanUseCount % actNum, updCanUseCount)
|
GameWorld.DebugLog(" randNum=%s,updItemState=%s,updCanUseCount=%s" % (randNum, updItemState, updCanUseCount))
|
|
itemID, itemCount, isAuctionItem = giveItemInfo
|
ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, [IPY_GameWorld.rptItem], event=["ActTurntable", False, {}])
|
|
if worldNotifyKey:
|
PlayerControl.WorldNotify(0, worldNotifyKey, [curPlayer.GetPlayerName(), itemID, itemCount])
|
|
Sync_TurntablePlayerInfo(curPlayer, actNum, randNum)
|
return
|
|
|
def Sync_TurntablePlayerInfo(curPlayer, actNum, getItemNum=0):
|
## ֪ͨÍæ¼ÒÊý¾ÝÐÅÏ¢
|
# @param getItemNum: ±¾´ÎתÅÌ»ñµÃµÄ¶ÔÓ¦ÎïÆ·±àºÅ
|
|
actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_Turntable, actNum)
|
if not actInfo.get(ShareDefine.ActKey_State):
|
return
|
|
cfgID = actInfo.get(ShareDefine.ActKey_CfgID)
|
if not cfgID:
|
return
|
|
ipyData = IpyGameDataPY.GetIpyGameData("ActTurntable", cfgID)
|
if not ipyData:
|
return
|
|
playerActInfo = ChPyNetSendPack.tagMCActTurntablePlayerInfo()
|
playerActInfo.ActNum = actNum
|
playerActInfo.CanUseCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TurntableCanUseCount % actNum)
|
playerActInfo.CTGTotal = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TurntableCTGValue % actNum)
|
playerActInfo.UseMoneyTotal = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TurntableUseGold % actNum)
|
playerActInfo.TurnItemState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TurntableItemState % actNum)
|
playerActInfo.GetItemNum = getItemNum
|
NetPackCommon.SendFakePack(curPlayer, playerActInfo)
|
return
|
|
def Sync_TurntableActionInfo(curPlayer, actNum):
|
## ֪ͨ»î¶¯ÐÅÏ¢
|
|
actInfo = GameWorld.GetActInfo(ShareDefine.OperationActionName_Turntable, actNum)
|
if not actInfo.get(ShareDefine.ActKey_State):
|
return
|
|
cfgID = actInfo.get(ShareDefine.ActKey_CfgID)
|
if not cfgID:
|
return
|
|
ipyData = IpyGameDataPY.GetIpyGameData("ActTurntable", cfgID)
|
if not ipyData:
|
return
|
|
actWorldLV = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TurntableWorldLV % actNum)
|
startDateStr, endDateStr = GameWorld.GetOperationActionDateStr(ipyData)
|
|
clientPack = ChPyNetSendPack.tagMCActTurntableInfo()
|
clientPack.ActNum = actNum
|
clientPack.StartDate = startDateStr
|
clientPack.EndtDate = endDateStr
|
clientPack.IsDayReset = ipyData.GetIsDayReset()
|
clientPack.LimitLV = ipyData.GetLVLimit()
|
clientPack.CTGPrizeList = [CommFunc.RMBToCoin(floatRMB) for floatRMB in ipyData.GetCTGPrizeList()]
|
clientPack.CTGPrizeCount = len(clientPack.CTGPrizeList)
|
clientPack.UseMoneyType = ipyData.GetUseMoneyType()
|
clientPack.UseMoneyPrizeList = ipyData.GetUseMoneyPrizeList()
|
clientPack.UseMoneyPrizeCount = len(clientPack.UseMoneyPrizeList)
|
|
numCountList = ipyData.GetLibChooseCountList()
|
numCountTotal = sum([numCount for numCount in numCountList])
|
|
clientPack.TurnItemList = []
|
for num in xrange(1, numCountTotal + 1):
|
itemIDInfo = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TurntableItemID % (actNum, num))
|
itemCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TurntableItemCount % (actNum, num))
|
itemID, itemLibType = itemIDInfo / 10, itemIDInfo % 10
|
if not itemID:
|
break
|
packItem = ChPyNetSendPack.tagMCActTurntableItem()
|
packItem.ItemNum = num
|
packItem.ItemLibType = itemLibType
|
packItem.ItemID = itemID
|
packItem.ItemCount = itemCount
|
clientPack.TurnItemList.append(packItem)
|
clientPack.TurnItemCount = len(clientPack.TurnItemList)
|
|
clientPack.GoodItemCanChooseCount = numCountList[1] if len(numCountList) > 1 else 0
|
goodItemLib = GameWorld.GetDictValueByRangeKey(ipyData.GetGoodItemLib(), actWorldLV, [])
|
for num, itemInfo in enumerate(goodItemLib, 1):
|
itemID, itemCount, _ = itemInfo
|
packItem = ChPyNetSendPack.tagMCActTurntableItem()
|
packItem.ItemNum = num
|
packItem.ItemLibType = ItemLibType_Good
|
packItem.ItemID = itemID
|
packItem.ItemCount = itemCount
|
clientPack.GoodItemList.append(packItem)
|
clientPack.GoodItemCount = len(clientPack.GoodItemList)
|
|
clientPack.SuperItemCanChooseCount = numCountList[2] if len(numCountList) > 2 else 0
|
superItemLib = GameWorld.GetDictValueByRangeKey(ipyData.GetSuperItemLib(), actWorldLV, [])
|
for num, itemInfo in enumerate(superItemLib, 1):
|
itemID, itemCount, _ = itemInfo
|
packItem = ChPyNetSendPack.tagMCActTurntableItem()
|
packItem.ItemNum = num
|
packItem.ItemLibType = ItemLibType_Super
|
packItem.ItemID = itemID
|
packItem.ItemCount = itemCount
|
clientPack.SuperItemList.append(packItem)
|
clientPack.SuperItemCount = len(clientPack.SuperItemList)
|
|
NetPackCommon.SendFakePack(curPlayer, clientPack)
|
return
|
|