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
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
##@package PyMongoDB.GMToolLogicProcess.Commands.GMT_FamilyTransfer
#
# @todo:GM¹¤¾ßÃüÁî - ×ªÈû᳤
# @author hxp
# @date 2025-12-21
# @version 1.0
#
# ÏêϸÃèÊö: GM¹¤¾ßÃüÁî - ×ªÈû᳤
#
#-------------------------------------------------------------------------------
#"""Version = 2025-12-21 17:30"""
#-------------------------------------------------------------------------------
 
import GMCommon
import GameWorld
import PlayerFamily
import PlayerMail
import DBDataMgr
 
## ÊÕµ½gmÃüÁîÖ´ÐÐ
# @param gmCmdDict:gmÃüÁî×Öµä
# @return None 
def OnExec(gmCmdDict):
    
    queryType = gmCmdDict.get(GMCommon.Def_GMKey_QueryType, '')      
    familyName = gmCmdDict.get(GMCommon.Def_GMKey_FamilyName, '')
    
    if familyName == '':
        return GMCommon.Def_ParamErr
    
    familyMgr = DBDataMgr.GetFamilyMgr()
    if queryType == "FamilyID":
        familyID = GameWorld.ToIntDef(familyName)
        if not familyID:
            return GMCommon.Def_ParamErr
        curFamily = familyMgr.FindFamily(familyID)
    else:
        curFamily = familyMgr.FindFamilyByName(familyName)
        
    if not curFamily:
        GameWorld.DebugLogEx("Ä¿±ê¹¤»á²»´æÔÚ")
        return GMCommon.Def_NoTag, "no tag family"
    
    familyID = curFamily.GetID()
    tagPlayer = None
    queryTagType = gmCmdDict.get("queryTagType", '')  
    queryTag = gmCmdDict.get("queryTag", '')
    if queryTagType == "PlayerName":
        tagPlayer = GameWorld.GetPlayerManager().FindPlayerByName(queryTag)
    else:
        tagPlayer = GameWorld.GetPlayerManager().FindPlayerByID(GameWorld.ToIntDef(queryTag))
        
    if not tagPlayer:
        GameWorld.DebugLogEx("Ä¿±êÍæ¼Ò²»ÔÚÏß")
        return GMCommon.Def_NoTag, "tagPlayer is offLine"
    
    tagPlayerID = tagPlayer.GetPlayerID()
    toMember = curFamily.FindMember(tagPlayerID)
    if not toMember:
        GameWorld.DebugLogEx("Ä¿±êÍæ¼Ò·Ç¸Ã¹¤»á³ÉÔ±: tagPlayerID=%s", tagPlayerID)
        return GMCommon.Def_NoTag, "tagPlayer is not this family member"
    
    PlayerFamily.ChangeFamilyLeader(curFamily, toMember)
    PlayerFamily.Broadcast_FamilyChange(familyID, PlayerFamily.FamilyChangeType_LeaderChange)
    
    # Óʼþ֪ͨ
    PlayerMail.SendMailByKey("FamilyLeaderAutoChange", tagPlayerID, [], [curFamily.GetName()])
    return GMCommon.Def_Success