hxp
2024-10-29 350bde4188052a6883d7c7e7dc9b41348e173866
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package Player.PlayerSuperDiscount
#
# @todo:ÖÁ×ð¿¨ÕÛ¿Û
# @author hxp
# @date 2024-10-18
# @version 1.0
#
# ÏêϸÃèÊö: ÖÁ×ð¿¨ÕÛ¿Û£¬½«³äÖµÔ­¼Û¹ºÂò±ä³É1ÕÛ£¬Ó¢Îİæ×¨ÓÃ
#
#-------------------------------------------------------------------------------
#"""Version = 2024-10-18 15:00"""
#-------------------------------------------------------------------------------
 
import GameWorld
import IpyGameDataPY
import PlayerControl
import ChPyNetSendPack
import NetPackCommon
import ShareDefine
import ChConfig
import time
 
def OnPlayerLogin(curPlayer):
    SyncTuijinbiInfo(curPlayer)
    return
 
def PlayerOnDay(curPlayer):
    GiveTuijinbiByDay(curPlayer)
    return
 
def GiveTuijinbiByDay(curPlayer):
    tuibanTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TuiJinbiBanTime)
    tuibanDayAwardInfo = IpyGameDataPY.GetFuncEvalCfg("EnSuperDiscount", 4)
    if tuibanTime and tuibanDayAwardInfo and len(tuibanDayAwardInfo) == 2:
        diffDays = GameWorld.GetDiff_Day(int(time.time()), tuibanTime) + 1
        giveMoney, maxDays = tuibanDayAwardInfo
        if diffDays <= maxDays:
            GameWorld.DebugLog("°´Ìì¸øÍÆ½ð±Ò´ÎÊý! diffDays=%s, maxDays=%s" % (diffDays, maxDays), curPlayer.GetPlayerID())
            PlayerControl.GiveMoney(curPlayer, ShareDefine.TYPE_Price_Tuijinbi, giveMoney, "tuibanonday")
    return
 
def GetSuperDiscountState(curPlayer):
    ## ÖÁ×ðÕÛ¿Û¿¨¼¤»î״̬
    return curPlayer.GetLV2() == 1
 
def ActSuperDiscountByCTG(curPlayer, ctgID):
    ## ³äÖµ¼¤»î
    if ctgID and ctgID == IpyGameDataPY.GetFuncCfg("EnSuperDiscount", 1):
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TuiJinbiBanTime, int(time.time()))
        GameWorld.DebugLog("±ê¼ÇÒѹºÂò³¬¼¶Íưåʱ¼ä´Á!", curPlayer.GetPlayerID())
        GiveTuijinbiByDay(curPlayer) # ¸øµÚÒ»Ìì½±Àø
    return
 
def __DoActiveSuperDiscount(curPlayer):
    ## ¼¤»îÖÁ×ð¿¨
    if GetSuperDiscountState(curPlayer):
        GameWorld.DebugLog("ÖÁ×ð¿¨ÒѼ¤»î!")
        return
    
    # Ã»ÓйºÂò³¬¼¶ÍưåµÄ£¬ÑéÖ¤Ãâ·Ñ¼¤»î
    tuibanTime = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TuiJinbiBanTime)
    if not tuibanTime:
        needCreateRoleDays = IpyGameDataPY.GetFuncCfg("EnSuperDiscount", 2)
        createRoleDays = GameWorld.GetCreateRoleDays(curPlayer)
        if createRoleDays < needCreateRoleDays:
            GameWorld.ErrLog("´´½ÇÌìÊý²»×㣬ÎÞ·¨Ãâ·Ñ¼¤»îÖÁ×ð¿¨! createRoleDays=%s < %s" % (createRoleDays, needCreateRoleDays), curPlayer.GetPlayerID())
            return
        
    GameWorld.DebugLog("¼¤»îÖÁ×ð¿¨: tuibanTime=%s" % (tuibanTime), curPlayer.GetPlayerID())
    curPlayer.SetLV2(1)
    return
 
#// AA 02 Íƽð±Ò #tagCMTuijinbi
#
#struct     tagCMTuijinbi
#{
#    tagHead        Head;
#    BYTE        OpType;    // ²Ù×÷ÀàÐÍ: 0-³é½±£»1-»ñµÃ½ð±Ò£»2-¼¤»îÖÁ×ð¿¨
#    DWORD        Value1;    // ÀàÐÍ1ʱΪ»õ±ÒÀàÐÍ
#    DWORD        Value2;    // ÀàÐÍ1ʱΪ»õ±ÒÊýÖµ
#};
def OnTuijinbi(index, clientData, tick):
    curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
    playerID = curPlayer.GetPlayerID()
    opType = clientData.OpType
    value1 = clientData.Value1
    value2 = clientData.Value2
    
    if opType == 0:
        # Ö±½Ó¿Û³ý´ÎÊý£¬½ö×÷Ϊ¼Ç¼Ó㬳齱Âß¼­Ç°¶Ë×Ô¼º¿ØÖÆ
        PlayerControl.PayMoney(curPlayer, ShareDefine.TYPE_Price_Tuijinbi, 1, isNotify=False)
        
    elif opType == 1:
        moneyType = value1
        moneyValue = value2
        moneyUpperLimitDict = IpyGameDataPY.GetFuncEvalCfg("EnSuperDiscount", 3, {})
        if moneyType not in moneyUpperLimitDict:
            GameWorld.DebugLog("ÍÆ½ð±ÒûÓÐÅäÖûñµÃ¸Ã»õ±Ò½±ÀøÉÏÏÞ! moneyType=%s" % moneyType, playerID)
            return
        moneyUpperLimit = moneyUpperLimitDict[moneyType]
        moneyTotal = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TuiJinbiMoney % moneyType)
        updMoneyTotal = min(moneyTotal + moneyValue, moneyUpperLimit, ChConfig.Def_UpperLimit_DWord)
        giveMoney = updMoneyTotal - moneyTotal
        if giveMoney <= 0:
            GameWorld.ErrLog("ÍÆ½ð±ÒÒÑ´ï½±ÀøÉÏÏÞ! moneyType=%s,moneyTotal=%s" % (moneyType, moneyTotal), playerID)
            return
        PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TuiJinbiMoney % moneyType, updMoneyTotal)
        GameWorld.DebugLog("¸üÐÂÍÆ½ð±Ò½±Àø: moneyType=%s,moneyValue=%s,giveMoney=%s,updMoneyTotal=%s" 
                           % (moneyType, moneyValue, giveMoney, updMoneyTotal), playerID)
        PlayerControl.GiveMoney(curPlayer, moneyType, giveMoney, "Tuijinbi")
        SyncTuijinbiInfo(curPlayer)
        
    elif opType == 2:
        __DoActiveSuperDiscount(curPlayer)
        
    return
 
def SyncTuijinbiInfo(curPlayer):
    awardMoneyList = []
    moneyUpperLimitDict = IpyGameDataPY.GetFuncEvalCfg("EnSuperDiscount", 3, {})
    for moneyType in moneyUpperLimitDict.keys():
        moneyTotal = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TuiJinbiMoney % moneyType)
        if not moneyTotal:
            continue
        moneyInfo = ChPyNetSendPack.tagMCTuijinbiMoney()
        moneyInfo.MoneyType = moneyType
        moneyInfo.MoneyValue = moneyTotal
        awardMoneyList.append(moneyInfo)
    if not awardMoneyList:
        return
    clientPack = ChPyNetSendPack.tagMCTuijinbiInfo()
    clientPack.AwardMoneyList = awardMoneyList
    clientPack.AwardMoneyCount = len(clientPack.AwardMoneyList)
    NetPackCommon.SendFakePack(curPlayer, clientPack)
    return