hxp
2024-10-29 328648da94a07437fc46024f3e9b7e48c2e2ae38
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/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