Commit a636af1e authored by nanahira's avatar nanahira

Merge branch 'master' of github.com:Fluorohydride/ygopro-core

parents c48f5e5f ea542f33
......@@ -529,8 +529,6 @@ uint32 card::get_link_type() {
return data.type;
return get_type();
}
// Atk and def are sepcial cases since text atk/def ? are involved.
// Asuumption: we can only change the atk/def of cards in LOCATION_MZONE.
int32 card::get_base_attack() {
if(!(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER) && !is_affected_by_effect(EFFECT_PRE_MONSTER))
return 0;
......@@ -931,10 +929,6 @@ int32 card::get_battle_defense() {
else
return get_defense();
}
// Level/Attribute/Race is available for:
// 1. cards with original type TYPE_MONSTER or
// 2. cards with current type TYPE_MONSTER or
// 3. cards with EFFECT_PRE_MONSTER
uint32 card::get_level() {
if((data.type & (TYPE_XYZ | TYPE_LINK)) || (status & STATUS_NO_LEVEL)
|| (!(data.type & TYPE_MONSTER) && !(get_type() & TYPE_MONSTER) && !is_affected_by_effect(EFFECT_PRE_MONSTER)))
......@@ -1073,7 +1067,6 @@ uint32 card::check_xyz_level(card* pcard, uint32 lv) {
}
return 0;
}
// see get_level()
uint32 card::get_attribute() {
if(assume_type == ASSUME_ATTRIBUTE)
return assume_value;
......@@ -1124,7 +1117,6 @@ uint32 card::get_link_attribute(uint8 playerid) {
}
return attribute;
}
// see get_level()
uint32 card::get_race() {
if(assume_type == ASSUME_RACE)
return assume_value;
......
......@@ -450,7 +450,7 @@ int32 effect::is_target(card* pcard) {
if((type & EFFECT_TYPE_TARGET) && !(type & EFFECT_TYPE_FIELD)) {
return is_fit_target_function(pcard);
}
if(pcard && !is_flag(EFFECT_FLAG_SET_AVAILABLE) && (pcard->current.location & LOCATION_ONFIELD)
if(!is_flag(EFFECT_FLAG_SET_AVAILABLE) && (pcard->current.location & LOCATION_ONFIELD)
&& !pcard->is_position(POS_FACEUP))
return FALSE;
if(!is_flag(EFFECT_FLAG_IGNORE_RANGE)) {
......
......@@ -535,7 +535,6 @@ inline effect_flag operator|(effect_flag flag1, effect_flag flag2)
#define EVENT_LEVEL_UP 1200
#define EVENT_PAY_LPCOST 1201
#define EVENT_DETACH_MATERIAL 1202
#define EVENT_RETURN_TO_GRAVE 1203
#define EVENT_TURN_END 1210
#define EVENT_PHASE 0x1000
#define EVENT_PHASE_START 0x2000
......
......@@ -3396,16 +3396,17 @@ int32 field::check_cteffect_hint(effect* peffect, uint8 playerid) {
}
return FALSE;
}
int32 field::check_hand_trigger(chain& ch) {
int32 field::check_nonpublic_trigger(chain& ch) {
effect* peffect = ch.triggering_effect;
card* phandler = peffect->get_handler();
if(!peffect->is_flag(EFFECT_FLAG_FIELD_ONLY)
&& ((peffect->type & EFFECT_TYPE_SINGLE) && !peffect->is_flag(EFFECT_FLAG_SINGLE_RANGE)
&& phandler->is_has_relation(ch) && ch.triggering_location == LOCATION_HAND
|| (peffect->range & LOCATION_HAND))) {
&& phandler->is_has_relation(ch) && (ch.triggering_location & (LOCATION_HAND | LOCATION_DECK))
|| (peffect->range & (LOCATION_HAND | LOCATION_DECK)))) {
ch.flag |= CHAIN_HAND_TRIGGER;
core.new_ochain_h.push_back(ch);
if(ch.triggering_location == LOCATION_HAND && phandler->is_position(POS_FACEDOWN)
|| ch.triggering_location == LOCATION_DECK
|| peffect->range && !peffect->in_range(ch))
return FALSE;
}
......
......@@ -483,7 +483,7 @@ public:
int32 get_cteffect(effect* peffect, int32 playerid, int32 store);
int32 get_cteffect_evt(effect* feffect, int32 playerid, const tevent& e, int32 store);
int32 check_cteffect_hint(effect* peffect, uint8 playerid);
int32 check_hand_trigger(chain& ch);
int32 check_nonpublic_trigger(chain& ch);
int32 check_trigger_effect(const chain& ch) const;
int32 check_spself_from_hand_trigger(const chain& ch) const;
int32 is_able_to_enter_bp();
......
......@@ -268,6 +268,8 @@ void field::send_to(card_set* targets, effect* reason_effect, uint32 reason, uin
p = reason_player;
if(destination & (LOCATION_GRAVE | LOCATION_REMOVED) || p == PLAYER_NONE)
p = pcard->owner;
if(destination == LOCATION_GRAVE && pcard->current.location == LOCATION_REMOVED)
pcard->current.reason |= REASON_RETURN;
uint32 pos = position;
if(destination != LOCATION_REMOVED)
pos = POS_FACEUP;
......@@ -3824,7 +3826,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
pduel->delete_group(targets);
return TRUE;
}
card_set leave_p, destroying;
card_set leave_p;
for(auto& pcard : targets->container) {
if((pcard->current.location & LOCATION_ONFIELD) && !pcard->is_status(STATUS_SUMMON_DISABLED) && !pcard->is_status(STATUS_ACTIVATE_DISABLED)) {
raise_single_event(pcard, 0, EVENT_LEAVE_FIELD_P, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0);
......@@ -3872,8 +3874,6 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
}
if(leave_p.size())
raise_event(&leave_p, EVENT_LEAVE_FIELD_P, reason_effect, reason, reason_player, 0, 0);
if(destroying.size())
raise_event(&destroying, EVENT_DESTROY, reason_effect, reason, reason_player, 0, 0);
process_single_event();
process_instant_event();
return FALSE;
......@@ -4184,7 +4184,7 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
core.units.begin()->ptarget = param->targets;
targets = param->targets;
delete param;
card_set tohand, todeck, tograve, remove, discard, released, destroyed, retgrave;
card_set tohand, todeck, tograve, remove, discard, released, destroyed;
card_set equipings, overlays;
for(auto& pcard : targets->container) {
uint8 nloc = pcard->current.location;
......@@ -4217,14 +4217,9 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
todeck.insert(pcard);
raise_single_event(pcard, 0, EVENT_TO_DECK, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0);
}
if(nloc == LOCATION_GRAVE) {
if(pcard->current.reason & REASON_RETURN) {
retgrave.insert(pcard);
raise_single_event(pcard, 0, EVENT_RETURN_TO_GRAVE, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0);
} else {
tograve.insert(pcard);
raise_single_event(pcard, 0, EVENT_TO_GRAVE, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0);
}
if(nloc == LOCATION_GRAVE && !(pcard->current.reason & REASON_RETURN)) {
tograve.insert(pcard);
raise_single_event(pcard, 0, EVENT_TO_GRAVE, pcard->current.reason_effect, pcard->current.reason, pcard->current.reason_player, 0, 0);
}
if(nloc == LOCATION_REMOVED || ((pcard->data.type & TYPE_TOKEN) && pcard->sendto_param.location == LOCATION_REMOVED)) {
remove.insert(pcard);
......@@ -4263,8 +4258,6 @@ int32 field::send_to(uint16 step, group * targets, effect * reason_effect, uint3
raise_event(&released, EVENT_RELEASE, reason_effect, reason, reason_player, 0, 0);
if(destroyed.size())
raise_event(&destroyed, EVENT_DESTROYED, reason_effect, reason, reason_player, 0, 0);
if(retgrave.size())
raise_event(&retgrave, EVENT_RETURN_TO_GRAVE, reason_effect, reason, reason_player, 0, 0);
raise_event(&targets->container, EVENT_MOVE, reason_effect, reason, reason_player, 0, 0);
process_single_event();
process_instant_event();
......
......@@ -1367,7 +1367,7 @@ int32 field::process_point_event(int16 step, int32 skip_trigger, int32 skip_free
clit->set_triggering_state(phandler);
}
uint8 tp = clit->triggering_player;
if(check_hand_trigger(*clit) && check_trigger_effect(*clit)
if(check_nonpublic_trigger(*clit) && check_trigger_effect(*clit)
&& peffect->is_chainable(tp) && peffect->is_activateable(tp, clit->evt, TRUE)
&& check_spself_from_hand_trigger(*clit)) {
if(tp == core.current_player)
......@@ -1666,9 +1666,9 @@ int32 field::process_quick_effect(int16 step, int32 skip_freechain, uint8 priori
ch.triggering_player = phandler->current.controler;
ch.set_triggering_state(phandler);
}
if(ch.triggering_player == priority && ch.triggering_location == LOCATION_HAND
&& phandler->is_position(POS_FACEDOWN) && !phandler->is_status(STATUS_CHAINING) && phandler->is_has_relation(ch)
&& peffect->is_chainable(priority) && peffect->is_activateable(priority, ch.evt, TRUE)
if(ch.triggering_player == priority && !phandler->is_status(STATUS_CHAINING)
&& (ch.triggering_location == LOCATION_HAND && phandler->is_position(POS_FACEDOWN) || ch.triggering_location == LOCATION_DECK)
&& phandler->is_has_relation(ch) && peffect->is_chainable(priority) && peffect->is_activateable(priority, ch.evt, TRUE)
&& check_spself_from_hand_trigger(ch))
core.select_chains.push_back(ch);
}
......@@ -3949,7 +3949,6 @@ int32 field::add_chain(uint16 step) {
}
}
if(peffect->type & EFFECT_TYPE_ACTIVATE) {
break_effect();
int32 ecode = 0;
if(phandler->current.location == LOCATION_HAND) {
if(phandler->data.type & TYPE_TRAP)
......@@ -4026,7 +4025,6 @@ int32 field::add_chain(uint16 step) {
pduel->write_buffer8(clit.triggering_sequence);
pduel->write_buffer32(peffect->description);
pduel->write_buffer8((uint8)core.current_chain.size() + 1);
break_effect();
for(auto& ch_lim : core.chain_limit)
luaL_unref(pduel->lua->lua_state, LUA_REGISTRYINDEX, ch_lim.function);
core.chain_limit.clear();
......
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