#!/usr/bin/python  
 | 
# -*- coding: GBK -*-  
 | 
#---------------------------------------------------------------------  
 | 
#  
 | 
#---------------------------------------------------------------------  
 | 
##@package FormulaControl  
 | 
# @todo: ¹«Ê½¹ÜÀíÆ÷  
 | 
#  
 | 
# @author: panwei  
 | 
# @date 2010-09-01  
 | 
# @version 1.0  
 | 
#  
 | 
# @note: ÓÃÓÚ»º´æÔ¤±à¼µÄ¹«Ê½, Ìá¸ßevalµÄЧÂÊ  
 | 
#---------------------------------------------------------------------  
 | 
"""Version = 2010-09-01 16:40"""  
 | 
#---------------------------------------------------------------------  
 | 
#===============================================================================  
 | 
# Áʽ¼ÆËãÌá¸ß25±¶µÄ·½·¨£º  
 | 
# 1.Ô·½·¨   
 | 
# expression = "a + b"  
 | 
# c = eval(expression)  
 | 
#   
 | 
# 2.ÏȱàÒ룬ºóeval  
 | 
# expression = "a + b"  
 | 
# d = compile(expression, "modeName", "eval")  
 | 
# c = eval(d)  
 | 
#   
 | 
# ´óÁ¿ÔËËã²âÊÔ½á¹û£º  
 | 
# c = eval(d) ±È  
 | 
# c = eval(expression) ¿ì25±¶  
 | 
#   
 | 
# evalÒ»¸ö×Ö·û´®µÄʱ¼ä = ±àÒëÒ»¸ö×Ö·û´® + evalÒ»¸ö±àÒëºÃµÄÄ£¿é  
 | 
#===============================================================================  
 | 
#---------------------------------------------------------------------  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
#¹«Ê½×ÖµäÃû×¢²á  
 | 
#×¢²á¹«Ê½×ÖµäÃû·½Ê½ 'Facl_DistKey_ + KeyName' (ǰ׺ÃûÓÃÓÚÇø±ð²ß»®ÅäÖÃtxt¹«Ê½Key)  
 | 
#ÀýÈç: Facl_DistKey_KillNPC = 'Facl_DistKey_KillNPC'  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
#»º´æ·þÎñÆ÷ËùÓеĹ«Ê½×ÖµäÐÅÏ¢{δ±àÒëµÄ¹«Ê½:±àÒëºóµÄ¹«Ê½}  
 | 
AllFormulaDist = {}  
 | 
  
 | 
#---------------------------------------------------------------------  
 | 
##»ñÈ¡±àÒëºóµÄ¹«Ê½.  
 | 
# @param formulaKey ×ÖµäKeyÃû  
 | 
# @param noCompileFormula Î´±àÒëµÄ¹«Ê½  
 | 
# @return ±àÒëºóµÄ¹«Ê½  
 | 
# @remarks »ñÈ¡±àÒëºóµÄ¹«Ê½.  
 | 
def GetCompileFormula(formulaKey, noCompileFormula):  
 | 
    global AllFormulaDist  
 | 
      
 | 
    compileFormula = AllFormulaDist.get(formulaKey)  
 | 
      
 | 
    #---Õâ¸ö¹«Ê½ÒѾ±àÒë¹ýÁË---  
 | 
    if compileFormula != None:  
 | 
        #GameWorld.Log('Õâ¸ö¹«Ê½ = %s ÒѾ±àÒë¹ý, Ö±½Ó·µ»Ø'%(formulaKey))  
 | 
        return compileFormula  
 | 
      
 | 
    #---Õâ¸ö¹«Ê½Î´±àÒë¹ýÁË---  
 | 
    compileFormula = compile(noCompileFormula, 'FormulaControl', 'eval')  
 | 
    #¸üÐÂ×Öµä  
 | 
    AllFormulaDist.update({formulaKey:compileFormula})  
 | 
    #GameWorld.Log('Õâ¸ö¹«Ê½ = %s Î´±àÒë¹ý, ¼ÓÈë±àÒë'%(formulaKey))  
 | 
    return compileFormula  
 | 
#---------------------------------------------------------------------  
 | 
##Çå¿Õ±àÒëºóµÄ¹«Ê½×Öµä  
 | 
# @param ÎÞ²ÎÊý  
 | 
# @return ·µ»ØÖµÎÞÒâÒå  
 | 
# @remarks Çå¿Õ±àÒëºóµÄ¹«Ê½×Öµä  
 | 
def ClearCompileFormulaDist():  
 | 
    global AllFormulaDist  
 | 
    AllFormulaDist = {}  
 | 
    #GameWorld.Log('ClearCompileFormulaDist Sucess AllFormulaDist = %s'%(AllFormulaDist))  
 | 
    return  
 |