Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update act in hand/set turn #254

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,13 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con
handler->filter_effect(ecode, &eset);
for(int32 i = 0; i < eset.size(); ++i) {
if(eset[i]->check_count_limit(playerid)) {
available = true;
break;
pduel->lua->add_param(eset[i], PARAM_TYPE_EFFECT);
pduel->lua->add_param(handler, PARAM_TYPE_CARD);
pduel->lua->add_param(playerid, PARAM_TYPE_INT);
if(pduel->lua->check_condition(eset[i]->cost, 3)) {
available = true;
break;
}
}
}
if(!available)
Expand All @@ -270,7 +275,7 @@ int32 effect::is_activateable(uint8 playerid, const tevent& e, int32 neglect_con
if(phandler->is_position(POS_FACEUP) && !phandler->is_status(STATUS_EFFECT_ENABLED))
return FALSE;
}
if(!(type & (EFFECT_TYPE_FLIP | EFFECT_TYPE_TRIGGER_F))
if(!(type & (EFFECT_TYPE_FLIP | EFFECT_TYPE_TRIGGER_F))
&& !((type & EFFECT_TYPE_SINGLE) && (code == EVENT_TO_GRAVE || code == EVENT_DESTROYED || code == EVENT_SPSUMMON_SUCCESS || code == EVENT_TO_HAND || code == EVENT_REMOVE || code == EVENT_FLIP))) {
if((code < 1132 || code > 1149) && pduel->game_field->infos.phase == PHASE_DAMAGE && !is_flag(EFFECT_FLAG_DAMAGE_STEP))
return FALSE;
Expand Down Expand Up @@ -572,7 +577,7 @@ int32 effect::reset(uint32 reset_level, uint32 reset_type) {
return FALSE;
uint8 pid = get_handler_player();
uint8 tp = handler->pduel->game_field->infos.turn_player;
if((((reset_flag & RESET_SELF_TURN) && pid == tp) || ((reset_flag & RESET_OPPO_TURN) && pid != tp))
if((((reset_flag & RESET_SELF_TURN) && pid == tp) || ((reset_flag & RESET_OPPO_TURN) && pid != tp))
&& (reset_level & 0x3ff & reset_flag))
reset_count--;
if(reset_count == 0)
Expand Down
82 changes: 62 additions & 20 deletions processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3743,6 +3743,13 @@ int32 field::add_chain(uint16 step) {
add_process(PROCESSOR_EXECUTE_OPERATION, 0, eset[i], 0, clit.triggering_player, 0);
}
}
return FALSE;
}
case 1: {
auto& clit = core.new_chains.front();
effect* peffect = clit.triggering_effect;
card* phandler = peffect->get_handler();
effect_set eset;
if(peffect->type & EFFECT_TYPE_ACTIVATE) {
break_effect();
int32 ecode = 0;
Expand All @@ -3759,24 +3766,59 @@ int32 field::add_chain(uint16 step) {
ecode = EFFECT_QP_ACT_IN_SET_TURN;
}
if(ecode) {
eset.clear();
core.select_effects.clear();
core.select_options.clear();
bool actflag = false;
phandler->filter_effect(ecode, &eset);
effect* pactin = 0;
for(int32 i = 0; i < eset.size(); ++i) {
if(!eset[i]->is_flag(EFFECT_FLAG_COUNT_LIMIT)) {
pactin = eset[i];
break;
if(eset[i]->check_count_limit(clit.triggering_player)) {
if(eset[i]->operation) {
pduel->lua->add_param(eset[i], PARAM_TYPE_EFFECT);
pduel->lua->add_param(phandler, PARAM_TYPE_CARD);
pduel->lua->add_param(clit.triggering_player, PARAM_TYPE_INT);
if(pduel->lua->check_condition(eset[i]->cost, 3)) {
core.select_effects.push_back(eset[i]);
core.select_options.push_back(eset[i]->description);
}
} else if(eset[i]->is_flag(EFFECT_FLAG_COUNT_LIMIT)) {
core.select_effects.push_back(eset[i]);
core.select_options.push_back(eset[i]->description);
} else
actflag = true;
}
}
if(!pactin) {
for(int32 i = 0; i < eset.size(); ++i) {
if(eset[i]->check_count_limit(phandler->current.controler)) {
eset[i]->dec_count(phandler->current.controler);
break;
}
}
if(actflag) {
core.select_effects.push_back(0);
core.select_options.push_back(13);
Copy link
Contributor

@DailyShana DailyShana Dec 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's hard to use just one string to describe activation of spell or trap, in set turn or from hand or from hand in opponent's turn.

We can do as follows:
If there is at least an effect that has side effect, just list all of them.
If no effect has side effect, choose arbitary one.

}
if(core.select_options.size() == 1) {
returns.ivalue[0] = 0;
return FALSE;
} else if(core.select_options.size() > 1) {
add_process(PROCESSOR_SELECT_OPTION, 0, 0, 0, clit.triggering_player, 0);
return FALSE;
}
}
}
core.units.begin()->step = 2;
return FALSE;
}
case 2: {
auto& clit = core.new_chains.front();
if(effect* peffect = core.select_effects[returns.ivalue[0]]) {
if(peffect->operation) {
core.sub_solving_event.push_back(clit.evt);
add_process(PROCESSOR_EXECUTE_OPERATION, 0, peffect, 0, clit.triggering_player, 0);
}
peffect->dec_count(clit.triggering_player);
}
return FALSE;
}
case 3: {
auto& clit = core.new_chains.front();
effect* peffect = clit.triggering_effect;
card* phandler = peffect->get_handler();
if(peffect->type & EFFECT_TYPE_ACTIVATE) {
if(phandler->current.location == LOCATION_HAND) {
uint32 zone = 0xff;
if(!(phandler->data.type & (TYPE_FIELD | TYPE_PENDULUM)) && peffect->is_flag(EFFECT_FLAG_LIMIT_ZONE)) {
Expand All @@ -3801,7 +3843,7 @@ int32 field::add_chain(uint16 step) {
}
return FALSE;
}
case 1: {
case 4: {
auto& clit = core.new_chains.front();
effect* peffect = clit.triggering_effect;
card* phandler = peffect->get_handler();
Expand Down Expand Up @@ -3855,7 +3897,7 @@ int32 field::add_chain(uint16 step) {
core.new_chains.pop_front();
return FALSE;
}
case 2: {
case 5: {
auto& clit = core.current_chain.back();
int32 playerid = clit.triggering_player;
effect* peffect = clit.triggering_effect;
Expand All @@ -3871,11 +3913,11 @@ int32 field::add_chain(uint16 step) {
returns.ivalue[0] = FALSE;
return FALSE;
}
case 3: {
case 6: {
if(!returns.ivalue[0]) {
core.select_chains.clear();
core.select_options.clear();
core.units.begin()->step = 4;
core.units.begin()->step = 7;
return FALSE;
}
if(core.select_chains.size() > 1) {
Expand All @@ -3885,7 +3927,7 @@ int32 field::add_chain(uint16 step) {
returns.ivalue[0] = 0;
return FALSE;
}
case 4: {
case 7: {
auto& clit = core.current_chain.back();
chain& ch = core.select_chains[returns.ivalue[0]];
int32 playerid = clit.triggering_player;
Expand Down Expand Up @@ -3915,7 +3957,7 @@ int32 field::add_chain(uint16 step) {
phandler->add_effect(deffect);
return FALSE;
}
case 5: {
case 8: {
auto& clit = core.current_chain.back();
effect* peffect = clit.triggering_effect;
if(peffect->cost) {
Expand All @@ -3924,7 +3966,7 @@ int32 field::add_chain(uint16 step) {
}
return FALSE;
}
case 6: {
case 9: {
auto& clit = core.current_chain.back();
effect* peffect = clit.triggering_effect;
if(peffect->target) {
Expand All @@ -3933,7 +3975,7 @@ int32 field::add_chain(uint16 step) {
}
return FALSE;
}
case 7: {
case 10: {
break_effect();
auto& clit = core.current_chain.back();
effect* peffect = clit.triggering_effect;
Expand Down