| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #---------------------------------------------------------------------  | 
| #  | 
| #---------------------------------------------------------------------  | 
| ##@package PlayerExam  | 
| # @todo: ´ðÌâϵͳ  | 
| #  | 
| # @author: panwei  | 
| # @date 2011-04-01  | 
| # @version 2.8  | 
| #  | 
| # @change: "2011-04-05 16:20" panwei Íæ¼ÒÊÇ·ñ»Ø´ðÌí¼ÓĬÈϱêʾ  | 
| # @change: "2011-04-07 17:30" panwei PsycoÓÅ»¯  | 
| # @change: "2011-04-08 10:40" panwei ½«½øÈë´ðÌâºÍÍ˳ö´ðÌâ·Ö¿ª  | 
| # @change: "2011-04-27 11:00" Alee Íæ¼ÒÊý¾ÝÁ÷Ïò¼Ç¼  | 
| # @change: "2011-05-20 11:00" panwei ÐÂÔö´ðÌâ»î¶¯, ÕæÐÄ»°´óðÏÕ  | 
| # @change: "2011-05-23 16:00" panwei ÕæÐÄ»°Í³¼ÆÂʼÆËã×ÖµäKeyÐÞ¸Ä  | 
| # @change: "2012-03-14 18:00" wdb Ð޸ĴðÌâÌâÄ¿¸öÊý  | 
| # @change: "2012-04-17 18:00" wdb Ìí¼ÓÖÁÑÓ³ÙÌáʾ   | 
| # @change: "2012-05-07 11:00" wdb ÕæÐÄ»°´óðÏÕÖ»Òª¼Ó·Ö¾ÍËã»Ø´ðÕýÈ·  | 
| # @change: "2012-05-16 14:30" jiang C++½Ó¿ÚÐÞ¸ÄMapServer_QueryPlayerResultºÍMapServer_QueryPlayerÐÞ¸Ä  | 
| # @change: "2012-05-23 12:00" wdb ÐÞ¸Äbug£¬³õʼ´ð¶ÔÌâÄ¿ÊýÁ¿Ê±»ú´íÎó  | 
| # @change: "2012-12-03 10:00" wdb ¿ç·þ·þÎñÆ÷¹¦ÄÜÏÞÖÆ  | 
| # @change: "2014-05-04 15:00" xcc ÐÞ¸ÄϵͳÏûÏ¢  | 
| # @change: "2014-05-12 11:30" xcc ÐÞ¸ÄÕæÐÄ»°´óðÏÕ£¬´ðÌâ·ÖÊý  | 
| # @change: "2014-05-19 15:30" xcc ½«Ò»Ð©´ðÌâ»î¶¯µÄдËÀµÄÅäÖÃÐÅÏ¢¿ªµ½ÅäÖÃÎļþÖÐ  | 
| # @change: "2014-11-13 11:00" hxp Ôö¼ÓÕæÐÄ»°³É¾Í  | 
| # @change: "2015-07-01 22:30" hxp Ð޸ĻÖÐËæÊ±¿É½øÈë´ðÌâ; Ê±¼äµ½Íæ¼Òδ´ðÌâÊ±Ëæ»ú°ïÍæ¼Ò´ðÌâ; ´ðÌâ³É¾Í£»Ôö¼ÓÈý±¶Ð§¹û1´Î  | 
| # @change: "2015-07-10 17:30" ljd ÅÅÐаñ¼ÓÍæ¼Òƽ̨²ÎÊýName2  | 
| #------------------------------------------------------------------------------------------------------------   | 
| """Version = 2015-07-10 17:30"""   | 
| #---------------------------------------------------------------------  | 
| import GameWorld  | 
| import ChConfig  | 
| import SubjectLib  | 
| import ShareDefine  | 
| import random  | 
| import ReadChConfig  | 
| import PlayerBillboard  | 
| import PlayerControl  | 
| import IPY_GameServer  | 
| #---------------------------------------------------------------------  | 
| (  | 
| Def_ExamStep_Close,               #´ðÌâ²½Öè, Î´¿ªÆô  | 
| Def_ExamStep_Wait,               #´ðÌâ²½Öè, µÈ´ýÍæ¼Ò½øÈë  | 
| Def_ExamStep_WaitCountDown,      #´ðÌâ²½Öè, ¿ªÊ¼µ¹¼ÆÊ±  | 
| Def_ExamStep_Begin,               #´ðÌâ²½Öè, ´ðÌ⿪ʼ  | 
| Def_ExamStep_Over,               #´ðÌâ²½Öè, ´ðÌâ½áÊø  | 
| ) = range(0, 4 + 1)  | 
|   | 
| #Ìâ¿â³¤¶È  | 
| Def_ExamSubjectLen = {  | 
|                       ShareDefine.Def_Game_Exam_ZGTX:1,      #ÖǹÚÌìÏ  | 
|                       ShareDefine.Def_Game_Exam_BSL:2,      #±äÉ«Áú  | 
|                       ShareDefine.Def_Game_Exam_JQBD:1,      #¾ÙÆì²»¶¨  | 
|                       ShareDefine.Def_Game_Exam_ZXH:0,      #ÕæÐÄ»°  | 
|                       }  | 
|   | 
| ##´ðÌâʱ¼ä(ºÁÃë)  | 
| #Def_ExamSubjectAnswerTick = {  | 
| #                      ShareDefine.Def_Game_Exam_ZGTX:1000*15,      #ÖǹÚÌìÏ  | 
| #                      ShareDefine.Def_Game_Exam_BSL:1000*5,      #±äÉ«Áú  | 
| #                      ShareDefine.Def_Game_Exam_JQBD:1000*10,      #¾ÙÆì²»¶¨  | 
| #                      ShareDefine.Def_Game_Exam_ZXH:1000*15,      #ÕæÐÄ»°(15Ãëºó»¹ÐèÒª5ÃëµÈ´ý·¢Ìâ, Õâʱºò¸øÍæ¼Ò¿´´ð°¸)  | 
| #                      }  | 
| #´ðÌâʱ¼ä(ºÁÃë)  | 
| Def_ExamSubjectAnswerTick = ReadChConfig.GetEvalChConfig("Exam_AnswerTick")  | 
|   | 
| ##´ðÌâ×î´óÊýÁ¿  | 
| #Def_ExamSubjectMaxCnt = {  | 
| #                      ShareDefine.Def_Game_Exam_ZGTX:10,      #ÖǹÚÌìÏ  | 
| #                      ShareDefine.Def_Game_Exam_BSL:18,      #±äÉ«Áú  | 
| #                      ShareDefine.Def_Game_Exam_JQBD:12,      #¾ÙÆì²»¶¨  | 
| #                      ShareDefine.Def_Game_Exam_ZXH:6,      #ÕæÐÄ»°  | 
| #                      }  | 
| #´ðÌâ×î´óÊýÁ¿  | 
| Def_ExamSubjectMaxCnt = ReadChConfig.GetEvalChConfig("Exam_SubjectMaxCnt")  | 
|   | 
| #´ðÌâ·ÖÊý¹«Ê½  | 
| Def_ExamSubjectMarkFormula = {  | 
|                       ShareDefine.Def_Game_Exam_ZGTX:'ZGTX_MarkFormula',      #ÖǹÚÌìÏ  | 
|                       ShareDefine.Def_Game_Exam_BSL:'BSL_MarkFormula',      #±äÉ«Áú  | 
|                       ShareDefine.Def_Game_Exam_JQBD:'JQBD_MarkFormula',      #¾ÙÆì²»¶¨  | 
|                       }  | 
|   | 
| ##´ðÌâ»î¶¯Ê±¼ä  | 
| #Def_ExamLastTime = {  | 
| #                      ShareDefine.Def_Game_Exam_ZGTX:1000*60*10,      #ÖǹÚÌìÏ  | 
| #                      ShareDefine.Def_Game_Exam_BSL:1000*60*9,      #±äÉ«Áú  | 
| #                      ShareDefine.Def_Game_Exam_JQBD:1000*60*10,      #¾ÙÆì²»¶¨  | 
| #                      ShareDefine.Def_Game_Exam_ZXH:1000*60*5,      #ÕæÐÄ»°  | 
| #                      }  | 
| #´ðÌâ»î¶¯Ê±¼ä  | 
| Def_ExamLastTime = ReadChConfig.GetEvalChConfig("Exam_LastTime")  | 
|   | 
| #´ðÌâʹÓÃÌØÊ⹦ÄÜ  | 
| Def_ExamUseFunc = {  | 
|                       ShareDefine.Def_Game_Exam_ZGTX:{  | 
|                                                         ShareDefine.Def_Game_Exam_Func_Double:1,  | 
|                                                         ShareDefine.Def_Game_Exam_Func_AnswerRight:1,  | 
|                                                         ShareDefine.Def_Game_Exam_Func_DelOper:0,  | 
|                                                         ShareDefine.Def_Game_Exam_Func_Three:1,  | 
|                                                         },        | 
|                       ShareDefine.Def_Game_Exam_BSL:{  | 
|                                                         ShareDefine.Def_Game_Exam_Func_Double:1,  | 
|                                                         ShareDefine.Def_Game_Exam_Func_AnswerRight:1,  | 
|                                                         ShareDefine.Def_Game_Exam_Func_DelOper:0,  | 
|                                                         ShareDefine.Def_Game_Exam_Func_Three:0,  | 
|                                                         },  | 
|                       ShareDefine.Def_Game_Exam_JQBD:{  | 
|                                                         ShareDefine.Def_Game_Exam_Func_Double:1,  | 
|                                                         ShareDefine.Def_Game_Exam_Func_AnswerRight:1,  | 
|                                                         ShareDefine.Def_Game_Exam_Func_DelOper:1,  | 
|                                                         ShareDefine.Def_Game_Exam_Func_Three:0,  | 
|                                                         },  | 
|                       ShareDefine.Def_Game_Exam_ZXH:{  | 
|                                                         ShareDefine.Def_Game_Exam_Func_Double:1,  | 
|                                                         ShareDefine.Def_Game_Exam_Func_AnswerRight:0,  | 
|                                                         ShareDefine.Def_Game_Exam_Func_DelOper:0,  | 
|                                                         ShareDefine.Def_Game_Exam_Func_Three:1,  | 
|                                                         },  | 
|                                                           | 
|                       }  | 
|   | 
| #¾ÙÆì²»¶¨Í¼Æ¬ÊýÁ¿  | 
| Def_Exam_JQBD_ImageCnt = 36  | 
|   | 
| #Íæ¼Òδ»Ø´ð±êʾ  | 
| Def_Exam_NoAnswersSign = 99  | 
|   | 
| ##´ðÌâ¹Ø±Õʱ¼ä  | 
| #Def_Tick_ExamPrepareWaitTime = 1000*60*4     #´ðÌâ×¼±¸µÚÒ»½×¶Îʱ¼ä  | 
| #Def_Tick_ExamPrepareCountDown = 1000*60*1    #´ðÌâ×¼±¸µÚ¶þ½×¶Îʱ¼ä, ²¥·Åµ¹¼ÆÊ±ÌØÐ§  | 
| #Def_Tick_ExamCloseTime = 1000*60*1           #´ðÌâ¹Ø±Õʱ¼ä  | 
| ##´ðÌâ¹Ø±Õʱ¼ä  | 
| Def_Tick_ExamPrepareWaitTime, \  | 
| Def_Tick_ExamPrepareCountDown, \  | 
| Def_Tick_ExamCloseTime = ReadChConfig.GetEvalChConfig("Exam_TimeSetting")  | 
|   | 
| #ÕæÐÄ»°´óðÏÕ  | 
| #µ±Ç°²ÎÓë´ðÌâµÄ×ÜÍæ¼ÒÊý  | 
| Def_ExamZXH_TotalAnswerCntKey = 'ExamZXH_TotalAnswerCntKey'  | 
| #µ±Ç°»Ø´ðµÚÒ»ÌâµÄÍæ¼ÒÊý  | 
| Def_ExamZXH_AnswerOneCntKey = 'ExamZXH_AnswerOneCntKey'  | 
| #µ±Ç°»Ø´ðµÚ¶þÌâµÄÍæ¼ÒÊý  | 
| Def_ExamZXH_AnswerTwoCntKey = 'ExamZXH_AnswerTwoCntKey'  | 
| #µ±Ç°»Ø´ðµÚÈýÌâµÄÍæ¼ÒÊý  | 
| Def_ExamZXH_AnswerThreeCntKey = 'ExamZXH_AnswerThreeCntKey'  | 
| #·¢Ë͵±Ç°×´Ì¬¸øÍæ¼Ò(10Ãë·¢ËÍ)  | 
| Def_ExamZXHSendRightAnswerTick = 1000 * 10  | 
| Def_ExamZXHSendRightAnswerkey = 'ExamZXH_SendRightAnswerkey'  | 
| #Íæ¼Ò¿´´ð°¸  | 
| Def_ExamZXHSeeAnswerTick = Def_ExamSubjectAnswerTick[ShareDefine.Def_Game_Exam_ZXH] + 1000 * 5  | 
| Def_ExamZXHSeeAnswerkey = 'Def_ExamZXHSeeAnswerkey'  | 
| #ÕæÐÄ»°·ÖÊý  | 
| #Def_ExamZXH_SuperWinPoint = 10  | 
| #Def_ExamZXH_WinPoint = 5  | 
| #Def_ExamZXH_FailPoint = 0  | 
| Def_ExamZXH_SuperWinPoint, \  | 
| Def_ExamZXH_WinPoint, \  | 
| Def_ExamZXH_FailPoint = ReadChConfig.GetEvalChConfig("Exam_ZXH_Point")  | 
| #---------------------------------------------------------------------  | 
|   | 
|   | 
| #---------------------------------------------------------------------  | 
| ##´ðÌâ״̬±ä»¯  | 
| # @param state ×´Ì¬(0¹Ø±Õ, Def_Game_Exam_Type)  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def Exam_ChangeState(state):  | 
|     # ¿ç·þ·þÎñÆ÷¹¦ÄÜÏÞÖÆ  | 
|     if GameWorld.IsCrossServer():  | 
|         return  | 
|       | 
|     if state == 0:  | 
|         #´ðÌâ¹Ø±ÕÓɳÌÐò×Ô¼º¹Ø±Õ__Exam_Close  | 
|         return  | 
|       | 
|     __Exam_Begin(state)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##´ðÌâ¹Ø±Õ  | 
| # @param examType ´ðÌâÀàÐÍ  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def __Exam_Close(examType, tick):  | 
|     #---´ðÌâ½áÊøTÈË---  | 
|     __DoLogic_ExamCloseKickPlayer(examType)  | 
|   | 
|     #---ÉèÖôðÌâ״̬---  | 
|     __SetExamStep(Def_ExamStep_Close, tick)  | 
|       | 
| #    GameWorld.Log('´ðÌâÀàÐÍ = %s, Def_ExamStep_Close'%(examType))  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##´ðÌâ½áÊøÌßÈË  | 
| # @param examType ´ðÌâÀàÐÍ  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def __DoLogic_ExamCloseKickPlayer(examType):  | 
|     examManager = GameWorld.GetGameWorld().GetPlayerExamManager()  | 
| #    GameWorld.Log("´ðÌâ½áÊø£¬·þÎñ¶Ë¿ªÊ¼ÌßÈË")  | 
|     for index in range(0, examManager.GetExamPlayerCount()):  | 
|         examPlayer = examManager.GetExamPlayer(index)  | 
|           | 
|         if not examPlayer or not examPlayer.GetInitOK():  | 
|             #Íæ¼Ò²»ÔÚÏß  | 
|             continue  | 
|           | 
|         #Çå³ýÍæ¼Ò´ðÌâ״̬  | 
|         examPlayer.GetPlayerExam().Clear()  | 
|         #֪ͨµØÍ¼·þÎñÆ÷ɾ³ýBuff  | 
|         examPlayer.MapServer_QueryPlayerResult(0, 0, 'ExamCloseKickPlayer', '', 0)  | 
|         #֪ͨ¿Í»§¶ËÍ˳ö´ðÌâ  | 
|         examPlayer.Sync_JoinActionOK(examType, False)  | 
|   | 
|     return  | 
| #---------------------------------------------------------------------  | 
| ##´ðÌ⿪ʼ  | 
| # @param examType ´ðÌâÀàÐÍDef_Game_Exam_Type  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def __Exam_Begin(examType):  | 
|     if examType not in ShareDefine.Def_Game_ExamTypeList:  | 
|         GameWorld.ErrLog('Ìâ¿âÒì³£, examType = %s, ÎÞ·¨¿ªÊ¼´ðÌâ'%(examType))  | 
|         return  | 
|       | 
|     gameWorld = GameWorld.GetGameWorld()  | 
|     tick = gameWorld.GetTick()  | 
|       | 
|     #ÉèÖñ¾´Î´ðÌâÀàÐÍ  | 
|     __SetExamType(examType)  | 
|       | 
|     #---³õʼ»¯´ðÌâ²½Öè---  | 
|     __SetExamStep(Def_ExamStep_Wait, tick)  | 
|       | 
|     #---³õʼ»¯ÒÑ·¢ÌâÄ¿---  | 
|     __ClearSendSubjectCnt()  | 
|       | 
|     #---³õʼ»¯¹ú¼Ò´ðÌâ¹ÜÀíÆ÷¶ÔÏó---  | 
|     gameWorld.GetPlayerExamManager().Clear()  | 
|       | 
|     #³õʼ»¯ÅÅÐаñ  | 
|     __ClearExamBillboard(examType)  | 
|       | 
|     #ÉèÖÿªÊ¼Ê±¼ä´Á  | 
|     __SetExamBeginTick(tick)  | 
|       | 
|     GameWorld.Log('´ðÌ⿪ʼ, examType = %s'%(examType))  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##Çå¿Õ´ðÌâÅÅÐаñ.  | 
| # @param examType ´ðÌâÀàÐÍ  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def __ClearExamBillboard(examType):  | 
|     billboardIndex = ChConfig.Def_ExamSubjectBTDict[examType]  | 
|   | 
|     billBoard = GameWorld.GetBillboard().FindBillboard(billboardIndex)  | 
|       | 
|     if not billBoard:  | 
|         GameWorld.ErrLog('__ClearExamBillboard, ÅÅÐаñ = %s ÎÞ·¨²éÕÒ'%(billboardIndex))  | 
|         return  | 
|   | 
|     billBoard.Clear()  | 
|     return  | 
| #---------------------------------------------------------------------  | 
| ##´ðÌⶨʱÆ÷  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def Exam_Process(tick):  | 
|     #´ðÌâ²½Öè  | 
|     examStep = __GetExamStep()  | 
|       | 
|     if examStep not in [Def_ExamStep_Wait, Def_ExamStep_WaitCountDown, Def_ExamStep_Begin, Def_ExamStep_Over]:  | 
|         #´ðÌâ먦Æô  | 
|         return  | 
|       | 
|     #---´ðÌâ×¼±¸µÚÒ»½×¶Î---  | 
|     if examStep == Def_ExamStep_Wait:  | 
|         __DoLogic_ExamWait(tick)  | 
|     #---´ðÌâ×¼±¸µÚ¶þ½×¶Î---  | 
|     elif examStep == Def_ExamStep_WaitCountDown:  | 
|         __DoLogic_ExamBeginCountDown(tick)  | 
|     #---´ðÌâÖÐ---  | 
|     elif examStep == Def_ExamStep_Begin:  | 
|         __DoLogic_ExamBegin(tick)  | 
|     #---´ðÌâÍê±Ï---  | 
|     elif examStep == Def_ExamStep_Over:  | 
|         __DoLogic_ExamOver(tick)  | 
|       | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##´ðÌâ½áÊø  | 
| # @param tick Ê±¼ä´Á  | 
| # @return None  | 
| # @remarks   | 
| def __DoLogic_ExamOver(tick):  | 
|     if tick - __GetExamStepTick() < Def_Tick_ExamCloseTime:  | 
|         return  | 
|     GameWorld.Log("´ðÌâ½áÊø£¬ÉèÖø±±¾Îª¹Ø±Õ״̬")  | 
|     examType = __GetExamType()  | 
|       | 
|     #֪ͨËùÓдðÌâÍæ¼Ò´ðÌâ½áÊø  | 
|     examManager = GameWorld.GetGameWorld().GetPlayerExamManager()  | 
|     examManager.Broadcast_EndExam(examType)  | 
|       | 
|     #ÉèÖø±±¾Îª¹Ø±Õ״̬  | 
|     __Exam_Close(examType, tick)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##´ðÌâÖÐ  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ÎÞ·µ»ØÖµ  | 
| # @remarks   | 
| def __DoLogic_ExamBegin(tick):  | 
|     sendSubjectCnt = __GetSendSubjectCnt()  | 
|       | 
|     if sendSubjectCnt == 0:  | 
|         #µÚÒ»ÌâÖ±½Ó·¢ËÍÌâÄ¿  | 
| #        GameWorld.Log("·¢Ë͵ÚÒ»µÀÌâ")  | 
|         __SendSubject(tick)  | 
|         return  | 
|       | 
|     gameWorld = GameWorld.GetGameWorld()  | 
|       | 
|     #´ðÌâ¹ÜÀíÆ÷  | 
|     examManager = GameWorld.GetGameWorld().GetPlayerExamManager()  | 
|       | 
|     #±¾´Î´ðÌâÀàÐÍ  | 
|     examType = __GetExamType()  | 
|       | 
|     #±¾´Î´ðÌâ¹ýȥʱ¼ä  | 
|     examSendSubjectLostTick = tick - examManager.GetSendSubjectTick()  | 
|       | 
|     #ÕæÐÄ»°´óðÏÕÉèÖÿ¨×¡, ¸øÍæ¼Ò¿´´ð°¸  | 
|     if examType == ShareDefine.Def_Game_Exam_ZXH and gameWorld.GetDictByKey(Def_ExamZXHSeeAnswerkey):  | 
|           | 
|         if examSendSubjectLostTick < Def_ExamZXHSeeAnswerTick:  | 
|             #ÕæÐÄ»°´óðÏÕ¿¨×¡5Ãë  | 
|             return  | 
|           | 
|         #·¢ËÍÏÂÒ»Ìâ  | 
|         __SendNextSubject(examManager, examType, sendSubjectCnt, tick)  | 
|         return  | 
|       | 
|     #ĬÈϻشð  | 
|     if examSendSubjectLostTick < Def_ExamSubjectAnswerTick[examType]:  | 
|           | 
|         if examType == ShareDefine.Def_Game_Exam_ZXH:  | 
|             #ÕæÐÄ»°´óðÏÕÌØÊâ´¦Àí, Òª·¢ËÍÒ»´Îµ±Ç°Ñ¡ÏîÇé¿ö¸øÍæ¼Ò  | 
|             __ExamZXH_SendSelectOption(examSendSubjectLostTick)  | 
|           | 
|         #·¢ÏÂÒ»Ìâ·¢Ìâʱ¼äδµ½  | 
|         return  | 
|       | 
|     #ÕýÈ·´ð°¸  | 
|     rightAnswer = examManager.GetRightAnswer()  | 
|     #´ðÌâÅÅÐаñ  | 
|     billboardIndex = ChConfig.Def_ExamSubjectBTDict[examType]  | 
|     #²Î¼Ó´ðÌâµÄÍæ¼ÒÁÐ±í  | 
|     examPlayerList = []  | 
|       | 
|     for index in range(0, examManager.GetExamPlayerCount()):  | 
|         examPlayer = examManager.GetExamPlayer(index)  | 
|           | 
|         if not examPlayer or not examPlayer.GetInitOK():  | 
|             #Íæ¼Ò²»ÔÚÏß  | 
|             continue  | 
|           | 
|         examPlayerList.append(examPlayer)  | 
|       | 
|     #¼ì²éÍæ¼Ò´ð°¸  | 
|     for curPlayer in examPlayerList:  | 
|         __CheckPlayerAnswer(curPlayer, rightAnswer, billboardIndex, tick)  | 
|       | 
|     #ÅÅÐòÅÅÐаñ  | 
|     PlayerBillboard.SortBillboardByIndex(billboardIndex)  | 
|       | 
|     #±éÀúÅÅÐаñÖеÄÍæ¼Ò, ÉèÖÃÍæ¼ÒÅÅÃû  | 
|     SetPlayerBillboardIndex(billboardIndex)  | 
|       | 
|     for curPlayer in examPlayerList:  | 
|         #¹ã²¥ÅÅÐаñ¸ø¿Í»§¶Ë(µÚÒ»Ò³)  | 
|         curPlayer.Sync_Billboard(billboardIndex)  | 
|       | 
|     #¹ã²¥ËùÓÐÍæ¼Ò´ðÌâ½á¹û  | 
|     examManager.Broadcast_ExamResult()  | 
|       | 
|     #ÕæÐÄ»°´óðÏÕÉèÖõȴý±ê¼Çλ  | 
|     if examType == ShareDefine.Def_Game_Exam_ZXH:  | 
|         if gameWorld.GetDictByKey(Def_ExamZXHSeeAnswerkey) == 0:  | 
|             #ÕâÀ│ס²»Ö´ÐÐÂß¼  | 
|             __ExamZXH_SendSeeAnswer(tick)  | 
|             return  | 
|           | 
|         GameWorld.ErrLog('-----------ÕæÐÄ»°´óðÏÕÂß¼Òì³£, ÑÓ³Ù·¢Ìâʧ°ÜÖ±½Ó·¢Ìâ, ±¯¾ç---------')  | 
|   | 
|     #·¢ËÍÏÂÒ»ÌâÄ¿  | 
|     __SendNextSubject(examManager, examType, sendSubjectCnt, tick)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##·¢ËÍÏÂÒ»ÌâÄ¿  | 
| # @param examManager ´ðÌâ¹ÜÀíÆ÷  | 
| # @param examType ´ðÌâÀàÐÍ  | 
| # @param sendSubjectCnt ·¢Ë͵ÄÌâÄ¿Êý  | 
| # @param tick Ê±¼ä´í  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks ¿Í»§¶Ë·â°üÏìÓ¦  | 
| def __SendNextSubject(examManager, examType, sendSubjectCnt, tick):  | 
|     #È«²¿ÌâÄ¿¶¼·¢ÍêÁË  | 
|     if sendSubjectCnt == Def_ExamSubjectMaxCnt[examType]:  | 
|         #¸øÍæ¼Ò½±Àø  | 
|         GivePlayerReward(examType)  | 
|           | 
|         #ÉèÖôðÌâ²½Öè  | 
|         __SetExamStep(Def_ExamStep_Over, tick)  | 
|           | 
| #        GameWorld.Log('´ðÌâÀàÐÍ = %s, Def_ExamStep_Over sendSubjectCnt = %s'%(examType, sendSubjectCnt))  | 
|         return  | 
|       | 
|     #·¢ËÍÌâÄ¿  | 
| #    GameWorld.Log('·¢ËÍÏÂÒ»ÌâÌâÄ¿')  | 
|     __SendSubject(tick)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##¸øÍæ¼Ò½±Àø  | 
| # @param examType ´ðÌâÀàÐÍ  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def GivePlayerReward(examType):  | 
|     #GameWorld.Log("¸ø²Î¼Ó»î¶¯µÄÍæ¼Ò½±Àø")  | 
|     # ÅÅÐаñ  | 
|     billboardIndex = ChConfig.Def_ExamSubjectBTDict[examType]  | 
|     billBoard = GameWorld.GetBillboard().FindBillboard(billboardIndex)  | 
|       | 
|     #´ðÌâ¹ÜÀíÆ÷  | 
|     examManager = GameWorld.GetGameWorld().GetPlayerExamManager()  | 
|       | 
|     for index in range(0, examManager.GetExamPlayerCount()):  | 
|         curPlayer = examManager.GetExamPlayer(index)  | 
|           | 
|         if not curPlayer or not curPlayer.GetInitOK():  | 
|             #Íæ¼Ò²»ÔÚÏß  | 
|             continue  | 
|           | 
|         if billBoard:  | 
|             billBoardIndex = curPlayer.GetPlayerExam().GetBillboardIndex()  | 
|             # ÕæÐÄ»°µÚÒ»Ãû³É¾Í  | 
| #            if examType in [ShareDefine.Def_Game_Exam_ZXH, ShareDefine.Def_Game_Exam_ZGTX] and billBoardIndex == 0:  | 
| #                PlayerControl.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_ZXHFirst, 1)  | 
|           | 
|         # »ñµÃ´ðÌâ¶Ô´íÊýÁ¿  | 
|         rightCnt = curPlayer.GetDictByKey(ChConfig.Def_Player_NoSave_Dict_PlayerExamRightCnt%examType)  | 
|         examResult = (rightCnt, Def_ExamSubjectMaxCnt.get(examType, 0) - rightCnt)  | 
|           | 
|         #¸øÍæ¼Ò½±Àø[´ðÌâÀàÐÍ, »ý·Ö]  | 
|         sendMsg = '%s'%[examType, curPlayer.GetPlayerExam().GetMark(), examResult]  | 
|         curPlayer.MapServer_QueryPlayerResult(0, 0, 'ExamGivePlayerReward',  | 
|                                                sendMsg, len(sendMsg))  | 
|           | 
|         #GeRen_liubo_570355 ´ðÌâ»î¶¯ÒѾ½áÊø, ¸ÐлÄúµÄ²ÎÓë!  | 
|         PlayerControl.NotifyCode(curPlayer, "GeRen_liubo_570355")  | 
|           | 
|         #·¢ËÍÀ뿪µ¹¼ÆÊ±  | 
|         curPlayer.Sync_TimeTick(ShareDefine.Def_TimeTickType_ExamLeaveMap, 0, Def_Tick_ExamCloseTime, True)   | 
|       | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##¹ã²¥²Î¼Ó´ðÌâµÄÍæ¼Òµ¹¼ÆÊ±.  | 
| # @param tickType µ¹¼ÆÊ±ÀàÐÍ  | 
| # @param lastTick ³ÖÐøÊ±¼ä  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def __Sync_ExamPlayerTimeTick(tickType, lastTick):  | 
|     #´ðÌâ¹ÜÀíÆ÷  | 
|     examManager = GameWorld.GetGameWorld().GetPlayerExamManager()  | 
| #    GameWorld.Log("¹ã²¥µ¹¼ÆÊ±")  | 
|     for index in range(0, examManager.GetExamPlayerCount()):  | 
|         curPlayer = examManager.GetExamPlayer(index)  | 
|           | 
|         if not curPlayer or not curPlayer.GetInitOK():  | 
|             #Íæ¼Ò²»ÔÚÏß  | 
|             continue  | 
|           | 
|         curPlayer.Sync_TimeTick(tickType, 0, lastTick, True)   | 
|   | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##ÉèÖÃÍæ¼ÒÅÅÐаñË÷Òý  | 
| # @param billboardIndex ÅÅÐаñË÷Òý  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def SetPlayerBillboardIndex(billboardIndex):  | 
|     billBoard = GameWorld.GetBillboard().FindBillboard(billboardIndex)  | 
|   | 
|     if not billBoard:  | 
|         GameWorld.ErrLog('SetPlayerBillboardIndex, ÅÅÐаñ = %s ÎÞ·¨²éÕÒ'%(billboardIndex))  | 
|         return  | 
|   | 
|     playerManager = GameWorld.GetPlayerManager()  | 
|   | 
|     for index in range(0, billBoard.GetCount()):  | 
|         billboardData = billBoard.At(index)  | 
|         curPlayer = playerManager.FindPlayerByID(billboardData.GetID())  | 
|   | 
|         if not curPlayer:  | 
|             #ûÕÒµ½Íæ¼Ò  | 
|             continue  | 
|   | 
|         curPlayer.GetPlayerExam().SetBillboardIndex(index)   | 
|   | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##¼ì²éÍæ¼Ò´ð°¸  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param rightAnswer ÕýÈ·´ð°¸  | 
| # @param billBoardIndex ÅÅÐаñÀàÐÍ  | 
| # @param tick Ê±¼ä´Á  | 
| # @return  | 
| # @remarks  | 
| def __CheckPlayerAnswer(curPlayer, rightAnswer, billboardIndex, tick):  | 
|     #´ðÌ⹦ÄÜö¾Ù Def_Game_Exam_Func_Cnt  | 
|     playerExamMgr = curPlayer.GetPlayerExam()  | 
| #    GameWorld.Log("¼ì²éÍæ¼Ò´ð°¸")  | 
|     #´ðÌâÀàÐÍ  | 
|     examType = __GetExamType()  | 
|       | 
|     if playerExamMgr.GetExtraOpt2():  | 
|         #ʹÓÃÌø¹ý¹¦ÄÜ  | 
|         isAnswerRight = True  | 
|     else:  | 
|         currentAnswer = playerExamMgr.GetCurrentAnswer()  | 
|         # Èç¹ûÍæ¼Òû´ðÌ⣬ÔòËæ»ú°ïÍæ¼Òѡһ¸ö  | 
|         if examType == ShareDefine.Def_Game_Exam_ZGTX and currentAnswer == Def_Exam_NoAnswersSign:  | 
|             currentAnswer = random.randint(1, 4)  | 
|             playerExamMgr.SetCurrentAnswer(currentAnswer)  | 
|             playerExamMgr.SetAnswerSubjectTick(max(0,   | 
|                                     tick - GameWorld.GetGameWorld().GetPlayerExamManager().GetSendSubjectTick()))  | 
|             #GameWorld.DebugLog("Ëæ»ú°ïÍæ¼ÒÑ¡Ôñ´ð°¸: %s, ÕýÈ·´ð°¸: %s" % (currentAnswer, rightAnswer))  | 
|               | 
|         isAnswerRight = (currentAnswer == rightAnswer)  | 
|       | 
|     # ÕýÈ·Êý¼Ó1(ÕæÐÄ»°´óðÏÕÌØÊâ´¦Àí)  | 
|     playerDictKey = ChConfig.Def_Player_NoSave_Dict_PlayerExamRightCnt%examType  | 
|     if isAnswerRight and examType != ShareDefine.Def_Game_Exam_ZXH:  | 
|         curPlayer.SetDict(playerDictKey, curPlayer.GetDictByKey(playerDictKey) + 1)  | 
|       | 
|     #¼ÆËãÍæ¼Ò´ðÌâ»ý·Ö  | 
|     curMark = __GetExamMark(playerExamMgr, isAnswerRight)  | 
|       | 
|     # ÕæÐÄ»°ÖÐÖ»Òª¼Ó·Ö¾ÍËã´ð¶Ô  | 
|     if curMark > 0 and examType == ShareDefine.Def_Game_Exam_ZXH:  | 
|         curPlayer.SetDict(playerDictKey, curPlayer.GetDictByKey(playerDictKey) + 1)  | 
|           | 
|     if examType == ShareDefine.Def_Game_Exam_ZXH:  | 
|         isRight = (curMark > 0)  | 
|     else:  | 
|         isRight = isAnswerRight  | 
|           | 
|     # Á¬Ðø´ð¶Ôͳ¼Æ  | 
|     examCRightCntKey = ChConfig.Def_Player_NoSave_Dict_PlayerExamCRightCnt % examType  | 
|     updCRightCnt = 0 if not isRight else curPlayer.GetDictByKey(examCRightCntKey) + 1  | 
|     curPlayer.SetDict(examCRightCntKey, updCRightCnt)  | 
|     # ÕæÐÄ»°Á¬Ðø´ð¶ÔxÌâ³É¾Í(10ÌâÒÔÉϲÅͬ²½)  | 
| #    if examType in [ShareDefine.Def_Game_Exam_ZXH, ShareDefine.Def_Game_Exam_ZGTX] and updCRightCnt >= 10:  | 
| #        PlayerControl.DoAddSuccessProgress(curPlayer, ShareDefine.SuccType_ZXHConRight, 1, updCRightCnt)  | 
|           | 
|     if curMark != 0:  | 
|         #»ý·ÖÓпÉÄÜΪ¸ºÊý  | 
|         playerExamMgr.SetMark(max(0, playerExamMgr.GetMark() + curMark))  | 
|         #Íæ¼Ò»ý·Ö²åÈëÅÅÐаñ  | 
|         PlayerBillboard.UpdatePlayerBillboard(curPlayer.GetID(), curPlayer.GetName(), curPlayer.GetOperateInfo(),  | 
|                                                billboardIndex, 0, 0, playerExamMgr.GetMark(),  | 
|                                                 playerExamMgr.GetMark(), autoSort = False)  | 
|       | 
|     #ÉèÖÃÍæ¼Ò´ðÌâÊôÐÔ  | 
|     playerExamMgr.SetExtraOpt1(0)  | 
|     playerExamMgr.SetExtraOpt2(0)  | 
|     playerExamMgr.SetExtraOpt3(0)  | 
|     playerExamMgr.SetExtraOpt4(0)  | 
|     playerExamMgr.SetCurrentAnswer(Def_Exam_NoAnswersSign)  | 
|     playerExamMgr.SetAnswerSubjectTick(0)  | 
|     playerExamMgr.SetIsSuccess(isAnswerRight)  | 
|     playerExamMgr.SetBillboardIndex(ShareDefine.Def_Game_Exam_NoInBillboardSign)  | 
|     #ÉèÖÃÊÇ·ñ¿ÉÒÔÔÙ´ÎÑ¡Ôñ´ð°¸  | 
|     playerExamMgr.SetCombo(0)                 | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##»ñµÃ´ðÌâµÄ»ý·Ö.  | 
| # @param playerExamMgr Íæ¼Ò´ðÌâ¹ÜÀíÆ÷  | 
| # @param isAnswerRight ÊÇ·ñ»Ø´ðÕýÈ·  | 
| # @return ±¾Ìâ»ñµÃµÄ»ý·Ö  | 
| # @remarks   | 
| def __GetExamMark(playerExamMgr, isAnswerRight):  | 
|     #´ðÌâÀàÐÍ  | 
|     examType = __GetExamType()  | 
|       | 
|     #---ÕæÐÄ»°¹¦ÄÜÌØÊâ´¦Àí---  | 
|     if examType == ShareDefine.Def_Game_Exam_ZXH:  | 
|         curMark = __GetExamZXHMark(playerExamMgr.GetCurrentAnswer())  | 
|     else:  | 
|         #·ÖÊý¼ÆËã, ¸ù¾Ý´ðÌâʱ¼ä¸øÓè  | 
|         curMark = __GetPlayerAnswerMark(isAnswerRight, playerExamMgr.GetAnswerSubjectTick())  | 
|       | 
|     #ʹÓÃË«±¶¹¦ÄÜ  | 
|     if playerExamMgr.GetExtraOpt1():  | 
|         curMark = curMark * 2  | 
|     #ʹÓÃÈý±¶¹¦ÄÜ  | 
|     elif playerExamMgr.GetExtraOpt4():  | 
|         curMark = curMark * 3  | 
|           | 
|     return curMark  | 
| #---------------------------------------------------------------------  | 
| ##»ñµÃÕæÐÄ»°´ðÌâµÄ»ý·Ö.  | 
| # @param playerAnswer Íæ¼ÒµÄÑ¡Ïî  | 
| # @return ±¾Ìâ»ñµÃµÄ»ý·Ö  | 
| # @remarks   | 
| def __GetExamZXHMark(playerAnswer):  | 
|     addMark = 0  | 
|       | 
|     if playerAnswer == Def_Exam_NoAnswersSign:  | 
|         #Íæ¼ÒÎÞÑ¡Ôñ  | 
|         return addMark  | 
|       | 
|     answerOnePer, answerTwoPer, answerThreePer = __GetExamZXH_AnswerScale()  | 
|       | 
|     if playerAnswer == 1:  | 
|         playerAnswerPer = answerOnePer  | 
|       | 
|     elif playerAnswer == 2:  | 
|         playerAnswerPer = answerTwoPer   | 
|       | 
|     elif playerAnswer == 3:  | 
|         playerAnswerPer = answerThreePer   | 
|       | 
|     else:  | 
|         GameWorld.ErrLog('__GetExamZXHMark playerAnswer = %s'%(playerAnswer))  | 
|         return addMark  | 
|       | 
|     #¹¹½¨×îСѡÏîºÍ×î´óÑ¡ÏîÁÐ±í  | 
|     answerList = [answerOnePer, answerTwoPer, answerThreePer]  | 
|     answerList.sort()  | 
|     answerMinPer = answerList[0]  | 
|     answerMaxPer = answerList[-1]  | 
|           | 
|     #Õý³£Çé¿ö3¸öÑ¡Ïî²»Ò»Ö  | 
|     if answerOnePer != answerTwoPer and answerOnePer != answerThreePer and answerThreePer != answerTwoPer:  | 
|         if playerAnswerPer == answerMinPer:  | 
|             return Def_ExamZXH_SuperWinPoint  | 
|           | 
|         if playerAnswerPer == answerMaxPer:  | 
|             return Def_ExamZXH_FailPoint  | 
|           | 
|         return Def_ExamZXH_WinPoint  | 
|       | 
|     #ÓÐ2¸öÑ¡ÏîÒ»ÖÂ(3¸öÑ¡ÏîÒ»Ö²»¿ÉÄÜ)  | 
|     if playerAnswerPer == answerMinPer:  | 
|         return Def_ExamZXH_SuperWinPoint  | 
|   | 
|     return Def_ExamZXH_WinPoint  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##»ñÈ¡Íæ¼Ò±¾´Î´ðÌâ·ÖÊý  | 
| # @param isAnswerRight ÊÇ·ñ´ð¶Ô  | 
| # @param lostTick Ê¹ÓõĺÁÃë  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks »ñÈ¡Íæ¼Ò±¾´Î´ðÌâ·ÖÊý  | 
| def __GetPlayerAnswerMark(isAnswerRight, lostTick):  | 
|     if not isAnswerRight:  | 
|         #»Ø´ð´íÎóÎÞ»ý·Ö  | 
|         return 0  | 
|       | 
|     examType = __GetExamType()  | 
|     foumulaStr = Def_ExamSubjectMarkFormula.get(examType)  | 
|       | 
|     if not foumulaStr:  | 
|         GameWorld.ErrLog('examType = %s, NoFindMarkFormul'%(examType))  | 
|         return 0  | 
|   | 
|     foumula = ReadChConfig.GetChConfig(foumulaStr)  | 
|     return int(eval(foumula))  | 
| #---------------------------------------------------------------------  | 
| ##´ðÌâ×¼±¸ÖÐÂß¼´¦Àí  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def __DoLogic_ExamWait(tick):  | 
|     if tick - __GetExamStepTick() < Def_Tick_ExamPrepareWaitTime:  | 
|         return  | 
|       | 
|     GameWorld.Log('´ðÌâÀàÐÍ = %s, Def_ExamStep_WaitCountDown'%(__GetExamType()))  | 
|       | 
|     #½øÈë´ðÌâµ¹¼ÆÊ±½×¶Î  | 
|     __SetExamStep(Def_ExamStep_WaitCountDown, tick)  | 
|       | 
|     #֪ͨËùÓÐÍæ¼Ò²¥·Åµ¹¼ÆÊ±ÌØÐ§  | 
|     __Sync_ExamPlayerTimeTick(ShareDefine.Def_TimeTickType_ExamBeginCountDown, Def_Tick_ExamPrepareCountDown)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##´ðÌâ×¼±¸Öе¹¼ÆÊ±´¦Àí  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def __DoLogic_ExamBeginCountDown(tick):  | 
|     if tick - __GetExamStepTick() < Def_Tick_ExamPrepareCountDown:  | 
|         return  | 
|       | 
|     examType = __GetExamType()  | 
|       | 
|     GameWorld.Log('´ðÌâÀàÐÍ = %s, Def_ExamStep_Begin'%(examType))  | 
|       | 
|     #´ðÌ⿪ʼ  | 
|     __SetExamStep(Def_ExamStep_Begin, tick)  | 
|   | 
|     # ³õʼ´ð¶ÔÌâÄ¿Êý  | 
|     __ClearPlayerRightCnt(examType)  | 
|           | 
|     gameWorld = GameWorld.GetGameWorld()  | 
|     examManager = gameWorld.GetPlayerExamManager()  | 
|     examManager.Broadcast_BeginExam(examType)  | 
|       | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##·¢ËÍÌâÄ¿.  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ÎÞÒâÒå  | 
| # @remarks   | 
| def __SendSubject(tick):  | 
|     examManager = GameWorld.GetGameWorld().GetPlayerExamManager()  | 
|       | 
|     #±¾´Î´ðÌâÀàÐÍ  | 
|     examType = __GetExamType()  | 
|       | 
|     #ÕæÐÄ»°·¢ÌâÄ¿µÄʱºòÇå³ýÉÏ»ØÍæ¼Ò²ÎÓë»Ø´ðµÄÊýÁ¿  | 
|     if examType == ShareDefine.Def_Game_Exam_ZXH:  | 
|         __ClearExamZXH_SaveDict()  | 
|   | 
|     #³éÈ¡ÌâÄ¿  | 
|     subjectTuple = SubjectLib.GetSubject(examType)  | 
|       | 
|     if not subjectTuple:  | 
|         #»ñÈ¡ÌâÄ¿Òì³£  | 
|         return  | 
|       | 
|     subjectIndex, subjectList = subjectTuple  | 
|       | 
|     #ÉèÖõ±Ç°·¢ÌâÐòºÅ×Öµä  | 
|     __AddSendSubjectCnt(tick)  | 
|     #ÉèÖñ¾´Î·¢ÌâË÷Òý  | 
|     examManager.SetQuestionIndex(__GetSendSubjectCnt())  | 
|       | 
|     if len(subjectList) != Def_ExamSubjectLen[examType]:  | 
|         #Ìâ¿âÒì³£  | 
|         GameWorld.ErrLog('²ß»®Ìâ¿â = %s ÌâÄ¿ = %s, ÅäÖôíÎó'%(examType, subjectIndex))  | 
|         return  | 
|       | 
|     #ÕæÐÄ»°´óðÏÕÎÞÕýÈ·´ð°¸  | 
|     if examType != ShareDefine.Def_Game_Exam_ZXH:  | 
|         #ĬÈϵÚÒ»¸öÔªËØ¶¼ÎªÕýÈ·´ð°¸  | 
|         examManager.SetRightAnswer(subjectList[0])  | 
|       | 
|     #¸½¼ÓÌõ¼þ1ÓÃÓÚ´¢´æµ±Ç°ÌâºÅ  | 
|     examManager.SetQuestionExrtaValue1(subjectIndex)  | 
|       | 
|     #±äÉ«Áú¸½¼ÓÌõ¼þ2ÓÃÓÚ´¢´æÑÕÉ«  | 
|     if examType == ShareDefine.Def_Game_Exam_BSL:  | 
|         examManager.SetQuestionExrtaValue2(subjectList[1])  | 
|     #¾ÙÆì²»¶¨¸½¼þÌõ¼þ2,3,4ÓÃÓÚËæ¼´³éȡͼƬË÷Òý  | 
|     elif examType == ShareDefine.Def_Game_Exam_JQBD:  | 
|         imageIndexList = __GetExam_JQBD_ImageList(subjectList[0])  | 
|         examManager.SetQuestionExrtaValue2(imageIndexList[0])  | 
|         examManager.SetQuestionExrtaValue3(imageIndexList[1])  | 
|         examManager.SetQuestionExrtaValue4(imageIndexList[2])  | 
|         examManager.SetQuestionExrtaValue5(imageIndexList[3])  | 
| #    GameWorld.Log('examManager.Broadcast_QuestionToAllPlayer()')  | 
|     #¹ã²¥Íæ¼Ò´ðÌâÌâÄ¿  | 
|     examManager.Broadcast_QuestionToAllPlayer()  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##¾ÙÆì²»¶¨Í¼Æ¬³éÈ¡  | 
| # @param rightAnswer ÕýÈ·Ë÷Òý  | 
| # @return [1,2,3,4]ÁÐ±í³¤¶È±ØÐëÊÇ4  | 
| # @remarks   | 
| def __GetExam_JQBD_ImageList(rightAnswer):  | 
|     #Ò»¸öÕýÈ·µÄË÷Òý, ´ÓÁíÍâ36ÕÅͼƬÖгéÈ¡3ÕÅ, ºÍÕýÈ·Ë÷Òý×é³ÉÁÐ±í  | 
|     rangeList = range(1, Def_Exam_JQBD_ImageCnt + 1)  | 
|       | 
|     if rightAnswer not in rangeList:  | 
|         GameWorld.ErrLog('JQBD£¬ ²ß»®Ìâ¿âÅäÖÃÒì³£, rightAnswer = %s'%(rightAnswer))  | 
|         return rangeList[0:4]  | 
|       | 
|     #ɾ³ýÕýÈ·ÔªËØ  | 
|     rangeList.remove(rightAnswer)  | 
|     #Ëæ»úÔÚÈ¡3¸ö  | 
|     returnList = random.sample(rangeList, 3)  | 
|     #½«ÕýÈ·´ð°¸Ëæ»ú²åÈëÁбíÖÐ  | 
|     returnList.insert(random.randint(0, 3), rightAnswer)  | 
|     return returnList  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##ÉèÖôðÌâ²½Öè.  | 
| # @param step ²½ÖèDef_ExamStep   | 
| # @param tick Ê±¼ä´Á  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def __SetExamStep(step, tick):  | 
|     gameWorld = GameWorld.GetGameWorld()  | 
|     gameWorld.SetDict(ChConfig.Def_WorldKey_ExamStep, step)  | 
|     gameWorld.SetDict(ChConfig.Def_WorldKey_ExamStepTick, tick)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##»ñÈ¡´ðÌâ²½Öè.  | 
| # @param ÎÞ²ÎÊý   | 
| # @return ²½ÖèDef_ExamStep  | 
| # @remarks   | 
| def __GetExamStep():  | 
|     return GameWorld.GetGameWorld().GetDictByKey(ChConfig.Def_WorldKey_ExamStep)  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##»ñÈ¡´ðÌâ²½ÖèTick  | 
| # @param ÎÞ²ÎÊý   | 
| # @return Ê±¼ä´Á  | 
| # @remarks   | 
| def __GetExamStepTick():  | 
|     return GameWorld.GetGameWorld().GetDictByKey(ChConfig.Def_WorldKey_ExamStepTick)  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##ÉèÖôðÌâÀàÐÍ.  | 
| # @param examType ´ðÌâÀàÐÍDef_Game_Exam_Type  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def __SetExamType(examType):  | 
|     GameWorld.GetGameWorld().SetDict(ChConfig.Def_WorldKey_ExamType, examType)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##»ñÈ¡´ðÌâÀàÐÍ.  | 
| # @param ÎÞ²ÎÊý  | 
| # @return Def_Game_Exam_Type  | 
| # @remarks   | 
| def __GetExamType():  | 
|     return GameWorld.GetGameWorld().GetDictByKey(ChConfig.Def_WorldKey_ExamType)  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##ÉèÖôðÌ⿪ʼʱ¼ä´ê.  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def __SetExamBeginTick(tick):  | 
|     GameWorld.GetGameWorld().SetDict(ChConfig.Def_WorldKey_ExamBeginTick, tick)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##³õÊ¼Íæ¼Ò´ð¶ÔÌâÊý  | 
| # @param examType  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| def __ClearPlayerRightCnt(examType):  | 
|   | 
|     examManager = GameWorld.GetGameWorld().GetPlayerExamManager()  | 
|     for index in range(0, examManager.GetExamPlayerCount()):  | 
|         examPlayer = examManager.GetExamPlayer(index)  | 
|       | 
|         if not examPlayer or not examPlayer.GetInitOK():  | 
|             #Íæ¼Ò²»ÔÚÏß  | 
|             continue  | 
|         examPlayer.SetDict(ChConfig.Def_Player_NoSave_Dict_PlayerExamRightCnt%examType, 0)  | 
|         examPlayer.SetDict(ChConfig.Def_Player_NoSave_Dict_PlayerExamCRightCnt%examType, 0)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##»ñÈ¡´ðÌ⿪ʼʱ¼ä´Á.  | 
| # @param ÎÞ²ÎÊý  | 
| # @return tick  | 
| # @remarks   | 
| def __GetExamBeginTick():  | 
|     return GameWorld.GetGameWorld().GetDictByKey(ChConfig.Def_WorldKey_ExamBeginTick)  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##ÉèÖôðÌâ×ÜÊý  | 
| # @param µ±Ç°Ê±¼ä´Á  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def __AddSendSubjectCnt(tick):  | 
|     gameWorld = GameWorld.GetGameWorld()  | 
|     #ÉèÖ÷¢ÌâÊý  | 
|     gameWorld.SetDict(ChConfig.Def_WorldKey_ExamSendSubjectCnt, __GetSendSubjectCnt() + 1)  | 
|     #ÉèÖ÷¢Ìâ¼ä¸ô  | 
|     gameWorld.GetPlayerExamManager().SetSendSubjectTick(tick)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##Çå³ý×ÜÊý  | 
| # @param ÎÞ²ÎÊý  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def __ClearSendSubjectCnt():  | 
|     #ÉèÖ÷¢ÌâÊý  | 
|     GameWorld.GetGameWorld().SetDict(ChConfig.Def_WorldKey_ExamSendSubjectCnt, 0)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##»ñÈ¡´ðÌâ×ÜÊý  | 
| # @param ÎÞ²ÎÊý  | 
| # @return ´ðÌâÊý  | 
| # @remarks   | 
| def __GetSendSubjectCnt():  | 
|     return GameWorld.GetGameWorld().GetDictByKey(ChConfig.Def_WorldKey_ExamSendSubjectCnt)  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##µØÍ¼·þÎñÆ÷ÇëÇóÍ˳ö´ðÌâ»î¶¯.  | 
| # @param curPlayerID Íæ¼ÒID  | 
| # @return None  | 
| # @remarks   | 
| def MapServer_ExitAction(curPlayerID):  | 
|     #´ðÌâ¹ÜÀíÆ÷  | 
|     examManager = GameWorld.GetGameWorld().GetPlayerExamManager()  | 
|     #´ðÌâ¹ÜÀíÆ÷ɾ³ýÍæ¼Ò  | 
|     if examManager.FindExamPlayerByID(curPlayerID):  | 
|         examManager.DeleteExamPlayerByID(curPlayerID)  | 
|     else:  | 
|         GameWorld.ErrLog('MapServer_ExitExam PlayerNoInExam = %s'%(curPlayerID))  | 
|   | 
|     #Íæ¼ÒʵÀý  | 
|     curPlayer = GameWorld.GetPlayerManager().FindPlayerByID(curPlayerID)  | 
|           | 
|     if not curPlayer:  | 
|         #Íæ¼ÒÒѾÏÂÏß  | 
|         return  | 
|           | 
|     playeExamMgr = curPlayer.GetPlayerExam()  | 
|       | 
|     if not playeExamMgr.GetIsExaming():  | 
|         #GameWorld.Log('MapServer_ExitExam, Íæ¼Ò²»ÔÚ´ðÌâ»î¶¯ÖÐ', curPlayer.GetID())  | 
|         return  | 
|   | 
|     #Çå¿ÕÍæ¼Ò´ðÌâ״̬  | 
|     playeExamMgr.Clear()  | 
|   | 
|     #֪ͨ¿Í»§¶ËÍ˳ö´ðÌâ  | 
|     curPlayer.Sync_JoinActionOK(__GetExamType(), False)  | 
|     return  | 
| #---------------------------------------------------------------------  | 
| ##µØÍ¼·þÎñÆ÷ÇëÇó¼ÓÈë´ðÌâ»î¶¯.  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param jionExamType Íæ¼ÒÏëÒª²Î¼ÓµÄ´ðÌâ  | 
| # @param tick Ê±¼ä´Á  | 
| # @return None  | 
| # @remarks   | 
| def MapServer_JoinAction(curPlayer, jionExamType, tick):  | 
| #    GameWorld.Log("µØÍ¼·þÎñÆ÷ÇëÇó¼ÓÈë´ðÌâ»î¶¯")  | 
|     serverExamType = __GetExamType()   | 
|       | 
|     if (jionExamType != serverExamType) or (serverExamType not in ShareDefine.Def_Game_ExamTypeList):  | 
|         GameWorld.ErrLog('MapServer_JoinActionErr, jionExamType = %s, serverExamType = %s'%(jionExamType,  | 
|                                                                                             serverExamType))  | 
|         return  | 
|       | 
|     examStep = __GetExamStep()  | 
|       | 
|     if examStep not in [Def_ExamStep_Wait, Def_ExamStep_WaitCountDown, Def_ExamStep_Begin]:  | 
|         #FB_liubo_254483 »î¶¯ÒѾ¿ªÊ¼  | 
|         PlayerControl.NotifyCode(curPlayer, "FB_liubo_254483")  | 
|         return  | 
|       | 
|     playerExamMgr = curPlayer.GetPlayerExam()  | 
|       | 
|     if playerExamMgr.GetIsExaming():  | 
|         #GameWorld.Log('Íæ¼ÒÒѾÔڻÖÐÖØ¸´±¨Ãû', curPlayer.GetID())  | 
|         return  | 
|       | 
|     #Çå¿ÕÍæ¼Ò´ðÌâ¹ÜÀí  | 
|     playerExamMgr.Clear()  | 
|       | 
|     #ÉèÖÃÍæ¼Òδ¿ªÊ¼´ðÌâ  | 
|     playerExamMgr.SetIsExaming(True)  | 
|     #ÉèÖõ±Ç°Ñ¡ÏîĬÈÏÄÚÈÝ  | 
|     playerExamMgr.SetCurrentAnswer(Def_Exam_NoAnswersSign)  | 
|       | 
|     #ÊÀ½ç´ðÌâ¹ÜÀíÆ÷Ìí¼ÓÍæ¼Ò  | 
|     examManager = GameWorld.GetGameWorld().GetPlayerExamManager()  | 
|     examManager.AddExamPlayer(curPlayer)  | 
|       | 
|     #֪ͨ±¨Ãû³É¹¦  | 
|     curPlayer.Sync_JoinActionOK(jionExamType, True)  | 
|       | 
| #===============================================================================  | 
| #    #¸±±¾Ê£Óàʱ¼ä, ¸±±¾×Üʱ¼ä - ÒѾ¹ýÈ¥µÄʱ¼ä  | 
| #    remainTime = max(0, Def_ExamLastTime[serverExamType] - (tick - __GetExamBeginTick()))  | 
| #      | 
| #    #֪ͨ¸±±¾×ÜÊ£Óàʱ¼ä  | 
| #    curPlayer.Sync_TimeTick(ShareDefine.Def_TimeTickType_ExamLeaveMap, 0, remainTime, True)   | 
| #===============================================================================  | 
|       | 
|     #֪ͨµÈ´ýµ¹¼ÆÊ±  | 
|     if examStep == Def_ExamStep_Wait:  | 
|         lastTime = max(0, (Def_Tick_ExamPrepareWaitTime + Def_Tick_ExamPrepareCountDown) \  | 
|                         - (tick - __GetExamStepTick()))  | 
|           | 
|         curPlayer.Sync_TimeTick(ShareDefine.Def_TimeTickType_ExamWaitStart, 0, lastTime, True)  | 
|     #Í¨ÖªÌØÐ§µ¹¼ÆÊ±  | 
|     else:  | 
|         lastTime = max(0, Def_Tick_ExamPrepareCountDown - (tick - __GetExamStepTick()))  | 
|         curPlayer.Sync_TimeTick(ShareDefine.Def_TimeTickType_ExamBeginCountDown, 0, lastTime, True)  | 
|   | 
|     #֪ͨµØÍ¼·þÎñÆ÷, Íæ¼Ò½øÈë´ðÌâ  | 
|     curPlayer.MapServer_QueryPlayerResult(0, 0, 'ExamJoinOK', '', 0)  | 
|     return  | 
| #---------------------------------------------------------------------  | 
| #===============================================================================  | 
| # //13 02 ÎÊÌâ´ð°¸#tagCQuestionAnswer  | 
| # ////////////////////////////////////////////////////////////////  | 
| #===============================================================================  | 
| ## ÎÊÌâ´ð°¸  | 
| # @param index Íæ¼ÒË÷Òý  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ²¼¶ûÖµ  | 
| def Client_QuestionAnswer(index, tick):  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     curPlayer.Sync_ExamAnswerOK(__DoLogic_QuestionAnswer(curPlayer, tick))  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##½ÓÊܿͻ§¶Ë·¢Ë͵ÄÎÊÌâ´ð°¸  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ²¼¶ûÖµ  | 
| # @remarks   | 
| def __DoLogic_QuestionAnswer(curPlayer, tick):  | 
|     examType = __GetExamType()  | 
|       | 
|     if examType not in ShareDefine.Def_Game_ExamTypeList:  | 
|         #GameWorld.Log('·¢ËÍ´ðÌâ´ð°¸Ê±»ú²»¶Ô examType = %s'%(examType))  | 
|         return False  | 
|       | 
|     if __GetExamStep() != Def_ExamStep_Begin:  | 
|         #²»ÔڻشðÎÊÌâ»·½Ú  | 
|         #GameWorld.Log('²»ÔڻشðÎÊÌâ»·½Ú %s'%(__GetExamStep()))  | 
|         return False  | 
|       | 
|     playerExamMgr = curPlayer.GetPlayerExam()  | 
|       | 
|     if not playerExamMgr.GetIsExaming():  | 
|         #²»ÔÚ´ðÌâÖÐ  | 
|         #GameWorld.Log('Íæ¼Ò²»ÔÚ´ðÌâÖÐ')  | 
|         return False  | 
|       | 
|     playerAnswer = playerExamMgr.GetCurrentAnswer()  | 
|       | 
|     if not playerExamMgr.GetCombo() and playerAnswer != Def_Exam_NoAnswersSign:  | 
|         #ÒѾ»Ø´ð¹ýÁË  | 
|         #GameWorld.Log('Íæ¼ÒÒѾ»Ø´ð¹ýÁË')  | 
|         return False  | 
|       | 
|     sendPack = IPY_GameServer.IPY_CQuestionAnswer()  | 
|       | 
|     if sendPack.GetSubjectIndex() != __GetSendSubjectCnt():  | 
|         #²»ÊÇÕâµÀÌâµÄ´ð°¸  | 
| #        GameWorld.Log('·¢ËÍ´ðÌâ·â°üË÷Òý´íÎó server = %s, client = %s'%(__GetSendSubjectCnt(),  | 
| #                                                              sendPack.GetSubjectIndex()))  | 
|         return False  | 
|       | 
|     #·â°üµÄ´ð°¸  | 
|     sendPackAnswer = sendPack.GetAnswer()  | 
|       | 
|     playerExamMgr.SetCurrentAnswer(sendPackAnswer)  | 
|     playerExamMgr.SetCombo(0)  | 
|     playerExamMgr.SetAnswerSubjectTick(max(0,   | 
|                             tick - GameWorld.GetGameWorld().GetPlayerExamManager().GetSendSubjectTick()))  | 
|   | 
|     if examType == ShareDefine.Def_Game_Exam_ZXH:  | 
|         #ÕæÐÄ»°´óðÏÕÐèҪͳ¼Æ»Ø´ðµÄÍæ¼Ò  | 
|         __CalcExamZXH_AnswerCnt(playerAnswer, sendPackAnswer)  | 
|       | 
|     #·â°üÇëÇóʹÓÃÌØÊ⹦ÄÜ Def_Game_Exam_Func_Cnt  | 
|     __UseExamFunc(examType, playerExamMgr, sendPack.GetExtraOpt1(), sendPack.GetExtraOpt2(),   | 
|                                                   sendPack.GetExtraOpt3(), sendPack.GetExtraOpt4())  | 
|     #·µ»Ø½ÓÊܴ𰸳ɹ¦  | 
|     return True  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##ÇëÇóʹÓÃÌØÊ⹦ÄÜ  | 
| # @param examType ´ðÌâÀàÐÍ  | 
| # @param playerExamMgr Íæ¼Ò´ðÌâ¹ÜÀíÆ÷  | 
| # @param useDouble Ê¹ÓÃË«±¶  | 
| # @param useAnswerRight Ê¹ÓÃÉèÖÃÕýÈ·´ð°¸  | 
| # @param useDelOper É¾³ýÑ¡Ïî  | 
| # @param useThree Ê¹ÓÃ3±¶»ý·Ö  | 
| # @return ²¼¶ûÖµ  | 
| # @remarks   | 
| def __UseExamFunc(examType, playerExamMgr, useDouble, useAnswerRight, useDelOper, useThree):  | 
|     examUseFuncDict = Def_ExamUseFunc[examType]  | 
|     useExamFuncResult = False  | 
|       | 
|     #ÇëÇóʹÓÃÌØÊ⹦ÄÜ Def_Game_Exam_Func_Cnt  | 
|     if useDouble and playerExamMgr.GetUseExtraOpt1Count() < examUseFuncDict[ShareDefine.Def_Game_Exam_Func_Double]:  | 
|         playerExamMgr.SetUseExtraOpt1Count(playerExamMgr.GetUseExtraOpt1Count() + 1)  | 
|         playerExamMgr.SetExtraOpt1(1)  | 
|         useExamFuncResult = True  | 
|       | 
|     if useAnswerRight and playerExamMgr.GetUseExtraOpt2Count() < \  | 
|      examUseFuncDict[ShareDefine.Def_Game_Exam_Func_AnswerRight]:  | 
|           | 
|         playerExamMgr.SetUseExtraOpt2Count(playerExamMgr.GetUseExtraOpt2Count() + 1)  | 
|         playerExamMgr.SetExtraOpt2(1)  | 
|         useExamFuncResult = True  | 
|           | 
|     if useDelOper and playerExamMgr.GetUseExtraOpt3Count() < examUseFuncDict[ShareDefine.Def_Game_Exam_Func_DelOper]:  | 
|         playerExamMgr.SetUseExtraOpt3Count(playerExamMgr.GetUseExtraOpt3Count() + 1)  | 
|         playerExamMgr.SetExtraOpt3(1)   | 
|         useExamFuncResult = True  | 
|       | 
|     if useThree and playerExamMgr.GetUseExtraOpt4Count() < examUseFuncDict[ShareDefine.Def_Game_Exam_Func_Three]:  | 
|         playerExamMgr.SetUseExtraOpt4Count(playerExamMgr.GetUseExtraOpt4Count() + 1)  | 
|         playerExamMgr.SetExtraOpt4(1)   | 
|         useExamFuncResult = True  | 
|   | 
|     return useExamFuncResult  | 
|   | 
| #---------------------------------------------------------------------  | 
| #===============================================================================  | 
| # //13 03 ¼¤»î´ðÌâÌØÊ⹦ÄÜ#tagCActivateExamSpecialFunction  | 
| # // ¶ÔÐÔÄÜÓÐÒ»¶¨Ó°Ïì  | 
| #===============================================================================  | 
| ## ¼¤»î´ðÌâÌØÊ⹦ÄÜ  | 
| # @param index Íæ¼ÒË÷Òý  | 
| # @param tick Ê±¼ä´Á  | 
| # @return None  | 
| def Client_ActivateExamSpecialFunction(index, tick):  | 
|     GameWorld.GetPsycoFunc(__Func_Client_ActivateExamSpecialFunction)(index, tick)  | 
|     return  | 
|   | 
|   | 
| ## ¼¤»î´ðÌâÌØÊ⹦ÄÜ  | 
| # @param index Íæ¼ÒË÷Òý  | 
| # @param tick Ê±¼ä´Á  | 
| # @return None    | 
| def __Func_Client_ActivateExamSpecialFunction(index, tick):  | 
| #===============================================================================  | 
| #    #Ŀǰ´Ë·â°ü½öÓÃÓÚ¾ÙÆå²»¶¨, É¾³ýÌØÊâÑ¡Ïî  | 
| #===============================================================================  | 
|     curPlayer = GameWorld.GetPlayerManager().GetPlayerByIndex(index)  | 
|     #»ñÈ¡·â°ü  | 
|     sendPack = IPY_GameServer.IPY_CActivateExamSpecialFunction()  | 
|     packExamType = sendPack.GetType()  | 
|     packQuestionNO = sendPack.GetQuestionNO()  | 
|     packFunctionNO = sendPack.GetFunctionNO()  | 
|       | 
|     #µ±Ç°´ðÌâÀàÐÍ  | 
|     examType = __GetExamType()  | 
|       | 
|     if examType != packExamType:  | 
|         #²»ÊÇÕâ¸ö´ðÌâ»î¶¯  | 
|         return  | 
|   | 
|     if packQuestionNO != __GetSendSubjectCnt():  | 
|         #²»ÊÇÕâÌâ  | 
|         return  | 
|   | 
|     if __GetExamStep() != Def_ExamStep_Begin:  | 
|         #²»ÔڻشðÎÊÌâ»·½Ú  | 
|         #GameWorld.Log('ExamSpecialFunction ²»ÔڻشðÎÊÌâ»·½Ú %s'%(__GetExamStep()))  | 
|         return  | 
|       | 
|     if examType == ShareDefine.Def_Game_Exam_JQBD:  | 
|         __DoLogic_ActivateExamSpecialFunction_JQBD(curPlayer, packQuestionNO, packFunctionNO)  | 
|   | 
|     else:  | 
|         GameWorld.ErrLog('µ±Ç°´ðÌâÀàÐÍ = %sÎÞ·¨Ê¹Óô˹¦ÄÜ'%(examType))  | 
|         return  | 
|   | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##¼¤»î¾ÙÆì²»¶¨ÌØÊ⹦ÄÜ  | 
| # @param curPlayer Íæ¼ÒʵÀý  | 
| # @param questionNO µ±Ç°ÌâÄ¿ºÅ  | 
| # @param functionNO ¹¦ÄܺŠ | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def __DoLogic_ActivateExamSpecialFunction_JQBD(curPlayer, questionNO, functionNO):  | 
|     playerExamMgr = curPlayer.GetPlayerExam()  | 
|   | 
|     if not playerExamMgr.GetIsExaming():  | 
|         #²»ÔÚ´ðÌâÖÐ  | 
|         #GameWorld.Log('ExamSpecialFunction Íæ¼Ò²»ÔÚ´ðÌâÖÐ')  | 
|         return  | 
|   | 
|     #·â°üÇëÇóʹÓÃÌØÊ⹦ÄÜ Def_Game_Exam_Func_Cnt  | 
|     if not __UseExamFunc(ShareDefine.Def_Game_Exam_JQBD, playerExamMgr, 0, 0, 1, 0):  | 
|         return  | 
|   | 
|     #ɾ³ý2¸ö´íÎóÑ¡Ïî  | 
|     examManager = GameWorld.GetGameWorld().GetPlayerExamManager()  | 
|     examAnswerList = [examManager.GetQuestionExrtaValue2(), examManager.GetQuestionExrtaValue3(),   | 
|                       examManager.GetQuestionExrtaValue4(), examManager.GetQuestionExrtaValue5()]  | 
|   | 
|     examRightAnswer = examManager.GetRightAnswer()  | 
|   | 
|     if examRightAnswer not in examAnswerList:  | 
|         GameWorld.ErrLog('¾ÙÆì²»¶¨´ðÌâÑ¡Ïî´íÎó, examRightAnswer = %s, examAnswerList = %s'%(examRightAnswer,  | 
|                                                                                            examAnswerList))  | 
|         return  | 
|   | 
|     #ɾ³ýÕýÈ·´ð°¸  | 
|     examAnswerList.remove(examRightAnswer)  | 
|     #Ëæ¼´Ñ¡2¸öɾ³ý  | 
|     delImageList = random.sample(examAnswerList, 2)  | 
|       | 
|     #֪ͨ¿Í»§¶Ë  | 
|     curPlayer.Sync_ActivateExamSpelFuncAnswer(ShareDefine.Def_Game_Exam_JQBD, questionNO,  | 
|                                                functionNO, delImageList[0], delImageList[1], 0, 0)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##Çå³ýÕæÐÄ»°»º´æµÄ×Öµä  | 
| # @param ÎÞ²ÎÊý  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def __ClearExamZXH_SaveDict():  | 
|     #Çå³ý´ð°¸Ñ¡Ôñ¼ÆÊý  | 
|     gameWorld = GameWorld.GetGameWorld()  | 
|     gameWorld.SetDict(Def_ExamZXH_TotalAnswerCntKey, 0)  | 
|     gameWorld.SetDict(Def_ExamZXH_AnswerOneCntKey, 0)  | 
|     gameWorld.SetDict(Def_ExamZXH_AnswerTwoCntKey, 0)  | 
|     gameWorld.SetDict(Def_ExamZXH_AnswerThreeCntKey, 0)  | 
|     #Çå³ýÌáʾ±ê¼Ç  | 
|     gameWorld.SetDict(Def_ExamZXHSendRightAnswerkey, 0)  | 
|     #Çå³ýµÈ´ýÍæ¼Ò²é¿´±ê¼Ç  | 
|     gameWorld.SetDict(Def_ExamZXHSeeAnswerkey, 0)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##·¢Ë͸ø¿Í»§¶Ë´ðÌâÑ¡Ïî  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def __ExamZXH_SendSeeAnswer(tick):  | 
|     gameWorld = GameWorld.GetGameWorld()  | 
|       | 
|     if gameWorld.GetDictByKey(Def_ExamZXHSeeAnswerkey):  | 
|         #ÕâÀïÖ»»áµ½Ò»´Î  | 
|         GameWorld.ErrLog('__ExamZXH_SendSeeAnswer Err = %s'%(gameWorld.GetDictByKey(Def_ExamZXHSeeAnswerkey)))  | 
|         return  | 
|       | 
|     #·¢ËÍÑ¡Ïî¸øÍæ¼Ò  | 
|     __DoLogic_ExamZXH_SendSelectOption(ShareDefine.Def_ExamZXH_FunctionNO_SendAnswer)  | 
|     #ÉèÖñê¼Çλ  | 
|     gameWorld.SetDict(Def_ExamZXHSeeAnswerkey, 1)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##·¢Ë͸ø¿Í»§¶Ë´ðÌâÑ¡Ïî, Ñ¡ÔñÇé¿ö.  | 
| # @param sendSubjectLostTick ´ðÌâ¹ÜÀíÆ÷  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def __ExamZXH_SendSelectOption(sendSubjectLostTick):  | 
|     gameWorld = GameWorld.GetGameWorld()  | 
|       | 
|     if gameWorld.GetDictByKey(Def_ExamZXHSendRightAnswerkey):  | 
|         #ÒѾ·¢¹ýÁË  | 
|         return  | 
|       | 
|     if sendSubjectLostTick < Def_ExamZXHSendRightAnswerTick:  | 
|         #¼ä¸ôδµ½  | 
|         return  | 
|       | 
|     #·¢ËÍÑ¡Ïî¸øÍæ¼Ò  | 
|     __DoLogic_ExamZXH_SendSelectOption(ShareDefine.Def_ExamZXH_FunctionNO_SendSelectOption)  | 
|       | 
|     #ÉèÖñê¼Çλ  | 
|     gameWorld.SetDict(Def_ExamZXHSendRightAnswerkey, 1)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##·¢ËÍÍæ¼Ò´ðÌâÑ¡ÏîÇé¿ö.  | 
| # @param funcNo Ñ¡ÏÄܺŠ | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def __DoLogic_ExamZXH_SendSelectOption(funcNo):  | 
|     examType = ShareDefine.Def_Game_Exam_ZXH  | 
|     #»ñµÃ´ðÌâ±ÈÀý  | 
|     answerOnePer, answerTwoPer, answerThreePer = __GetExamZXH_AnswerScale()  | 
|       | 
|     #´ðÌâ¹ÜÀíÆ÷  | 
|     examManager = GameWorld.GetGameWorld().GetPlayerExamManager()  | 
|       | 
|     for index in range(0, examManager.GetExamPlayerCount()):  | 
|         examPlayer = examManager.GetExamPlayer(index)  | 
|           | 
|         if not examPlayer or not examPlayer.GetInitOK():  | 
|             #Íæ¼Ò²»ÔÚÏß  | 
|             continue  | 
|           | 
|         if funcNo == ShareDefine.Def_ExamZXH_FunctionNO_SendSelectOption:  | 
|             #Íæ¼Ò¿ÉÒÔÔÙ´ÎÑ¡Ôñ´ð°¸  | 
|             examPlayer.GetPlayerExam().SetCombo(1)  | 
|           | 
|         #֪ͨ¿Í»§¶Ëµ±Ç°»Ø´ðÇé¿ö  | 
|         examPlayer.Sync_ActivateExamSpelFuncAnswer(examType, 0, funcNo,  | 
|                                                           answerOnePer, answerTwoPer, answerThreePer, 0)  | 
|     return  | 
|   | 
| ##»ñµÃÕæÐÄ»°´ðÌâÒѻشðÍæ¼ÒÊý  | 
| # @param index Íæ¼ÒË÷Òý  | 
| # @param tick Ê±¼ä´Á  | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks ¿Í»§¶Ë·â°üÏìÓ¦  | 
| def __GetExamZXH_TotalAnswerCnt():  | 
|     return GameWorld.GetGameWorld().GetDictByKey(Def_ExamZXH_TotalAnswerCntKey)  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##¼ÆËã´ðÌâͳ¼ÆÂÊ  | 
| # @param playerAnswer Íæ¼ÒÉϴεÄÑ¡Ôñ   | 
| # @param answerIndex Íæ¼ÒÑ¡ÔñµÄ´ð°¸Ë÷Òý   | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def __CalcExamZXH_AnswerCnt(playerAnswer, answerIndex):  | 
|     if playerAnswer == Def_Exam_NoAnswersSign:  | 
|         #Íæ¼Ò½øÐеÚÒ»´Î´ðÌâ  | 
|         __AddExamZXH_AnswerCnt(answerIndex)  | 
|         return  | 
|       | 
|     #Íæ¼Ò±ä¸üÑ¡Ïî  | 
|     __ChangeExamZXH_AnswerCnt(playerAnswer, answerIndex)  | 
|     return  | 
| #---------------------------------------------------------------------  | 
| ##ÀÛ¼ÓÑ¡ÔñÌâÄ¿µÄÍæ¼ÒÊý  | 
| # @param answerIndex Íæ¼ÒÑ¡ÔñµÄ´ð°¸Ë÷Òý   | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def __AddExamZXH_AnswerCnt(answerIndex):  | 
|     gameWorld = GameWorld.GetGameWorld()  | 
|       | 
|     #ÀÛ¼Óͳ¼ÆÂÊ  | 
|     if not __AddExamZXHAnswerCntKey(gameWorld, answerIndex):  | 
|         return  | 
|       | 
|     #Àۼӻشð×ÜÈËÊý  | 
|     gameWorld.SetDict(Def_ExamZXH_TotalAnswerCntKey, gameWorld.GetDictByKey(Def_ExamZXH_TotalAnswerCntKey) + 1)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##±ä¸üÑ¡ÔñÌâÄ¿µÄÍæ¼ÒÊý  | 
| # @param playerAnswer Íæ¼ÒÉϴεÄÑ¡Ôñ   | 
| # @param answerIndex Íæ¼ÒÑ¡ÔñµÄ´ð°¸Ë÷Òý   | 
| # @return ·µ»ØÖµÎÞÒâÒå  | 
| # @remarks   | 
| def __ChangeExamZXH_AnswerCnt(playerAnswer, answerIndex):  | 
|     gameWorld = GameWorld.GetGameWorld()  | 
|       | 
|     if playerAnswer == answerIndex:  | 
|         #2´Î»Ø´ðÒ»Ñù²»ÖØÐÂͳ¼Æ  | 
|         return  | 
|       | 
|     if playerAnswer == 1:  | 
|         gameWorld.SetDict(Def_ExamZXH_AnswerOneCntKey,  | 
|                            max(0, gameWorld.GetDictByKey(Def_ExamZXH_AnswerOneCntKey) - 1))  | 
|       | 
|     elif playerAnswer == 2:  | 
|         gameWorld.SetDict(Def_ExamZXH_AnswerTwoCntKey,  | 
|                            max(0, gameWorld.GetDictByKey(Def_ExamZXH_AnswerTwoCntKey) - 1))  | 
|           | 
|     elif playerAnswer == 3:  | 
|         gameWorld.SetDict(Def_ExamZXH_AnswerThreeCntKey,  | 
|                            max(0, gameWorld.GetDictByKey(Def_ExamZXH_AnswerThreeCntKey) - 1))  | 
|       | 
|     else:  | 
|         GameWorld.ErrLog('ExamZXH playerAnswer = %s Error'%(playerAnswer))  | 
|         return  | 
|       | 
|     #ÀÛ¼Óͳ¼ÆÂÊ  | 
|     __AddExamZXHAnswerCntKey(gameWorld, answerIndex)  | 
|     return  | 
|   | 
| #---------------------------------------------------------------------  | 
| ##ÀÛ¼Ó¸÷Ñ¡ÏîµÄͳ¼ÆÂÊ.  | 
| # @param gameWorld Íæ¼ÒË÷Òý  | 
| # @param answerIndex »Ø´ðË÷Òý  | 
| # @return ²¼¶ûÖµ  | 
| # @remarks   | 
| def __AddExamZXHAnswerCntKey(gameWorld, answerIndex):  | 
|     if answerIndex == 1:  | 
|         gameWorld.SetDict(Def_ExamZXH_AnswerOneCntKey, gameWorld.GetDictByKey(Def_ExamZXH_AnswerOneCntKey) + 1)  | 
|           | 
|     elif answerIndex == 2:  | 
|         gameWorld.SetDict(Def_ExamZXH_AnswerTwoCntKey, gameWorld.GetDictByKey(Def_ExamZXH_AnswerTwoCntKey) + 1)  | 
|       | 
|     elif answerIndex == 3:  | 
|         gameWorld.SetDict(Def_ExamZXH_AnswerThreeCntKey, gameWorld.GetDictByKey(Def_ExamZXH_AnswerThreeCntKey) + 1)  | 
|       | 
|     else:  | 
|         GameWorld.ErrLog('ExamZXH AnswerIndex = %s Error'%(answerIndex))  | 
|         return False  | 
|        | 
|     return True  | 
| #---------------------------------------------------------------------  | 
| ##»ñµÃÕæÐÄ»°Ñ¡ÔñµÄ´ð°¸±ÈÀý.  | 
| # @param ÎÞ²ÎÊý  | 
| # @return µÚһѡÏî±ÈÀý, µÚ¶þÑ¡Ïî±ÈÀý, µÚÈýÑ¡Ïî±ÈÀý  | 
| # @remarks   | 
| def __GetExamZXH_AnswerScale():  | 
|     #»ñµÃ´ðÌâ±ÈÀý  | 
|     gameWorld = GameWorld.GetGameWorld()  | 
|     totalAnswerCnt = gameWorld.GetDictByKey(Def_ExamZXH_TotalAnswerCntKey)  | 
|       | 
|     if totalAnswerCnt == 0:  | 
|         #ÎÞÈ˻شð  | 
|         return 0, 0, 0  | 
|       | 
|     #±¶ÂÊ  | 
|     per = 100  | 
|     answerOnePer = int(gameWorld.GetDictByKey(Def_ExamZXH_AnswerOneCntKey) / float(totalAnswerCnt) * per)  | 
|     answerTwoPer = int(gameWorld.GetDictByKey(Def_ExamZXH_AnswerTwoCntKey) / float(totalAnswerCnt) * per)  | 
|     answerThreePer = max(0, per - answerOnePer - answerTwoPer)  | 
|     return answerOnePer, answerTwoPer, answerThreePer  | 
|   |