From 0a6ffef4ba4593b8a112981b3e0be438889202e1 Mon Sep 17 00:00:00 2001 From: hxp <ale99527@vip.qq.com> Date: 星期一, 29 九月 2025 15:53:55 +0800 Subject: [PATCH] 16 卡牌服务端(修改GM命令Mail中物品,包含货币、装备、武将、常规物品;) --- ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/FormulaControl.py | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/FormulaControl.py b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/FormulaControl.py index 514a9a4..0428a46 100644 --- a/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/FormulaControl.py +++ b/ServerPython/ZoneServerGroup/map1_8G/MapServer/MapServerData/Script/FormulaControl.py @@ -79,13 +79,14 @@ #GameWorld.Log('ClearCompileFormulaDist Sucess AllFormulaDist = %s'%(AllFormulaDist)) return -def Eval(formulaKey, formula, paramDict, toInt=True, ceil=False, playerID=0): +def Eval(formulaKey, formula, paramDict, toInt=True, ceil=False, ndigits=0, playerID=0): """ 动态计算 :param formulaKey: 公式编译缓存key :param formula: 公式字符串,如 "int(Atk*10 + MaxHP)" :param paramDict: 参数字典,如 {'Atk': 100, 'MaxHP': 5000} :param toInt: 是否转为整数 :param ceil: 是否向上取整 + :param ndigits: 小数精确位数 :return: 计算结果 """ compileFormula = GetCompileFormula(formulaKey, formula) @@ -110,6 +111,8 @@ try: # 执行计算 value = eval(compileFormula, safe_env) + if ndigits > 0: + value = round(value, ndigits) if ceil: value = math.ceil(value) if toInt: -- Gitblit v1.8.0