Commit 96ca3ab7 authored by nanahira's avatar nanahira

Merge branch 'develop' of ../../versions/ygopro-mc/ocgcore into develop

parents 5bebf72b e0acb211
...@@ -466,7 +466,7 @@ uint32 card::get_info_location() { ...@@ -466,7 +466,7 @@ uint32 card::get_info_location() {
} }
// get the printed code on card // get the printed code on card
uint32 card::get_original_code() const { uint32 card::get_original_code() const {
if (data.alias && (data.alias < data.code + CARD_ARTWORK_VERSIONS_OFFSET) && (data.code < data.alias + CARD_ARTWORK_VERSIONS_OFFSET)) if (data.is_alternative())
return data.alias; return data.alias;
else else
return data.code; return data.code;
...@@ -521,95 +521,66 @@ uint32 card::get_another_code() { ...@@ -521,95 +521,66 @@ uint32 card::get_another_code() {
return otcode; return otcode;
return 0; return 0;
} }
inline bool check_setcode(uint16_t setcode, uint32 value) {
uint16_t settype = value & 0x0fff;
uint16_t setsubtype = value & 0xf000;
return (setcode & 0x0fff) == settype && (setcode & 0xf000 & setsubtype) == setsubtype;
}
bool card::check_card_setcode(uint32 code, uint32 value) {
card_data dat;
::read_card(code, &dat);
return dat.is_setcode(value);
}
int32 card::is_set_card(uint32 set_code) { int32 card::is_set_card(uint32 set_code) {
uint32 code = get_code(); uint32 code1 = get_code();
uint64 setcode; card_data dat1;
if (code == data.code) { if (code1 == data.code) {
setcode = data.setcode; if (data.is_setcode(set_code))
} else { return TRUE;
card_data dat;
::read_card(code, &dat);
setcode = dat.setcode;
} }
uint32 settype = set_code & 0xfff; else {
uint32 setsubtype = set_code & 0xf000; if (check_card_setcode(code1, set_code))
while(setcode) {
if ((setcode & 0xfff) == settype && (setcode & 0xf000 & setsubtype) == setsubtype)
return TRUE; return TRUE;
setcode = setcode >> 16;
} }
uint32 code2 = get_another_code();
if (code2 && check_card_setcode(code2, set_code))
return TRUE;
//add set code //add set code
effect_set eset; effect_set eset;
filter_effect(EFFECT_ADD_SETCODE, &eset); filter_effect(EFFECT_ADD_SETCODE, &eset);
for(int32 i = 0; i < eset.size(); ++i) { for(int32 i = 0; i < eset.size(); ++i) {
uint32 value = eset[i]->get_value(this); uint32 value = eset[i]->get_value(this);
if ((value & 0xfff) == settype && (value & 0xf000 & setsubtype) == setsubtype) uint16_t new_setcode = value & 0xffff;
if (check_setcode(new_setcode, set_code))
return TRUE; return TRUE;
} }
//another code
uint32 code2 = get_another_code();
uint64 setcode2;
if (code2 != 0) {
card_data dat;
::read_card(code2, &dat);
setcode2 = dat.setcode;
} else {
return FALSE;
}
while(setcode2) {
if ((setcode2 & 0xfff) == settype && (setcode2 & 0xf000 & setsubtype) == setsubtype)
return TRUE;
setcode2 = setcode2 >> 16;
}
return FALSE; return FALSE;
} }
int32 card::is_origin_set_card(uint32 set_code) { int32 card::is_origin_set_card(uint32 set_code) {
uint64 setcode = data.setcode; if (data.is_setcode(set_code))
uint32 settype = set_code & 0xfff; return TRUE;
uint32 setsubtype = set_code & 0xf000; uint32 code2 = std::get<1>(get_original_code_rule());
while(setcode) { if (code2 && check_card_setcode(code2, set_code))
if((setcode & 0xfff) == settype && (setcode & 0xf000 & setsubtype) == setsubtype) return TRUE;
return TRUE;
setcode = setcode >> 16;
}
return FALSE; return FALSE;
} }
int32 card::is_pre_set_card(uint32 set_code) { int32 card::is_pre_set_card(uint32 set_code) {
uint32 code = previous.code; uint32 code = previous.code;
uint64 setcode;
if (code == data.code) { if (code == data.code) {
setcode = data.setcode; if (data.is_setcode(set_code))
} else {
card_data dat;
::read_card(code, &dat);
setcode = dat.setcode;
}
uint32 settype = set_code & 0xfff;
uint32 setsubtype = set_code & 0xf000;
while(setcode) {
if ((setcode & 0xfff) == settype && (setcode & 0xf000 & setsubtype) == setsubtype)
return TRUE; return TRUE;
setcode = setcode >> 16;
} }
//add set code else {
for(auto& presetcode : previous.setcode) { if (check_card_setcode(code, set_code))
if (presetcode && (presetcode & 0xfff) == settype && (presetcode & 0xf000 & setsubtype) == setsubtype)
return TRUE; return TRUE;
} }
//another code
uint32 code2 = previous.code2; uint32 code2 = previous.code2;
uint64 setcode2; if (code2 && check_card_setcode(code2, set_code))
if (code2 != 0) { return TRUE;
card_data dat; //add set code
::read_card(code2, &dat); for(auto& presetcode : previous.setcode) {
setcode2 = dat.setcode; if (check_setcode(presetcode, set_code))
} else {
return FALSE;
}
while(setcode2) {
if ((setcode2 & 0xfff) == settype && (setcode2 & 0xf000 & setsubtype) == setsubtype)
return TRUE; return TRUE;
setcode2 = setcode2 >> 16;
} }
return FALSE; return FALSE;
} }
...@@ -618,26 +589,19 @@ int32 card::is_fusion_set_card(uint32 set_code) { ...@@ -618,26 +589,19 @@ int32 card::is_fusion_set_card(uint32 set_code) {
return TRUE; return TRUE;
if(pduel->game_field->core.not_material) if(pduel->game_field->core.not_material)
return FALSE; return FALSE;
uint32 settype = set_code & 0xfff;
uint32 setsubtype = set_code & 0xf000;
effect_set eset; effect_set eset;
filter_effect(EFFECT_ADD_FUSION_CODE, &eset); filter_effect(EFFECT_ADD_FUSION_CODE, &eset);
for(int32 i = 0; i < eset.size(); ++i) { for(int32 i = 0; i < eset.size(); ++i) {
uint32 code = eset[i]->get_value(this); uint32 code = eset[i]->get_value(this);
card_data dat; if (check_card_setcode(code, set_code))
::read_card(code, &dat); return TRUE;
uint64 setcode = dat.setcode;
while(setcode) {
if ((setcode & 0xfff) == settype && (setcode & 0xf000 & setsubtype) == setsubtype)
return TRUE;
setcode = setcode >> 16;
}
} }
eset.clear(); eset.clear();
filter_effect(EFFECT_ADD_FUSION_SETCODE, &eset); filter_effect(EFFECT_ADD_FUSION_SETCODE, &eset);
for(int32 i = 0; i < eset.size(); ++i) { for(int32 i = 0; i < eset.size(); ++i) {
uint32 setcode = eset[i]->get_value(this); uint32 value = eset[i]->get_value(this);
if ((setcode & 0xfff) == settype && (setcode & 0xf000 & setsubtype) == setsubtype) uint16_t new_setcode = value & 0xffff;
if (check_setcode(new_setcode, set_code))
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
...@@ -651,54 +615,23 @@ int32 card::is_link_set_card(uint32 set_code) { ...@@ -651,54 +615,23 @@ int32 card::is_link_set_card(uint32 set_code) {
filter_effect(EFFECT_ADD_LINK_CODE, &eset); filter_effect(EFFECT_ADD_LINK_CODE, &eset);
for(int32 i = 0; i < eset.size(); ++i) { for(int32 i = 0; i < eset.size(); ++i) {
uint32 code = eset[i]->get_value(this); uint32 code = eset[i]->get_value(this);
card_data dat; if (check_card_setcode(code, set_code))
::read_card(code, &dat); return TRUE;
uint64 setcode = dat.setcode;
while(setcode) {
if ((setcode & 0xfff) == settype && (setcode & 0xf000 & setsubtype) == setsubtype)
return TRUE;
setcode = setcode >> 16;
}
} }
return FALSE; return FALSE;
} }
int32 card::is_special_summon_set_card(uint32 set_code) { int32 card::is_special_summon_set_card(uint32 set_code) {
uint32 code = spsummon.code; uint32 code = spsummon.code;
uint64 setcode; if (check_card_setcode(code, set_code))
if (code == data.code) { return TRUE;
setcode = data.setcode; uint32 code2 = spsummon.code2;
} else { if (code2 && check_card_setcode(code2, set_code))
card_data dat; return TRUE;
::read_card(code, &dat);
setcode = dat.setcode;
}
uint32 settype = set_code & 0xfff;
uint32 setsubtype = set_code & 0xf000;
while(setcode) {
if ((setcode & 0xfff) == settype && (setcode & 0xf000 & setsubtype) == setsubtype)
return TRUE;
setcode = setcode >> 16;
}
//add set code //add set code
for(auto& spsetcode : spsummon.setcode) { for(auto& spsetcode : spsummon.setcode) {
if (spsetcode && (spsetcode & 0xfff) == settype && (spsetcode & 0xf000 & setsubtype) == setsubtype) if (check_setcode(spsetcode, set_code))
return TRUE; return TRUE;
} }
//another code
uint32 code2 = spsummon.code2;
uint64 setcode2;
if (code2 != 0) {
card_data dat;
::read_card(code2, &dat);
setcode2 = dat.setcode;
} else {
return FALSE;
}
while(setcode2) {
if ((setcode2 & 0xfff) == settype && (setcode2 & 0xf000 & setsubtype) == setsubtype)
return TRUE;
setcode2 = setcode2 >> 16;
}
return FALSE; return FALSE;
} }
uint32 card::get_type() { uint32 card::get_type() {
...@@ -2725,7 +2658,7 @@ void card::set_special_summon_status(effect* peffect) { ...@@ -2725,7 +2658,7 @@ void card::set_special_summon_status(effect* peffect) {
effect_set eset; effect_set eset;
pcard->filter_effect(EFFECT_ADD_SETCODE, &eset); pcard->filter_effect(EFFECT_ADD_SETCODE, &eset);
for(int32 i = 0; i < eset.size(); ++i) { for(int32 i = 0; i < eset.size(); ++i) {
spsummon.setcode.push_back((uint32)eset[i]->get_value(pcard)); spsummon.setcode.push_back((uint32)eset[i]->get_value(pcard) & 0xffff);
} }
spsummon.reason_effect = peffect; spsummon.reason_effect = peffect;
spsummon.reason_player = peffect->get_handler_player(); spsummon.reason_player = peffect->get_handler_player();
...@@ -2744,7 +2677,7 @@ void card::set_special_summon_status(effect* peffect) { ...@@ -2744,7 +2677,7 @@ void card::set_special_summon_status(effect* peffect) {
effect_set eset; effect_set eset;
pcard->filter_effect(EFFECT_ADD_SETCODE, &eset); pcard->filter_effect(EFFECT_ADD_SETCODE, &eset);
for(int32 i = 0; i < eset.size(); ++i) { for(int32 i = 0; i < eset.size(); ++i) {
spsummon.setcode.push_back((uint32)eset[i]->get_value(pcard)); spsummon.setcode.push_back((uint32)eset[i]->get_value(pcard) & 0xffff);
} }
spsummon.reason_effect = cait->triggering_effect; spsummon.reason_effect = cait->triggering_effect;
spsummon.reason_player = cait->triggering_player; spsummon.reason_player = cait->triggering_player;
...@@ -3576,6 +3509,28 @@ int32 card::is_can_be_summoned(uint8 playerid, uint8 ignore_count, effect* peffe ...@@ -3576,6 +3509,28 @@ int32 card::is_can_be_summoned(uint8 playerid, uint8 ignore_count, effect* peffe
pduel->game_field->restore_lp_cost(); pduel->game_field->restore_lp_cost();
return TRUE; return TRUE;
} }
int32 card::is_summon_negatable(uint32 sumtype, effect* reason_effect) {
uint32 code = 0;
if (sumtype & SUMMON_TYPE_NORMAL)
code = EFFECT_CANNOT_DISABLE_SUMMON;
else if (sumtype & SUMMON_TYPE_FLIP)
code = EFFECT_CANNOT_DISABLE_FLIP_SUMMON;
else if (sumtype & SUMMON_TYPE_SPECIAL)
code = EFFECT_CANNOT_DISABLE_SPSUMMON;
else
return FALSE;
if (is_affected_by_effect(code))
return FALSE;
if (sumtype == SUMMON_TYPE_DUAL || sumtype & SUMMON_TYPE_FLIP) {
if (!is_status(STATUS_FLIP_SUMMONING))
return FALSE;
if (!is_affect_by_effect(reason_effect))
return FALSE;
if (sumtype == SUMMON_TYPE_DUAL && (!is_affected_by_effect(EFFECT_DUAL_SUMMONABLE) || is_affected_by_effect(EFFECT_DUAL_STATUS)))
return FALSE;
}
return TRUE;
}
int32 card::get_summon_tribute_count() { int32 card::get_summon_tribute_count() {
int32 min = 0, max = 0; int32 min = 0, max = 0;
int32 level = get_level(); int32 level = get_level();
...@@ -4047,8 +4002,8 @@ int32 card::is_capable_send_to_hand(uint8 playerid) { ...@@ -4047,8 +4002,8 @@ int32 card::is_capable_send_to_hand(uint8 playerid) {
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
int32 card::is_capable_send_to_deck(uint8 playerid) { int32 card::is_capable_send_to_deck(uint8 playerid, uint8 send_activating) {
if(is_status(STATUS_LEAVE_CONFIRMED)) if(!send_activating && is_status(STATUS_LEAVE_CONFIRMED))
return FALSE; return FALSE;
if((current.location == LOCATION_EXTRA) && is_extra_deck_monster()) if((current.location == LOCATION_EXTRA) && is_extra_deck_monster())
return FALSE; return FALSE;
......
...@@ -26,7 +26,7 @@ struct chain; ...@@ -26,7 +26,7 @@ struct chain;
struct card_state { struct card_state {
uint32 code{ 0 }; uint32 code{ 0 };
uint32 code2{ 0 }; uint32 code2{ 0 };
std::vector<uint32> setcode; std::vector<uint16_t> setcode;
uint32 type{ 0 }; uint32 type{ 0 };
uint32 level{ 0 }; uint32 level{ 0 };
uint32 rank{ 0 }; uint32 rank{ 0 };
...@@ -226,6 +226,7 @@ public: ...@@ -226,6 +226,7 @@ public:
std::tuple<uint32, uint32> get_original_code_rule() const; std::tuple<uint32, uint32> get_original_code_rule() const;
uint32 get_code(); uint32 get_code();
uint32 get_another_code(); uint32 get_another_code();
static bool check_card_setcode(uint32 code, uint32 value);
int32 is_set_card(uint32 set_code); int32 is_set_card(uint32 set_code);
int32 is_origin_set_card(uint32 set_code); int32 is_origin_set_card(uint32 set_code);
int32 is_pre_set_card(uint32 set_code); int32 is_pre_set_card(uint32 set_code);
...@@ -349,6 +350,7 @@ public: ...@@ -349,6 +350,7 @@ public:
int32 is_spsummonable(effect* proc, material_info info = null_info); int32 is_spsummonable(effect* proc, material_info info = null_info);
int32 is_summonable(effect* proc, uint8 min_tribute, uint32 zone = 0x1f, uint32 releasable = 0xff00ff); int32 is_summonable(effect* proc, uint8 min_tribute, uint32 zone = 0x1f, uint32 releasable = 0xff00ff);
int32 is_can_be_summoned(uint8 playerid, uint8 ingore_count, effect* peffect, uint8 min_tribute, uint32 zone = 0x1f); int32 is_can_be_summoned(uint8 playerid, uint8 ingore_count, effect* peffect, uint8 min_tribute, uint32 zone = 0x1f);
int32 is_summon_negatable(uint32 sumtype, effect* reason_effect);
int32 get_summon_tribute_count(); int32 get_summon_tribute_count();
int32 get_set_tribute_count(); int32 get_set_tribute_count();
int32 is_can_be_flip_summoned(uint8 playerid); int32 is_can_be_flip_summoned(uint8 playerid);
...@@ -372,7 +374,7 @@ public: ...@@ -372,7 +374,7 @@ public:
int32 is_releasable_by_effect(uint8 playerid, effect* reason_effect); int32 is_releasable_by_effect(uint8 playerid, effect* reason_effect);
int32 is_capable_send_to_grave(uint8 playerid); int32 is_capable_send_to_grave(uint8 playerid);
int32 is_capable_send_to_hand(uint8 playerid); int32 is_capable_send_to_hand(uint8 playerid);
int32 is_capable_send_to_deck(uint8 playerid); int32 is_capable_send_to_deck(uint8 playerid, uint8 send_activating = FALSE);
int32 is_capable_send_to_extra(uint8 playerid); int32 is_capable_send_to_extra(uint8 playerid);
int32 is_capable_cost_to_grave(uint8 playerid); int32 is_capable_cost_to_grave(uint8 playerid);
int32 is_capable_cost_to_hand(uint8 playerid); int32 is_capable_cost_to_hand(uint8 playerid);
...@@ -417,6 +419,8 @@ public: ...@@ -417,6 +419,8 @@ public:
#define SUMMON_VALUE_CUSTOM_TYPE 0x0000ffff #define SUMMON_VALUE_CUSTOM_TYPE 0x0000ffff
constexpr uint32 DEFAULT_SUMMON_TYPE = SUMMON_VALUE_MAIN_TYPE | SUMMON_VALUE_SUB_TYPE | SUMMON_VALUE_CUSTOM_TYPE; constexpr uint32 DEFAULT_SUMMON_TYPE = SUMMON_VALUE_MAIN_TYPE | SUMMON_VALUE_SUB_TYPE | SUMMON_VALUE_CUSTOM_TYPE;
#define SUMMON_VALUE_FUTURE_FUSION 0x18
//Counter //Counter
#define COUNTER_WITHOUT_PERMIT 0x1000 #define COUNTER_WITHOUT_PERMIT 0x1000
//#define COUNTER_NEED_ENABLE 0x2000 //#define COUNTER_NEED_ENABLE 0x2000
...@@ -444,6 +448,4 @@ constexpr uint32 DEFAULT_SUMMON_TYPE = SUMMON_VALUE_MAIN_TYPE | SUMMON_VALUE_SUB ...@@ -444,6 +448,4 @@ constexpr uint32 DEFAULT_SUMMON_TYPE = SUMMON_VALUE_MAIN_TYPE | SUMMON_VALUE_SUB
#define SUMMON_INFO_REASON_EFFECT 0x200 #define SUMMON_INFO_REASON_EFFECT 0x200
#define SUMMON_INFO_REASON_PLAYER 0x400 #define SUMMON_INFO_REASON_PLAYER 0x400
#define CARD_ARTWORK_VERSIONS_OFFSET 10
#endif /* CARD_H_ */ #endif /* CARD_H_ */
#ifndef CARD_DATA_H_ #ifndef CARD_DATA_H_
#define CARD_DATA_H_ #define CARD_DATA_H_
#include "common.h"
constexpr int CARD_ARTWORK_VERSIONS_OFFSET = 10;
constexpr int SIZE_SETCODE = 16;
struct card_data { struct card_data {
uint32 code{ 0 }; uint32 code{};
uint32 alias{ 0 }; uint32 alias{};
uint64 setcode{ 0 }; uint16_t setcode[SIZE_SETCODE]{};
uint32 type{ 0 }; uint32 type{};
uint32 level{ 0 }; uint32 level{};
uint32 attribute{ 0 }; uint32 attribute{};
uint32 race{ 0 }; uint32 race{};
int32 attack{ 0 }; int32 attack{};
int32 defense{ 0 }; int32 defense{};
uint32 lscale{ 0 }; uint32 lscale{};
uint32 rscale{ 0 }; uint32 rscale{};
uint32 link_marker{ 0 }; uint32 link_marker{};
void clear() { void clear() {
code = 0; code = 0;
alias = 0; alias = 0;
setcode = 0; for (auto& x : setcode)
x = 0;
type = 0; type = 0;
level = 0; level = 0;
attribute = 0; attribute = 0;
...@@ -29,6 +35,35 @@ struct card_data { ...@@ -29,6 +35,35 @@ struct card_data {
rscale = 0; rscale = 0;
link_marker = 0; link_marker = 0;
} }
bool is_setcode(uint32 value) const {
uint16_t settype = value & 0x0fff;
uint16_t setsubtype = value & 0xf000;
for (auto& x : setcode) {
if ((x & 0x0fff) == settype && (x & 0xf000 & setsubtype) == setsubtype)
return true;
if (!x)
return false;
}
return false;
}
bool is_alternative() const {
return alias && (alias < code + CARD_ARTWORK_VERSIONS_OFFSET) && (code < alias + CARD_ARTWORK_VERSIONS_OFFSET);
}
void set_setcode(uint64 value) {
int ctr = 0;
while (value) {
if (value & 0xffff) {
setcode[ctr] = value & 0xffff;
++ctr;
}
value >>= 16;
}
for (int i = ctr; i < SIZE_SETCODE; ++i)
setcode[i] = 0;
}
}; };
#endif /* CARD_DATA_H_ */ #endif /* CARD_DATA_H_ */
...@@ -180,27 +180,27 @@ struct card_sort { ...@@ -180,27 +180,27 @@ struct card_sort {
#define REASONS_PROCEDURE (REASON_SYNCHRO | REASON_XYZ | REASON_LINK) #define REASONS_PROCEDURE (REASON_SYNCHRO | REASON_XYZ | REASON_LINK)
//Status //Status
#define STATUS_DISABLED 0x0001 // #define STATUS_DISABLED 0x0001
#define STATUS_TO_ENABLE 0x0002 // #define STATUS_TO_ENABLE 0x0002
#define STATUS_TO_DISABLE 0x0004 // #define STATUS_TO_DISABLE 0x0004
#define STATUS_PROC_COMPLETE 0x0008 // #define STATUS_PROC_COMPLETE 0x0008
#define STATUS_SET_TURN 0x0010 // #define STATUS_SET_TURN 0x0010
#define STATUS_NO_LEVEL 0x0020 // #define STATUS_NO_LEVEL 0x0020
#define STATUS_BATTLE_RESULT 0x0040 // #define STATUS_BATTLE_RESULT 0x0040
#define STATUS_SPSUMMON_STEP 0x0080 // #define STATUS_SPSUMMON_STEP 0x0080
#define STATUS_FORM_CHANGED 0x0100 // #define STATUS_FORM_CHANGED 0x0100
#define STATUS_SUMMONING 0x0200 // #define STATUS_SUMMONING 0x0200
#define STATUS_EFFECT_ENABLED 0x0400 // #define STATUS_EFFECT_ENABLED 0x0400
#define STATUS_SUMMON_TURN 0x0800 // #define STATUS_SUMMON_TURN 0x0800
#define STATUS_DESTROY_CONFIRMED 0x1000 // #define STATUS_DESTROY_CONFIRMED 0x1000
#define STATUS_LEAVE_CONFIRMED 0x2000 // #define STATUS_LEAVE_CONFIRMED 0x2000
#define STATUS_BATTLE_DESTROYED 0x4000 // #define STATUS_BATTLE_DESTROYED 0x4000
#define STATUS_COPYING_EFFECT 0x8000 // #define STATUS_COPYING_EFFECT 0x8000
#define STATUS_CHAINING 0x10000 // #define STATUS_CHAINING 0x10000
#define STATUS_SUMMON_DISABLED 0x20000 // #define STATUS_SUMMON_DISABLED 0x20000
#define STATUS_ACTIVATE_DISABLED 0x40000 // #define STATUS_ACTIVATE_DISABLED 0x40000
#define STATUS_EFFECT_REPLACED 0x80000 #define STATUS_EFFECT_REPLACED 0x80000
#define STATUS_FUTURE_FUSION 0x100000 #define STATUS_FLIP_SUMMONING 0x100000
#define STATUS_ATTACK_CANCELED 0x200000 #define STATUS_ATTACK_CANCELED 0x200000
#define STATUS_INITIALIZING 0x400000 #define STATUS_INITIALIZING 0x400000
#define STATUS_TO_HAND_WITHOUT_CONFIRM 0x800000 #define STATUS_TO_HAND_WITHOUT_CONFIRM 0x800000
......
...@@ -308,6 +308,8 @@ struct processor { ...@@ -308,6 +308,8 @@ struct processor {
uint8 coin_result[MAX_COIN_COUNT]{}; uint8 coin_result[MAX_COIN_COUNT]{};
int32 coin_count{ 0 }; int32 coin_count{ 0 };
bool is_target_ready{ false }; bool is_target_ready{ false };
bool is_gemini_summoning{ false };
bool is_summon_negated{ false };
uint8 to_bp{ FALSE }; uint8 to_bp{ FALSE };
uint8 to_m2{ FALSE }; uint8 to_m2{ FALSE };
...@@ -572,8 +574,8 @@ public: ...@@ -572,8 +574,8 @@ public:
void destroy(card* target, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid = 2, uint32 destination = 0, uint32 sequence = 0); void destroy(card* target, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid = 2, uint32 destination = 0, uint32 sequence = 0);
void release(card_set* targets, effect* reason_effect, uint32 reason, uint32 reason_player); void release(card_set* targets, effect* reason_effect, uint32 reason, uint32 reason_player);
void release(card* target, effect* reason_effect, uint32 reason, uint32 reason_player); void release(card* target, effect* reason_effect, uint32 reason, uint32 reason_player);
void send_to(card_set* targets, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position); void send_to(card_set* targets, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position, uint8 send_activating = FALSE);
void send_to(card* target, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position); void send_to(card* target, effect* reason_effect, uint32 reason, uint32 reason_player, uint32 playerid, uint32 destination, uint32 sequence, uint32 position, uint8 send_activating = FALSE);
void move_to_field(card* target, uint32 move_player, uint32 playerid, uint32 destination, uint32 positions, uint32 enable = FALSE, uint32 ret = 0, uint32 pzone = FALSE, uint32 zone = 0xff); void move_to_field(card* target, uint32 move_player, uint32 playerid, uint32 destination, uint32 positions, uint32 enable = FALSE, uint32 ret = 0, uint32 pzone = FALSE, uint32 zone = 0xff);
void change_position(card_set* targets, effect* reason_effect, uint32 reason_player, uint32 au, uint32 ad, uint32 du, uint32 dd, uint32 flag, uint32 enable = FALSE); void change_position(card_set* targets, effect* reason_effect, uint32 reason_player, uint32 au, uint32 ad, uint32 du, uint32 dd, uint32 flag, uint32 enable = FALSE);
void change_position(card* target, effect* reason_effect, uint32 reason_player, uint32 npos, uint32 flag, uint32 enable = FALSE); void change_position(card* target, effect* reason_effect, uint32 reason_player, uint32 npos, uint32 flag, uint32 enable = FALSE);
...@@ -605,7 +607,7 @@ public: ...@@ -605,7 +607,7 @@ public:
int32 release_replace(uint16 step, group* targets, card* target); int32 release_replace(uint16 step, group* targets, card* target);
int32 release(uint16 step, group* targets, effect* reason_effect, uint32 reason, uint8 reason_player); int32 release(uint16 step, group* targets, effect* reason_effect, uint32 reason, uint8 reason_player);
int32 send_replace(uint16 step, group* targets, card* target); int32 send_replace(uint16 step, group* targets, card* target);
int32 send_to(uint16 step, group* targets, effect* reason_effect, uint32 reason, uint8 reason_player); int32 send_to(uint16 step, group* targets, effect* reason_effect, uint32 reason, uint8 reason_player, uint8 send_activating);
int32 discard_deck(uint16 step, uint8 playerid, uint8 count, uint32 reason); int32 discard_deck(uint16 step, uint8 playerid, uint8 count, uint32 reason);
int32 move_to_field(uint16 step, card* target, uint32 enable, uint32 ret, uint32 pzone, uint32 zone); int32 move_to_field(uint16 step, card* target, uint32 enable, uint32 ret, uint32 pzone, uint32 zone);
int32 change_position(uint16 step, group* targets, effect* reason_effect, uint8 reason_player, uint32 enable); int32 change_position(uint16 step, group* targets, effect* reason_effect, uint8 reason_player, uint32 enable);
......
...@@ -144,7 +144,7 @@ int32 interpreter::register_card(card *pcard) { ...@@ -144,7 +144,7 @@ int32 interpreter::register_card(card *pcard) {
//some userdata may be created in script like token so use current_state //some userdata may be created in script like token so use current_state
lua_rawgeti(current_state, LUA_REGISTRYINDEX, pcard->ref_handle); lua_rawgeti(current_state, LUA_REGISTRYINDEX, pcard->ref_handle);
//load script //load script
if(pcard->data.alias && (pcard->data.alias < pcard->data.code + CARD_ARTWORK_VERSIONS_OFFSET) && (pcard->data.code < pcard->data.alias + CARD_ARTWORK_VERSIONS_OFFSET)) if(pcard->data.is_alternative())
load_card_script(pcard->data.alias); load_card_script(pcard->data.alias);
else else
load_card_script(pcard->data.code); load_card_script(pcard->data.code);
......
...@@ -882,12 +882,15 @@ int32 scriptlib::duel_sendto_deck(lua_State *L) { ...@@ -882,12 +882,15 @@ int32 scriptlib::duel_sendto_deck(lua_State *L) {
uint32 sequence = (uint32)lua_tointeger(L, 3); uint32 sequence = (uint32)lua_tointeger(L, 3);
uint32 reason = (uint32)lua_tointeger(L, 4); uint32 reason = (uint32)lua_tointeger(L, 4);
uint32 reason_player = pduel->game_field->core.reason_player; uint32 reason_player = pduel->game_field->core.reason_player;
uint8 send_activating = FALSE;
if (lua_gettop(L) >= 5) if (lua_gettop(L) >= 5)
reason_player = (uint32)lua_tointeger(L, 5); reason_player = (uint32)lua_tointeger(L, 5);
if(pcard) if (lua_gettop(L) >= 6)
pduel->game_field->send_to(pcard, pduel->game_field->core.reason_effect, reason, reason_player, playerid, LOCATION_DECK, sequence, POS_FACEUP); send_activating = (uint8)lua_toboolean(L, 6);
if (pcard)
pduel->game_field->send_to(pcard, pduel->game_field->core.reason_effect, reason, reason_player, playerid, LOCATION_DECK, sequence, POS_FACEUP, send_activating);
else else
pduel->game_field->send_to(&(pgroup->container), pduel->game_field->core.reason_effect, reason, reason_player, playerid, LOCATION_DECK, sequence, POS_FACEUP); pduel->game_field->send_to(&(pgroup->container), pduel->game_field->core.reason_effect, reason, reason_player, playerid, LOCATION_DECK, sequence, POS_FACEUP, send_activating);
return lua_yieldk(L, 0, (lua_KContext)pduel, [](lua_State *L, int32 status, lua_KContext ctx) { return lua_yieldk(L, 0, (lua_KContext)pduel, [](lua_State *L, int32 status, lua_KContext ctx) {
duel* pduel = (duel*)ctx; duel* pduel = (duel*)ctx;
lua_pushinteger(L, pduel->game_field->returns.ivalue[0]); lua_pushinteger(L, pduel->game_field->returns.ivalue[0]);
...@@ -2051,30 +2054,66 @@ int32 scriptlib::duel_disable_summon(lua_State *L) { ...@@ -2051,30 +2054,66 @@ int32 scriptlib::duel_disable_summon(lua_State *L) {
pduel = pgroup->pduel; pduel = pgroup->pduel;
} else } else
return luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 1); return luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 1);
uint32 sumtype = 0;
if (pduel->game_field->check_event(EVENT_SUMMON)) {
if (pduel->game_field->core.is_gemini_summoning)
sumtype = SUMMON_TYPE_DUAL;
else
sumtype = SUMMON_TYPE_NORMAL;
}
else if (pduel->game_field->check_event(EVENT_FLIP_SUMMON))
sumtype = SUMMON_TYPE_FLIP;
else if (pduel->game_field->check_event(EVENT_SPSUMMON))
sumtype = SUMMON_TYPE_SPECIAL;
else
return 0;
if (sumtype & SUMMON_TYPE_NORMAL || sumtype & SUMMON_TYPE_FLIP) {
if (pgroup && pgroup->container.size() != 1)
return 0;
if (!pcard)
pcard = *pgroup->container.begin();
}
uint8 sumplayer = PLAYER_NONE; uint8 sumplayer = PLAYER_NONE;
if(pcard) { effect* reason_effect = pduel->game_field->core.reason_effect;
field::card_set negated_cards;
if (sumtype == SUMMON_TYPE_DUAL || sumtype & SUMMON_TYPE_FLIP) {
if (!pcard->is_summon_negatable(sumtype, reason_effect))
return 0;
sumplayer = pcard->summon_player; sumplayer = pcard->summon_player;
pcard->set_status(STATUS_SUMMONING, FALSE); pcard->set_status(STATUS_FLIP_SUMMONING, FALSE);
pcard->set_status(STATUS_SUMMON_DISABLED, TRUE); pcard->set_status(STATUS_SUMMON_DISABLED, TRUE);
if (!match_all(pcard->summon_info, SUMMON_TYPE_FLIP) && !match_all(pcard->summon_info, SUMMON_TYPE_DUAL)) }
pcard->set_status(STATUS_PROC_COMPLETE, FALSE); else {
} else { if (pcard) {
for(auto& pcard : pgroup->container) { if (!pcard->is_summon_negatable(sumtype, reason_effect))
return 0;
sumplayer = pcard->summon_player; sumplayer = pcard->summon_player;
pcard->set_status(STATUS_SUMMONING, FALSE); pcard->set_status(STATUS_SUMMONING, FALSE);
pcard->set_status(STATUS_SUMMON_DISABLED, TRUE); pcard->set_status(STATUS_SUMMON_DISABLED, TRUE);
if (!match_all(pcard->summon_info, SUMMON_TYPE_FLIP) && !match_all(pcard->summon_info, SUMMON_TYPE_DUAL)) pcard->set_status(STATUS_PROC_COMPLETE, FALSE);
}
else {
for (auto& pcard : pgroup->container) {
if (!pcard->is_summon_negatable(sumtype, reason_effect))
continue;
sumplayer = pcard->summon_player;
pcard->set_status(STATUS_SUMMONING, FALSE);
pcard->set_status(STATUS_SUMMON_DISABLED, TRUE);
pcard->set_status(STATUS_PROC_COMPLETE, FALSE); pcard->set_status(STATUS_PROC_COMPLETE, FALSE);
negated_cards.insert(pcard);
}
if (!negated_cards.size())
return 0;
} }
} }
pduel->game_field->core.is_summon_negated = true;
uint32 event_code = 0; uint32 event_code = 0;
if(pduel->game_field->check_event(EVENT_SUMMON)) if(sumtype & SUMMON_TYPE_NORMAL)
event_code = EVENT_SUMMON_NEGATED; event_code = EVENT_SUMMON_NEGATED;
else if(pduel->game_field->check_event(EVENT_FLIP_SUMMON)) else if(sumtype & SUMMON_TYPE_FLIP)
event_code = EVENT_FLIP_SUMMON_NEGATED; event_code = EVENT_FLIP_SUMMON_NEGATED;
else if(pduel->game_field->check_event(EVENT_SPSUMMON)) else if(sumtype & SUMMON_TYPE_SPECIAL)
event_code = EVENT_SPSUMMON_NEGATED; event_code = EVENT_SPSUMMON_NEGATED;
effect* reason_effect = pduel->game_field->core.reason_effect;
uint8 reason_player = pduel->game_field->core.reason_player; uint8 reason_player = pduel->game_field->core.reason_player;
if(pcard) if(pcard)
pduel->game_field->raise_event(pcard, event_code, reason_effect, REASON_EFFECT, reason_player, sumplayer, 0); pduel->game_field->raise_event(pcard, event_code, reason_effect, REASON_EFFECT, reason_player, sumplayer, 0);
...@@ -4547,8 +4586,10 @@ int32 scriptlib::duel_is_player_can_spsummon_monster(lua_State * L) { ...@@ -4547,8 +4586,10 @@ int32 scriptlib::duel_is_player_can_spsummon_monster(lua_State * L) {
::read_card(code, &dat); ::read_card(code, &dat);
dat.code = code; dat.code = code;
dat.alias = 0; dat.alias = 0;
if(!lua_isnil(L, 3)) if(!lua_isnil(L, 3)) {
dat.setcode = lua_tointeger(L, 3); uint64 setcode_list = lua_tointeger(L, 3);
dat.set_setcode(setcode_list);
}
if(!lua_isnil(L, 4)) if(!lua_isnil(L, 4))
dat.type = (uint32)lua_tointeger(L, 4); dat.type = (uint32)lua_tointeger(L, 4);
if(!lua_isnil(L, 5)) if(!lua_isnil(L, 5))
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
class card; class card;
struct card_data; struct card_data;
struct card_info;
class group; class group;
class effect; class effect;
class interpreter; class interpreter;
......
This diff is collapsed.
...@@ -920,15 +920,7 @@ static int32 is_declarable(card_data const& cd, const std::vector<uint32>& opcod ...@@ -920,15 +920,7 @@ static int32 is_declarable(card_data const& cd, const std::vector<uint32>& opcod
if(stack.size() >= 1) { if(stack.size() >= 1) {
int32 set_code = stack.top(); int32 set_code = stack.top();
stack.pop(); stack.pop();
uint64 sc = cd.setcode; bool res = cd.is_setcode(set_code);
bool res = false;
uint32 settype = set_code & 0xfff;
uint32 setsubtype = set_code & 0xf000;
while(sc) {
if((sc & 0xfff) == settype && (sc & 0xf000 & setsubtype) == setsubtype)
res = true;
sc = sc >> 16;
}
stack.push(res); stack.push(res);
} }
break; break;
......
...@@ -308,7 +308,7 @@ uint32 field::process() { ...@@ -308,7 +308,7 @@ uint32 field::process() {
return pduel->message_buffer.size(); return pduel->message_buffer.size();
} }
case PROCESSOR_SENDTO: { case PROCESSOR_SENDTO: {
if (send_to(it->step, it->ptarget, it->peffect, it->arg1, it->arg2)) if (send_to(it->step, it->ptarget, it->peffect, it->arg1, it->arg2, it->arg3))
core.units.pop_front(); core.units.pop_front();
else else
++it->step; ++it->step;
......
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