#!/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 import time 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") elif opType == 2: __DoActiveSuperDiscount(curPlayer) return