Commit 3503baea authored by Nanahira's avatar Nanahira Committed by GitHub

Merge pull request #21 from mycard/develop-8888

Develop 8888
parents 36530db9 92f0aa48
This diff is collapsed.
...@@ -30,6 +30,9 @@ using effect_container = std::multimap<uint32, effect*>; ...@@ -30,6 +30,9 @@ using effect_container = std::multimap<uint32, effect*>;
using effect_indexer = std::unordered_map<effect*, effect_container::iterator>; using effect_indexer = std::unordered_map<effect*, effect_container::iterator>;
using effect_collection = std::unordered_set<effect*>; using effect_collection = std::unordered_set<effect*>;
using effect_filter = bool(*)(card* self, effect* peffect);
using effect_filter_target = bool(*)(card* self, effect* peffect, card* target);
struct card_state { struct card_state {
uint32 code{ 0 }; uint32 code{ 0 };
uint32 code2{ 0 }; uint32 code2{ 0 };
...@@ -56,7 +59,7 @@ struct card_state { ...@@ -56,7 +59,7 @@ struct card_state {
uint8 reason_player{ PLAYER_NONE }; uint8 reason_player{ PLAYER_NONE };
effect* reason_effect{ nullptr }; effect* reason_effect{ nullptr };
bool is_location(int32 loc) const; bool is_location(uint32 loc) const;
bool is_main_mzone() const { bool is_main_mzone() const {
return location == LOCATION_MZONE && sequence >= 0 && sequence <= 4; return location == LOCATION_MZONE && sequence >= 0 && sequence <= 4;
} }
...@@ -218,6 +221,8 @@ public: ...@@ -218,6 +221,8 @@ public:
effect_indexer indexer; effect_indexer indexer;
effect_relation relate_effect; effect_relation relate_effect;
effect_set_v immune_effect; effect_set_v immune_effect;
effect_collection initial_effect;
effect_collection owning_effect;
uint8 to_leave_fromex; uint8 to_leave_fromex;
...@@ -330,9 +335,11 @@ public: ...@@ -330,9 +335,11 @@ public:
void clear_card_target(); void clear_card_target();
void set_special_summon_status(effect* peffect); void set_special_summon_status(effect* peffect);
void filter_effect(int32 code, effect_set* eset, uint8 sort = TRUE); template<typename T>
void filter_single_continuous_effect(int32 code, effect_set* eset, uint8 sort = TRUE); void filter_effect_container(const effect_container& container, uint32 code, effect_filter f, T& eset);
void filter_self_effect(int32 code, effect_set* eset, uint8 sort = TRUE); void filter_effect(uint32 code, effect_set* eset, uint8 sort = TRUE);
void filter_single_continuous_effect(uint32 code, effect_set* eset, uint8 sort = TRUE);
void filter_self_effect(uint32 code, effect_set* eset, uint8 sort = TRUE);
void filter_immune_effect(); void filter_immune_effect();
void filter_disable_related_cards(); void filter_disable_related_cards();
int32 filter_summon_procedure(uint8 playerid, effect_set* eset, uint8 ignore_count, uint8 min_tribute, uint32 zone); int32 filter_summon_procedure(uint8 playerid, effect_set* eset, uint8 ignore_count, uint8 min_tribute, uint32 zone);
...@@ -341,7 +348,9 @@ public: ...@@ -341,7 +348,9 @@ public:
int32 check_set_procedure(effect* proc, uint8 playerid, uint8 ignore_count, uint8 min_tribute, uint32 zone); int32 check_set_procedure(effect* proc, uint8 playerid, uint8 ignore_count, uint8 min_tribute, uint32 zone);
void filter_spsummon_procedure(uint8 playerid, effect_set* eset, uint32 summon_type, material_info info = null_info); void filter_spsummon_procedure(uint8 playerid, effect_set* eset, uint32 summon_type, material_info info = null_info);
void filter_spsummon_procedure_g(uint8 playerid, effect_set* eset); void filter_spsummon_procedure_g(uint8 playerid, effect_set* eset);
effect* is_affected_by_effect(int32 code); effect* find_effect(const effect_container& container, uint32 code, effect_filter f);
effect* find_effect_with_target(const effect_container& container, uint32 code, effect_filter_target f, card* target);
effect* is_affected_by_effect(uint32 code);
effect* is_affected_by_effect(int32 code, card* target); effect* is_affected_by_effect(int32 code, card* target);
int32 fusion_check(group* fusion_m, card* cg, uint32 chkf, uint8 not_material); int32 fusion_check(group* fusion_m, card* cg, uint32 chkf, uint8 not_material);
void fusion_select(uint8 playerid, group* fusion_m, card* cg, uint32 chkf, uint8 not_material); void fusion_select(uint8 playerid, group* fusion_m, card* cg, uint32 chkf, uint8 not_material);
...@@ -404,6 +413,8 @@ public: ...@@ -404,6 +413,8 @@ public:
int32 is_can_be_ritual_material(card* scard); int32 is_can_be_ritual_material(card* scard);
int32 is_can_be_xyz_material(card* scard); int32 is_can_be_xyz_material(card* scard);
int32 is_can_be_link_material(card* scard); int32 is_can_be_link_material(card* scard);
int32 is_original_effect_property(int32 filter);
int32 is_effect_property(int32 filter);
}; };
//Summon Type in summon_info //Summon Type in summon_info
......
...@@ -625,6 +625,11 @@ int32 effect::is_hand_trigger() const { ...@@ -625,6 +625,11 @@ int32 effect::is_hand_trigger() const {
int32 effect::is_initial_single() const { int32 effect::is_initial_single() const {
return (type & EFFECT_TYPE_SINGLE) && is_flag(EFFECT_FLAG_SINGLE_RANGE) && is_flag(EFFECT_FLAG_INITIAL); return (type & EFFECT_TYPE_SINGLE) && is_flag(EFFECT_FLAG_SINGLE_RANGE) && is_flag(EFFECT_FLAG_INITIAL);
} }
int32 effect::is_monster_effect() const {
if (range & (LOCATION_SZONE | LOCATION_FZONE | LOCATION_PZONE))
return FALSE;
return TRUE;
}
//return: this can be reset by reset_level or not //return: this can be reset by reset_level or not
//RESET_DISABLE is valid only when owner == handler //RESET_DISABLE is valid only when owner == handler
int32 effect::reset(uint32 reset_level, uint32 reset_type) { int32 effect::reset(uint32 reset_level, uint32 reset_type) {
......
...@@ -11,9 +11,7 @@ ...@@ -11,9 +11,7 @@
#include "common.h" #include "common.h"
#include "field.h" #include "field.h"
#include "effectset.h" #include "effectset.h"
#include <stdlib.h>
#include <vector> #include <vector>
#include <map>
class card; class card;
class duel; class duel;
...@@ -90,6 +88,7 @@ public: ...@@ -90,6 +88,7 @@ public:
int32 is_chainable(uint8 tp); int32 is_chainable(uint8 tp);
int32 is_hand_trigger() const; int32 is_hand_trigger() const;
int32 is_initial_single() const; int32 is_initial_single() const;
int32 is_monster_effect() const;
int32 reset(uint32 reset_level, uint32 reset_type); int32 reset(uint32 reset_level, uint32 reset_type);
void dec_count(uint8 playerid = PLAYER_NONE); void dec_count(uint8 playerid = PLAYER_NONE);
void recharge(); void recharge();
...@@ -173,6 +172,8 @@ public: ...@@ -173,6 +172,8 @@ public:
#define RESET_OVERLAY 0x04000000 #define RESET_OVERLAY 0x04000000
#define RESET_MSCHANGE 0x08000000 #define RESET_MSCHANGE 0x08000000
constexpr uint32 RESETS_STANDARD = RESET_TOFIELD | RESET_LEAVE | RESET_TODECK | RESET_TOHAND | RESET_TEMP_REMOVE | RESET_REMOVE | RESET_TOGRAVE | RESET_TURN_SET;
//========== Types ========== //========== Types ==========
#define EFFECT_TYPE_SINGLE 0x0001 // #define EFFECT_TYPE_SINGLE 0x0001 //
#define EFFECT_TYPE_FIELD 0x0002 // #define EFFECT_TYPE_FIELD 0x0002 //
...@@ -208,7 +209,7 @@ enum effect_flag : uint32 { ...@@ -208,7 +209,7 @@ enum effect_flag : uint32 {
EFFECT_FLAG_CANNOT_DISABLE = 0x0400, EFFECT_FLAG_CANNOT_DISABLE = 0x0400,
EFFECT_FLAG_PLAYER_TARGET = 0x0800, EFFECT_FLAG_PLAYER_TARGET = 0x0800,
EFFECT_FLAG_BOTH_SIDE = 0x1000, EFFECT_FLAG_BOTH_SIDE = 0x1000,
// EFFECT_FLAG_COPY_INHERIT = 0x2000, EFFECT_FLAG_COPY = 0x2000,
EFFECT_FLAG_DAMAGE_STEP = 0x4000, EFFECT_FLAG_DAMAGE_STEP = 0x4000,
EFFECT_FLAG_DAMAGE_CAL = 0x8000, EFFECT_FLAG_DAMAGE_CAL = 0x8000,
EFFECT_FLAG_DELAY = 0x10000, EFFECT_FLAG_DELAY = 0x10000,
...@@ -240,7 +241,7 @@ enum effect_flag2 : uint32 { ...@@ -240,7 +241,7 @@ enum effect_flag2 : uint32 {
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<uint32>(flag1) | static_cast<uint32>(flag2));
} }
constexpr uint32 INTERNAL_FLAGS = EFFECT_FLAG_INITIAL | EFFECT_FLAG_FUNC_VALUE | EFFECT_FLAG_COUNT_LIMIT | EFFECT_FLAG_FIELD_ONLY | EFFECT_FLAG_ABSOLUTE_TARGET; 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;
//========== Codes ========== //========== Codes ==========
#define EFFECT_IMMUNE_EFFECT 1 // #define EFFECT_IMMUNE_EFFECT 1 //
#define EFFECT_DISABLE 2 // #define EFFECT_DISABLE 2 //
......
...@@ -26,10 +26,6 @@ struct effect_set { ...@@ -26,10 +26,6 @@ struct effect_set {
void remove_item(int index) { void remove_item(int index) {
if (index < 0 || index >= count) if (index < 0 || index >= count)
return; return;
if(index == count - 1) {
--count;
return;
}
for(int i = index; i < count - 1; ++i) for(int i = index; i < count - 1; ++i)
container[i] = container[i + 1]; container[i] = container[i + 1];
--count; --count;
...@@ -86,10 +82,7 @@ struct effect_set_v { ...@@ -86,10 +82,7 @@ struct effect_set_v {
return (int)container.size(); return (int)container.size();
} }
void sort() { void sort() {
int count = (int)container.size(); std::sort(container.begin(), container.end(), effect_sort_id);
if(count < 2)
return;
std::sort(container.begin(), container.begin() + count, effect_sort_id);
} }
effect* const& get_last() const { effect* const& get_last() const {
assert(container.size()); assert(container.size());
......
...@@ -1187,6 +1187,8 @@ void field::tag_swap(uint8 playerid) { ...@@ -1187,6 +1187,8 @@ void field::tag_swap(uint8 playerid) {
pduel->write_buffer32(pcard->data.code | (pcard->is_position(POS_FACEUP) ? 0x80000000 : 0)); pduel->write_buffer32(pcard->data.code | (pcard->is_position(POS_FACEUP) ? 0x80000000 : 0));
} }
void field::add_effect(effect* peffect, uint8 owner_player) { void field::add_effect(effect* peffect, uint8 owner_player) {
if (!peffect)
return;
if (effects.indexer.find(peffect) != effects.indexer.end()) if (effects.indexer.find(peffect) != effects.indexer.end())
return; return;
effect_container::iterator it; effect_container::iterator it;
......
...@@ -16,8 +16,6 @@ ...@@ -16,8 +16,6 @@
#include <set> #include <set>
#include <map> #include <map>
#include <list> #include <list>
#include <array>
#include <functional>
#include <unordered_map> #include <unordered_map>
#include <unordered_set> #include <unordered_set>
......
...@@ -1476,6 +1476,24 @@ int32 scriptlib::card_is_tuner(lua_State* L) { ...@@ -1476,6 +1476,24 @@ int32 scriptlib::card_is_tuner(lua_State* L) {
lua_pushboolean(L, pcard->is_tuner(scard)); lua_pushboolean(L, pcard->is_tuner(scard));
return 1; return 1;
} }
int32 scriptlib::card_is_original_effect_property(lua_State* L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1);
check_param(L, PARAM_TYPE_FUNCTION, 2);
card* pcard = *(card**)lua_touserdata(L, 1);
int32 filter = interpreter::get_function_handle(L, 2);
lua_pushboolean(L, pcard->is_original_effect_property(filter));
return 1;
}
int32 scriptlib::card_is_effect_property(lua_State* L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1);
check_param(L, PARAM_TYPE_FUNCTION, 2);
card* pcard = *(card**)lua_touserdata(L, 1);
int32 filter = interpreter::get_function_handle(L, 2);
lua_pushboolean(L, pcard->is_effect_property(filter));
return 1;
}
int32 scriptlib::card_set_status(lua_State *L) { int32 scriptlib::card_set_status(lua_State *L) {
check_param_count(L, 3); check_param_count(L, 3);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
...@@ -3691,6 +3709,8 @@ static const struct luaL_Reg cardlib[] = { ...@@ -3691,6 +3709,8 @@ static const struct luaL_Reg cardlib[] = {
{ "IsStatus", scriptlib::card_is_status }, { "IsStatus", scriptlib::card_is_status },
{ "IsNotTuner", scriptlib::card_is_not_tuner }, { "IsNotTuner", scriptlib::card_is_not_tuner },
{ "IsTuner", scriptlib::card_is_tuner }, { "IsTuner", scriptlib::card_is_tuner },
{ "IsOriginalEffectProperty", scriptlib::card_is_original_effect_property },
{ "IsEffectProperty", scriptlib::card_is_effect_property },
{ "SetStatus", scriptlib::card_set_status }, { "SetStatus", scriptlib::card_set_status },
{ "IsDualState", scriptlib::card_is_dual_state }, { "IsDualState", scriptlib::card_is_dual_state },
{ "EnableDualState", scriptlib::card_enable_dual_state }, { "EnableDualState", scriptlib::card_enable_dual_state },
......
...@@ -5039,7 +5039,7 @@ int32 scriptlib::duel_majestic_copy(lua_State *L) { ...@@ -5039,7 +5039,7 @@ int32 scriptlib::duel_majestic_copy(lua_State *L) {
ceffect->flag[0] &= ~EFFECT_FLAG_INITIAL; ceffect->flag[0] &= ~EFFECT_FLAG_INITIAL;
ceffect->effect_owner = PLAYER_NONE; ceffect->effect_owner = PLAYER_NONE;
ceffect->reset_flag = RESET_EVENT + 0x1fe0000 + RESET_PHASE + PHASE_END + RESET_SELF_TURN + RESET_OPPO_TURN; ceffect->reset_flag = RESET_EVENT + 0x1fe0000 + RESET_PHASE + PHASE_END + RESET_SELF_TURN + RESET_OPPO_TURN;
ceffect->reset_count = 0x1; ceffect->reset_count = 1;
ceffect->recharge(); ceffect->recharge();
if(ceffect->type & EFFECT_TYPE_TRIGGER_F) { if(ceffect->type & EFFECT_TYPE_TRIGGER_F) {
ceffect->type &= ~EFFECT_TYPE_TRIGGER_F; ceffect->type &= ~EFFECT_TYPE_TRIGGER_F;
......
...@@ -46,6 +46,64 @@ int32 scriptlib::effect_get_count_limit(lua_State *L) { ...@@ -46,6 +46,64 @@ int32 scriptlib::effect_get_count_limit(lua_State *L) {
return args; return args;
} }
int32 scriptlib::get_effect_property(lua_State* L, effect_member type) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**)lua_touserdata(L, 1);
lua_Integer value{};
if (peffect) {
switch (type) {
case MEMBER_CATEGORY:
value = peffect->category;
break;
case MEMBER_CODE:
value = peffect->code;
break;
case MEMBER_DESCRIPTION:
value = peffect->description;
break;
case MEMBER_ID:
value = peffect->id;
break;
case MEMBER_RANGE:
value = peffect->range;
break;
case MEMBER_TYPE:
value = peffect->type;
break;
}
}
lua_pushinteger(L, value);
return 1;
}
int32 scriptlib::is_effect_property(lua_State* L, effect_member type) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**)lua_touserdata(L, 1);
uint64 value{};
if (peffect) {
switch (type) {
case MEMBER_CATEGORY:
value = peffect->category;
break;
case MEMBER_CODE:
value = peffect->code;
break;
case MEMBER_RANGE:
value = peffect->range;
break;
case MEMBER_TYPE:
value = peffect->type;
break;
}
}
uint64 x = lua_tointeger(L, 2);
if (value & x)
lua_pushboolean(L, 1);
else
lua_pushboolean(L, 0);
return 1;
}
int32 scriptlib::effect_new(lua_State *L) { int32 scriptlib::effect_new(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
...@@ -86,11 +144,7 @@ int32 scriptlib::effect_reset(lua_State *L) { ...@@ -86,11 +144,7 @@ int32 scriptlib::effect_reset(lua_State *L) {
return 0; return 0;
} }
int32 scriptlib::effect_get_field_id(lua_State *L) { int32 scriptlib::effect_get_field_id(lua_State *L) {
check_param_count(L, 1); return get_effect_property(L, MEMBER_ID);
check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1);
lua_pushinteger(L, peffect->id);
return 1;
} }
int32 scriptlib::effect_set_description(lua_State *L) { int32 scriptlib::effect_set_description(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
...@@ -181,19 +235,27 @@ int32 scriptlib::effect_set_type(lua_State *L) { ...@@ -181,19 +235,27 @@ int32 scriptlib::effect_set_type(lua_State *L) {
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 v = (uint32)lua_tointeger(L, 2); uint32 v = (uint32)lua_tointeger(L, 2);
if (v & EFFECT_TYPE_ACTIVATE) {
v = EFFECT_TYPE_FIELD | EFFECT_TYPE_ACTIVATE;
peffect->range = LOCATION_SZONE + LOCATION_FZONE + LOCATION_HAND;
}
else if(v & EFFECT_TYPE_FLIP) {
peffect->code = EVENT_FLIP;
if (v & EFFECT_TYPE_TRIGGER_O) {
v = EFFECT_TYPE_SINGLE | EFFECT_TYPE_FLIP | EFFECT_TYPE_TRIGGER_O;
peffect->flag[0] |= EFFECT_FLAG_DELAY;
}
else {
v = EFFECT_TYPE_SINGLE | EFFECT_TYPE_FLIP | EFFECT_TYPE_TRIGGER_F;
}
}
else if (v & (EFFECT_TYPE_IGNITION | EFFECT_TYPE_QUICK_O | EFFECT_TYPE_QUICK_F)) {
v |= EFFECT_TYPE_FIELD;
}
if (v & (EFFECT_TYPES_CHAIN_LINK | EFFECT_TYPE_CONTINUOUS)) if (v & (EFFECT_TYPES_CHAIN_LINK | EFFECT_TYPE_CONTINUOUS))
v |= EFFECT_TYPE_ACTIONS; v |= EFFECT_TYPE_ACTIONS;
else else
v &= ~EFFECT_TYPE_ACTIONS; v &= ~EFFECT_TYPE_ACTIONS;
if(v & (EFFECT_TYPE_ACTIVATE | EFFECT_TYPE_IGNITION | EFFECT_TYPE_QUICK_O | EFFECT_TYPE_QUICK_F))
v |= EFFECT_TYPE_FIELD;
if(v & EFFECT_TYPE_ACTIVATE)
peffect->range = LOCATION_SZONE + LOCATION_FZONE + LOCATION_HAND;
if(v & EFFECT_TYPE_FLIP) {
peffect->code = EVENT_FLIP;
if(!(v & EFFECT_TYPE_TRIGGER_O))
v |= EFFECT_TYPE_TRIGGER_F;
}
peffect->type = v; peffect->type = v;
return 0; return 0;
} }
...@@ -337,34 +399,13 @@ int32 scriptlib::effect_set_owner_player(lua_State *L) { ...@@ -337,34 +399,13 @@ int32 scriptlib::effect_set_owner_player(lua_State *L) {
return 0; return 0;
} }
int32 scriptlib::effect_get_description(lua_State *L) { int32 scriptlib::effect_get_description(lua_State *L) {
check_param_count(L, 1); return get_effect_property(L, MEMBER_DESCRIPTION);
check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1);
if (peffect) {
lua_pushinteger(L, peffect->description);
return 1;
}
return 0;
} }
int32 scriptlib::effect_get_code(lua_State *L) { int32 scriptlib::effect_get_code(lua_State *L) {
check_param_count(L, 1); return get_effect_property(L, MEMBER_CODE);
check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1);
if (peffect) {
lua_pushinteger(L, peffect->code);
return 1;
}
return 0;
} }
int32 scriptlib::effect_get_type(lua_State *L) { int32 scriptlib::effect_get_type(lua_State *L) {
check_param_count(L, 1); return get_effect_property(L, MEMBER_TYPE);
check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1);
if (peffect) {
lua_pushinteger(L, peffect->type);
return 1;
}
return 0;
} }
int32 scriptlib::effect_get_property(lua_State *L) { int32 scriptlib::effect_get_property(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
...@@ -410,14 +451,10 @@ int32 scriptlib::effect_get_label_object(lua_State *L) { ...@@ -410,14 +451,10 @@ int32 scriptlib::effect_get_label_object(lua_State *L) {
} }
} }
int32 scriptlib::effect_get_category(lua_State *L) { int32 scriptlib::effect_get_category(lua_State *L) {
check_param_count(L, 1); return get_effect_property(L, MEMBER_CATEGORY);
check_param(L, PARAM_TYPE_EFFECT, 1); }
effect* peffect = *(effect**) lua_touserdata(L, 1); int32 scriptlib::effect_get_range(lua_State* L) {
if (peffect) { return get_effect_property(L, MEMBER_RANGE);
lua_pushinteger(L, peffect->category);
return 1;
}
return 0;
} }
int32 scriptlib::effect_get_owner(lua_State *L) { int32 scriptlib::effect_get_owner(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
...@@ -516,26 +553,13 @@ int32 scriptlib::effect_is_has_property(lua_State *L) { ...@@ -516,26 +553,13 @@ int32 scriptlib::effect_is_has_property(lua_State *L) {
return 1; return 1;
} }
int32 scriptlib::effect_is_has_category(lua_State *L) { int32 scriptlib::effect_is_has_category(lua_State *L) {
check_param_count(L, 2); return is_effect_property(L, MEMBER_CATEGORY);
check_param(L, PARAM_TYPE_EFFECT, 1);
effect* peffect = *(effect**) lua_touserdata(L, 1);
uint32 tcate = (uint32)lua_tointeger(L, 2);
if (peffect && (peffect->category & tcate))
lua_pushboolean(L, 1);
else
lua_pushboolean(L, 0);
return 1;
} }
int32 scriptlib::effect_is_has_type(lua_State *L) { int32 scriptlib::effect_is_has_type(lua_State *L) {
check_param_count(L, 2); return is_effect_property(L, MEMBER_TYPE);
check_param(L, PARAM_TYPE_EFFECT, 1); }
effect* peffect = *(effect**) lua_touserdata(L, 1); int32 scriptlib::effect_is_has_range(lua_State* L) {
uint32 ttype = (uint32)lua_tointeger(L, 2); return is_effect_property(L, MEMBER_RANGE);
if (peffect && (peffect->type & ttype))
lua_pushboolean(L, 1);
else
lua_pushboolean(L, 0);
return 1;
} }
int32 scriptlib::effect_is_activatable(lua_State *L) { int32 scriptlib::effect_is_activatable(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
...@@ -653,6 +677,7 @@ static const struct luaL_Reg effectlib[] = { ...@@ -653,6 +677,7 @@ static const struct luaL_Reg effectlib[] = {
{ "GetLabel", scriptlib::effect_get_label }, { "GetLabel", scriptlib::effect_get_label },
{ "GetLabelObject", scriptlib::effect_get_label_object }, { "GetLabelObject", scriptlib::effect_get_label_object },
{ "GetCategory", scriptlib::effect_get_category }, { "GetCategory", scriptlib::effect_get_category },
{ "GetRange", scriptlib::effect_get_range },
{ "GetOwner", scriptlib::effect_get_owner }, { "GetOwner", scriptlib::effect_get_owner },
{ "GetHandler", scriptlib::effect_get_handler }, { "GetHandler", scriptlib::effect_get_handler },
{ "GetCondition", scriptlib::effect_get_condition }, { "GetCondition", scriptlib::effect_get_condition },
...@@ -667,6 +692,7 @@ static const struct luaL_Reg effectlib[] = { ...@@ -667,6 +692,7 @@ static const struct luaL_Reg effectlib[] = {
{ "IsHasProperty", scriptlib::effect_is_has_property }, { "IsHasProperty", scriptlib::effect_is_has_property },
{ "IsHasCategory", scriptlib::effect_is_has_category }, { "IsHasCategory", scriptlib::effect_is_has_category },
{ "IsHasType", scriptlib::effect_is_has_type }, { "IsHasType", scriptlib::effect_is_has_type },
{ "IsHasRange", scriptlib::effect_is_has_range },
{ "IsActivatable", scriptlib::effect_is_activatable }, { "IsActivatable", scriptlib::effect_is_activatable },
{ "IsActivated", scriptlib::effect_is_activated }, { "IsActivated", scriptlib::effect_is_activated },
{ "IsCostChecked", scriptlib::effect_is_cost_checked }, { "IsCostChecked", scriptlib::effect_is_cost_checked },
......
...@@ -4621,9 +4621,9 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret, ...@@ -4621,9 +4621,9 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret,
} }
} else if(pzone && location == LOCATION_SZONE && (target->data.type & TYPE_PENDULUM)) { } else if(pzone && location == LOCATION_SZONE && (target->data.type & TYPE_PENDULUM)) {
uint32 flag = 0; uint32 flag = 0;
if(is_location_useable(playerid, LOCATION_PZONE, 0)) if (is_location_useable(playerid, LOCATION_PZONE, 0) && zone & 0x1)
flag |= 0x1u << (core.duel_rule >= NEW_MASTER_RULE ? 8 : 14); flag |= 0x1u << (core.duel_rule >= NEW_MASTER_RULE ? 8 : 14);
if(is_location_useable(playerid, LOCATION_PZONE, 1)) if (is_location_useable(playerid, LOCATION_PZONE, 1) && zone & 0x10)
flag |= 0x1u << (core.duel_rule >= NEW_MASTER_RULE ? 12 : 15); flag |= 0x1u << (core.duel_rule >= NEW_MASTER_RULE ? 12 : 15);
if(!flag) { if(!flag) {
core.units.begin()->step = 3; core.units.begin()->step = 3;
...@@ -4815,7 +4815,7 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret, ...@@ -4815,7 +4815,7 @@ int32 field::move_to_field(uint16 step, card* target, uint32 enable, uint32 ret,
peffect->reset_flag = RESET_EVENT + 0x1fc0000; peffect->reset_flag = RESET_EVENT + 0x1fc0000;
peffect->value = TYPE_MONSTER | type; peffect->value = TYPE_MONSTER | type;
target->add_effect(peffect); target->add_effect(peffect);
if(core.duel_rule <= 4 && (type & TYPE_TRAPMONSTER)) { if(core.duel_rule <= NEW_MASTER_RULE && (type & TYPE_TRAPMONSTER)) {
peffect = pduel->new_effect(); peffect = pduel->new_effect();
peffect->owner = target; peffect->owner = target;
peffect->type = EFFECT_TYPE_FIELD; peffect->type = EFFECT_TYPE_FIELD;
......
...@@ -17,6 +17,14 @@ constexpr bool match_all(uint32 x, uint32 y) { ...@@ -17,6 +17,14 @@ constexpr bool match_all(uint32 x, uint32 y) {
class scriptlib { class scriptlib {
public: public:
enum effect_member : int32 {
MEMBER_CATEGORY,
MEMBER_CODE,
MEMBER_DESCRIPTION,
MEMBER_ID,
MEMBER_RANGE,
MEMBER_TYPE,
};
static int32 check_param(lua_State* L, int32 param_type, int32 index, int32 retfalse = FALSE); static int32 check_param(lua_State* L, int32 param_type, int32 index, int32 retfalse = FALSE);
static int32 check_param_count(lua_State* L, int32 count); static int32 check_param_count(lua_State* L, int32 count);
static int32 check_action_permission(lua_State* L); static int32 check_action_permission(lua_State* L);
...@@ -165,6 +173,8 @@ public: ...@@ -165,6 +173,8 @@ public:
static int32 card_is_status(lua_State *L); static int32 card_is_status(lua_State *L);
static int32 card_is_not_tuner(lua_State *L); static int32 card_is_not_tuner(lua_State *L);
static int32 card_is_tuner(lua_State* L); static int32 card_is_tuner(lua_State* L);
static int32 card_is_original_effect_property(lua_State* L);
static int32 card_is_effect_property(lua_State* L);
static int32 card_set_status(lua_State *L); static int32 card_set_status(lua_State *L);
static int32 card_is_dual_state(lua_State *L); static int32 card_is_dual_state(lua_State *L);
static int32 card_enable_dual_state(lua_State *L); static int32 card_enable_dual_state(lua_State *L);
...@@ -323,6 +333,8 @@ public: ...@@ -323,6 +333,8 @@ public:
static void open_cardlib(lua_State *L); static void open_cardlib(lua_State *L);
//Effect functions //Effect functions
static int32 get_effect_property(lua_State* L, effect_member type);
static int32 is_effect_property(lua_State* L, effect_member type);
static int32 effect_new(lua_State *L); static int32 effect_new(lua_State *L);
static int32 effect_newex(lua_State *L); static int32 effect_newex(lua_State *L);
static int32 effect_clone(lua_State *L); static int32 effect_clone(lua_State *L);
...@@ -354,6 +366,7 @@ public: ...@@ -354,6 +366,7 @@ public:
static int32 effect_get_label(lua_State *L); static int32 effect_get_label(lua_State *L);
static int32 effect_get_label_object(lua_State *L); static int32 effect_get_label_object(lua_State *L);
static int32 effect_get_category(lua_State *L); static int32 effect_get_category(lua_State *L);
static int32 effect_get_range(lua_State* L);
static int32 effect_get_owner(lua_State *L); static int32 effect_get_owner(lua_State *L);
static int32 effect_get_handler(lua_State *L); static int32 effect_get_handler(lua_State *L);
static int32 effect_get_owner_player(lua_State *L); static int32 effect_get_owner_player(lua_State *L);
...@@ -367,6 +380,7 @@ public: ...@@ -367,6 +380,7 @@ public:
static int32 effect_is_active_type(lua_State *L); static int32 effect_is_active_type(lua_State *L);
static int32 effect_is_has_property(lua_State *L); static int32 effect_is_has_property(lua_State *L);
static int32 effect_is_has_category(lua_State *L); static int32 effect_is_has_category(lua_State *L);
static int32 effect_is_has_range(lua_State* L);
static int32 effect_is_has_type(lua_State *L); static int32 effect_is_has_type(lua_State *L);
static int32 effect_is_activatable(lua_State *L); static int32 effect_is_activatable(lua_State *L);
static int32 effect_is_activated(lua_State *L); static int32 effect_is_activated(lua_State *L);
......
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