#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#
|
#
|
##@package PlayerSignDay
|
#
|
# @todo: ÿÈÕÇ©µ½
|
#
|
# @author jiang
|
# @date 2012-03-23
|
# @version 1.8
|
# @note:
|
# @change: "2013-03-13 17:00" wdb ɾ³ý·â°ü
|
# @change: "2013-10-31 11:00" hxp ÐÞ¸ÄÿÈÕÇ©µ½Âß¼
|
# @change: "2013-11-05 20:20" hxp Ôö¼Ó¹ýÌì֪ͨǩµ½¼Ç¼Çé¿ö
|
# @change: "2014-04-03 22:00" xmnathan ÿÈÕÇ©µ½Âß¼Ð޸ģ¬Ôö¼ÓVIP²¹Ç©
|
# @change: "2015-06-16 15:40" ljd Ð޸ijÉÀàµÇ½½±Àø£¬²¹µÇ
|
# @change: "2015-08-03 16:40" ljd ²¹Ç©´ÎÊý´ÓVIP Ųµ½ ¹ó×å
|
# @change: "2015-08-24 14:40" zqx Ôö¼ÓÇ©µ½³É¾Í
|
# @change: "2016-10-26 11:00" hxp Ç©µ½Âß¼ÐÞ¸Ä
|
#-------------------------------------------------------------------------------
|
#"""Version = 2016-10-26 11:00"""
|
#-------------------------------------------------------------------------------
|
|
import ShareDefine
|
import NetPackCommon
|
import IPY_GameWorld
|
import ItemControler
|
import DataRecordPack
|
import ChPyNetSendPack
|
import PlayerMagicWeapon
|
import PlayerTongTianLing
|
import PlayerActTask
|
import PlayerPet
|
import PlayerControl
|
import GameWorld
|
import ChConfig
|
import GameFuncComm
|
import IpyGameDataPY
|
import ItemCommon
|
|
import time
|
#===============================================================================
|
#//A5 09 Íæ¼ÒÇ©µ½ #tagCMDaySign
|
# struct tagCMDaySign
|
#{
|
# tagHead Head;
|
# BYTE Day; //ĬÈÏ0±íʾµ±ÈÕÇ©µ½£¬´Ó1±íʾ²¹Ç©¡£
|
# };
|
#===============================================================================
|
## Íæ¼ÒÇ©µ½·â°üÈë¿Ú
|
# @param index: Íæ¼ÒË÷Òý
|
# @param clientData: ·â°ü½á¹¹Ìå
|
# @param tick: ʱ¼ä´Á
|
# @return: None
|
def OnSignDay(index, clientData, tick):
|
# ¿ç·þ·þÎñÆ÷¹¦ÄÜÏÞÖÆ
|
if GameWorld.IsCrossServer():
|
return
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
#¹¦ÄÜ¿ªÆôÅжÏ
|
if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_SignDay):
|
GameWorld.DebugLog("Íæ¼ÒµÈ¼¶²»×㣬먦ÆôÇ©µ½¹¦ÄÜ PlayerLv=%s" % curPlayer.GetLV())
|
return
|
|
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
signDay = clientData.Day # 0-Õý³£Ç©µ½£»1-²¹Ç©
|
isAddLogin = 1 if signDay else 0 # ÊÇ·ñ²¹Ç©
|
|
if not isAddLogin:
|
#ÊÇ·ñ½ñÌìÒѾǩµ½
|
signState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DayLoginSignState)
|
if signState:
|
GameWorld.DebugLog("½ñÈÕÒÑÇ©µ½¹ý£¡")
|
return
|
signCost = 0
|
else:
|
#±¾ÂÖÀۼƿɲ¹Ç©´ÎÊý
|
canAddSignNum = GetCanAddSignNum(curPlayer)
|
#ÊÇ·ñÓÐÊ£Óಹǩ´ÎÊý
|
if canAddSignNum <= 0:
|
GameWorld.DebugLog("ÒѾûÓв¹Ç©´ÎÊý£¬²¹Ç©Ê§°Ü£¡canAddSignNum=%s" % canAddSignNum)
|
return
|
#»ñÈ¡ÐèÒªÏûºÄÍæ¼ÒÏÉÓñ
|
signCost = IpyGameDataPY.GetFuncCfg("SignConsumption")
|
if not PlayerControl.HaveMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, signCost, True):
|
GameWorld.DebugLog("²¹Ç©ËùÐè»õ±Ò²»×ã! signCost=%s" % signCost)
|
return
|
|
#»ñµÃÇ©µ½ÌìÊý
|
curSignNum = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DayLoginSignNum) + 1
|
totalSignNum = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalSignNum) + 1
|
|
#»ñµÃÇ©µ½Àۼƽ±Àø±íijÈÕÐÅÏ¢
|
awardInfo = IpyGameDataPY.GetIpyGameData("SignAward", curSignNum)
|
if not awardInfo:
|
GameWorld.DebugLog("ÕÒ²»µ½Ç©µ½½±Àø! Ç©µ½µÚ(%s)´Î" % curSignNum)
|
return
|
|
#»ñµÃÁÐÐÅÏ¢
|
itemIDList = awardInfo.GetItemID()
|
ordinaryNumList = awardInfo.GetOrdinaryNum()
|
isBind = awardInfo.GetIsBind()
|
vipLv = awardInfo.GetVipLv()
|
vipMultiple = awardInfo.GetVipMultiple()
|
#ÅжÏÊÇ·ñÊǵڶþÔÂÒÔºó
|
isMulti = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DayLoginSignIsMulti)
|
if not isMulti:
|
itemID = itemIDList[0]
|
ordinaryNum = ordinaryNumList[0]
|
else:
|
itemID = itemIDList[1]
|
ordinaryNum = ordinaryNumList[1]
|
#ÅжÏÊÇ·ñÐèÒªVip¶à±¶
|
curVipLV = curPlayer.GetVIPLv()
|
if curVipLV >= vipLv:
|
ordinaryNum *= vipMultiple
|
|
#¼Ç¼ǩµ½ÐÅÏ¢
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DayLoginSignNum, curSignNum)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalSignNum, totalSignNum)
|
if not isAddLogin:
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DayLoginSignState, 1)
|
|
#Ö§¸¶ÏÉÓñ
|
if signCost > 0:
|
PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, signCost, ChConfig.Def_Cost_AddSignDay)
|
|
#Ç©µ½½±ÀøÐÅÏ¢
|
awardInfoList = [[itemID, ordinaryNum, isBind]]
|
|
#¸øÓèÇ©µ½½±ÀøÎïÆ·
|
__GivePlayerItemByItemInfoList(curPlayer, awardInfoList, "SignToPlayer")
|
|
#ÀÛ¼ÆÇ©µ½½±ÀøÐÅÏ¢
|
contineAwardInfoList = []
|
|
#»ñµÃÁ¬ÐøÇ©µ½½±Àø±íÐÅÏ¢
|
contineAwardInfo = IpyGameDataPY.GetIpyGameData("ContineSignAward", curSignNum)
|
if not contineAwardInfo:
|
GameWorld.DebugLog("ÕÒ²»µ½Á¬ÐøÇ©µ½½±Àø! Ç©µ½µÚ(%s)´Î" % curSignNum)
|
else:
|
jobItemList = contineAwardInfo.GetJobItemList()
|
itemIDList = contineAwardInfo.GetItemID()
|
itemNumList = contineAwardInfo.GetItemNum()
|
awardIndex = 1 if (len(itemIDList) > 1 and isMulti) else 0
|
itemID = itemIDList[awardIndex]
|
itemCount = itemNumList[awardIndex]
|
if itemID in jobItemList and curPlayer.GetJob() <= len(jobItemList):
|
itemID = jobItemList[curPlayer.GetJob() - 1]
|
contineAwardInfoList = [[itemID, itemCount, contineAwardInfo.GetIsBind()]]
|
#for index in xrange(len(itemIDList)):
|
# contineAwardInfoList.append([itemIDList[index], itemNumList[index], itemIsBind])
|
|
#¸øÓèÀۼƽ±ÀøÎïÆ·
|
__GivePlayerItemByItemInfoList(curPlayer, contineAwardInfoList, "ContineSignToPlayer")
|
PlayerControl.NotifyCode(curPlayer, 'SignInText')
|
#ͬ²½¿Í»§¶Ë
|
Sync_SignDayInfo(curPlayer)
|
|
addDataDict = {"signNum":curSignNum, "vipLV":curVipLV, "itemInfo":str(awardInfoList + contineAwardInfoList),
|
"isAddSign":isAddLogin, "CostMoney":str([IPY_GameWorld.TYPE_Price_Gold_Money, signCost])}
|
DataRecordPack.DR_FuncGiveItem(curPlayer, "DayLoginSignAward", addDataDict)
|
GameWorld.DebugLog("%s: %s" % ("²¹Ç©" if isAddLogin else "Ç©µ½", addDataDict), curPlayer.GetPlayerID())
|
ItemControler.NotifyGiveAwardInfo(curPlayer, awardInfoList + contineAwardInfoList, "SignDay")
|
|
# ˢǩµ½¸½¼Ó¹¦ÄÜÊôÐÔ
|
PlayerMagicWeapon.CalcMagicWeaponAttr(curPlayer)
|
PlayerPet.CalcPetItemAddPlayerAttr(curPlayer)
|
PlayerControl.PlayerControl(curPlayer).RefreshPlayerAttrState()
|
|
mwID = IpyGameDataPY.GetFuncCfg('MWSignDayAttr', 2)
|
if mwID:
|
effDict = IpyGameDataPY.GetFuncEvalCfg('MWSignDayAttr', 1, {})
|
if PlayerMagicWeapon.GetIsActiveMagicWeapon(curPlayer, mwID) and effDict:
|
PlayerControl.NotifyCode(curPlayer, "SignInText1", [mwID, effDict.keys()[0], effDict.values()[0]])
|
|
|
petLearnSkillList, petPassiveSkillList = PlayerPet.GetPetLearnSkill(curPlayer)
|
if ChConfig.Def_SkillID_PetSignDay in petPassiveSkillList:
|
signDayAttrSkill = GameWorld.GetGameData().GetSkillBySkillID(ChConfig.Def_SkillID_PetSignDay)
|
if signDayAttrSkill:
|
curEffect = signDayAttrSkill.GetEffect(0)
|
PlayerControl.NotifyCode(curPlayer, "SignInText2", [ChConfig.Def_SkillID_PetSignDay, curEffect.GetEffectID(), curEffect.GetEffectValue(0)])
|
|
PlayerTongTianLing.AddTongTianTaskValue(curPlayer, ChConfig.TTLTaskType_Sign, 1)
|
PlayerActTask.AddActTaskValue(curPlayer, ChConfig.ActTaskType_Sign)
|
return
|
|
## Ç©µ½×ܽ±ÀøÌìÊý
|
def GetSignAwardCountMax(): return IpyGameDataPY.IPY_Data().GetSignAwardCount()
|
|
def DoSignDayOpen(curPlayer):
|
ResetDaySign(curPlayer)
|
return
|
|
def SignDayOnLogin(curPlayer):
|
''' Íæ¼ÒÉÏÏß '''
|
#¹¦ÄÜ¿ªÆôÅжÏ
|
if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_SignDay):
|
#GameWorld.DebugLog("Íæ¼Ò먦ÆôÇ©µ½¹¦ÄÜ PlayerLv=%s" % curPlayer.GetLV())
|
return
|
Sync_SignDayInfo(curPlayer)
|
return
|
|
def SignDayOnDay(curPlayer):
|
''' Íæ¼Ò¹ýÌì '''
|
#¹¦ÄÜ¿ªÆôÅжÏ
|
if not GameFuncComm.GetFuncCanUse(curPlayer, ShareDefine.GameFuncID_SignDay):
|
GameWorld.DebugLog("Íæ¼Ò¹¥»÷²»×㣬먦ÆôÇ©µ½¹¦ÄÜ PlayerLv=%s" % curPlayer.GetLV())
|
return
|
curSignNum = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DayLoginSignNum)
|
#Ç©µ½ÌìÊýÒÑÂú×î´óÖµ£¬Ë¢Ð°ñµ¥
|
if curSignNum >= GetSignAwardCountMax():
|
GameWorld.DebugLog("ÀÛ¼ÆÇ©µ½ÌìÊýÂúÖØÖÃ! curSignNum=%s" % curSignNum)
|
ResetDaySign(curPlayer, 1)
|
return
|
|
#Ë¢ÐÂÊÇ·ñÇ©µ½¼Ç¼
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DayLoginSignState, 0)
|
Sync_SignDayInfo(curPlayer)
|
return
|
|
def ResetDaySign(curPlayer, isMulti=0):
|
''' ÖØÖÃÇ©µ½
|
@param isMulti: ÊÇ·ñ´ÎÔÂÆð
|
'''
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DayLoginSignIsMulti, isMulti)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DayLoginSignNum, 0)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DayLoginSignState, 0)
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_DayLoginSignStartTime, int(time.time()))
|
if isMulti:
|
Sync_SignDayInfo(curPlayer)
|
else:
|
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TotalSignNum, 0)
|
return
|
|
def GetCanAddSignNum(curPlayer):
|
## »ñÈ¡¿É²¹Ç©ÌìÊý
|
curTime = int(time.time())
|
startTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DayLoginSignStartTime) # ¿ªÊ¼Ê±¼ä
|
if not startTime:
|
return 0
|
if curTime < startTime:
|
return 0
|
signNumMax = GetSignAwardCountMax()
|
signNumMax = min(GameWorld.GetDiff_Day(curTime, startTime) + 1, signNumMax) # ×î´ó¿ÉÇ©µ½´ÎÊý
|
signState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DayLoginSignState) # ½ñÈÕÊÇ·ñÒÑÇ©µ½
|
signCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DayLoginSignNum) # ÒÑÇ©µ½´ÎÊý
|
signNumRemain = signNumMax - signCount # Ê£Óà¿ÉÇ©µ½´ÎÊý
|
if not signState:
|
signNumRemain -= 1
|
signNumRemain = max(0, signNumRemain)
|
#GameWorld.DebugLog("×î´ó¿ÉÇ©µ½´ÎÊý=%s,ÒÑÇ©µ½´ÎÊý=%s,½ñÌìÊÇ·ñÒÑÇ©µ½=%s,¿É²¹Ç©´ÎÊý=%s"
|
# % (signNumMax, signCount, signState, signNumRemain), curPlayer.GetPlayerID())
|
return signNumRemain
|
|
## ֪ͨǩµ½´ÎÊý½±ÀøÁìÈ¡Çé¿ö
|
# @param curPlayer: Íæ¼ÒʵÀý
|
# @return: None
|
def Sync_SignDayInfo(curPlayer):
|
signInfo = ChPyNetSendPack.tagMCDaySignInfo()
|
signInfo.Clear()
|
signInfo.DaySignCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DayLoginSignNum)
|
signInfo.ReplenishSignCount = GetCanAddSignNum(curPlayer)
|
signInfo.IsSign = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DayLoginSignState)
|
isFrist = 0 if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_DayLoginSignIsMulti) else 1
|
signInfo.IsFrist = isFrist
|
signInfo.TotalSignCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TotalSignNum)
|
NetPackCommon.SendFakePack(curPlayer, signInfo)
|
return
|
|
##¸øÓèÍæ¼ÒÎïÆ·
|
def __GivePlayerItemByItemInfoList(curPlayer, awardInfoList, mailTypeKey):
|
signCount = len(awardInfoList)
|
|
packSpace = ItemCommon.GetItemPackSpace(curPlayer, IPY_GameWorld.rptItem, signCount)
|
if packSpace >= signCount:
|
for awardInfo in awardInfoList:
|
ItemControler.GivePlayerItem(curPlayer, awardInfo[0], awardInfo[1], 0, [IPY_GameWorld.rptItem])
|
else:
|
GameWorld.DebugLog("±³°üÒÑÂú Óʼþ·¢ËÍÎïÆ·")
|
PlayerControl.SendMailByKey(mailTypeKey, [curPlayer.GetPlayerID()], awardInfoList)
|
return
|
|
|