xdh
2019-01-28 8305e47be942c376430044332780e6e69a3c7a7f
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/python
# -*- coding: GBK -*-
#-------------------------------------------------------------------------------
#
#-------------------------------------------------------------------------------
#
##@package Player.PlayerFreshmanGuide
#
# @todo:ÐÂÊÖÖ¸µ¼Ô±
# @author hxp
# @date 2014-02-28
# @version 1.0
#
# ÏêϸÃèÊö: ÐÂÊÖÖ¸µ¼Ô±
#
#---------------------------------------------------------------------
#"""Version = 2014-02-28 21:10"""
 
import ChConfig
import BuffSkill
import GameWorld
import SkillCommon
import ReadChConfig
import PlayerControl
 
 
## ÉèÖÃÐÂÊÖÖ¸µ¼Ô±ÓÐЧÌìÊý
#  @param curPlayer Íæ¼ÒʵÀý
#  @param day ÌìÊý£¬Îª0ʱȡÏûÐÂÊÖÖ¸µ¼Ô±¹¦ÄÜ
#  @param tick µ±Ç°Ê±¼ä
#  @return
def SetFreshmanGuideDay(curPlayer, day):
    GameWorld.DebugLog("SetFreshmanGuideDay day=%s" % day, curPlayer.GetPlayerID())
    day = max(0, day)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FreshmanGuideDay, day)
    
    tick = GameWorld.GetGameWorld().GetTick()
    
    # buff´¦Àí
    if day > 0:
        SkillCommon.AddBuffBySkillType(curPlayer, ChConfig.Def_SkillID_FreshmanGuideBuff, tick)
    else:
        BuffSkill.DelBuffBySkillID(curPlayer, ChConfig.Def_SkillID_FreshmanGuideBuff, tick)
    
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FreshmanGuideSpeakerCntToday, 0)
    # Í¨ÖªGameServer
    __NotifyGameServer(curPlayer)
    return
 
 
## »ñÈ¡ÐÂÊÖÖ¸µ¼Ô±Ê£ÓàÌìÊý
#  @param curPlayer Íæ¼ÒʵÀý
#  @return Ê£ÓàÌìÊý£¬Îª0±íʾ·ÇÖ¸µ¼Ô±
def GetFreshmanGuiderDay(curPlayer):
    return curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FreshmanGuideDay)
 
 
## Í¨ÖªGameServer
#  @param curPlayer Íæ¼ÒʵÀý
#  @return None
def __NotifyGameServer(curPlayer):
    msgList = [GetFreshmanGuiderDay(curPlayer)]
    GameWorld.GetPlayerManager().GameServer_QueryPlayerResult(curPlayer.GetID(), 0, 0, 'FreshmanGuiderDay', \
                                                               '%s' % (msgList), len(str(msgList)))
    return
 
 
## ÐÂÊÖÖ¸µ¼Ô±µÇ¼´¦Àí
#  @param curPlayer ·¢³öÇëÇóµÄÍæ¼Ò
#  @return None
def FreshmanGuiderOnLogin(curPlayer):
    # ·ÇÐÂÊÖÖ¸µ¼Ô±
    if GetFreshmanGuiderDay(curPlayer) <= 0:
        return
    
    # µÇ¼ʱÏòGameServerͬ²½Ê£ÓàÌìÊý
    __NotifyGameServer(curPlayer)
    return
 
 
## ÐÂÊÖÖ¸µ¼Ô±¹ýÌì´¦Àí
#  @param curPlayer ·¢³öÇëÇóµÄÍæ¼Ò
#  @param tick µ±Ç°Ê±¼ä
#  @return None
def FreshmanGuiderOnDay(curPlayer):
    # ·ÇÐÂÊÖÖ¸µ¼Ô±
    if GetFreshmanGuiderDay(curPlayer) <= 0:
        GameWorld.DebugLog("FreshmanGuiderOnDay...·ÇÐÂÊÖÖ¸µ¼Ô±!", curPlayer.GetPlayerID())
        return
    
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FreshmanGuideSpeakerCntToday, 0)
    nowDay = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FreshmanGuideDay)
    nowDay = max(0, nowDay - 1)
    GameWorld.DebugLog("FreshmanGuiderOnDay...¸üÐÂÐÂÊÖÖ¸µ¼Ô±ÌìÊý£º%s,Çå¿Õ´«Òô´ÎÊý£¡" % nowDay, curPlayer.GetPlayerID())
    SetFreshmanGuideDay(curPlayer, nowDay)
    return
 
 
## ÐÂÊÖÖ¸µ¼Ô±¿É·ñÃâ·ÑʹÓô«Òô
#  @param curPlayer ·¢³öÇëÇóµÄÍæ¼Ò
#  @return True or False
def CanFreeSpeak(curPlayer):
    # ·ÇÐÂÊÖÖ¸µ¼Ô±
    if GetFreshmanGuiderDay(curPlayer) <= 0:
        return False
    
    maxFreeCnt = ReadChConfig.GetEvalChConfig("FreshmanGuiderFreeSpeakCnt")  
    todayCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FreshmanGuideSpeakerCntToday)
    GameWorld.DebugLog("CanFreeSpeak maxFreeCnt=%s,todayCnt=%s" % (maxFreeCnt, todayCnt), curPlayer.GetPlayerID())
    return todayCnt < maxFreeCnt
 
 
## Ôö¼ÓÐÂÊÖÖ¸µ¼Ô±Ãâ·ÑʹÓô«Òô´ÎÊý
#  @param curPlayer ·¢³öÇëÇóµÄÍæ¼Ò
#  @return
#  @remarks Ä¬ÈϼÓ1
def AddFreeSpeakCnt(curPlayer):
    speakerCnt = curPlayer.NomalDictGetProperty(ChConfig.Def_PDict_FreshmanGuideSpeakerCntToday)
    PlayerControl.NomalDictSetProperty(curPlayer, ChConfig.Def_PDict_FreshmanGuideSpeakerCntToday, speakerCnt + 1)
    GameWorld.DebugLog("AddFreeSpeakCnt ÐÂÊÖÖ¸µ¼Ô±Ôö¼ÓÃâ·Ñ·¢´«Òô´ÎÊý£¡µ±Ç°ÒÑÃâ·Ñ´ÎÊý=%s" 
                       % (speakerCnt + 1), curPlayer.GetPlayerID())
    return