hxp
2024-10-18 fb30a62bca5aa44399c1e8e9aa3dc2e5c250bbf2
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
#!/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 ShareDefine
import ChConfig
 
def GetSuperDiscountState(curPlayer):
    ## ÖÁ×ðÕÛ¿Û¿¨¼¤»î״̬
    return curPlayer.GetLV2() == 1
 
def ActSuperDiscountByCTG(curPlayer, ctgID):
    ## ³äÖµ¼¤»î
    ctgList = IpyGameDataPY.GetFuncEvalCfg("EnSuperDiscount", 1)
    if ctgID in ctgList:
        __DoActiveSuperDiscount(curPlayer, ctgID)
    return
 
def __DoActiveSuperDiscount(curPlayer, ctgID=0):
    ## ¼¤»îÖÁ×ð¿¨
    if GetSuperDiscountState(curPlayer):
        GameWorld.DebugLog("ÖÁ×ð¿¨ÒѼ¤»î!")
        return
    
    if not ctgID:
        needCreateRoleDays = IpyGameDataPY.GetFuncCfg("EnSuperDiscount", 2)
        createRoleDays = GameWorld.GetCreateRoleDays(curPlayer)
        if createRoleDays < needCreateRoleDays:
            GameWorld.ErrLog("´´½ÇÌìÊý²»×㣬ÎÞ·¨Ãâ·Ñ¼¤»îÖÁ×ð¿¨! createRoleDays=%s < %s" % (createRoleDays, needCreateRoleDays), curPlayer.GetPlayerID())
            return
        
    GameWorld.DebugLog("¼¤»îÖÁ×ð¿¨: ctgID=%s" % (ctgID), 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")
        
    elif opType == 2:
        __DoActiveSuperDiscount(curPlayer)
        
    return