Commit 16aea8eb authored by VanillaSalt's avatar VanillaSalt Committed by GitHub

Merge pull request #79 from edo9300/mr4

Added TYPE_LINK
parents f0f1ede3 6973f2ba
...@@ -105,6 +105,7 @@ uint32 card::get_infos(byte* buf, int32 query_flag, int32 use_cache) { ...@@ -105,6 +105,7 @@ uint32 card::get_infos(byte* buf, int32 query_flag, int32 use_cache) {
if(query_flag & QUERY_TYPE) q_cache.type = *p++ = get_type(); if(query_flag & QUERY_TYPE) q_cache.type = *p++ = get_type();
if(query_flag & QUERY_LEVEL) q_cache.level = *p++ = get_level(); if(query_flag & QUERY_LEVEL) q_cache.level = *p++ = get_level();
if(query_flag & QUERY_RANK) q_cache.rank = *p++ = get_rank(); if(query_flag & QUERY_RANK) q_cache.rank = *p++ = get_rank();
if(query_flag & QUERY_LINK) q_cache.link = *p++ = get_link();
if(query_flag & QUERY_ATTRIBUTE) q_cache.attribute = *p++ = get_attribute(); if(query_flag & QUERY_ATTRIBUTE) q_cache.attribute = *p++ = get_attribute();
if(query_flag & QUERY_RACE) q_cache.race = *p++ = get_race(); if(query_flag & QUERY_RACE) q_cache.race = *p++ = get_race();
if(query_flag & QUERY_ATTACK) q_cache.attack = *p++ = get_attack(); if(query_flag & QUERY_ATTACK) q_cache.attack = *p++ = get_attack();
...@@ -129,6 +130,11 @@ uint32 card::get_infos(byte* buf, int32 query_flag, int32 use_cache) { ...@@ -129,6 +130,11 @@ uint32 card::get_infos(byte* buf, int32 query_flag, int32 use_cache) {
q_cache.rank = tdata; q_cache.rank = tdata;
*p++ = tdata; *p++ = tdata;
} else query_flag &= ~QUERY_RANK; } else query_flag &= ~QUERY_RANK;
if((query_flag & QUERY_LINK) && ((uint32)(tdata = get_link()) != q_cache.link)) {
q_cache.link = tdata;
*p++ = tdata;
}
else query_flag &= ~QUERY_LINK;
if((query_flag & QUERY_ATTRIBUTE) && ((uint32)(tdata = get_attribute()) != q_cache.attribute)) { if((query_flag & QUERY_ATTRIBUTE) && ((uint32)(tdata = get_attribute()) != q_cache.attribute)) {
q_cache.attribute = tdata; q_cache.attribute = tdata;
*p++ = tdata; *p++ = tdata;
...@@ -429,8 +435,11 @@ int32 card::get_base_attack() { ...@@ -429,8 +435,11 @@ int32 card::get_base_attack() {
bdef = 0; bdef = 0;
temp.base_attack = batk; temp.base_attack = batk;
effect_set eset; effect_set eset;
int32 swap = 0;
if(!(data.type & TYPE_LINK)) {
filter_effect(EFFECT_SWAP_BASE_AD, &eset, FALSE); filter_effect(EFFECT_SWAP_BASE_AD, &eset, FALSE);
int32 swap = eset.size(); swap = eset.size();
}
filter_effect(EFFECT_SET_BASE_ATTACK, &eset, FALSE); filter_effect(EFFECT_SET_BASE_ATTACK, &eset, FALSE);
if(swap) if(swap)
filter_effect(EFFECT_SET_BASE_DEFENSE, &eset, FALSE); filter_effect(EFFECT_SET_BASE_DEFENSE, &eset, FALSE);
...@@ -577,6 +586,7 @@ int32 card::get_attack() { ...@@ -577,6 +586,7 @@ int32 card::get_attack() {
swap_final = !swap_final; swap_final = !swap_final;
break; break;
case EFFECT_SWAP_BASE_AD: case EFFECT_SWAP_BASE_AD:
if(!(data.type & TYPE_LINK))
std::swap(batk, bdef); std::swap(batk, bdef);
break; break;
} }
...@@ -592,7 +602,7 @@ int32 card::get_attack() { ...@@ -592,7 +602,7 @@ int32 card::get_attack() {
for(int32 i = 0; i < effects_atk.size(); ++i) for(int32 i = 0; i < effects_atk.size(); ++i)
temp.attack = effects_atk[i]->get_value(this); temp.attack = effects_atk[i]->get_value(this);
if(temp.defense == -1) { if(temp.defense == -1) {
if(swap_final) { if(swap_final && !(data.type & TYPE_LINK)) {
temp.attack = get_defense(); temp.attack = get_defense();
} }
for(int32 i = 0; i < effects_atk_r.size(); ++i) { for(int32 i = 0; i < effects_atk_r.size(); ++i) {
...@@ -609,7 +619,7 @@ int32 card::get_attack() { ...@@ -609,7 +619,7 @@ int32 card::get_attack() {
return atk; return atk;
} }
int32 card::get_base_defense() { int32 card::get_base_defense() {
if(!(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER) && !is_affected_by_effect(EFFECT_PRE_MONSTER)) if((!(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER) && !is_affected_by_effect(EFFECT_PRE_MONSTER)) || (data.type & TYPE_LINK))
return 0; return 0;
if (current.location != LOCATION_MZONE || get_status(STATUS_SUMMONING | STATUS_SPSUMMON_STEP)) if (current.location != LOCATION_MZONE || get_status(STATUS_SUMMONING | STATUS_SPSUMMON_STEP))
return data.defense; return data.defense;
...@@ -671,6 +681,8 @@ int32 card::get_base_defense() { ...@@ -671,6 +681,8 @@ int32 card::get_base_defense() {
return bdef; return bdef;
} }
int32 card::get_defense() { int32 card::get_defense() {
if(data.type & TYPE_LINK)
return 0;
if(assume_type == ASSUME_DEFENSE) if(assume_type == ASSUME_DEFENSE)
return assume_value; return assume_value;
if(!(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER) && !is_affected_by_effect(EFFECT_PRE_MONSTER)) if(!(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER) && !is_affected_by_effect(EFFECT_PRE_MONSTER))
...@@ -806,7 +818,7 @@ int32 card::get_defense() { ...@@ -806,7 +818,7 @@ int32 card::get_defense() {
// 2. cards with current type TYPE_MONSTER or // 2. cards with current type TYPE_MONSTER or
// 3. cards with EFFECT_PRE_MONSTER // 3. cards with EFFECT_PRE_MONSTER
uint32 card::get_level() { uint32 card::get_level() {
if((data.type & TYPE_XYZ) || (status & STATUS_NO_LEVEL) if((data.type & TYPE_XYZ) || (data.type & TYPE_LINK) || (status & STATUS_NO_LEVEL)
|| (!(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER) && !is_affected_by_effect(EFFECT_PRE_MONSTER))) || (!(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER) && !is_affected_by_effect(EFFECT_PRE_MONSTER)))
return 0; return 0;
if(assume_type == ASSUME_LEVEL) if(assume_type == ASSUME_LEVEL)
...@@ -894,7 +906,7 @@ uint32 card::get_link() { ...@@ -894,7 +906,7 @@ uint32 card::get_link() {
return data.level; return data.level;
} }
uint32 card::get_synchro_level(card* pcard) { uint32 card::get_synchro_level(card* pcard) {
if((data.type & TYPE_XYZ) || (status & STATUS_NO_LEVEL)) if((data.type & TYPE_XYZ) || (data.type & TYPE_LINK) || (status & STATUS_NO_LEVEL))
return 0; return 0;
uint32 lev; uint32 lev;
effect_set eset; effect_set eset;
...@@ -906,7 +918,7 @@ uint32 card::get_synchro_level(card* pcard) { ...@@ -906,7 +918,7 @@ uint32 card::get_synchro_level(card* pcard) {
return lev; return lev;
} }
uint32 card::get_ritual_level(card* pcard) { uint32 card::get_ritual_level(card* pcard) {
if((data.type & TYPE_XYZ) || (status & STATUS_NO_LEVEL)) if((data.type & TYPE_XYZ) || (data.type & TYPE_LINK) || (status & STATUS_NO_LEVEL))
return 0; return 0;
uint32 lev; uint32 lev;
effect_set eset; effect_set eset;
...@@ -2925,7 +2937,7 @@ int32 card::is_capable_send_to_grave(uint8 playerid) { ...@@ -2925,7 +2937,7 @@ int32 card::is_capable_send_to_grave(uint8 playerid) {
int32 card::is_capable_send_to_hand(uint8 playerid) { int32 card::is_capable_send_to_hand(uint8 playerid) {
if(is_status(STATUS_LEAVE_CONFIRMED)) if(is_status(STATUS_LEAVE_CONFIRMED))
return FALSE; return FALSE;
if((current.location == LOCATION_EXTRA) && (data.type & (TYPE_FUSION + TYPE_SYNCHRO + TYPE_XYZ))) if((current.location == LOCATION_EXTRA) && (data.type & (TYPE_FUSION + TYPE_SYNCHRO + TYPE_XYZ + TYPE_LINK)))
return FALSE; return FALSE;
if(is_affected_by_effect(EFFECT_CANNOT_TO_HAND)) if(is_affected_by_effect(EFFECT_CANNOT_TO_HAND))
return FALSE; return FALSE;
...@@ -2936,7 +2948,7 @@ int32 card::is_capable_send_to_hand(uint8 playerid) { ...@@ -2936,7 +2948,7 @@ int32 card::is_capable_send_to_hand(uint8 playerid) {
int32 card::is_capable_send_to_deck(uint8 playerid) { int32 card::is_capable_send_to_deck(uint8 playerid) {
if(is_status(STATUS_LEAVE_CONFIRMED)) if(is_status(STATUS_LEAVE_CONFIRMED))
return FALSE; return FALSE;
if((current.location == LOCATION_EXTRA) && (data.type & (TYPE_FUSION + TYPE_SYNCHRO + TYPE_XYZ))) if((current.location == LOCATION_EXTRA) && (data.type & (TYPE_FUSION + TYPE_SYNCHRO + TYPE_XYZ + TYPE_LINK)))
return FALSE; return FALSE;
if(is_affected_by_effect(EFFECT_CANNOT_TO_DECK)) if(is_affected_by_effect(EFFECT_CANNOT_TO_DECK))
return FALSE; return FALSE;
...@@ -2945,7 +2957,7 @@ int32 card::is_capable_send_to_deck(uint8 playerid) { ...@@ -2945,7 +2957,7 @@ int32 card::is_capable_send_to_deck(uint8 playerid) {
return TRUE; return TRUE;
} }
int32 card::is_capable_send_to_extra(uint8 playerid) { int32 card::is_capable_send_to_extra(uint8 playerid) {
if(!(data.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_PENDULUM))) if(!(data.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_PENDULUM | TYPE_LINK)))
return FALSE; return FALSE;
if(is_affected_by_effect(EFFECT_CANNOT_TO_DECK)) if(is_affected_by_effect(EFFECT_CANNOT_TO_DECK))
return FALSE; return FALSE;
...@@ -2981,7 +2993,7 @@ int32 card::is_capable_cost_to_grave(uint8 playerid) { ...@@ -2981,7 +2993,7 @@ int32 card::is_capable_cost_to_grave(uint8 playerid) {
int32 card::is_capable_cost_to_hand(uint8 playerid) { int32 card::is_capable_cost_to_hand(uint8 playerid) {
uint32 redirect = 0; uint32 redirect = 0;
uint32 dest = LOCATION_HAND; uint32 dest = LOCATION_HAND;
if(data.type & (TYPE_TOKEN | TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ)) if(data.type & (TYPE_TOKEN | TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK))
return FALSE; return FALSE;
if(current.location == LOCATION_HAND) if(current.location == LOCATION_HAND)
return FALSE; return FALSE;
...@@ -3004,7 +3016,7 @@ int32 card::is_capable_cost_to_hand(uint8 playerid) { ...@@ -3004,7 +3016,7 @@ int32 card::is_capable_cost_to_hand(uint8 playerid) {
int32 card::is_capable_cost_to_deck(uint8 playerid) { int32 card::is_capable_cost_to_deck(uint8 playerid) {
uint32 redirect = 0; uint32 redirect = 0;
uint32 dest = LOCATION_DECK; uint32 dest = LOCATION_DECK;
if(data.type & (TYPE_TOKEN | TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ)) if(data.type & (TYPE_TOKEN | TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK))
return FALSE; return FALSE;
if(current.location == LOCATION_DECK) if(current.location == LOCATION_DECK)
return FALSE; return FALSE;
...@@ -3027,7 +3039,7 @@ int32 card::is_capable_cost_to_deck(uint8 playerid) { ...@@ -3027,7 +3039,7 @@ int32 card::is_capable_cost_to_deck(uint8 playerid) {
int32 card::is_capable_cost_to_extra(uint8 playerid) { int32 card::is_capable_cost_to_extra(uint8 playerid) {
uint32 redirect = 0; uint32 redirect = 0;
uint32 dest = LOCATION_DECK; uint32 dest = LOCATION_DECK;
if(!(data.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ))) if(!(data.type & (TYPE_FUSION | TYPE_SYNCHRO | TYPE_XYZ | TYPE_LINK)))
return FALSE; return FALSE;
if(current.location == LOCATION_EXTRA) if(current.location == LOCATION_EXTRA)
return FALSE; return FALSE;
...@@ -3170,7 +3182,7 @@ int32 card::is_can_be_fusion_material(card* fcard) { ...@@ -3170,7 +3182,7 @@ int32 card::is_can_be_fusion_material(card* fcard) {
return TRUE; return TRUE;
} }
int32 card::is_can_be_synchro_material(card* scard, card* tuner) { int32 card::is_can_be_synchro_material(card* scard, card* tuner) {
if(data.type & TYPE_XYZ) if((data.type & TYPE_XYZ) || (data.type & TYPE_LINK))
return FALSE; return FALSE;
if(!(get_type() & TYPE_MONSTER)) if(!(get_type() & TYPE_MONSTER))
return FALSE; return FALSE;
......
...@@ -43,6 +43,7 @@ struct card_state { ...@@ -43,6 +43,7 @@ struct card_state {
uint32 type; uint32 type;
uint32 level; uint32 level;
uint32 rank; uint32 rank;
uint32 link;
uint32 lscale; uint32 lscale;
uint32 rscale; uint32 rscale;
uint32 attribute; uint32 attribute;
...@@ -67,6 +68,7 @@ struct query_cache { ...@@ -67,6 +68,7 @@ struct query_cache {
uint32 type; uint32 type;
uint32 level; uint32 level;
uint32 rank; uint32 rank;
uint32 link;
uint32 attribute; uint32 attribute;
uint32 race; uint32 race;
int32 attack; int32 attack;
...@@ -481,6 +483,7 @@ public: ...@@ -481,6 +483,7 @@ public:
#define QUERY_IS_PUBLIC 0x100000 #define QUERY_IS_PUBLIC 0x100000
#define QUERY_LSCALE 0x200000 #define QUERY_LSCALE 0x200000
#define QUERY_RSCALE 0x400000 #define QUERY_RSCALE 0x400000
#define QUERY_LINK 0x800000
#define ASSUME_CODE 1 #define ASSUME_CODE 1
#define ASSUME_TYPE 2 #define ASSUME_TYPE 2
......
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