Commit 8bd31d4c authored by DailyShana's avatar DailyShana

cleanup

parent 4ad244b9
...@@ -1254,18 +1254,10 @@ int32 field::check_release_list(uint8 playerid, int32 count, int32 use_con, int3 ...@@ -1254,18 +1254,10 @@ int32 field::check_release_list(uint8 playerid, int32 count, int32 use_con, int3
} }
// return: the max release count of mg or all monsters on field // return: the max release count of mg or all monsters on field
int32 field::get_summon_release_list(card* target, card_set* release_list, card_set* ex_list, card_set* ex_list_sum, group* mg, uint32 ex) { int32 field::get_summon_release_list(card* target, card_set* release_list, card_set* ex_list, card_set* ex_list_sum, group* mg, uint32 ex) {
int32 m1 = get_summon_release_slist(target, release_list, mg);
int32 m2 = get_summon_release_olist(target, ex_list, ex_list_sum, mg, ex);
return m1 + m2;
}
// let the controller of target be p
// search in mg or mzone of p, and put the tribute monsters in release_list
int32 field::get_summon_release_slist(card* target, card_set* release_list, group* mg) {
uint8 p = target->current.controler; uint8 p = target->current.controler;
card* pcard;
uint32 rcount = 0; uint32 rcount = 0;
for(int i = 0; i < 5; ++i) { for(int i = 0; i < 5; ++i) {
pcard = player[p].list_mzone[i]; card* pcard = player[p].list_mzone[i];
if(pcard && pcard->is_releasable_by_summon(p, target)) { if(pcard && pcard->is_releasable_by_summon(p, target)) {
if(mg && !mg->has_card(pcard)) if(mg && !mg->has_card(pcard))
continue; continue;
...@@ -1278,20 +1270,10 @@ int32 field::get_summon_release_slist(card* target, card_set* release_list, grou ...@@ -1278,20 +1270,10 @@ int32 field::get_summon_release_slist(card* target, card_set* release_list, grou
rcount += pcard->release_param; rcount += pcard->release_param;
} }
} }
return rcount;
}
// ex: the procedure of target can release opponent monster
// ex_list: the tribute monsters controlled by 1-p
// ex_list_sum: the opponent monsters affected by EFFECT_EXTRA_RELEASE_SUM
// search in mg or mzone of 1-p, and maintain ex_list, ex_list_sum
int32 field::get_summon_release_olist(card* target, card_set* ex_list, card_set* ex_list_sum, group* mg, uint32 ex) {
uint8 p = target->current.controler;
card* pcard;
uint32 rcount = 0;
uint32 ex_sum_max = 0; uint32 ex_sum_max = 0;
for(int i = 0; i < 5; ++i) { for(int i = 0; i < 5; ++i) {
pcard = player[1 - p].list_mzone[i]; card* pcard = player[1 - p].list_mzone[i];
if(!(pcard && pcard->is_releasable_by_summon(p, target))) if(!pcard || !pcard->is_releasable_by_summon(p, target))
continue; continue;
if(mg && !mg->has_card(pcard)) if(mg && !mg->has_card(pcard))
continue; continue;
...@@ -1319,22 +1301,6 @@ int32 field::get_summon_release_olist(card* target, card_set* ex_list, card_set* ...@@ -1319,22 +1301,6 @@ int32 field::get_summon_release_olist(card* target, card_set* ex_list, card_set*
} }
return rcount + ex_sum_max; return rcount + ex_sum_max;
} }
// put the monsters of 1-p affected by EFFECT_EXTRA_RELEASE
int32 field::get_summon_release_exlist(card* target, card_set* ex_list, group* mg) {
uint8 p = target->current.controler;
card* pcard;
for(int i = 0; i < 5; ++i) {
pcard = player[1 - p].list_mzone[i];
if(!(pcard && pcard->is_releasable_by_summon(p, target)))
continue;
if(mg && !mg->has_card(pcard))
continue;
if(pcard->is_affected_by_effect(EFFECT_EXTRA_RELEASE)) {
ex_list->insert(pcard);
}
}
return TRUE;
}
int32 field::get_summon_count_limit(uint8 playerid) { int32 field::get_summon_count_limit(uint8 playerid) {
effect_set eset; effect_set eset;
filter_player_effect(playerid, EFFECT_SET_SUMMON_COUNT_LIMIT, &eset); filter_player_effect(playerid, EFFECT_SET_SUMMON_COUNT_LIMIT, &eset);
...@@ -2219,46 +2185,31 @@ int32 field::check_tuner_material(card* pcard, card* tuner, int32 findex1, int32 ...@@ -2219,46 +2185,31 @@ int32 field::check_tuner_material(card* pcard, card* tuner, int32 findex1, int32
pduel->restore_assumes(); pduel->restore_assumes();
return FALSE; return FALSE;
} }
// check if "releasing min~max tributes" is available
int32 field::check_tribute(card* pcard, int32 min, int32 max, group* mg, uint8 toplayer) { int32 field::check_tribute(card* pcard, int32 min, int32 max, group* mg, uint8 toplayer) {
card_set test, exset; int32 ex = FALSE;
int32 m1 = 0, m2 = 0; if(toplayer == 1 - pcard->current.controler)
ex = TRUE;
card_set release_list, ex_list;
int32 m = get_summon_release_list(pcard, &release_list, &ex_list, 0, mg, ex);
if(max > m)
max = m;
if(min > max)
return FALSE;
int32 s;
if(toplayer == pcard->current.controler) { if(toplayer == pcard->current.controler) {
m1 = get_summon_release_slist(pcard, &test, mg); s = release_list.size();
m2 = get_summon_release_olist(pcard, NULL, NULL, mg, 0); max -= (int32)ex_list.size();
} else { } else {
m1 = get_summon_release_olist(pcard, &test, NULL, mg, 1); s = ex_list.size();
m2 = get_summon_release_slist(pcard, NULL, mg);
} }
// sum of release count is the real upper bound
if(max > m1 + m2)
max = m1 + m2;
if(min > max)
return FALSE;
int32 fcount = get_useable_count(toplayer, LOCATION_MZONE, pcard->current.controler, LOCATION_REASON_TOFIELD); int32 fcount = get_useable_count(toplayer, LOCATION_MZONE, pcard->current.controler, LOCATION_REASON_TOFIELD);
// test "releasing i tributes" if(s < -fcount + 1)
for(int32 i = min; i <= max; ++i){ return FALSE;
int32 rmax = 0; if(max < 0)
if(toplayer == pcard->current.controler) { max = 0;
get_summon_release_exlist(pcard, &exset, mg); if(max < -fcount + 1)
// let r be the number of monsters released from mzone of toplayer return FALSE;
// r<=i-ex, r<=test return TRUE;
// rmax = min{i-ex, test}
if(i >= (int32)exset.size()){
rmax = i - (int32)exset.size();
if(rmax > (int32)test.size())
rmax = (int32)test.size();
}
else
rmax = 0;
}
else
rmax = (int32)test.size();
// this is the # of slots after the advance summon
if(fcount + rmax - 1 >= 0)
return TRUE;
}
return FALSE;
} }
int32 field::check_with_sum_limit(const card_vector& mats, int32 acc, int32 index, int32 count, int32 min, int32 max) { int32 field::check_with_sum_limit(const card_vector& mats, int32 acc, int32 index, int32 count, int32 min, int32 max) {
if(count > max) if(count > max)
......
...@@ -364,9 +364,6 @@ public: ...@@ -364,9 +364,6 @@ public:
int32 get_release_list(uint8 playerid, card_set* release_list, card_set* ex_list, int32 use_con, int32 use_hand, int32 fun, int32 exarg, card* exp); int32 get_release_list(uint8 playerid, card_set* release_list, card_set* ex_list, int32 use_con, int32 use_hand, int32 fun, int32 exarg, card* exp);
int32 check_release_list(uint8 playerid, int32 count, int32 use_con, int32 use_hand, int32 fun, int32 exarg, card* exp); int32 check_release_list(uint8 playerid, int32 count, int32 use_con, int32 use_hand, int32 fun, int32 exarg, card* exp);
int32 get_summon_release_list(card* target, card_set* release_list, card_set* ex_list, card_set* ex_list_sum, group* mg = NULL, uint32 ex = 0); int32 get_summon_release_list(card* target, card_set* release_list, card_set* ex_list, card_set* ex_list_sum, group* mg = NULL, uint32 ex = 0);
int32 get_summon_release_slist(card* target, card_set* release_list, group* mg = NULL);
int32 get_summon_release_olist(card* target, card_set* ex_list, card_set* ex_list_sum, group* mg = NULL, uint32 ex = 0);
int32 get_summon_release_exlist(card* target, card_set* ex_list, group* mg = NULL);
int32 get_summon_count_limit(uint8 playerid); int32 get_summon_count_limit(uint8 playerid);
int32 get_draw_count(uint8 playerid); int32 get_draw_count(uint8 playerid);
void get_ritual_material(uint8 playerid, effect* peffect, card_set* material); void get_ritual_material(uint8 playerid, effect* peffect, card_set* material);
......
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