#!/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 ItemControler import IPY_GameWorld import ShareDefine import ChConfig import random import time PrizeType_Gold = 1 # ½ð±Ò = 10ÍòÍ­Ç® PrizeType_Xianyu = 2 # ÏÉÓñ±Ò = 10ÏÉÓñ PrizeType_Redpack = 3 # ºì°ü PrizeType_Super = 4 # ³¬¼¶½±Àø PrizeMoneyTypeList = [1, 2, 3] # ±¾¹¦Äܿɲú³öµÄ»õ±ÒÀàÐÍ Sign_NewVerPlayer = 1 # а汾ºó¶Ë´¦ÀíÍæ¼Ò Sign_OldVerPlayer = 2 # Àϰ汾ǰ¶Ë´¦ÀíÍæ¼Ò def __InitOldPlayerTjb(curPlayer): ## ÀÏÍæ¼ÒÍÆ½ð±ÒĬÈϽ±³Ø´¦Àí if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TuiJinbiSign): #GameWorld.DebugLog("ÍÆ½ð±ÒÍæ¼Ò±ê¼ÇÒÑ´¦Àí: %s" % curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TuiJinbiSign), curPlayer.GetPlayerID()) return sign = Sign_NewVerPlayer for moneyType in PrizeMoneyTypeList: if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TuiJinbiMoney % moneyType): sign = Sign_OldVerPlayer # ÓÐʵ¼Ê»ñµÃ¹ý½±ÀøÊÓΪÀÏÍæ¼Ò break PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TuiJinbiSign, sign) if sign != Sign_OldVerPlayer: return # ¸øÀÏÍæ¼Ò³õÊ¼Ì¨Ãæ initPrizeList = IpyGameDataPY.GetFuncEvalCfg("EnSuperDiscount", 5) for prizeType, prizeCount in initPrizeList: if curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TuiJinbiPool % prizeType): continue PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TuiJinbiPool % prizeType, prizeCount) GameWorld.Log("ÍÆ½ð±ÒÀÏÍæ¼ÒÉèÖóõÊ¼Ì¨ÃæÊý¾Ý: %s" % str(initPrizeList), curPlayer.GetPlayerID()) return def OnPlayerLogin(curPlayer): __InitOldPlayerTjb(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) opType = clientData.OpType value1 = clientData.Value1 value2 = clientData.Value2 if opType == 0: __DoDraw(curPlayer) elif opType == 1: __DoGivePrize(curPlayer, value1, value2) elif opType == 2: __DoActiveSuperDiscount(curPlayer) return def __DoDraw(curPlayer): ## ³é½± if not PlayerControl.HaveMoney(curPlayer, ShareDefine.TYPE_Price_Tuijinbi, 1): return playerID = curPlayer.GetPlayerID() prizeSetList = IpyGameDataPY.GetFuncEvalCfg("PushCoin", 1) # ½±³Ø [[ÀàÐÍ, ¸ÅÂÊ, ÊýÁ¿], ...] prizeRateList = [] for setInfo in prizeSetList: prizeRateList.append([setInfo[1], [setInfo[0], setInfo[2]]]) playerSign = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TuiJinbiSign) tuijinbiCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TuiJinbiCnt) GameWorld.DebugLog("ÍÆ½ð±Ò³é½±: playerSign=%s,tuijinbiCnt=%s,prizeRateList=%s" % (playerSign, tuijinbiCnt, prizeRateList), playerID) addPoolPrizeInfo = {} # Ôö¼ÓÌ¨Ãæ½±³ØÐÅÏ¢ drawIndex, drawInfo = GameWorld.GetResultIndexByRandomList(prizeRateList) if playerSign == Sign_NewVerPlayer and not tuijinbiCnt: # ÐÂ°æ±¾Íæ¼ÒÊ×´ÎÍÆ for _ in range(100): if drawInfo and drawInfo[0] in [PrizeType_Gold, PrizeType_Xianyu]: # Ê×´ÎÖ»Äܲú³ö½ð±Ò»òÏÉÓñ±Ò break drawIndex, drawInfo = GameWorld.GetResultIndexByRandomList(prizeRateList) # Ê״θ½¼ÓĬÈϳõʼ½±Àø initPrizeList = IpyGameDataPY.GetFuncEvalCfg("EnSuperDiscount", 5) for prizeType, prizeCnt in initPrizeList: addPoolPrizeInfo[prizeType] = prizeCnt GameWorld.DebugLog("ÐÂÊÖÊ×´ÎÍÆ¶îÍâ½±Àø: %s" % addPoolPrizeInfo, playerID) if not drawInfo or len(drawInfo) != 2: return drawType, drawCount = drawInfo GameWorld.DebugLog("³éµ½: drawIndex=%s,drawInfo=%s,drawType=%s,drawCount=%s" % (drawIndex, drawInfo, drawType, drawCount), playerID) PlayerControl.PayMoney(curPlayer, ShareDefine.TYPE_Price_Tuijinbi, 1, isNotify=False) # ºì°ü£¬Ö±½Ó¸ø½±Àø if drawType == PrizeType_Redpack: randMoneyList = IpyGameDataPY.GetFuncEvalCfg("PushCoin", 3) GameWorld.DebugLog("ºì°üÖ±½Ó¸ø: %s" % str(randMoneyList), playerID) for randMoney in randMoneyList: if randMoney and len(randMoney) == 2: __GiveMoney(curPlayer, randMoney[0], randMoney[1]) # ³¬¼¶½±Àø elif drawType == PrizeType_Super: randPrizeList = IpyGameDataPY.GetFuncEvalCfg("PushCoin", 2) GameWorld.DebugLog("³¬¼¶½±Àø: %s" % str(randPrizeList), playerID) for randPrize in randPrizeList: if randPrize and len(randPrize) == 2: randPrizeType, randValue = randPrize addPoolPrizeInfo[randPrizeType] = addPoolPrizeInfo.get(randPrizeType, 0) + randValue else: GameWorld.DebugLog("Ìí¼Ó½±³Ø: drawType=%s,drawCount=%s" % (drawType, drawCount), playerID) addPoolPrizeInfo[drawType] = addPoolPrizeInfo.get(drawType, 0) + drawCount for prizeType, addCnt in addPoolPrizeInfo.items(): curCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TuiJinbiPool % prizeType) updCnt = curCnt + addCnt PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TuiJinbiPool % prizeType, updCnt) GameWorld.DebugLog("ÍÆ½ð±Ò¸üÐÂÌ¨Ãæ: prizeType=%s,curCnt=%s,addCnt=%s,updCnt=%s" % (prizeType, curCnt, addCnt, updCnt), playerID) tuijinbiCnt += 1 PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TuiJinbiCnt, tuijinbiCnt) GameWorld.DebugLog("¸üÐÂÀÛ¼ÆÍƽð±Ò´ÎÊý: %s" % (tuijinbiCnt), playerID) SyncTuijinbiInfo(curPlayer, drawIndex + 1) return def __DoGivePrize(curPlayer, prizeType, prizeCount): if prizeType not in [PrizeType_Gold, PrizeType_Xianyu]: return curCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TuiJinbiPool % prizeType) giveCnt = min(prizeCount, curCnt) if not giveCnt: return updCnt = curCnt - giveCnt PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TuiJinbiPool % prizeType, updCnt) GameWorld.DebugLog("µôÂä¸üÐÂÌ¨Ãæ: prizeType=%s,prizeCount=%s,curCnt=%s,giveCnt=%s,updCnt=%s" % (prizeType, prizeCount, curCnt, giveCnt, updCnt), curPlayer.GetPlayerID()) if prizeType == PrizeType_Gold: __GiveMoney(curPlayer, IPY_GameWorld.TYPE_Price_Silver_Money, 100000 * giveCnt) elif prizeType == PrizeType_Xianyu: __GiveMoney(curPlayer, IPY_GameWorld.TYPE_Price_Gold_Money, 10 * giveCnt) SyncTuijinbiInfo(curPlayer) return def __GiveMoney(curPlayer, moneyType, moneyValue): moneyTotal = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TuiJinbiMoney % moneyType) updMoneyTotal = min(moneyTotal + moneyValue, ChConfig.Def_UpperLimit_DWord) PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_TuiJinbiMoney % moneyType, updMoneyTotal) GameWorld.DebugLog("¸üÐÂÍÆ½ð±ÒÀۼƽ±Àø»õ±Ò: moneyType=%s,moneyValue=%s,updMoneyTotal=%s" % (moneyType, moneyValue, updMoneyTotal), curPlayer.GetPlayerID()) PlayerControl.GiveMoney(curPlayer, moneyType, moneyValue, "Tuijinbi") return def SyncTuijinbiInfo(curPlayer, drawNum=0): poolPrizeList = [] # Ì¨ÃæÐÅÏ¢ for prizeType in [PrizeType_Gold, PrizeType_Xianyu]: prizeCount = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_TuiJinbiPool % prizeType) if not prizeCount: continue poolInfo = ChPyNetSendPack.tagMCTuijinbiPool() poolInfo.PrizeType = prizeType poolInfo.PrizeCount = prizeCount poolPrizeList.append(poolInfo) clientPack = ChPyNetSendPack.tagMCTuijinbiInfo() clientPack.DrawNum = drawNum clientPack.PoolPrizeList = poolPrizeList clientPack.PoolPrizeCnt = len(clientPack.PoolPrizeList) NetPackCommon.SendFakePack(curPlayer, clientPack) return