#!/usr/bin/python
|
# -*- coding: GBK -*-
|
#---------------------------------------------------------------------
|
#
|
#---------------------------------------------------------------------
|
##@package PlayerFamilyTech
|
# @todo: ¼Ò×å¿Æ¼¼
|
#
|
# @author: panwei
|
# @date 2011-06-17
|
# @version 1.2
|
#
|
# @change: "2016-06-08 16:00" hxp ÓÀºãÕ½Ã˿Ƽ¼°æ±¾
|
# @change: "2016-10-31 16:00" hxp ÆÁ±ÎÕ½Ã˿Ƽ¼, ¸ÄΪ´¿µØÍ¼´¦Àíģʽ
|
#---------------------------------------------------------------------
|
#"""Version = 2016-10-31 16:00"""
|
#---------------------------------------------------------------------
|
import GameWorld
|
import ReadChConfig
|
#import PlayerFamily
|
#import PlayerFamilyAction
|
#import DataRecordPack
|
#import IPY_GameServer
|
#import PlayerControl
|
#import ShareDefine
|
#import ChConfig
|
#---------------------------------------------------------------------
|
|
(
|
Def_TechLVUP_NeedBoomValue, # ÏûºÄÕ½ÃË·±ÈÙ
|
Def_TechLVUP_NeedMoney, # ÏûºÄÕ½Ã˽ðÇ®
|
Def_TechLVUP_NeedHornor, # ÏûºÄÕ½ÃË×êʯ
|
Def_TechLVUP_NeedContribution, # ¸öÈËÉý¼¶ÐèÒªÏûºÄ¹±Ï×¶È
|
) = range(4)
|
|
#---------------------------------------------------------------------
|
##Íæ¼ÒµÇ½, ¼Ò×å¿Æ¼¼Âß¼´¦Àí
|
# @param curPlayer Íæ¼ÒʵÀý
|
# @param tick ʱ¼ä´Á
|
# @return None
|
# @remarks
|
def OnLogin(curPlayer, tick):
|
curFamily = curPlayer.GetFamily()
|
if not curFamily:
|
#Íæ¼ÒÎÞ¼Ò×å
|
return
|
|
if not GameWorld.GetFamilyTechManager().GetFamilyTechByFamilyID(curFamily.GetID()):
|
return
|
|
#֪ͨ¿Í»§¶Ë¼Ò×å¿Æ¼¼ÐÅÏ¢
|
curPlayer.Sync_FamilyTechInfo()
|
return
|
|
#===============================================================================
|
# //0F 16 °ï»á¿Æ¼¼Éý¼¶#tagCFamilyTecLvUP
|
#
|
# struct tagCFamilyTecLvUP
|
# {
|
# tagHead Head;
|
# DWORD TecID; //¿Æ¼¼ID
|
# BYTE IsUseKey; //ÊÇ·ñʹÓÃÍ»·ÉÁî
|
# };
|
#===============================================================================
|
##°ï»á¿Æ¼¼Éý¼¶»òÈ¡Ïû
|
# @param index Íæ¼ÒË÷Òý
|
# @param tick ʱ¼ä´Á
|
# @return ·µ»ØÖµÎÞÒâÒå
|
# @remarks ¿Í»§¶Ë·â°üÏìÓ¦ °ï»á¿Æ¼¼Éý¼¶#tagCFamilyTecLvUP
|
def CChangeFamilyTech(index, tick):
|
#¸ÄΪµØÍ¼Ö±½Ó´¦Àí£¬ÔÝÆÁ±Î
|
# curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)
|
# curFamily = curPlayer.GetFamily()
|
#
|
# if not curFamily:
|
# return
|
#
|
# clientPack = IPY_GameServer.IPY_CFamilyTecLvUP()
|
# techID = clientPack.GetTecID()
|
#
|
# #Ñé֤ȨÏÞ
|
# if not PlayerFamily.GetPlayerHasFamilyPow(curPlayer, ChConfig.Def_PurviewDictKey_CanLvUpTech):
|
# GameWorld.DebugLog("ûÓÐÉý¼¶Õ½Ã˿Ƽ¼È¨ÏÞ!")
|
# return
|
#
|
# FamilyTechIDList = ReadChConfig.GetEvalChConfig("FamilyTechID")
|
# if techID not in FamilyTechIDList:
|
# GameWorld.DebugLog("Õ½Ã˿Ƽ¼²»´æÔÚ, techID=%s not in FamilyTechID.txt!" % techID)
|
# return
|
#
|
# curFamilyID = curFamily.GetID()
|
# curFamilyLv = curFamily.GetLV()
|
# FamilyTechMaxLVDict = ReadChConfig.GetEvalChConfig("FamilyTechMaxLV")
|
# if not FamilyTechMaxLVDict:
|
# return
|
# maxConfFamilyLV = max(FamilyTechMaxLVDict)
|
# getLV = maxConfFamilyLV if curFamilyLv > maxConfFamilyLV else curFamilyLv
|
# maxTechLV = FamilyTechMaxLVDict.get(getLV)
|
# if not maxTechLV:
|
# GameWorld.DebugLog("Õ½Ã˵ȼ¶=%s, ¶ÔÓ¦µÄÕ½Ã˿Ƽ¼×î´óµÈ¼¶²»´æÔÚ! ¼ì²é FamilyTechMaxLV.txt!" % (getLV))
|
# return
|
#
|
# familyTechMgr = GameWorld.GetFamilyTechManager()
|
# learnTech = familyTechMgr.FindFamilyTechData(curFamilyID, techID)
|
# curTechLV = 0 if not learnTech else learnTech.GetTechCurLV()
|
# if curTechLV >= maxTechLV:
|
# GameWorld.DebugLog("µ±Ç°Õ½Ã˿Ƽ¼ÒÑ´ï×î´óµÈ¼¶! curTechLV=%s,curFamilyLv=%s,maxTechLV=%s!" % (curTechLV, curFamilyLv, maxTechLV))
|
# return
|
#
|
# lvUPTechLV = curTechLV + 1
|
# FamilyTechLVUPDict = ReadChConfig.GetEvalChConfig("FamilyTechLVUP")
|
# techLVUPInfo = FamilyTechLVUPDict.get(lvUPTechLV)
|
# if not techLVUPInfo:
|
# GameWorld.ErrLog("Õ½Ã˿Ƽ¼µÈ¼¶(%s) not in FamilyTechLVUP.txt!" % lvUPTechLV)
|
# return
|
#
|
# needBoomValue = techLVUPInfo[Def_TechLVUP_NeedBoomValue]
|
# needMoney = techLVUPInfo[Def_TechLVUP_NeedMoney]
|
# needHornor = techLVUPInfo[Def_TechLVUP_NeedHornor]
|
#
|
# if curFamily.GetBoomValue() < needBoomValue:
|
# GameWorld.DebugLog("Õ½ÃË·±ÈÙ»îÔ¾¶È²»×ã! needBoomValue=%s" % (needBoomValue))
|
# return
|
# if curFamily.GetMoney() < needMoney:
|
# GameWorld.DebugLog("Õ½ÃË×ʽð²»×ã! needMoney=%s" % (needMoney))
|
# return
|
# if curFamily.GetHornor() < needHornor:
|
# GameWorld.DebugLog("Õ½ÃË×êʯ²»×ã! needHornor=%s" % (needHornor))
|
# return
|
#
|
# if learnTech == None:
|
# learnTech = familyTechMgr.AddFamilyTechData(curFamilyID, techID)
|
# if learnTech == None:
|
# GameWorld.ErrLog('curFamilyID = %s, Éý¼¶ techID = %s Òì³£' % (curFamilyID, techID))
|
# return
|
# #ÉèÖÿƼ¼¼Ò×åID
|
# learnTech.SetFamilyID(curFamilyID)
|
#
|
# #---¿ªÊ¼Éý¼¶---
|
# curFamily.SetBoomValue(curFamily.GetBoomValue() - needBoomValue)
|
# curFamily.SetMoney(curFamily.GetMoney() - needMoney)
|
# curFamily.SetHornor(curFamily.GetHornor() - needHornor)
|
#
|
# learnTech.SetTechCurLV(lvUPTechLV)
|
#
|
# #¿Æ¼¼Éý¼¶Á÷Ïò
|
# dataDict = {"familyID":curFamilyID, "techID":techID, "lvUPTechLV":lvUPTechLV, "needBoomValue":needBoomValue,
|
# "needMoney":needMoney, "needHornor":needHornor}
|
# DataRecordPack.SendEventPack("FamilyTechLVUP", dataDict)
|
#
|
# #¼Ç¼Éý¼¶ÐÅÏ¢
|
# PlayerFamilyAction.AddFamilyActionNote(curPlayer.GetName(), curFamilyID, ShareDefine.Def_ActionType_FamilyEvent,
|
# [ShareDefine.Def_FamilyActionEvent_Tech, techID, lvUPTechLV], tick)
|
#
|
# #֪ͨ¿Í»§¶Ë¼Ò×åÊôÐÔ±ä¸ü
|
# curFamily.Broadcast_FamilyChange()
|
# #֪ͨµØÍ¼·þÎñÆ÷ˢмÒ×åÊôÐÔ
|
# PlayerFamily.SendPack_MapServer_PlayerFamilyRefresh(curFamily)
|
#
|
# #֪ͨ¼Ò×å¿Æ¼¼±ä¸ü
|
# NotifyFamilyTechInfoChange(curFamily)
|
#
|
# #¿Æ¼¼Éý¼¶³É¹¦
|
# PlayerControl.FamilyNotify(curFamilyID, "jiazu_liubo_318691", [techID, lvUPTechLV])
|
# GameWorld.Log('¿Æ¼¼Éý¼¶³É¹¦ familyID=%s,techID=%s,lvUPTechLV=%s' % (curFamilyID, techID, lvUPTechLV))
|
return
|
|
#---------------------------------------------------------------------
|
##֪ͨ¼Ò×å¿Æ¼¼±ä¸ü
|
# @param curFamily ¼Ò×åʵÀý
|
# @param sendMPack ·¢°üµØÍ¼·þÎñÆ÷
|
# @return None
|
# @remarks
|
def NotifyFamilyTechInfoChange(curFamily):
|
|
#֪ͨËùÓÐÔÚÏßÍæ¼Ò, ¼Ò×å¿Æ¼¼±ä¸ü
|
for i in range(0, curFamily.GetCount()):
|
curMember = curFamily.GetAt(i)
|
curPlayer = curMember.GetPlayer()
|
if curPlayer == None:
|
continue
|
curPlayer.Sync_FamilyTechInfo()
|
|
return
|
|
#---------------------------------------------------------------------
|
##ɾ³ýÕ½Ã˿Ƽ¼
|
# @param familyID ¼Ò×åID
|
# @return ·µ»ØÖµÎÞÒâÒå
|
# @remarks
|
def DelFamilyTechData(familyID):
|
familyTechMgr = GameWorld.GetFamilyTechManager()
|
playerFamilyTech = familyTechMgr.GetFamilyTechByFamilyID(familyID)
|
|
if not playerFamilyTech:
|
#ÎÞ¼Ò×å¿Æ¼¼ÐÅÏ¢
|
return
|
|
#---ɾ³ý¼Ò×å¿Æ¼¼ÐÅÏ¢---
|
familyTechIDList = []
|
|
for familyTechIndex in range(0, playerFamilyTech.GetCount()):
|
familyTechData = playerFamilyTech.GetAt(familyTechIndex)
|
familyTechIDList.append(familyTechData.GetTechID())
|
|
for techID in familyTechIDList:
|
#Çå³ýÕâ¸ö¼Ò×åµÄ°ï»áÊôÐÔ
|
familyTechMgr.DeleteFamilyTechData(familyID, techID);
|
GameWorld.Log("DelFamilyTechData familyID=%s, techID=%s" % (familyID, techID))
|
|
return
|
|
|
## Íæ¼ÒÇëÇóÕ½Ã˿Ƽ¼Éý¼¶
|
# @param curPlayer Íæ¼ÒʵÀý
|
# @return
|
def OnQuery_PlayerFamilyTechLVUP(curPlayer, infoList):
|
techID, curPlayerTechLV = infoList
|
|
curFamily = curPlayer.GetFamily()
|
|
if not curFamily:
|
return []
|
|
familyTech = GameWorld.GetFamilyTechManager().FindFamilyTechData(curFamily.GetID(), techID)
|
familyTechLV = 0 if not familyTech else familyTech.GetTechCurLV()
|
if curPlayerTechLV >= familyTechLV:
|
GameWorld.DebugLog("Íæ¼Òµ±Ç°¿Æ¼¼µÈ¼¶³¬¹ý¸ÃÕ½Ã˵ĿƼ¼µÈ¼¶, ²»¿ÉÉý¼¶!techID=%s,curPlayerTechLV=%s,familyTechLV=%s"
|
% (techID, curPlayerTechLV, familyTechLV))
|
return []
|
|
tagTechLV = curPlayerTechLV + 1
|
FamilyTechLVUPDict = ReadChConfig.GetEvalChConfig("FamilyTechLVUP")
|
techLVUPInfo = FamilyTechLVUPDict.get(tagTechLV)
|
if not techLVUPInfo:
|
GameWorld.ErrLog("¼Ò×å¿Æ¼¼µÈ¼¶(%s) not in FamilyTechLVUP.txt!" % tagTechLV)
|
return []
|
|
needContribution = techLVUPInfo[Def_TechLVUP_NeedContribution]
|
return [techID, curPlayerTechLV, needContribution]
|
|
|
|
|
|