| | |
| | | import random
|
| | |
|
| | | FamilyPartyFB_QuestionID = 'FamilyPartyFB_QuestionID%s' #当前题ID
|
| | | FamilyPartyFB_QuestionTick = 'FamilyPartyFB_QuestionTick%s' #当前题出题时间
|
| | | FamilyPartyFB_AnswerTick = 'FamilyPartyFB_AnswerTick%s' #答对时间
|
| | |
|
| | |
|
| | | AnswerState = 2 #开始答题活动状态
|
| | | ## 玩家登录
|
| | | # @param None
|
| | | # @return None
|
| | |
| | | #刚登录的或刚进仙盟的补发最近的题目
|
| | | gameWorld = GameWorld.GetGameWorld()
|
| | | state = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_FBFuncState % ChConfig.Def_FBMapID_FamilyParty)
|
| | | if state != 1:
|
| | | if state != AnswerState:
|
| | | return
|
| | | curFamilyid = curPlayer.GetFamilyID()
|
| | | if not curFamilyid:
|
| | |
| | | familyID = family.GetID()
|
| | | gameWorld.SetDict(FamilyPartyFB_QuestionID % familyID, 0)
|
| | | gameWorld.SetDict(FamilyPartyFB_AnswerTick % familyID, 0)
|
| | | |
| | | |
| | | GameWorld.SendMapServerMsgEx(ShareDefine.Def_Notify_WorldKey_FamilyPartyInfo, [])
|
| | | |
| | | if state == 0:
|
| | | #活动结算 前3名仙盟、答题王
|
| | | GameWorld.Log(" 仙盟宴会结算 g_familyAnswerDict=%s, g_familyPartyTopInfo=%s"%(PyGameData.g_familyAnswerDict, PyGameData.g_familyPartyTopInfo))
|
| | |
| | | #开始出题
|
| | | gameWorld = GameWorld.GetGameWorld()
|
| | | state = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_FBFuncState % ChConfig.Def_FBMapID_FamilyParty)
|
| | | if state != 1:
|
| | | if state != AnswerState:
|
| | | return
|
| | | |
| | | allQuestionIDList = IpyGameDataPY.GetConfigEx('AllQuestionID')
|
| | | ipyMgr = IpyGameDataPY.IPY_Data()
|
| | | if not allQuestionIDList:
|
| | | allQuestionIDList = []
|
| | | for i in xrange(ipyMgr.GetQuestionBankCount()):
|
| | | ipyData = ipyMgr.GetQuestionBankByIndex(i)
|
| | | questionID = ipyData.GetID()
|
| | | allQuestionIDList.append(questionID)
|
| | | IpyGameDataPY.SetConfigEx('AllQuestionID', allQuestionIDList)
|
| | | if not allQuestionIDList:
|
| | | GameWorld.ErrLog('仙盟宴会题库没有题目!')
|
| | | return
|
| | | familyManager = GameWorld.GetFamilyManager()
|
| | | for i in range(0, familyManager.GetCount()):
|
| | | family = familyManager.GetAt(i)
|
| | | familyID = family.GetID()
|
| | | |
| | | if gameWorld.GetDictByKey(FamilyPartyFB_QuestionID % familyID):
|
| | | lastQuestionID = gameWorld.GetDictByKey(FamilyPartyFB_QuestionID % familyID)
|
| | | if lastQuestionID:
|
| | | #还有题未答
|
| | | continue
|
| | | maxSecond = IpyGameDataPY.GetFuncCfg('FairyCorrectAnswer')
|
| | | if tick - gameWorld.GetDictByKey(FamilyPartyFB_QuestionTick % familyID) > maxSecond*1000:
|
| | | ipyData = IpyGameDataPY.GetIpyGameData('QuestionBank', lastQuestionID)
|
| | | if ipyData:
|
| | | answer = ipyData.GetAnswer()
|
| | | answer = answer.replace('[', '')
|
| | | answer = answer.replace(']', '')
|
| | | PlayerControl.FamilyNotify(familyID, 'Party_Correct', [maxSecond, GameWorld.GbkToCode(answer)])
|
| | | else:
|
| | | continue
|
| | | answerTick = gameWorld.GetDictByKey(FamilyPartyFB_AnswerTick % familyID)
|
| | | if tick - answerTick < 5000:
|
| | | if not lastQuestionID and tick - answerTick < 5000:
|
| | | continue
|
| | |
|
| | | #随机题目
|
| | | historyQuestionIDList = PyGameData.g_questionIDHistory.get(familyID, [])
|
| | | questionCnt = IpyGameDataPY.IPY_Data().GetQuestionBankCount()
|
| | | for i in xrange(50):
|
| | | questionID = random.randint(1, questionCnt)
|
| | | questionID = random.choice(allQuestionIDList)
|
| | | # 随机到不重复的即可
|
| | | if questionID not in historyQuestionIDList or i == 49:
|
| | | historyQuestionIDList.append(questionID)
|
| | | PyGameData.g_questionIDHistory[familyID] = historyQuestionIDList
|
| | | if questionID not in historyQuestionIDList:
|
| | | historyQuestionIDList.append(questionID)
|
| | | PyGameData.g_questionIDHistory[familyID] = historyQuestionIDList
|
| | | break
|
| | |
|
| | | gameWorld.SetDict(FamilyPartyFB_QuestionID % familyID, questionID)
|
| | | gameWorld.SetDict(FamilyPartyFB_QuestionTick % familyID, tick)
|
| | | |
| | | PlayerControl.FamilyNotify(familyID, 'Party_Topic', [questionID])
|
| | | return
|
| | |
|
| | |
| | |
|
| | | gameWorld = GameWorld.GetGameWorld()
|
| | | state = gameWorld.GetDictByKey(ShareDefine.Def_Notify_WorldKey_FBFuncState % ChConfig.Def_FBMapID_FamilyParty)
|
| | | if state != 1:
|
| | | if state != AnswerState:
|
| | | return
|
| | |
|
| | | curFamilyid = curPlayer.GetFamilyID()
|
| | |
| | | questionID = gameWorld.GetDictByKey(FamilyPartyFB_QuestionID % curFamilyid)
|
| | | if not questionID:
|
| | | return
|
| | | ipyData = IpyGameDataPY.GetIpyGameData('QuestionBank', questionID)
|
| | | if not ipyData:
|
| | | GameWorld.ErrLog('仙盟宴会答题 该题不存在,异常 questionID=%s, 重新出题'%questionID)
|
| | | gameWorld.SetDict(FamilyPartyFB_QuestionID % curFamilyid, 0)
|
| | | gameWorld.SetDict(FamilyPartyFB_QuestionTick % curFamilyid, 0)
|
| | | return
|
| | |
|
| | | ipyData = IpyGameDataPY.IPY_Data().GetQuestionBankByIndex(questionID-1)
|
| | | answerList = eval(ipyData.GetAnswer())
|
| | | ChContent = PlayerTalk.ChangeVoiceChat(content)
|
| | | ChContent = ChContent.decode(GameWorld.GetCharacterEncoding()).encode(ShareDefine.Def_Game_Character_Encoding)
|
| | | ChContent = GameWorld.CodeToGBK(ChContent)
|
| | | ChContent = ChContent.strip()
|
| | | isRight = ChContent in answerList
|
| | | # if curPlayer.GetMapID() != ChConfig.Def_FBMapID_FamilyParty:
|
| | | # if isRight:
|
| | | # PlayerControl.FamilyNotify(curFamilyid, 'FamilyPleaseIntoParty')
|
| | | # PlayerControl.NotifyCode(curPlayer, 'FamilyNoIntoParty')
|
| | | # return
|
| | | if curPlayer.GetMapID() != ChConfig.Def_FBMapID_FamilyParty:
|
| | | if isRight:
|
| | | PlayerControl.FamilyNotify(curFamilyid, 'FamilyPleaseIntoParty')
|
| | | PlayerControl.NotifyCode(curPlayer, 'FamilyNoIntoParty')
|
| | | return
|
| | |
|
| | | playerID = curPlayer.GetID()
|
| | | GameWorld.DebugLog(" answer=%s ChContent=%s"%(answerList, ChContent), playerID)
|