提交 | 用户 | age
|
7d1895
|
1 |
#!/usr/bin/python
|
H |
2 |
# -*- coding: GBK -*-
|
|
3 |
#-------------------------------------------------------------------------------
|
|
4 |
#
|
|
5 |
##@package Player.PlayerXiangong
|
|
6 |
#
|
|
7 |
# @todo:仙宫
|
|
8 |
# @author hxp
|
|
9 |
# @date 2024-09-04
|
|
10 |
# @version 1.0
|
|
11 |
#
|
|
12 |
# 详细描述: 仙宫
|
|
13 |
#
|
|
14 |
#-------------------------------------------------------------------------------
|
|
15 |
#"""Version = 2024-09-04 16:30"""
|
|
16 |
#-------------------------------------------------------------------------------
|
|
17 |
|
|
18 |
import ChConfig
|
|
19 |
import IpyGameDataPY
|
|
20 |
import PlayerControl
|
|
21 |
import ChPyNetSendPack
|
|
22 |
import DataRecordPack
|
|
23 |
import NetPackCommon
|
|
24 |
import ItemControler
|
|
25 |
import GameWorld
|
|
26 |
|
|
27 |
def OnPlayerLogin(curPlayer):
|
|
28 |
SyncXiangongInfo(curPlayer)
|
|
29 |
SyncTiandaoTreeInfo(curPlayer, True)
|
|
30 |
return
|
|
31 |
|
|
32 |
def PlayerOnDay(curPlayer):
|
|
33 |
|
|
34 |
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XiangongLikeState % 0, 0)
|
|
35 |
|
|
36 |
xiangongIDList = []
|
|
37 |
ipyMgr = IpyGameDataPY.IPY_Data()
|
|
38 |
for index in range(ipyMgr.GetXiangongCount()):
|
|
39 |
ipyData = ipyMgr.GetXiangongByIndex(index)
|
|
40 |
xiangongID = ipyData.GetXiangongID()
|
|
41 |
if not curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XiangongLikeState % xiangongID):
|
|
42 |
continue
|
|
43 |
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XiangongLikeState % xiangongID, 0)
|
|
44 |
xiangongIDList.append(xiangongID)
|
|
45 |
|
|
46 |
if xiangongIDList:
|
|
47 |
SyncXiangongInfo(curPlayer, xiangongIDList)
|
|
48 |
|
|
49 |
return
|
|
50 |
|
|
51 |
def AddTiandaoQiyun(curPlayer, addValue, addDict={}):
|
|
52 |
curQiyun = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TiandaoQiyun)
|
|
53 |
updQiyun = min(curQiyun + addValue, ChConfig.Def_UpperLimit_DWord)
|
|
54 |
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TiandaoQiyun, updQiyun)
|
3d9819
|
55 |
PlayerControl.NotifyCode(curPlayer, "AddQiyun", [addValue])
|
7d1895
|
56 |
dataDict = {'PlayerID':curPlayer.GetPlayerID(), "PlayerName":curPlayer.GetPlayerName(),
|
H |
57 |
'AccID':curPlayer.GetAccID(), "updQiyun":updQiyun, "addValue":addValue}
|
|
58 |
dataDict.update(addDict)
|
|
59 |
DataRecordPack.SendEventPack("AddTiandaoQiyun", dataDict, curPlayer)
|
|
60 |
SyncTiandaoTreeInfo(curPlayer)
|
|
61 |
return updQiyun
|
|
62 |
|
|
63 |
def GameServer_Xiangong_DoResult(curPlayer, msgData):
|
|
64 |
|
|
65 |
msgType = msgData[0]
|
|
66 |
dataMsg = msgData[1]
|
|
67 |
|
|
68 |
## 点赞仙宫
|
|
69 |
if msgType == "LikeXiangong":
|
|
70 |
__DoLikeXiangong(curPlayer, dataMsg)
|
|
71 |
|
|
72 |
return
|
|
73 |
|
|
74 |
def __DoLikeXiangong(curPlayer, dataMsg):
|
|
75 |
|
|
76 |
xiangongID, moneyType, moneyValue = dataMsg
|
|
77 |
|
|
78 |
playerID = curPlayer.GetPlayerID()
|
|
79 |
likeState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XiangongLikeState % xiangongID)
|
|
80 |
if likeState:
|
|
81 |
GameWorld.DebugLog("该仙宫已点赞! xiangongID=%s" % xiangongID, playerID)
|
|
82 |
return
|
|
83 |
GameWorld.DebugLog("仙宫点赞! xiangongID=%s,moneyType=%s,moneyValue=%s" % (xiangongID, moneyType, moneyValue), playerID)
|
|
84 |
PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_XiangongLikeState % xiangongID, 1)
|
|
85 |
SyncXiangongInfo(curPlayer, [xiangongID])
|
|
86 |
PlayerControl.GiveMoney(curPlayer, moneyType, moneyValue, "LikeXiangong", {"xiangongID":xiangongID})
|
61f8b7
|
87 |
ItemControler.NotifyGiveAwardInfo(curPlayer, [], "LikeXiangong", moneyInfo={moneyType:moneyValue})
|
7d1895
|
88 |
return
|
H |
89 |
|
|
90 |
def GetTiandaoTreeAward(curPlayer, awardIndex):
|
|
91 |
## 领取天道树奖励
|
|
92 |
|
|
93 |
playerID = curPlayer.GetPlayerID()
|
|
94 |
ipyData = IpyGameDataPY.GetIpyGameData("TiandaoTree", awardIndex)
|
|
95 |
if not ipyData:
|
|
96 |
return
|
|
97 |
if GameWorld.GetDictValueByBit(curPlayer, ChConfig.Def_PDict_TiandaoAward, awardIndex):
|
|
98 |
GameWorld.DebugLog("该天道树奖励已领奖! awardIndex=%s" % awardIndex, playerID)
|
|
99 |
return
|
|
100 |
|
|
101 |
needQiyun = ipyData.GetNeedQiyun()
|
|
102 |
awardItemList = ipyData.GetAwardItemList()
|
|
103 |
|
|
104 |
qiyun = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TiandaoQiyun)
|
|
105 |
if qiyun < needQiyun:
|
|
106 |
GameWorld.DebugLog("当前天道树气运不足,无法领奖! awardIndex=%s,qiyun=%s < %s" % (awardIndex, qiyun, needQiyun), playerID)
|
|
107 |
return
|
|
108 |
|
|
109 |
GameWorld.SetDictValueByBit(curPlayer, ChConfig.Def_PDict_TiandaoAward, awardIndex, 1)
|
|
110 |
|
61f8b7
|
111 |
ItemControler.GivePlayerItemOrMail(curPlayer, awardItemList, event=["TiandaoTree", False, {}])
|
7d1895
|
112 |
|
H |
113 |
SyncTiandaoTreeInfo(curPlayer)
|
|
114 |
return
|
|
115 |
|
|
116 |
def SyncXiangongInfo(curPlayer, xiangongIDList=None):
|
|
117 |
syncXiangongIDList = []
|
|
118 |
if xiangongIDList == None:
|
|
119 |
ipyMgr = IpyGameDataPY.IPY_Data()
|
|
120 |
for index in range(ipyMgr.GetXiangongCount()):
|
|
121 |
ipyData = ipyMgr.GetXiangongByIndex(index)
|
|
122 |
syncXiangongIDList.append(ipyData.GetXiangongID())
|
|
123 |
else:
|
|
124 |
syncXiangongIDList = xiangongIDList
|
|
125 |
|
|
126 |
xiangongList = []
|
|
127 |
for xiangongID in syncXiangongIDList:
|
|
128 |
if not xiangongID:
|
|
129 |
continue
|
|
130 |
likeState = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XiangongLikeState % xiangongID)
|
|
131 |
if not likeState and xiangongIDList == None:
|
|
132 |
continue
|
|
133 |
xg = ChPyNetSendPack.tagMCXiangong()
|
|
134 |
xg.XiangongID = xiangongID
|
|
135 |
xg.LikeStateToday = likeState
|
|
136 |
xiangongList.append(xg)
|
|
137 |
|
|
138 |
likeStateToday = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_XiangongLikeState % 0)
|
|
139 |
if xiangongIDList == None and not xiangongList and not likeStateToday:
|
|
140 |
return
|
|
141 |
|
|
142 |
clientPack = ChPyNetSendPack.tagMCXiangongInfo()
|
|
143 |
clientPack.LikeStateToday = likeStateToday
|
|
144 |
clientPack.XiangongList = xiangongList
|
|
145 |
clientPack.XiangongCount = len(clientPack.XiangongList)
|
|
146 |
NetPackCommon.SendFakePack(curPlayer, clientPack)
|
|
147 |
return
|
|
148 |
|
|
149 |
def SyncTiandaoTreeInfo(curPlayer, isLogin=False):
|
|
150 |
ipyMgr = IpyGameDataPY.IPY_Data()
|
|
151 |
treeCount = ipyMgr.GetTiandaoTreeCount()
|
|
152 |
if not treeCount:
|
|
153 |
return
|
|
154 |
lastIpyData = ipyMgr.GetTiandaoTreeByIndex(treeCount - 1)
|
|
155 |
if not lastIpyData:
|
|
156 |
return
|
|
157 |
keyNumMax = lastIpyData.GetAwardIndex() / 31 + 1
|
|
158 |
awardStateList = []
|
|
159 |
for keyNum in range(keyNumMax):
|
|
160 |
awardStateList.append(curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TiandaoAward % keyNum))
|
|
161 |
|
|
162 |
qiyun = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TiandaoQiyun)
|
|
163 |
if isLogin and not qiyun and awardStateList.count(0) == len(awardStateList):
|
|
164 |
return
|
|
165 |
|
|
166 |
clientPack = ChPyNetSendPack.tagMCTiandaoTreeInfo()
|
|
167 |
clientPack.Qiyun = qiyun
|
|
168 |
clientPack.AwardStateList = awardStateList
|
|
169 |
clientPack.AwardCount = len(clientPack.AwardStateList)
|
|
170 |
NetPackCommon.SendFakePack(curPlayer, clientPack)
|
|
171 |
return
|