| | |
| | | import NetPackCommon
|
| | | import PlayerFace
|
| | | import PlayerHero
|
| | | import PlayerMail
|
| | | import ChConfig
|
| | |
|
| | | import random
|
| | |
| | | HJGType_FacePic = 3
|
| | | HJGType_ChatBox = 4
|
| | | HJGType_Title = 5
|
| | |
|
| | | # 称号效果类型
|
| | | (
|
| | | TitleEff_FBZhanchuiItemEx, # 1.白骨盈野扫荡额外物品奖励 TypeValue:物品ID Value:数量
|
| | | TitleEff_DayGold, # 2.每天俸禄元宝数量 Value:元宝数量
|
| | | TitleEff_HeroItemExPer, # 3.遣散/吞噬武将额外返还 Value:百分比
|
| | | TitleEff_DingjungeQuickPer, # 4. 定军阁速战获取奖励提高百分比 Value:百分比
|
| | | ) = range(1, 1 + 4)
|
| | |
|
| | | def OnPlayerLogin(curPlayer):
|
| | | SyncTitleInfo(curPlayer)
|
| | |
| | | OnMinuteModel(curPlayer)
|
| | | PlayerFace.OnMinute(curPlayer)
|
| | | PlayerChatBox.OnMinute(curPlayer)
|
| | | return
|
| | |
|
| | | def PlayerOnDay(curPlayer):
|
| | | OnDayTitle(curPlayer)
|
| | | return
|
| | |
|
| | | #// B2 25 幻境阁操作 #tagCSHJGOP
|
| | |
| | |
|
| | | playerID = curPlayer.GetPlayerID()
|
| | | attrDict = {}
|
| | | titleEffDict = {}
|
| | |
|
| | | ipyDataMgr = IpyGameDataPY.IPY_Data()
|
| | | # 称号
|
| | |
| | | perStarAdd = perStarAddList[aIndex] if len(perStarAddList) > aIndex else 0
|
| | | attrValue = initValue + perStarAdd * star
|
| | | attrDict[attrID] = attrDict.get(attrID, 0) + attrValue
|
| | | |
| | | # 特殊效果
|
| | | effType = ipyData.GetEffType()
|
| | | effTypeValue = ipyData.GetEffTypeValue()
|
| | | effValue = ipyData.GetEffValue()
|
| | | effPerStarAdd = ipyData.GetEffPerStarAdd()
|
| | | if effType:
|
| | | effValue = effValue + effPerStarAdd * star
|
| | | if effType not in titleEffDict:
|
| | | titleEffDict[effType] = [0, effTypeValue]
|
| | | titleEffDict[effType][0] = titleEffDict[effType][0] + effValue
|
| | | #GameWorld.DebugLog("称号特殊效果: titleID=%s,effType=%s,star=%s,%s" % (titleID, effType, star, titleEffDict), playerID)
|
| | | |
| | | #GameWorld.DebugLog("幻境阁累加称号,总属性: %s" % attrDict)
|
| | |
|
| | | # 形象
|
| | |
| | | # 保存计算值
|
| | | GameWorld.DebugLog("幻境阁属性: %s" % attrDict, playerID)
|
| | | PlayerOnline.GetOnlinePlayer(curPlayer).SetCalcAttr(ChConfig.Def_CalcAttr_HJG, attrDict)
|
| | | PlayerOnline.GetOnlinePlayer(curPlayer).SetCalcSpecInfo("Title", titleEffDict)
|
| | | return
|
| | |
|
| | | ## ----------------------------------------- 称号 --------------------------------------------------
|
| | |
|
| | | def GetTitleEffInfo(curPlayer, effType):
|
| | | ## 获取称号特殊效果信息
|
| | | # @return: effValue, effTypeValue
|
| | | titleEffDict = PlayerOnline.GetOnlinePlayer(curPlayer).GetCalcSpecInfo("Title")
|
| | | return titleEffDict.get(effType, [0, 0])
|
| | |
|
| | | def __GiveTitleGoldSalary(curPlayer, ipyData):
|
| | | ## 给称号每日俸禄 - 邮件发放
|
| | | |
| | | if not ipyData:
|
| | | return
|
| | | |
| | | titleID = ipyData.GetTitleID()
|
| | | effType = ipyData.GetEffType()
|
| | | if effType != TitleEff_DayGold:
|
| | | #GameWorld.DebugLog("非俸禄效果称号不处理! titleID=%s" % titleID)
|
| | | return
|
| | | |
| | | if not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_TitleState, titleID):
|
| | | #GameWorld.DebugLog("未激活俸禄效果称号不处理! titleID=%s" % titleID)
|
| | | return
|
| | | |
| | | playerID = curPlayer.GetPlayerID()
|
| | | |
| | | curTime = int(time.time())
|
| | | lastRewardTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TitleGoldRewardTime % titleID)
|
| | | if not lastRewardTime:
|
| | | lastRewardTime = curTime - 3600 * 24 # 未发放过的设置为昨天,让今天也可以发放
|
| | | #GameWorld.DebugLog("从未发放过该称号俸禄")
|
| | | |
| | | endTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TitleEndTime % titleID)
|
| | | calcTime = curTime if (not endTime or endTime > curTime) else endTime
|
| | | |
| | | rewardDays = GameWorld.GetDiff_Day(calcTime, lastRewardTime)
|
| | | GameWorld.DebugLog("俸禄称号可发放天数: %s,titleID=%s,lastRewardTime=%s,calcTime=%s,endTime=%s" |
| | | % (rewardDays, titleID, GameWorld.ChangeTimeNumToStr(lastRewardTime), GameWorld.ChangeTimeNumToStr(calcTime), |
| | | GameWorld.ChangeTimeNumToStr(endTime)), playerID)
|
| | | if rewardDays <= 0:
|
| | | #GameWorld.DebugLog("不用发放称号每日俸禄: titleID=%s" % (titleID), playerID)
|
| | | return
|
| | | |
| | | moneyItemID = ItemCommon.GetMoneyItemID(IPY_GameWorld.TYPE_Price_Gold_Money)
|
| | | if not moneyItemID:
|
| | | return
|
| | | |
| | | star = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TitleStar % titleID)
|
| | | effValue = ipyData.GetEffValue()
|
| | | effPerStarAdd = ipyData.GetEffPerStarAdd()
|
| | | |
| | | goldOneDay = effValue + effPerStarAdd * star
|
| | | giveGold = int(goldOneDay * rewardDays)
|
| | | |
| | | mailItemList = [[moneyItemID, giveGold]]
|
| | | GameWorld.DebugLog("邮件发放称号每日俸禄! titleID=%s,rewardDays=%s,goldOneDay=%s, %s" % (titleID, rewardDays, goldOneDay, mailItemList), playerID)
|
| | | updRewardTime = curTime
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TitleGoldRewardTime % titleID, updRewardTime)
|
| | | if rewardDays > 1:
|
| | | PlayerMail.SendMailByKey("TitleGoldSalaryDays", playerID, mailItemList, [titleID, rewardDays], limitDays=3)
|
| | | else:
|
| | | PlayerMail.SendMailByKey("TitleGoldSalaryDay", playerID, mailItemList, [titleID], limitDays=3)
|
| | | return
|
| | |
|
| | | def OnDayTitle(curPlayer):
|
| | | ipyDataMgr = IpyGameDataPY.IPY_Data()
|
| | | for index in range(ipyDataMgr.GetTitleCount()):
|
| | | ipyData = ipyDataMgr.GetTitleByIndex(index)
|
| | | titleID = ipyData.GetTitleID()
|
| | | if not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_TitleState, titleID):
|
| | | # 未激活的不处理
|
| | | continue
|
| | | __GiveTitleGoldSalary(curPlayer, ipyData) # 过天发放
|
| | | return
|
| | |
|
| | | def OnMinuteTitle(curPlayer):
|
| | | curTime = int(time.time())
|
| | |
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TitleEndTime % titleID, updEndTime)
|
| | | RefreshHJGAttr(curPlayer)
|
| | | SyncTitleInfo(curPlayer, [titleID])
|
| | | __GiveTitleGoldSalary(curPlayer, ipyData) # 激活发放
|
| | | return True
|
| | |
|
| | | def DelTitle(curPlayer, titleID, isRefreshAttr=True, notifyMail=""):
|
| | |
| | | if not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_TitleState, titleID):
|
| | | return
|
| | | GameWorld.Log("删除称号: titleID=%s,notifyMail=%s" % (titleID, notifyMail), playerID)
|
| | | __GiveTitleGoldSalary(curPlayer, ipyData) # 过期补发
|
| | | GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_TitleState, titleID, 0)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TitleEndTime % titleID, 0)
|
| | | PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TitleGoldRewardTime % titleID, 0)
|
| | | # 星级不重置,重新激活后再次生效
|
| | |
|
| | | if PlayerControl.GetTitleID(curPlayer) == titleID:
|