| | |
| | |
|
| | | import random
|
| | |
|
| | | FamilyPartyFB_QuestionID = 'FamilyPartyFB_QuestionID%s' #当前题ID
|
| | | FamilyPartyFB_QuestionTick = 'FamilyPartyFB_QuestionTick%s' #当前题出题时间
|
| | | FamilyPartyFB_AnswerTick = 'FamilyPartyFB_AnswerTick%s' #答对时间
|
| | | FamilyPartyFB_HisQuestionID = 'FamParty_HisQuestionID%s' #当前题ID - 不重置, 参数 familyID
|
| | | FamilyPartyFB_QuestionID = 'FamParty_QuestionID%s' #当前题ID - 答对会重置, 参数 familyID
|
| | | FamilyPartyFB_QuestionTick = 'FamParty_QuestionTick%s' #当前题出题时间, 参数 familyID
|
| | | FamilyPartyFB_AnswerTick = 'FamParty_AnswerTick%s' #答对时间, 参数 familyID
|
| | |
|
| | | AnswerState = 2 #开始答题活动状态
|
| | | AnswerState = 1 #开始答题活动状态
|
| | | ## 玩家登录
|
| | | # @param None
|
| | | # @return None
|
| | |
| | | def NotifyFamilyPartyQuestion(curPlayer):
|
| | | #刚登录的或刚进仙盟的补发最近的题目
|
| | | gameWorld = GameWorld.GetGameWorld()
|
| | | state = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_FBFuncState % ChConfig.Def_FBMapID_FamilyParty)
|
| | | state = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_DailyActionState % ShareDefine.DailyActionID_FamilyParty)
|
| | | if state != AnswerState:
|
| | | return
|
| | | curFamilyid = curPlayer.GetFamilyID()
|
| | |
| | |
|
| | | def FamilyPartyStateChange(state, beforeState=0):
|
| | | #活动状态变更
|
| | | if state == beforeState:
|
| | | return
|
| | |
|
| | | if state == 1:
|
| | | if state == AnswerState:
|
| | | PyGameData.g_questionIDHistory = {}
|
| | | PyGameData.g_familyAnswerDict = {}
|
| | | PyGameData.g_familyPartyTopInfo = []
|
| | | PyGameData.g_partyheroAnswerDict = {}
|
| | | PyGameData.g_familyAnswerPlayerIDDict = {}
|
| | | gameWorld = GameWorld.GetGameWorld()
|
| | | familyManager = GameWorld.GetFamilyManager()
|
| | | for i in range(0, familyManager.GetCount()):
|
| | | family = familyManager.GetAt(i)
|
| | | familyID = family.GetID()
|
| | | gameWorld.SetDict(FamilyPartyFB_QuestionID % familyID, 0)
|
| | | gameWorld.SetDict(FamilyPartyFB_HisQuestionID % familyID, 0)
|
| | | gameWorld.SetDict(FamilyPartyFB_AnswerTick % familyID, 0)
|
| | | GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_FamilyPartyInfo, [])
|
| | |
|
| | |
| | | continue
|
| | | PlayerFamilyRedPacket.CreatNewFamilyRedPacket(family, family.GetLeaderID(), redPackID)
|
| | |
|
| | | if beforeState == AnswerState:
|
| | | PlayerControl.WorldNotify(0, 'Party_TopThree', topfamilyNameList)
|
| | | |
| | |
|
| | | if PyGameData.g_familyPartyTopInfo:
|
| | | topHeroID, topHeroName = PyGameData.g_familyPartyTopInfo[:2]
|
| | |
| | | PlayerControl.WorldNotify(0, 'Party_TopPlayer', [topHeroName])
|
| | |
|
| | | #给参与奖励
|
| | | joinPlayerIDList = PyGameData.g_partyheroAnswerDict.keys()
|
| | | if joinPlayerIDList:
|
| | | joinReward = IpyGameDataPY.GetFuncEvalCfg('PartyReward')
|
| | | answerRWItemReward = IpyGameDataPY.GetFuncEvalCfg('PartyReward2', 1)
|
| | | for playerID, ansRightCount in PyGameData.g_partyheroAnswerDict.items():
|
| | | if answerRWItemReward and len(answerRWItemReward) == 2:
|
| | | ansTotalCount = len(PyGameData.g_familyAnswerPlayerIDDict.get(playerID, []))
|
| | | ansWrongCount = max(0, ansTotalCount - ansRightCount)
|
| | | isAuctionItem = False
|
| | | rightRewardEx, wrongRewardEx = [], []
|
| | | rightItemID, wrongItemID = answerRWItemReward
|
| | | if rightItemID and ansRightCount:
|
| | | rightRewardEx = [(rightItemID, ansRightCount, isAuctionItem)]
|
| | | if wrongItemID and ansWrongCount:
|
| | | wrongRewardEx = [(wrongItemID, ansWrongCount, isAuctionItem)]
|
| | | curJoinReward = joinReward + rightRewardEx + wrongRewardEx
|
| | | else:
|
| | | curJoinReward = joinReward
|
| | | if joinReward:
|
| | | PlayerCompensation.SendMailByKey('FamilyParty', joinPlayerIDList, joinReward)
|
| | | PlayerCompensation.SendMailByKey('FamilyParty', [playerID], curJoinReward)
|
| | |
|
| | | return
|
| | |
|
| | |
| | | def FamilyParty_Process(tick):
|
| | | #开始出题
|
| | | gameWorld = GameWorld.GetGameWorld()
|
| | | state = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_FBFuncState % ChConfig.Def_FBMapID_FamilyParty)
|
| | | state = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_DailyActionState % ShareDefine.DailyActionID_FamilyParty)
|
| | | if state != AnswerState:
|
| | | return
|
| | | allQuestionIDList = IpyGameDataPY.GetConfigEx('AllQuestionID')
|
| | |
| | | break
|
| | |
|
| | | gameWorld.SetDict(FamilyPartyFB_QuestionID % familyID, questionID)
|
| | | gameWorld.SetDict(FamilyPartyFB_HisQuestionID % familyID, questionID)
|
| | | gameWorld.SetDict(FamilyPartyFB_QuestionTick % familyID, tick)
|
| | |
|
| | | PlayerControl.FamilyNotify(familyID, 'Party_Topic', [questionID])
|
| | |
| | | def OnTalkFamily(curPlayer, content, tick):
|
| | |
|
| | | gameWorld = GameWorld.GetGameWorld()
|
| | | state = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_FBFuncState % ChConfig.Def_FBMapID_FamilyParty)
|
| | | state = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_DailyActionState % ShareDefine.DailyActionID_FamilyParty)
|
| | | if state != AnswerState:
|
| | | return
|
| | |
|
| | | playerID = curPlayer.GetID()
|
| | | curFamilyid = curPlayer.GetFamilyID()
|
| | | if not curFamilyid:
|
| | | return
|
| | | |
| | | ## 添加玩家参与答题的题目ID,只要在本地图答题期间仙盟发送聊天信息就算
|
| | | ## 在每题中间有5秒缓冲,在此期间可能速度慢的玩家还在回答上一题,在缓冲期间题目ID为0,所以添加题目ID需用不重置的历史题目ID
|
| | | if curPlayer.GetMapID() == ChConfig.Def_FBMapID_FamilyParty:
|
| | | if playerID not in PyGameData.g_familyAnswerPlayerIDDict:
|
| | | PyGameData.g_familyAnswerPlayerIDDict[playerID] = []
|
| | | answerQuestionIDList = PyGameData.g_familyAnswerPlayerIDDict[playerID]
|
| | | hisQuestionID = gameWorld.GetDictByKey(FamilyPartyFB_HisQuestionID % curFamilyid)
|
| | | if hisQuestionID and hisQuestionID not in answerQuestionIDList:
|
| | | answerQuestionIDList.append(hisQuestionID)
|
| | | |
| | | questionID = gameWorld.GetDictByKey(FamilyPartyFB_QuestionID % curFamilyid)
|
| | | if not questionID:
|
| | | return
|
| | |
| | | PlayerControl.NotifyCode(curPlayer, 'FamilyNoIntoParty')
|
| | | return
|
| | |
|
| | | playerID = curPlayer.GetID()
|
| | | GameWorld.DebugLog(" answer=%s ChContent=%s"%(answerList, ChContent), playerID)
|
| | | |
| | | if isRight:
|
| | | GameWorld.DebugLog(" 答对了! %s"%playerID)
|
| | | playerName = curPlayer.GetName()
|