From 7d6425827901a98ff9f47b25718542bd81dbbfac Mon Sep 17 00:00:00 2001
From: hxp <ale99527@vip.qq.com>
Date: 星期一, 08 三月 2021 14:43:41 +0800
Subject: [PATCH] 8807 【BT2】【后端】Part1 14、投资返利送充值券(增加登录投资9、等级投资10、boss投资11;优化永久投资、周卡投资逻辑 同步主干);
---
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py | 91 ++++++
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py | 3
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/ClearInvest.py | 37 +-
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py | 4
PySysDB/PySysDBPY.h | 1
ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py | 91 ++++++
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGoldInvest.py | 624 ++++++++++++++++------------------------
ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py | 33 -
8 files changed, 475 insertions(+), 409 deletions(-)
diff --git a/PySysDB/PySysDBPY.h b/PySysDB/PySysDBPY.h
index 10f62a8..0d81430 100644
--- a/PySysDB/PySysDBPY.h
+++ b/PySysDB/PySysDBPY.h
@@ -1278,6 +1278,7 @@
BYTE Type; //投资类型
BYTE NeedDay; //需要天数
WORD NeedLV; //需要等级
+ DWORD NeedNPCID; //需要NPCID
dict Reward; //奖励 {"key":[[物品ID,个数,是否绑定],...], ...}
};
diff --git a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
index 69b131c..b6ad441 100644
--- a/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
+++ b/ServerPython/CoreServerGroup/GameServer/Script/ChPyNetSendPack.py
@@ -17134,6 +17134,97 @@
#------------------------------------------------------
+# A3 38 投资理财信息 #tagMCInvestInfo
+
+class tagMCInvestInfo(Structure):
+ Head = tagHead()
+ InvestType = 0 #(BYTE InvestType)// 投资类型
+ CurDay = 0 #(WORD CurDay)// 当前天数,投资第一天为1
+ ValueCount = 0 #(BYTE ValueCount)
+ RewardValue = list() #(vector<DWORD> RewardValue)//领奖记录值,按投资回报索引位记录是否已领取
+ ProgressValue = list() #(vector<DWORD> ProgressValue)//投资相关可领取进度记录值: 9登录投资-记录已登录天数;11Boss投资-按回报索引位记录是否已击杀该boss
+ data = None
+
+ def __init__(self):
+ self.Clear()
+ self.Head.Cmd = 0xA3
+ self.Head.SubCmd = 0x38
+ return
+
+ def ReadData(self, _lpData, _pos=0, _Len=0):
+ self.Clear()
+ _pos = self.Head.ReadData(_lpData, _pos)
+ self.InvestType,_pos = CommFunc.ReadBYTE(_lpData, _pos)
+ self.CurDay,_pos = CommFunc.ReadWORD(_lpData, _pos)
+ self.ValueCount,_pos = CommFunc.ReadBYTE(_lpData, _pos)
+ for i in range(self.ValueCount):
+ value,_pos=CommFunc.ReadDWORD(_lpData,_pos)
+ self.RewardValue.append(value)
+ for i in range(self.ValueCount):
+ value,_pos=CommFunc.ReadDWORD(_lpData,_pos)
+ self.ProgressValue.append(value)
+ return _pos
+
+ def Clear(self):
+ self.Head = tagHead()
+ self.Head.Clear()
+ self.Head.Cmd = 0xA3
+ self.Head.SubCmd = 0x38
+ self.InvestType = 0
+ self.CurDay = 0
+ self.ValueCount = 0
+ self.RewardValue = list()
+ self.ProgressValue = list()
+ return
+
+ def GetLength(self):
+ length = 0
+ length += self.Head.GetLength()
+ length += 1
+ length += 2
+ length += 1
+ length += 4 * self.ValueCount
+ length += 4 * self.ValueCount
+
+ return length
+
+ def GetBuffer(self):
+ data = ''
+ data = CommFunc.WriteString(data, self.Head.GetLength(), self.Head.GetBuffer())
+ data = CommFunc.WriteBYTE(data, self.InvestType)
+ data = CommFunc.WriteWORD(data, self.CurDay)
+ data = CommFunc.WriteBYTE(data, self.ValueCount)
+ for i in range(self.ValueCount):
+ data = CommFunc.WriteDWORD(data, self.RewardValue[i])
+ for i in range(self.ValueCount):
+ data = CommFunc.WriteDWORD(data, self.ProgressValue[i])
+ return data
+
+ def OutputString(self):
+ DumpString = '''
+ Head:%s,
+ InvestType:%d,
+ CurDay:%d,
+ ValueCount:%d,
+ RewardValue:%s,
+ ProgressValue:%s
+ '''\
+ %(
+ self.Head.OutputString(),
+ self.InvestType,
+ self.CurDay,
+ self.ValueCount,
+ "...",
+ "..."
+ )
+ return DumpString
+
+
+m_NAtagMCInvestInfo=tagMCInvestInfo()
+ChNetPackDict[eval("0x%02x%02x"%(m_NAtagMCInvestInfo.Head.Cmd,m_NAtagMCInvestInfo.Head.SubCmd))] = m_NAtagMCInvestInfo
+
+
+#------------------------------------------------------
# A3 52 法宝等级信息 #tagMCMagicWeaponLVInfo
class tagMCMagicWeaponInfo(Structure):
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
index 3b06f95..c1f67b0 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChConfig.py
@@ -3910,11 +3910,11 @@
Def_PDict_FamilyActivityFinishCnt = "FamilyActivityFinishCnt%s" # 已完成次数
Def_PDict_FamilyActivityAwardRecord = "FamilyActivityAwardRecord" # 活跃度奖励领取记录,按二进制位标识
-# 投资理财 Def_PDictType_GoldInvest
-Def_PDict_GoldInvest_Time = "Invest_Time_%s" # 投资时的时间,参数为投资类型
-Def_PDict_GoldInvest_Gold = "Invest_Gold_%s" # 投资的额度,参数为投资类型
-Def_PDict_GoldInvest_AwardData = "Invest_AwardData_%s" # 投资时的数据,参数为投资类型
-Def_PDict_GoldInvest_GotRewardValue = "Invest_GotRewardValue_%s_%s" # 等级回报已领取数值,参数为投资类型 索引
+# 投资理财
+Def_PDict_InvestTime = "InvestTime_%s" # 投资时的时间,参数为投资类型
+Def_PDict_InvestProgress = "InvestProgress_%s_%s" # 投资可领奖进度值,参数为(投资类型, key编号)
+Def_PDict_InvestReward = "InvestReward_%s_%s" # 投资领奖记录,参数为(投资类型, key编号)
+Def_PDict_InvestKeyCount = 3 # key编号数
# 成就 Def_PDictType_Success
Def_PDict_Success_AwardRecord = "Succ_AwardRecord_%s" # 成就领奖记录,参数(key编号),按索引位存储0-未领,1-已领
@@ -5284,22 +5284,15 @@
}
-# 投资理财类型
-GoldInvestTypeList = (
-GoldInvestType_Month, # 旧月卡投资1(已废弃)
-GoldInvestType_VIP, # vip投资2
-GoldInvestType_Gold, # 仙玉投资3
-GoldInvestType_Gold2, # 仙玉投资4
-GoldInvestType_Gold3, # 仙玉投资5
-GoldInvestType_Week, # 周卡投资6(已废弃)
-GoldInvestType_NewMonth, # 至尊月卡投资7
-GoldInvestType_Month1, # 新30元月卡投资8
-) = range(1,8+1)
+# 投资理财类型,和前端对应,从7开始
+InvestTypeList = (
+InvestType_NewMonth, # 至尊月卡投资7
+InvestType_Month1, # 新30元月卡投资8
+InvestType_Login, # 登录 9
+InvestType_LV, # 等级 10
+InvestType_Boss, # Boss 11
+) = range(7, 7 + 5)
-#可以循环投资的类型
-CanRepeatInvestType = [GoldInvestType_Week, GoldInvestType_Month, GoldInvestType_VIP, GoldInvestType_NewMonth, GoldInvestType_Month1]
-#仙玉投资类型
-InvestGoldTypeList = [GoldInvestType_Gold, GoldInvestType_Gold2, GoldInvestType_Gold3]
#前端特殊新手引导存储标记
GuideState_BZZDShow = 202
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
index 69b131c..b6ad441 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/ChPyNetSendPack.py
@@ -17134,6 +17134,97 @@
#------------------------------------------------------
+# A3 38 投资理财信息 #tagMCInvestInfo
+
+class tagMCInvestInfo(Structure):
+ Head = tagHead()
+ InvestType = 0 #(BYTE InvestType)// 投资类型
+ CurDay = 0 #(WORD CurDay)// 当前天数,投资第一天为1
+ ValueCount = 0 #(BYTE ValueCount)
+ RewardValue = list() #(vector<DWORD> RewardValue)//领奖记录值,按投资回报索引位记录是否已领取
+ ProgressValue = list() #(vector<DWORD> ProgressValue)//投资相关可领取进度记录值: 9登录投资-记录已登录天数;11Boss投资-按回报索引位记录是否已击杀该boss
+ data = None
+
+ def __init__(self):
+ self.Clear()
+ self.Head.Cmd = 0xA3
+ self.Head.SubCmd = 0x38
+ return
+
+ def ReadData(self, _lpData, _pos=0, _Len=0):
+ self.Clear()
+ _pos = self.Head.ReadData(_lpData, _pos)
+ self.InvestType,_pos = CommFunc.ReadBYTE(_lpData, _pos)
+ self.CurDay,_pos = CommFunc.ReadWORD(_lpData, _pos)
+ self.ValueCount,_pos = CommFunc.ReadBYTE(_lpData, _pos)
+ for i in range(self.ValueCount):
+ value,_pos=CommFunc.ReadDWORD(_lpData,_pos)
+ self.RewardValue.append(value)
+ for i in range(self.ValueCount):
+ value,_pos=CommFunc.ReadDWORD(_lpData,_pos)
+ self.ProgressValue.append(value)
+ return _pos
+
+ def Clear(self):
+ self.Head = tagHead()
+ self.Head.Clear()
+ self.Head.Cmd = 0xA3
+ self.Head.SubCmd = 0x38
+ self.InvestType = 0
+ self.CurDay = 0
+ self.ValueCount = 0
+ self.RewardValue = list()
+ self.ProgressValue = list()
+ return
+
+ def GetLength(self):
+ length = 0
+ length += self.Head.GetLength()
+ length += 1
+ length += 2
+ length += 1
+ length += 4 * self.ValueCount
+ length += 4 * self.ValueCount
+
+ return length
+
+ def GetBuffer(self):
+ data = ''
+ data = CommFunc.WriteString(data, self.Head.GetLength(), self.Head.GetBuffer())
+ data = CommFunc.WriteBYTE(data, self.InvestType)
+ data = CommFunc.WriteWORD(data, self.CurDay)
+ data = CommFunc.WriteBYTE(data, self.ValueCount)
+ for i in range(self.ValueCount):
+ data = CommFunc.WriteDWORD(data, self.RewardValue[i])
+ for i in range(self.ValueCount):
+ data = CommFunc.WriteDWORD(data, self.ProgressValue[i])
+ return data
+
+ def OutputString(self):
+ DumpString = '''
+ Head:%s,
+ InvestType:%d,
+ CurDay:%d,
+ ValueCount:%d,
+ RewardValue:%s,
+ ProgressValue:%s
+ '''\
+ %(
+ self.Head.OutputString(),
+ self.InvestType,
+ self.CurDay,
+ self.ValueCount,
+ "...",
+ "..."
+ )
+ return DumpString
+
+
+m_NAtagMCInvestInfo=tagMCInvestInfo()
+ChNetPackDict[eval("0x%02x%02x"%(m_NAtagMCInvestInfo.Head.Cmd,m_NAtagMCInvestInfo.Head.SubCmd))] = m_NAtagMCInvestInfo
+
+
+#------------------------------------------------------
# A3 52 法宝等级信息 #tagMCMagicWeaponLVInfo
class tagMCMagicWeaponInfo(Structure):
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/ClearInvest.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/ClearInvest.py
index 3747330..7621542 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/ClearInvest.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/GM/Commands/ClearInvest.py
@@ -20,6 +20,7 @@
import PlayerControl
import GameWorld
#---------------------------------------------------------------------
+
#逻辑实现
## GM命令执行入口
# @param curPlayer 当前玩家
@@ -27,22 +28,28 @@
# @return None
# @remarks 函数详细说明.
def OnExec(curPlayer, msgList):
- GameWorld.DebugAnswer(curPlayer, "ClearInvest 投资类型(不写则全部重置)")
- investTypeList = [msgList[0]] if msgList else ChConfig.GoldInvestTypeList
- for itype in investTypeList:
- valueKey = ChConfig.Def_PDict_GoldInvest_Time % itype
- PlayerControl.NomalDictSetProperty(curPlayer, valueKey, 0, ChConfig.Def_PDictType_GoldInvest)
-
- valueKey = ChConfig.Def_PDict_GoldInvest_Gold % itype
- PlayerControl.NomalDictSetProperty(curPlayer, valueKey, 0, ChConfig.Def_PDictType_GoldInvest)
-
- valueKey = ChConfig.Def_PDict_GoldInvest_AwardData % itype
- PlayerControl.NomalDictSetProperty(curPlayer, valueKey, 0, ChConfig.Def_PDictType_GoldInvest)
- for i in range(1, 32):
- valueKey = ChConfig.Def_PDict_GoldInvest_GotRewardValue % (itype, i)
- PlayerControl.NomalDictSetProperty(curPlayer, valueKey, 0, ChConfig.Def_PDictType_GoldInvest)
- PlayerGoldInvest.Sync_GoldInvestInfo(curPlayer, itype, isForce=True)
+ if not msgList:
+ GameWorld.DebugAnswer(curPlayer, "重置所有投资: ClearInvest 0")
+ GameWorld.DebugAnswer(curPlayer, "重置指定投资: ClearInvest 类型")
+ GameWorld.DebugAnswer(curPlayer, "类型:7-永久卡;8-周卡;9-登录卡;10-等级卡;11-boss卡;")
+ return
+
+ investType = msgList[0]
+ if not investType:
+ investTypeList = ChConfig.InvestTypeList
+ elif investType not in ChConfig.InvestTypeList:
+ GameWorld.DebugAnswer(curPlayer, "不存在该投资类型!")
+ return
+ else:
+ investTypeList = [investType]
+
+ for itype in investTypeList:
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_InvestTime % itype, 0)
+ for keyNum in range(ChConfig.Def_PDict_InvestKeyCount):
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_InvestReward % (itype, keyNum), 0)
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_InvestProgress % (itype, keyNum), 0)
+ PlayerGoldInvest.Sync_InvestInfo(curPlayer, itype)
return
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py
index 5aaa761..620042e 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/IpyGameDataPY.py
@@ -1025,6 +1025,7 @@
("BYTE", "Type", 0),
("BYTE", "NeedDay", 0),
("WORD", "NeedLV", 0),
+ ("DWORD", "NeedNPCID", 0),
("dict", "Reward", 0),
),
@@ -3802,6 +3803,7 @@
self.Type = 0
self.NeedDay = 0
self.NeedLV = 0
+ self.NeedNPCID = 0
self.Reward = {}
return
@@ -3809,6 +3811,7 @@
def GetType(self): return self.Type # 投资类型
def GetNeedDay(self): return self.NeedDay # 需要天数
def GetNeedLV(self): return self.NeedLV # 需要等级
+ def GetNeedNPCID(self): return self.NeedNPCID # 需要NPCID
def GetReward(self): return self.Reward # 奖励 {"key":[[物品ID,个数,是否绑定],...], ...}
# 仙宝寻主表
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py
index 5bd88cb..e6238f9 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/NPC/NPCCommon.py
@@ -55,6 +55,7 @@
import GameLogic_CrossGrassland
import PlayerFeastWish
import PlayerFeastTravel
+import PlayerGoldInvest
import PlayerWeekParty
import NPCHurtManager
import PlayerActLogin
@@ -5077,6 +5078,9 @@
EventShell.EventRespons_KillWorldBoss(curPlayer)
#击杀特定NPC成就
PlayerSuccess.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_KillSpecificNPC, 1, [npcID])
+ #Boss投资,击杀及摸怪都算
+ if limitIndex != None:
+ PlayerGoldInvest.OnKillBoss(curPlayer, npcID)
return
def __GetIsLog(self):
diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGoldInvest.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGoldInvest.py
index 0fbd2e6..7591379 100644
--- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGoldInvest.py
+++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/Player/PlayerGoldInvest.py
@@ -2,175 +2,114 @@
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
-#-------------------------------------------------------------------------------
-#
##@package Player.PlayerGoldInvest
#
-# @todo:理财投资
-# @author xdh
-# @date 2018-04-02
+# @todo:投资
+# @author hxp
+# @date 2020-09-10
# @version 1.0
#
+# 详细描述: 投资
#
-# 详细描述: 理财投资
-#
-#---------------------------------------------------------------------
-#"""Version = 2018-04-02 10:30"""
-#---------------------------------------------------------------------
+#-------------------------------------------------------------------------------
+#"""Version = 2020-09-10 11:00"""
+#-------------------------------------------------------------------------------
+import GameWorld
import IpyGameDataPY
import NetPackCommon
-import ChPyNetSendPack
-import IPY_GameWorld
-import PlayerControl
-import GameWorld
-import ChConfig
-import ItemControler
import DataRecordPack
+import ChPyNetSendPack
import PlayerFamilyRedPacket
+import ItemControler
+import PlayerControl
+import IPY_GameWorld
+import ChConfig
import time
-import re
-
-## 获取投资理财玩家数据库字典信息值
-# @param curPlayer 玩家实例
-# @param key 字典key
-# @param defaultValue 默认值
-# @return
-def __GetPDictValue(curPlayer, key, defaultValue=0):
- return curPlayer.NomalDictGetProperty(key, defaultValue, ChConfig.Def_PDictType_GoldInvest)
-
-
-## 设置投资理财玩家数据库字典信息值
-# @param curPlayer 玩家实例
-# @param key 字典key
-# @param value 设置的值
-# @return
-def __SetPDictValue(curPlayer, key, value):
- PlayerControl.NomalDictSetProperty(curPlayer, key, value, ChConfig.Def_PDictType_GoldInvest)
+def __TransferPlayerInvestDBKey(curPlayer):
+ ## 转换玩家存储字典,换key名
+
+ # 旧版key
+ # 投资理财 Def_PDictType_GoldInvest
+ Def_PDict_GoldInvest_Time = "Invest_Time_%s" # 投资时的时间,参数为投资类型
+ #Def_PDict_GoldInvest_Gold = "Invest_Gold_%s" # 投资的额度,参数为投资类型 标记是否已投资,可用投资时间即可,不处理
+ #Def_PDict_GoldInvest_AwardData = "Invest_AwardData_%s" # 投资时的数据,参数为投资类型 默认1,无用,可不管
+ Def_PDict_GoldInvest_GotRewardValue = "Invest_GotRewardValue_%s_%s" # 等级回报已领取数值,参数为投资类型 索引
+
+ playerID = curPlayer.GetPlayerID()
+ for investType in [ChConfig.InvestType_NewMonth, ChConfig.InvestType_Month1]:
+ investTimeKeyOld = Def_PDict_GoldInvest_Time % investType
+ investTime = curPlayer.NomalDictGetProperty(investTimeKeyOld, 0, ChConfig.Def_PDictType_GoldInvest)
+ if not investTime:
+ continue
+
+ investTimeKeyNew = ChConfig.Def_PDict_InvestTime % investType
+ PlayerControl.NomalDictSetProperty(curPlayer, investTimeKeyNew, investTime)
+ PlayerControl.NomalDictSetProperty(curPlayer, investTimeKeyOld, 0, ChConfig.Def_PDictType_GoldInvest)
+ GameWorld.Log("转换投资key: investType=%s,investTimeKeyNew=%s,investTime=%s,investTimeKeyOld=%s"
+ % (investType, investTimeKeyNew, investTime, investTimeKeyOld), playerID)
+
+ maxDay = __GetInvestMaxDays(investType)
+ for i in xrange(1, maxDay + 1):
+ rewardKeyOld = Def_PDict_GoldInvest_GotRewardValue % (investType, i)
+ reward = curPlayer.NomalDictGetProperty(rewardKeyOld, 0, ChConfig.Def_PDictType_GoldInvest)
+ if not reward:
+ continue
+
+ GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_InvestReward, i, 1, True, [investType])
+ PlayerControl.NomalDictSetProperty(curPlayer, rewardKeyOld, 0, ChConfig.Def_PDictType_GoldInvest)
+ GameWorld.Log(" 转换投资已领取记录: i=%s,rewardKeyOld=%s" % (i, rewardKeyOld), playerID)
+
return
-
-## 投资理财玩家登录处理
-# @param curPlayer 玩家
-# @return
+## 登录
def OnLogin(curPlayer):
- CheckOldInvestMail(curPlayer)
- __CheckInvestReset(curPlayer)
- for iType in ChConfig.GoldInvestTypeList:
- Sync_GoldInvestInfo(curPlayer, iType)
+ __TransferPlayerInvestDBKey(curPlayer)
+ for investType in ChConfig.InvestTypeList:
+ if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_InvestTime % investType):
+ continue
+ Sync_InvestInfo(curPlayer, investType)
return
-
-## 投资理财玩家过天处理
-# @param curPlayer 玩家
-# @return
+## 过天
def OnDay(curPlayer):
- CheckOldInvestMail(curPlayer)
- #vip投资过了整个周期则重置
- __CheckInvestReset(curPlayer)
-
-
- for iType in ChConfig.GoldInvestTypeList:
- Sync_GoldInvestInfo(curPlayer, iType)
-
- awardData = __GetInvestLVData(curPlayer)
- __SetPDictValue(curPlayer, ChConfig.Def_PDict_GoldInvest_AwardData % ChConfig.GoldInvestType_VIP, awardData)
+ for investType in ChConfig.InvestTypeList:
+ if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_InvestTime % investType):
+ continue
+
+ # 登录卡
+ if investType == ChConfig.InvestType_Login:
+ progressValue = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_InvestProgress % (investType, 0))
+ maxDays = __GetInvestMaxDays(investType)
+ if maxDays and progressValue < maxDays:
+ progressValue += 1
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_InvestProgress % (investType, 0), progressValue)
+ GameWorld.DebugLog("更新登录投资可领奖天数进度: %s" % progressValue)
+
+ Sync_InvestInfo(curPlayer, investType)
return
-def __CheckInvestReset(curPlayer):
- ##检查vip投资重置 超过28天或28天奖励已领取可重置
- for investType in ChConfig.CanRepeatInvestType:
- investGoldRecord = __GetPDictValue(curPlayer, ChConfig.Def_PDict_GoldInvest_Gold % investType)
- if not investGoldRecord:
- continue
- curDay = __GetInvestCurDay(curPlayer, investType)
- investMaxDayDict = IpyGameDataPY.GetFuncEvalCfg('InvestMaxDay')
- maxDay = investMaxDayDict.get(str(investType), 0)
- if curDay > maxDay or __GetPDictValue(curPlayer, ChConfig.Def_PDict_GoldInvest_GotRewardValue % (investType, maxDay)):
- __SetPDictValue(curPlayer, ChConfig.Def_PDict_GoldInvest_Time % investType, 0)
- __SetPDictValue(curPlayer, ChConfig.Def_PDict_GoldInvest_Gold % investType, 0)
- for i in xrange(1, maxDay+1):
- __SetPDictValue(curPlayer, ChConfig.Def_PDict_GoldInvest_GotRewardValue % (investType, i), 0)
- Sync_GoldInvestInfo(curPlayer, investType, isForce=True)
- return
+def __GetInvestPassDays(curPlayer, investType):
+ ## 获取投资已过天数,投资当天为第一天,即从 1 开始; 0代表未投资
+ investTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_InvestTime % investType)
+ if not investTime:
+ return 0
+ curTime = int(time.time())
+ return max(0, GameWorld.GetDiff_Day(curTime, investTime) + 1)
-def CheckOldInvestMail(curPlayer):
- ## 老号旧投资邮件补偿
- investMaxDayDict = IpyGameDataPY.GetFuncEvalCfg('InvestMaxDay')
-
- for oldInvestType in [ChConfig.GoldInvestType_Month, ChConfig.GoldInvestType_Week]:
- investGoldRecord = __GetPDictValue(curPlayer, ChConfig.Def_PDict_GoldInvest_Gold % oldInvestType)
- if not investGoldRecord:
- continue
- curDay = __GetInvestCurDay(curPlayer, oldInvestType)
- maxDay = investMaxDayDict.get(str(oldInvestType), 0)
- hasGotGold, lostGold, notGetGold, notGetDays = 0, 0, 0, 0 #已领取,错过领取,未领取,还有几天可领
- for day in xrange(1, maxDay+1):
- ipyData = IpyGameDataPY.GetIpyGameData('Invest', oldInvestType*100+day)
- if not ipyData:
- continue
- rewardDict = ipyData.GetReward()
- awardData = __GetPDictValue(curPlayer, ChConfig.Def_PDict_GoldInvest_AwardData % oldInvestType, 1)
- if str(awardData) not in rewardDict:
- GameWorld.DebugLog(' 旧投资邮件补偿, rewardDict=%s, 没有key=%s'%(rewardDict, awardData))
- continue
- rewardList = rewardDict[str(awardData)]
- gold = rewardList[0][1]
- rewardRecord = __GetPDictValue(curPlayer, ChConfig.Def_PDict_GoldInvest_GotRewardValue % (oldInvestType, day))
- if rewardRecord:
- hasGotGold += gold
- elif day < curDay:
- lostGold += gold
- else:
- notGetGold += gold
- notGetDays += 1
- GameWorld.DebugLog('旧投资邮件补偿 oldInvestType=%s,hasGotGold=%s, lostGold=%s, notGetGold=%s,notGetDays=%s'%
- (oldInvestType, hasGotGold, lostGold, notGetGold, notGetDays))
- if not notGetGold:
- continue
- if oldInvestType == ChConfig.GoldInvestType_Week:
- PlayerControl.SendMailByKey('WeekCardMail', [curPlayer.GetID()], [], [notGetDays, notGetGold], notGetGold)
- elif oldInvestType == ChConfig.GoldInvestType_Month:
- newInvestType = ChConfig.GoldInvestType_NewMonth
- newMaxDay = investMaxDayDict.get(str(newInvestType), 0)
- newTotalGold = 0
- for day in xrange(1, newMaxDay+1):
- ipyData = IpyGameDataPY.GetIpyGameData('Invest', newInvestType*100+day)
- if not ipyData:
- continue
- rewardDict = ipyData.GetReward()
- awardData = __GetPDictValue(curPlayer, ChConfig.Def_PDict_GoldInvest_AwardData % newInvestType, 1)
- if str(awardData) not in rewardDict:
- GameWorld.DebugLog(' 旧投资邮件补偿, rewardDict=%s, 没有key=%s'%(rewardDict, awardData))
- continue
- rewardList = rewardDict[str(awardData)]
- gold = rewardList[0][1]
- newTotalGold+=gold
- oldTotalGold = hasGotGold+ lostGold+notGetGold
- giveGold = newTotalGold-oldTotalGold + notGetGold
- if not giveGold:
- continue
- if lostGold:
- paramList = [newTotalGold, oldTotalGold, hasGotGold, lostGold, notGetGold, notGetGold, newTotalGold-oldTotalGold]
- else:
- paramList = [newTotalGold, oldTotalGold, hasGotGold, notGetGold, notGetGold, newTotalGold-oldTotalGold]
- PlayerControl.SendMailByKey('MonthCardMail2' if lostGold else 'MonthCardMail1', [curPlayer.GetID()], [], paramList, giveGold)
- #重置数据
- valueKey = ChConfig.Def_PDict_GoldInvest_Time % oldInvestType
- PlayerControl.NomalDictSetProperty(curPlayer, valueKey, 0, ChConfig.Def_PDictType_GoldInvest)
-
- valueKey = ChConfig.Def_PDict_GoldInvest_Gold % oldInvestType
- PlayerControl.NomalDictSetProperty(curPlayer, valueKey, 0, ChConfig.Def_PDictType_GoldInvest)
-
- valueKey = ChConfig.Def_PDict_GoldInvest_AwardData % oldInvestType
- PlayerControl.NomalDictSetProperty(curPlayer, valueKey, 0, ChConfig.Def_PDictType_GoldInvest)
- for i in xrange(1, maxDay+1):
- valueKey = ChConfig.Def_PDict_GoldInvest_GotRewardValue % (oldInvestType, i)
- PlayerControl.NomalDictSetProperty(curPlayer, valueKey, 0, ChConfig.Def_PDictType_GoldInvest)
- return
+def __GetInvestMaxDays(investType):
+ ## 获取投资最大天数,0为永久
+ investMaxDayDict = IpyGameDataPY.GetFuncEvalCfg("InvestMaxDay", 1, {})
+ return investMaxDayDict.get(str(investType), 0)
+def GetInvestState(curPlayer, investType):
+ ## 获取投资卡状态 0-未投资;1-已投资;
+ investTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_InvestTime % investType)
+ if not investTime:
+ return 0
+ return 1
#// A5 40 投资理财 #tagCMGoldInvest
#
@@ -180,169 +119,96 @@
# BYTE InvestType; // 投资类型
# DWORD InvestGold; // 投资额度
#};
-## 投资理财
-# @param
-# @return
def OnGoldInvest(index, clientData, tick):
- curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
- investType = clientData.InvestType
- investGold = clientData.InvestGold
- investCostDict = IpyGameDataPY.GetFuncEvalCfg('InvestCost')
- if str(investType) not in investCostDict:
- return
- costList = investCostDict[str(investType)]
- if investGold not in costList:
- GameWorld.DebugLog(' 投资理财 投资额度不存在 investGold=%s, investType=%s'%(investGold, investType))
- return
- awardData = costList.index(investGold) + 1
- if investType == ChConfig.GoldInvestType_VIP:
- awardData = __GetInvestLVData(curPlayer)
- __DoLogicInvest(curPlayer, investType, investGold, awardData)
+ ## 消耗仙玉投资的,暂废弃
return
+## 充值直购投资
def InvestByCTG(curPlayer, ctgID):
- ## 充值投资
- ctgInvestDict = IpyGameDataPY.GetFuncEvalCfg('InvestCost', 3, {})
+ ctgInvestDict = IpyGameDataPY.GetFuncEvalCfg("InvestCost", 3, {})
for investType, ctgIDList in ctgInvestDict.items():
if ctgID in ctgIDList:
- __DoLogicInvest(curPlayer, int(investType), ctgID, 1)
- GameWorld.Log('投资理财 investType=%s,ctgID=%s'%(investType, ctgID), curPlayer.GetID())
+ __DoLogicInvest(curPlayer, int(investType))
break
return
-
-def __DoLogicInvest(curPlayer, investType, investGold, awardData):
- GameWorld.DebugLog("投资理财:investType=%s,investGold=%s, awardData=%s" % (investType, investGold, awardData))
-
- needVIPLVDict = IpyGameDataPY.GetFuncEvalCfg('InvestCost', 2, {})
- needVIPLV = needVIPLVDict.get(str(investType), 0)
- if curPlayer.GetVIPLv() < needVIPLV:
- GameWorld.DebugLog(' 投资理财 需要VIP%s'%(needVIPLV))
+## 执行投资逻辑
+def __DoLogicInvest(curPlayer, investType):
+ if GetInvestState(curPlayer, investType) == 1:
+ GameWorld.DebugLog("已投资,无法重复投资! investType=%s" % investType)
return
+ # 可投资,更新重置投资相关数据
+ curTime = int(time.time())
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_InvestTime % investType, curTime)
+ for keyNum in range(ChConfig.Def_PDict_InvestKeyCount):
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_InvestReward % (investType, keyNum), 0)
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_InvestProgress % (investType, keyNum), 0)
+
+ # 登录卡,投资当天可领奖,完成设置为1
+ if investType == ChConfig.InvestType_Login:
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_InvestProgress % (investType, 0), 1)
- deductGold = investGold
- if str(investType) in IpyGameDataPY.GetFuncEvalCfg('InvestCost', 3, {}):
- deductGold = 0 #充钱的不用扣仙玉
- investGoldRecord = __GetPDictValue(curPlayer, ChConfig.Def_PDict_GoldInvest_Gold % investType)
- if investGoldRecord:
- curDay = __GetInvestCurDay(curPlayer, investType)
- #可循环投资
- if investType in ChConfig.CanRepeatInvestType:
- # 已投资过,检查天数是否已结束
- investMaxDayDict = IpyGameDataPY.GetFuncEvalCfg('InvestMaxDay')
- maxDay = investMaxDayDict.get(str(investType), 0)
- if curDay < maxDay:
- GameWorld.DebugLog(' 还有投资天数未领取!curDay=%s,maxDay=%s'%(curDay,maxDay))
- return
- if curDay == maxDay:
- rewardRecord = __GetPDictValue(curPlayer, ChConfig.Def_PDict_GoldInvest_GotRewardValue % (investType, maxDay))
- if not rewardRecord:
- GameWorld.DebugLog(" 还有未领取的投资回报,不可投资!investType=%s,rewardRecord=%s"
- % (investType, rewardRecord))
- return
-
-
- # 不可循环投资,但可追加投资
- elif investType in ChConfig.InvestGoldTypeList:
- if investGoldRecord >= investGold:
- GameWorld.DebugLog(" 已投资档次=%s >= 追加投资档次=%s ,不可追加投资!"
- % (investGoldRecord, investGold))
- return
-
- deductGold = investGold - investGoldRecord # 追加投资需要扣除的钻石
- GameWorld.DebugLog(" 已投资=%s,追加投资需扣除=%s" % (investGoldRecord, deductGold))
- else:
- GameWorld.DebugLog(" investType = %s 已投资过,不可重复投资" % investType)
- return
-# elif investType in ChConfig.InvestGoldTypeList:
-# goldInvestLVLimit = IpyGameDataPY.GetFuncEvalCfg('GoldInvestLVLimit', 1, {}).get(investType, 0)
-# if goldInvestLVLimit and curPlayer.GetLV() > goldInvestLVLimit:
-# GameWorld.DebugLog(' 仙玉投资理财 等级不能高于%s'%(goldInvestLVLimit))
-# return
+ # 投资红包
+ redPacketID = IpyGameDataPY.GetFuncEvalCfg("InvestRedPackAward", 1, {}).get(investType, 0)
+ if redPacketID:
+ PlayerFamilyRedPacket.CreatRedPacketByID(curPlayer, redPacketID)
- __DoGoldInvest(curPlayer, investType, investGold, deductGold, awardData)
- return
-
-def __GetInvestCurDay(curPlayer, investType):
- ## 获取投资当前第几天
- investTime = __GetPDictValue(curPlayer, ChConfig.Def_PDict_GoldInvest_Time % investType)
- curTime = GameWorld.ChangeTimeStrToNum(GameWorld.GetCurrentDataTimeStr())
- passTick = max(0, curTime - investTime)
- return passTick / 3600 / 24 + 1
-
-def __GetInvestLVData(curPlayer):
- #vip投资 当前所属等级范围
- investLVDataDict = IpyGameDataPY.GetFuncEvalCfg('VIPInvest')
- lv = curPlayer.GetLV()
- for keyData, lvRange in investLVDataDict.items():
- if lvRange[0] <=lv <= lvRange[1]:
- return int(keyData)
- return 0
-
-## 执行投资理财
-# @param
-# @return
-def __DoGoldInvest(curPlayer, investType, investGold, deductGold, awardData):
- #扣钻石
- infoDict = {"InvestType":investType, "DeductGold":deductGold, "InvestGold":investGold,
- ChConfig.Def_Cost_Reason_SonKey:investType}
- if not PlayerControl.PayMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, deductGold,
- ChConfig.Def_Cost_GoldInvest, infoDict):
- return
- #红包奖励
- if not (investType in ChConfig.InvestGoldTypeList and investGold != deductGold):
- redPacketID = IpyGameDataPY.GetFuncEvalCfg('InvestRedPackAward', 1, {}).get(investType, 0)
- if redPacketID:
- PlayerFamilyRedPacket.CreatRedPacketByID(curPlayer, redPacketID)
- if investType == ChConfig.GoldInvestType_VIP:
- PlayerControl.WorldNotify(0, 'VIPInvestmentRadio', [curPlayer.GetName()])
- elif investType in ChConfig.InvestGoldTypeList:
- PlayerControl.WorldNotify(0, 'JadeInvestmentRadio', [curPlayer.GetName(), investGold])
- elif investType == ChConfig.GoldInvestType_NewMonth:
- PlayerControl.WorldNotify(0, 'MonthInvestment', [curPlayer.GetName(), __GetTotalGetGold(investType)])
- elif investType == ChConfig.GoldInvestType_Month1:
- PlayerControl.WorldNotify(0, 'WeekInPInvestment', [curPlayer.GetName(), __GetTotalGetGold(investType)])
-
- # 更新投资时时间,投资金额,重置回报记录
- curTime = GameWorld.GetCurrentTime()
- curTimeNum = GameWorld.ChangeTimeStrToNum(str(curTime)[:10], ChConfig.TYPE_Time_Format_Day)
- __SetPDictValue(curPlayer, ChConfig.Def_PDict_GoldInvest_Time % investType, curTimeNum)
- __SetPDictValue(curPlayer, ChConfig.Def_PDict_GoldInvest_Gold % investType, investGold)
- __SetPDictValue(curPlayer, ChConfig.Def_PDict_GoldInvest_AwardData % investType, awardData)
+ # 广播
+ PlayerControl.WorldNotify(0, "BuyInvest_%s" % investType, [curPlayer.GetName(), __GetTotalGetGold(investType)])
- if investType in ChConfig.CanRepeatInvestType:
- investMaxDayDict = IpyGameDataPY.GetFuncEvalCfg('InvestMaxDay')
- maxDay = investMaxDayDict.get(str(investType), 0)
- for i in xrange(1, maxDay+1):
- __SetPDictValue(curPlayer, ChConfig.Def_PDict_GoldInvest_GotRewardValue % (investType, i), 0)
-
-
- #EventShell.EventRespons_OnGoldInvest(curPlayer, investType)
- # 同步投资信息
- Sync_GoldInvestInfo(curPlayer, investType)
-
- # 投资全服广播
-
- GameWorld.DebugLog(" 投资成功!扣除钻石=%s" % deductGold)
+ GameWorld.DebugLog("投资理财成功: investType=%s" % (investType))
+ Sync_InvestInfo(curPlayer, investType)
return
def __GetTotalGetGold(investType):
- investMaxDayDict = IpyGameDataPY.GetFuncEvalCfg('InvestMaxDay')
- newMaxDay = investMaxDayDict.get(str(investType), 0)
- newTotalGold = 0
- for day in xrange(1, newMaxDay+1):
- ipyData = IpyGameDataPY.GetIpyGameData('Invest', investType*100+day)
- if not ipyData:
+ ## 获取投资预计总收益仙玉、灵石
+ totalGold = 0
+ ipyDataMgr = IpyGameDataPY.IPY_Data()
+ for index in xrange(ipyDataMgr.GetInvestCount()):
+ ipyData = ipyDataMgr.GetInvestByIndex(index)
+ if ipyData.GetType() != investType:
continue
rewardDict = ipyData.GetReward()
- awardData = 1 #__GetPDictValue(curPlayer, ChConfig.Def_PDict_GoldInvest_AwardData % newInvestType, 1)
- if str(awardData) not in rewardDict:
- continue
- rewardList = rewardDict[str(awardData)]
- gold = rewardList[0][1]
- newTotalGold+=gold
- return newTotalGold
+ for rewardInfo in rewardDict.values():
+ for itemID, itemCount, _ in rewardInfo:
+ if itemID in [20, 30]: # 单位1的仙玉、灵石
+ totalGold += itemCount
+ return totalGold
+
+def OnKillBoss(curPlayer, npcID):
+ ## 参与击杀boss
+ if GetInvestState(curPlayer, ChConfig.InvestType_Boss) != 1:
+ #GameWorld.DebugLog("boss投资未投资!")
+ return
+ key = "BossInvestNPCIDDict"
+ BossInvestNPCIDDict = IpyGameDataPY.GetConfigEx(key)
+ if not BossInvestNPCIDDict:
+ BossInvestNPCIDDict = {}
+ ipyDataMgr = IpyGameDataPY.IPY_Data()
+ for index in xrange(ipyDataMgr.GetInvestCount()):
+ ipyData = ipyDataMgr.GetInvestByIndex(index)
+ if ipyData.GetType() != ChConfig.InvestType_Boss:
+ continue
+ if not ipyData.GetNeedNPCID():
+ continue
+ BossInvestNPCIDDict[ipyData.GetNeedNPCID()] = ipyData.GetID()
+ IpyGameDataPY.SetConfigEx(key, BossInvestNPCIDDict)
+ GameWorld.Log("缓存boss投资对应关系: %s" % BossInvestNPCIDDict)
+
+ if npcID not in BossInvestNPCIDDict:
+ #GameWorld.DebugLog(" 该boss没有投资奖励!")
+ return
+ investID = BossInvestNPCIDDict[npcID]
+ investType, rewardIndex = investID / 100, investID % 100
+ if GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_InvestProgress, rewardIndex, True, [investType]):
+ #GameWorld.DebugLog("已设置击杀过该投资boss: npcID=%s,rewardIndex=%s,progressValue=%s" % (npcID, rewardIndex, progressValue))
+ return
+ progressValue, updProgressValue = GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_InvestProgress, rewardIndex, 1, True, [investType])
+ Sync_InvestInfo(curPlayer, investType)
+ GameWorld.DebugLog("设置杀过投资boss: npcID=%s,rewardIndex=%s,progressValue=%s,updProgressValue=%s"
+ % (npcID, rewardIndex, progressValue, updProgressValue))
+ return
#// A5 41 领取投资理财回报 #tagCMGetInvestReward
#
@@ -352,111 +218,121 @@
# BYTE InvestType; // 投资类型
# BYTE RewardIndex; // 回报索引
#};
-## 领取投资理财回报
-# @param
-# @return
-def OnGetGoldInvestReward(index, clientData, tick):
+def OnGetInvestReward(index, clientData, tick):
curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
investType = clientData.InvestType
rewardIndex = clientData.RewardIndex
- ipyData = IpyGameDataPY.GetIpyGameData('Invest', investType*100+rewardIndex)
+ GameWorld.DebugLog("领取投资理财回报:investType=%s,rewardIndex=%s" % (investType, rewardIndex))
+
+ if investType not in ChConfig.InvestTypeList:
+ #GameWorld.DebugLog("不存在该投资类型!")
+ return
+
+ if GetInvestState(curPlayer, investType) != 1:
+ GameWorld.DebugLog(" 未投资或已过期,无法领奖!")
+ return
+
+ ipyData = IpyGameDataPY.GetIpyGameData("Invest", investType * 100 + rewardIndex)
if not ipyData:
return
- investGold = __GetPDictValue(curPlayer, ChConfig.Def_PDict_GoldInvest_Gold % investType)
-
- GameWorld.DebugLog("领取投资理财回报:investType=%s,investGold=%s,rewardIndex=%s"
- % (investType, investGold, rewardIndex))
-
- if not investGold:
- GameWorld.DebugLog(" 该类型没有投资过,无法领取回报!investType=%s" % investType)
- return
needLV = ipyData.GetNeedLV()
- if curPlayer.GetLV() < needLV:
- GameWorld.DebugLog(" 等级不够%s,无法领取回报!investType=%s" % (needLV, investType))
+ if needLV and curPlayer.GetLV() < needLV:
+ GameWorld.DebugLog(" 等级不足,无法领奖! needLV=%s" % needLV)
+ return
+
+ if GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_InvestReward, rewardIndex, True, [investType]):
+ GameWorld.DebugLog(" 已领取过该索引奖励! rewardIndex=%s" % rewardIndex)
return
needDay = ipyData.GetNeedDay()
- if needDay:
- curDay = __GetInvestCurDay(curPlayer, investType)
- if needDay != curDay:
- GameWorld.DebugLog(" 无法领取回报! 只能领取当天的,curDay=%s,needDay=%s" % (curDay, needDay))
- return
+ rewardInfo = ipyData.GetReward()
- rewardDict = ipyData.GetReward()
- awardData = __GetPDictValue(curPlayer, ChConfig.Def_PDict_GoldInvest_AwardData % investType, 1)
- if str(awardData) not in rewardDict:
- GameWorld.DebugLog(' 领取投资理财回报, rewardDict=%s, 没有key=%s'%(rewardDict, awardData))
- return
- rewardList = rewardDict[str(awardData)]
-
- rewardItemList = rewardList # 回报物品列表
- rewardValueKey = ChConfig.Def_PDict_GoldInvest_GotRewardValue % (investType, rewardIndex)
- lastDayGotData = __GetPDictValue(curPlayer, rewardValueKey) # 已领取数据
-
- if lastDayGotData:
- if investType in ChConfig.InvestGoldTypeList:
- if awardData > lastDayGotData:
- lastGotAwardList = rewardDict[str(lastDayGotData)]
- rewardItemList = []
- for itemID, itemCnt, isBind in rewardList:
- newCnt = itemCnt
- for itemInfo in lastGotAwardList:
- if itemID == itemInfo[0]:
- newCnt = max(1,itemCnt - itemInfo[1])
- break
- rewardItemList.append([itemID, newCnt, isBind])
- else:
- GameWorld.DebugLog(' 11领取投资理财回报, 已领取过! investType=%s, rewardIndex=%s'%(investType, rewardIndex))
- return
- else:
- GameWorld.DebugLog(' 领取投资理财回报, 已领取过! investType=%s, rewardIndex=%s'%(investType, rewardIndex))
+ indexProgressState = GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_InvestProgress, rewardIndex, True, [investType])
+
+ # 月卡
+ if investType in [ChConfig.InvestType_NewMonth, ChConfig.InvestType_Month1]:
+ passDays = __GetInvestPassDays(curPlayer, investType) # 按投资时间计算天
+ if needDay > passDays:
+ GameWorld.DebugLog(" 投资天数不足,无法领取! needDay=%s > passDays=%s" % (ipyData.GetNeedDay(), passDays))
return
-
- __SetPDictValue(curPlayer, rewardValueKey, awardData)
-
- GameWorld.DebugLog(" 领取投资理财回报 rewardItemList=%s" % (rewardItemList))
- if rewardItemList:
- for itemID, itemCnt, isBind in rewardItemList:
- ItemControler.GivePlayerItem(curPlayer, itemID, itemCnt, 0, [IPY_GameWorld.rptItem, IPY_GameWorld.rptAnyWhere])
+ # 登录
+ elif investType == ChConfig.InvestType_Login:
+ loginDays = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_InvestProgress % (investType, 0)) # 按登录天计算天,有登录才算
+ if needDay > loginDays:
+ GameWorld.DebugLog(" 登录投资天数不足,无法领取! needDay=%s > loginDays=%s" % (needDay, loginDays))
+ return
+
+ # 等级
+ elif investType == ChConfig.InvestType_LV:
+ # 公共等级条件已判断
+ pass
+
+ # Boss
+ elif investType == ChConfig.InvestType_Boss:
+ if not indexProgressState:
+ GameWorld.DebugLog(" Boss投资无参与击杀该boss,无法领取! rewardIndex=%s" % (rewardIndex))
+ return
+
+ else:
+ return
- __CheckInvestReset(curPlayer)
+ if not ipyData:
+ return
+
+ rewardKey = "1" # 默认1
+ rewardItemList = rewardInfo.get(str(rewardKey), [])
+ if not rewardItemList:
+ return
+
+ if not ItemControler.CheckPackSpaceEnough(curPlayer, rewardItemList):
+ return
+
+ rewardValue, updRewardValue = GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_InvestReward, rewardIndex, 1, True, [investType])
+ Sync_InvestInfo(curPlayer, investType)
+ GameWorld.DebugLog(" rewardValue=%s,updRewardValue=%s,rewardItemList=%s" % (rewardValue, updRewardValue, rewardItemList))
+
+ for itemID, itemCount, isAuctionItem in rewardItemList:
+ ItemControler.GivePlayerItem(curPlayer, itemID, itemCount, isAuctionItem, [IPY_GameWorld.rptItem],
+ event=["Invest", False, {}])
+
# 记录领取事件
DataRecordPack.DR_GetGoldInvestReward(curPlayer, investType, rewardIndex, rewardItemList)
-
- Sync_GoldInvestInfo(curPlayer, investType, rewardIndex)
+
+ # 领完了,重置可重复购买的非永久卡
+ maxDays = __GetInvestMaxDays(investType)
+ canRepetBuyTypeList = IpyGameDataPY.GetFuncEvalCfg("InvestMaxDay", 2)
+ if maxDays > 1 and investType in canRepetBuyTypeList:
+ isAllDayGet = True
+ for i in range(maxDays, -1, -1):
+ if not IpyGameDataPY.GetIpyGameDataNotLog("Invest", investType * 100 + i):
+ continue
+ if not GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_InvestReward, i, True, [investType]):
+ isAllDayGet = False
+ #GameWorld.DebugLog(" 还有未领取: i=%s,isAllDayGet=%s" % (i, isAllDayGet))
+ break
+
+ if isAllDayGet:
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_InvestTime % investType, 0)
+ for keyNum in range(ChConfig.Def_PDict_InvestKeyCount):
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_InvestReward % (investType, keyNum), 0)
+ PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_InvestProgress % (investType, keyNum), 0)
+ Sync_InvestInfo(curPlayer, investType)
+ GameWorld.DebugLog(" 领完奖励了,重置投资! investType=%s" % investType)
+
return
## 同步投资理财信息
-# @param
-# @return
-def Sync_GoldInvestInfo(curPlayer, investType, index=-1, isForce=False):
- investGold = __GetPDictValue(curPlayer, ChConfig.Def_PDict_GoldInvest_Gold % investType)
- if not isForce and not investGold:
- return
- investInfoPack = ChPyNetSendPack.tagMCGoldInvestInfo()
- investInfoPack.Clear()
+def Sync_InvestInfo(curPlayer, investType):
+ investInfoPack = ChPyNetSendPack.tagMCInvestInfo()
investInfoPack.InvestType = investType
- investInfoPack.CurDay = __GetInvestCurDay(curPlayer, investType)
- investInfoPack.InvestGold = investGold
- investInfoPack.InvestRewardList = []
- ipyGameDataList = IpyGameDataPY.GetIpyGameDataByCondition('Invest', {'Type':investType}, True)
-
- if not ipyGameDataList:
- return
- for ipyData in ipyGameDataList:
- rewardIndex = ipyData.GetID() % 100
- if index !=-1 and rewardIndex != index:
- continue
- investReward = ChPyNetSendPack.tagMCInvestReward()
- investReward.RewardIndex = rewardIndex
- investReward.RewardValue = __GetPDictValue(curPlayer, ChConfig.Def_PDict_GoldInvest_GotRewardValue % (investType, rewardIndex))
- investInfoPack.InvestRewardList.append(investReward)
- investInfoPack.RewardRecordCnt = len(investInfoPack.InvestRewardList)
+ investInfoPack.CurDay = __GetInvestPassDays(curPlayer, investType)
+ for keyNum in range(ChConfig.Def_PDict_InvestKeyCount):
+ investInfoPack.RewardValue.append(curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_InvestReward % (investType, keyNum)))
+ investInfoPack.ProgressValue.append(curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_InvestProgress % (investType, keyNum)))
+ investInfoPack.ValueCount = len(investInfoPack.RewardValue)
NetPackCommon.SendFakePack(curPlayer, investInfoPack)
return
-
-
--
Gitblit v1.8.0