From 6900b83497bfad806b70779790e500886d0b9c9c Mon Sep 17 00:00:00 2001 From: xiyoo0812 Date: Sun, 28 Apr 2024 23:58:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=A9=E5=B1=95=E5=B1=9E=E6=80=A7=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/quanta/quanta.lmak | 4 -- core/quanta/quanta.mak | 9 ++-- core/quanta/quanta.vcxproj | 7 --- core/quanta/quanta.vcxproj.filters | 9 ---- server/business/component/attr_component.lua | 45 +++++++++++++++++--- 5 files changed, 45 insertions(+), 29 deletions(-) diff --git a/core/quanta/quanta.lmak b/core/quanta/quanta.lmak index 15791e38..0d31f688 100644 --- a/core/quanta/quanta.lmak +++ b/core/quanta/quanta.lmak @@ -34,10 +34,6 @@ LINUX_LIBS = { "stdc++fs" } -OBJS = { - "quanta.cpp", "main.cpp" -} - --非WINDOWS预编译命令 --格式: cmd --"cp -r bin/libcurl-x64.dll $(SolutionDir)bin" diff --git a/core/quanta/quanta.mak b/core/quanta/quanta.mak index a0c90256..b829fc15 100644 --- a/core/quanta/quanta.mak +++ b/core/quanta/quanta.mak @@ -97,10 +97,11 @@ LDFLAGS += -L$(SOLUTION_DIR)library #自动生成目标 OBJS = -COBJS = $(patsubst %.c, $(INT_DIR)/%.o, quanta.cpp main.cpp) -MOBJS = $(patsubst %.m, $(INT_DIR)/%.o, $(COBJS)) -CCOBJS = $(patsubst %.cc, $(INT_DIR)/%.o, $(MOBJS)) -OBJS = $(patsubst %.cpp, $(INT_DIR)/%.o, $(CCOBJS)) +#根目录 +OBJS += $(patsubst $(SRC_DIR)/%.c, $(INT_DIR)/%.o, $(filter-out $(EXCLUDE), $(wildcard $(SRC_DIR)/*.c))) +OBJS += $(patsubst $(SRC_DIR)/%.m, $(INT_DIR)/%.o, $(filter-out $(EXCLUDE), $(wildcard $(SRC_DIR)/*.m))) +OBJS += $(patsubst $(SRC_DIR)/%.cc, $(INT_DIR)/%.o, $(filter-out $(EXCLUDE), $(wildcard $(SRC_DIR)/*.cc))) +OBJS += $(patsubst $(SRC_DIR)/%.cpp, $(INT_DIR)/%.o, $(filter-out $(EXCLUDE), $(wildcard $(SRC_DIR)/*.cpp))) # 编译所有源文件 $(INT_DIR)/%.o : $(SRC_DIR)/%.c diff --git a/core/quanta/quanta.vcxproj b/core/quanta/quanta.vcxproj index b9563ec9..14c633be 100644 --- a/core/quanta/quanta.vcxproj +++ b/core/quanta/quanta.vcxproj @@ -7,17 +7,10 @@ - - - true - - - true - diff --git a/core/quanta/quanta.vcxproj.filters b/core/quanta/quanta.vcxproj.filters index f809558c..4d1348db 100644 --- a/core/quanta/quanta.vcxproj.filters +++ b/core/quanta/quanta.vcxproj.filters @@ -1,23 +1,14 @@  - - inc - inc - - src - src - - src - src diff --git a/server/business/component/attr_component.lua b/server/business/component/attr_component.lua index e34e5c37..007eaab3 100644 --- a/server/business/component/attr_component.lua +++ b/server/business/component/attr_component.lua @@ -3,6 +3,7 @@ local qenum = quanta.enum local log_warn = logger.warn local log_debug = logger.debug local tinsert = table.insert +local supper = string.upper local sformat = string.format local qmerge = qtable.merge @@ -11,6 +12,10 @@ local config_mgr = quanta.get("config_mgr") local attr_db = config_mgr:get_table("attribute") +local AttrID = quanta.enum("AttrID") +local INTERNAL = { "_base", "_inc", "_per" } +local INTERNALID = 1000 + local AttrComponent = mixin() local prop = property(AttrComponent) prop:reader("range", {}) --属性集合 @@ -26,7 +31,7 @@ dbprop:store_values("attrs", {}) --属性集合 --委托回调 function AttrComponent:__delegate() - for _, attr in attr_db:iterator() do + local function delegate_attr(attr) AttrComponent["get_" .. attr.nick] = function(this) return this:get_attr(attr.id) end @@ -41,6 +46,26 @@ function AttrComponent:__delegate() return this:cost_attr(attr.id, value) end end + local function delegate_internal_attr(attr_bid, attr) + for idx, name in ipairs(INTERNAL) do + AttrID[attr.enum_key .. supper(name)] = attr_bid + idx + delegate_attr({ id = attr_bid + idx, nick = attr.nick .. name, increase = true}) + end + end + end + for _, attr in attr_db:iterator() do + if attr.complex then + local attr_bid = INTERNALID + attr.id * 3 + delegate_internal_attr(attr_bid, attr) + AttrComponent["get_" .. attr.nick] = function(this) + local base = this:get_attr(attr_bid) + local add_val = this:get_attr(attr_bid + 1) + local per_val = this:get_attr(attr_bid + 2) + return (base + add_val) * (1 + per_val) + end + else + delegate_attr(attr) + end end end @@ -50,12 +75,22 @@ function AttrComponent:init_attrset(type_attr_db, range) for _, attr in type_attr_db:iterator() do local attr_id = qenum("AttrID", attr.key) local attr_type = attr_db:find_value("type", attr_id) + local attr_limit = attr_db:find_value("limit", attr_id) + local attr_complex = attr_db:find_value("complex", attr_id) local attr_def = { save = attr.save, back = attr.back, range = attr.range, type = attr_type } - if attr.limit then - attr_def.limit_id = qenum("AttrID", attr.limit) + if attr_limit then + attr_def.limit_id = qenum("AttrID", attr_limit) + end + if attr_complex then + local attr_bid = INTERNALID + attr_id * 3 + for idx, name in ipairs(INTERNAL) do + self.attr_set[attr_bid + idx] = { save = false, back = false, range = 0, type = attr_type } + self.attrs[attr_bid + idx] = attr_type == "int" and 0 or "" + end + else + self.attr_set[attr_id] = attr_def + self.attrs[attr_id] = attr_type == "int" and 0 or "" end - self.attr_set[attr_id] = attr_def - self.attrs[attr_id] = attr_type == "int" and 0 or "" end end