| #!/usr/bin/python  | 
| # -*- coding: GBK -*-  | 
| #---------------------------------------------------------------------  | 
| #  | 
| #---------------------------------------------------------------------  | 
| ##@package SubjectLib  | 
| # @todo: ´ðÌâ¶ÁÌâ¹ÜÀíÆ÷  | 
| #  | 
| # @author: panwei  | 
| # @date 2011-03-31  | 
| # @version 1.0  | 
| #  | 
| #ΪÁ˱ÜÃâÈ¡µ½ÏàͬÌâÄ¿µÄÇé¿ö:  | 
| #Ìâ¿â·ÖΪ: ÔʼÌâ¿âºÍ¶¯Ì¬Ìâ¿â, ÔʼÌâ¿â¶ÁÈ¡ÌâÄ¿,  | 
| #  | 
| #1. ¶¯Ì¬Ìâ¿â ¸ù¾ÝÔʼÌâ¿âÉú³ÉËæ»úÌâ¿â  | 
| #2. Ìâ¿â´Ó¶¯Ì¬Ìâ¿âÀïÃæÈ¡  | 
| #3. Ã¿È¡Ò»Ìâ, ´Ó¶¯Ì¬Ìâ¿âÖÐɾ³ýÕâÒ»Ìâ  | 
| #4. Èç¹û¶¯Ì¬Ìâ¿âÈ¡ÍêÁË, ÔòÖØÐÂÉú³É¶¯Ì¬Ìâ¿â  | 
| #---------------------------------------------------------------------  | 
| """Version = 2011-03-31 17:30"""  | 
| #---------------------------------------------------------------------  | 
| import ReadChConfig  | 
| import ChConfig  | 
| import GameWorld  | 
| import copy  | 
| import random  | 
| #---------------------------------------------------------------------  | 
| #¹Ì̬Ìâ¿â  | 
| __AllSubject = {}  | 
| #¶¯Ì¬Ìâ¿â  | 
| __DelicacySuject = {}  | 
| #---------------------------------------------------------------------  | 
| ## Ëæ»ú»ñµÃÒ»µÀÌâÄ¿  | 
| #  @param examType ´ðÌâÀàÐÍDef_Game_Exam_Type  | 
| #  @return Ôª×é(ID: [ÌâÄ¿ÊôÐÔ])  | 
| #  @remarks º¯ÊýÏêϸ˵Ã÷.  | 
| def GetSubject(examType):  | 
|     global __DelicacySuject  | 
|       | 
|     if len(__AllSubject) == 0:  | 
|         __ReloadExamSubject()  | 
|           | 
|     #µÚÒ»´Î¼ÓÔØÌâÄ¿,³õʼ»¯  | 
|     if len(__DelicacySuject) == 0:  | 
|         __DelicacySuject = copy.deepcopy(__AllSubject)  | 
|    | 
|     #»ñµÃÌâ¿â  | 
|     sujectDict = __DelicacySuject.get(examType)  | 
|     #ÅׯúÒì³£  | 
|     if sujectDict == None:  | 
|         GameWorld.ErrLog("»ñÈ¡Ìâ¿âÒì³£ examType = %s"%(examType))  | 
|         return []  | 
|       | 
|     #ÎÞÌâÄ¿ÁË,ÖØÐ¼ÓÔØÔʼÌâ¿â  | 
|     if len(sujectDict) == 0:  | 
|         __DelicacySuject = copy.deepcopy(__AllSubject)  | 
|       | 
|     #»ñµÃÌâ¿â  | 
|     sujectDict = __DelicacySuject.get(examType)  | 
|       | 
|     if len(sujectDict) == 0:  | 
|         GameWorld.ErrLog("Ìâ¿âÒì³£ examType = %s, ÎÞÌâÄ¿"%(examType))  | 
|         return []  | 
|       | 
|     #Ëæ»úÕÒÒ»¸öÌâÄ¿, ²¢´ÓÁÙʱÌâ¿âÖÐɾ³ý  | 
|     randNum = random.choice(sujectDict.keys())  | 
|     randSubjectList = [randNum, sujectDict[randNum]]  | 
|     sujectDict.pop(randNum)  | 
|       | 
|     return randSubjectList  | 
| #---------------------------------------------------------------------  | 
| ##ÖØÐ¼ÓÔØÌâ¿â  | 
| # @param ÎÞ²ÎÊý  | 
| # @return None  | 
| # @remarks   | 
| def __ReloadExamSubject():  | 
|     global __AllSubject  | 
|       | 
|     for examType, examName in ChConfig.Def_ExamSubjectNameDict.items():  | 
|         __AllSubject.update({examType : ReadChConfig.GetEvalChConfig(examName)})  | 
|       | 
|     return  | 
|   | 
|   | 
|   | 
|      |