Commit 66c117dd authored by Chen Bill's avatar Chen Bill Committed by GitHub

add effect flag in Card.RegisterEffect (#677)

* add enum effect_category

* add effect flag in Card.RegisterEffect

* fix effect_flag

* use uint64 flag
parent 7a93233e
...@@ -22,6 +22,7 @@ struct effect_set; ...@@ -22,6 +22,7 @@ struct effect_set;
struct effect_set_v; struct effect_set_v;
enum effect_flag : uint64; enum effect_flag : uint64;
enum effect_flag2 : uint64; enum effect_flag2 : uint64;
enum effect_category :uint64;
enum code_type : int32; enum code_type : int32;
bool is_continuous_event(uint32 code); bool is_continuous_event(uint32 code);
...@@ -214,6 +215,9 @@ enum effect_flag : uint64 { ...@@ -214,6 +215,9 @@ enum effect_flag : uint64 {
EFFECT_FLAG_ACTIVATE_CONDITION = 0x20000000, EFFECT_FLAG_ACTIVATE_CONDITION = 0x20000000,
// EFFECT_FLAG_CVAL_CHECK = 0x40000000, // EFFECT_FLAG_CVAL_CHECK = 0x40000000,
EFFECT_FLAG_IMMEDIATELY_APPLY = 0x80000000, EFFECT_FLAG_IMMEDIATELY_APPLY = 0x80000000,
EFFECT_FLAG_COIN = 0x100000000,
EFFECT_FLAG_DICE = 0x200000000,
EFFECT_FLAG_FUSION_SUMMON = 0x400000000,
}; };
enum effect_flag2 : uint64 { enum effect_flag2 : uint64 {
EFFECT_FLAG2_REPEAT_UPDATE = 0x0001, EFFECT_FLAG2_REPEAT_UPDATE = 0x0001,
...@@ -222,9 +226,52 @@ enum effect_flag2 : uint64 { ...@@ -222,9 +226,52 @@ enum effect_flag2 : uint64 {
EFFECT_FLAG2_OPTION = 0x0008, EFFECT_FLAG2_OPTION = 0x0008,
}; };
constexpr effect_flag operator|(effect_flag flag1, effect_flag flag2) { constexpr effect_flag operator|(effect_flag flag1, effect_flag flag2) {
return static_cast<effect_flag>(static_cast<uint32>(flag1) | static_cast<uint32>(flag2)); return static_cast<effect_flag>(static_cast<uint64>(flag1) | static_cast<uint64>(flag2));
} }
constexpr uint32 INTERNAL_FLAGS = EFFECT_FLAG_INITIAL | EFFECT_FLAG_COPY | EFFECT_FLAG_FUNC_VALUE | EFFECT_FLAG_COUNT_LIMIT | EFFECT_FLAG_FIELD_ONLY | EFFECT_FLAG_ABSOLUTE_TARGET; constexpr uint64 INTERNAL_FLAGS = EFFECT_FLAG_INITIAL | EFFECT_FLAG_COPY | EFFECT_FLAG_FUNC_VALUE | EFFECT_FLAG_COUNT_LIMIT | EFFECT_FLAG_FIELD_ONLY | EFFECT_FLAG_ABSOLUTE_TARGET;
//Category
enum effect_category : uint64 {
CATEGORY_DESTROY = 0x1,
CATEGORY_RELEASE = 0x2,
CATEGORY_REMOVE = 0x4,
CATEGORY_TOHAND = 0x8,
CATEGORY_TODECK = 0x10,
CATEGORY_TOGRAVE = 0x20,
CATEGORY_DECKDES = 0x40,
CATEGORY_HANDES = 0x80,
CATEGORY_SUMMON = 0x100,
CATEGORY_SPECIAL_SUMMON = 0x200,
CATEGORY_TOKEN = 0x400,
CATEGORY_GRAVE_ACTION = 0x800,
CATEGORY_POSITION = 0x1000,
CATEGORY_CONTROL = 0x2000,
CATEGORY_DISABLE = 0x4000,
CATEGORY_DISABLE_SUMMON = 0x8000,
CATEGORY_DRAW = 0x10000,
CATEGORY_SEARCH = 0x20000,
CATEGORY_EQUIP = 0x40000,
CATEGORY_DAMAGE = 0x80000,
CATEGORY_RECOVER = 0x100000,
CATEGORY_ATKCHANGE = 0x200000,
CATEGORY_DEFCHANGE = 0x400000,
CATEGORY_COUNTER = 0x800000,
CATEGORY_COIN = 0x1000000,
CATEGORY_DICE = 0x2000000,
CATEGORY_LEAVE_GRAVE = 0x4000000,
CATEGORY_GRAVE_SPSUMMON = 0x8000000,
CATEGORY_NEGATE = 0x10000000,
CATEGORY_ANNOUNCE = 0x20000000,
CATEGORY_FUSION_SUMMON = 0x40000000,
CATEGORY_TOEXTRA = 0x80000000,
};
const std::map<uint64, uint64> category_checklist{
{CATEGORY_COIN, EFFECT_FLAG_COIN},
{CATEGORY_DICE, EFFECT_FLAG_DICE},
{CATEGORY_FUSION_SUMMON, EFFECT_FLAG_FUSION_SUMMON},
};
//========== Codes ========== //========== Codes ==========
#define EFFECT_IMMUNE_EFFECT 1 // #define EFFECT_IMMUNE_EFFECT 1 //
#define EFFECT_DISABLE 2 // #define EFFECT_DISABLE 2 //
......
...@@ -1828,6 +1828,10 @@ int32 scriptlib::card_register_effect(lua_State *L) { ...@@ -1828,6 +1828,10 @@ int32 scriptlib::card_register_effect(lua_State *L) {
pduel->game_field->core.reseted_effects.insert(peffect); pduel->game_field->core.reseted_effects.insert(peffect);
return 0; return 0;
} }
for (auto& entry : category_checklist) {
if (peffect->category & entry.first)
peffect->flag[0] |= entry.second;
}
int32 id; int32 id;
if (peffect->handler) if (peffect->handler)
id = -1; id = -1;
...@@ -1891,7 +1895,7 @@ int32 scriptlib::card_register_flag_effect(lua_State *L) { ...@@ -1891,7 +1895,7 @@ int32 scriptlib::card_register_flag_effect(lua_State *L) {
card* pcard = *(card**) lua_touserdata(L, 1); card* pcard = *(card**) lua_touserdata(L, 1);
int32 code = (lua_tointeger(L, 2) & MAX_CARD_ID) | EFFECT_FLAG_EFFECT; int32 code = (lua_tointeger(L, 2) & MAX_CARD_ID) | EFFECT_FLAG_EFFECT;
int32 reset = (int32)lua_tointeger(L, 3); int32 reset = (int32)lua_tointeger(L, 3);
uint32 flag = (uint32)lua_tointeger(L, 4); uint64 flag = lua_tointeger(L, 4);
int32 count = (int32)lua_tointeger(L, 5); int32 count = (int32)lua_tointeger(L, 5);
lua_Integer lab = 0; lua_Integer lab = 0;
int32 desc = 0; int32 desc = 0;
......
...@@ -97,7 +97,7 @@ int32 scriptlib::duel_register_flag_effect(lua_State *L) { ...@@ -97,7 +97,7 @@ int32 scriptlib::duel_register_flag_effect(lua_State *L) {
return 0; return 0;
int32 code = (lua_tointeger(L, 2) & MAX_CARD_ID) | EFFECT_FLAG_EFFECT; int32 code = (lua_tointeger(L, 2) & MAX_CARD_ID) | EFFECT_FLAG_EFFECT;
int32 reset = (int32)lua_tointeger(L, 3); int32 reset = (int32)lua_tointeger(L, 3);
uint32 flag = (uint32)lua_tointeger(L, 4); uint64 flag = lua_tointeger(L, 4);
int32 count = (int32)lua_tointeger(L, 5); int32 count = (int32)lua_tointeger(L, 5);
lua_Integer lab = 0; lua_Integer lab = 0;
if(lua_gettop(L) >= 6) if(lua_gettop(L) >= 6)
......
...@@ -226,8 +226,8 @@ int32 scriptlib::effect_set_property(lua_State *L) { ...@@ -226,8 +226,8 @@ int32 scriptlib::effect_set_property(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1); check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1); effect* peffect = *(effect**) lua_touserdata(L, 1);
uint32 v1 = (uint32)lua_tointeger(L, 2); uint64 v1 = lua_tointeger(L, 2);
uint32 v2 = (uint32)lua_tointeger(L, 3); uint64 v2 = lua_tointeger(L, 3);
peffect->flag[0] = (peffect->flag[0] & INTERNAL_FLAGS) | (v1 & ~INTERNAL_FLAGS); peffect->flag[0] = (peffect->flag[0] & INTERNAL_FLAGS) | (v1 & ~INTERNAL_FLAGS);
peffect->flag[1] = v2; peffect->flag[1] = v2;
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment