Commit fa3c18f5 authored by mercury233's avatar mercury233
parents ae8adc53 90a07a09
......@@ -1426,78 +1426,58 @@ int32 card::is_status(uint32 status) {
return TRUE;
return FALSE;
}
uint32 card::get_column_zone(int32 loc1, int32 left, int32 right) {
uint32 card::get_column_zone(int32 location) {
int32 zones = 0;
int32 loc2 = current.location;
int32 s = current.sequence;
if(!(loc1 & LOCATION_ONFIELD) || !(loc2 & LOCATION_ONFIELD) || loc2 == LOCATION_SZONE && s >=5 || left < 0 || right < 0)
uint8 seq = current.sequence;
if(!(location & LOCATION_ONFIELD) || !(current.location & LOCATION_ONFIELD) || current.location == LOCATION_SZONE && seq >= 5)
return 0;
if(s <= 4) {
if(loc1 != loc2)
zones |= 1u << s;
zones |= 1u << (16 + (4 - s));
if(loc1 & LOCATION_MZONE) {
if(s == 1)
if(seq <= 4) {
if(location & LOCATION_MZONE) {
if(!(current.location & LOCATION_MZONE))
zones |= 1u << seq;
zones |= 1u << (16 + (4 - seq));
if(seq == 1)
zones |= (1u << 5) | (1u << (16 + 6));
if(s == 3)
if(seq == 3)
zones |= (1u << 6) | (1u << (16 + 5));
}
}
if(s == 5)
zones |= (1u << 1) | (1u << (16 + 3));
if(s == 6)
zones |= (1u << 3) | (1u << (16 + 1));
for(int32 i = 1; i <= left; ++i) {
int32 seq = s - i;
if(s == 5)
seq = 1 - i;
if(s == 6)
seq = 3 - i;
if(seq >= 0 && seq <= 4) {
zones |= 1u << seq | 1u << (16 + (4 - seq));
if(loc1 & LOCATION_MZONE) {
if(seq == 1)
zones |= (1u << 5) | (1u << (16 + 6));
if(seq == 3)
zones |= (1u << 6) | (1u << (16 + 5));
}
if(location & LOCATION_SZONE) {
if(!(current.location & LOCATION_SZONE))
zones |= 1u << (seq + 8);
zones |= 1u << (16 + 8 + (4 - seq));
}
}
for(int32 i = 1; i <= right; ++i) {
int32 seq = s + i;
if(s == 5)
seq = 1 + i;
if(s == 6)
seq = 3 + i;
if(seq >= 0 && seq <= 4) {
zones |= 1u << seq | 1u << (16 + (4 - seq));
if(loc1 & LOCATION_MZONE) {
if(seq == 1)
zones |= (1u << 5) | (1u << (16 + 6));
if(seq == 3)
zones |= (1u << 6) | (1u << (16 + 5));
}
}
if(seq == 5) {
if(location & LOCATION_MZONE)
zones |= (1u << 1) | (1u << (16 + 3));
if(location & LOCATION_SZONE)
zones |= (1u << (8 + 1)) | (1u << (16 + 8 + 3));
}
if(seq == 6) {
if(location & LOCATION_MZONE)
zones |= (1u << 3) | (1u << (16 + 1));
if(location & LOCATION_SZONE)
zones |= (1u << (8 + 3)) | (1u << (16 + 8 + 1));
}
return zones;
}
void card::get_column_cards(card_set* cset, int32 left, int32 right) {
void card::get_column_cards(card_set* cset) {
cset->clear();
if(!(current.location & LOCATION_ONFIELD))
return;
int32 p = current.controler;
uint32 column_mzone = get_column_zone(LOCATION_MZONE, left, right);
uint32 column_szone = get_column_zone(LOCATION_SZONE, left, right);
uint32 column_mzone = get_column_zone(LOCATION_MZONE);
uint32 column_szone = get_column_zone(LOCATION_SZONE);
pduel->game_field->get_cards_in_zone(cset, column_mzone, p, LOCATION_MZONE);
pduel->game_field->get_cards_in_zone(cset, column_mzone >> 16, 1 - p, LOCATION_MZONE);
pduel->game_field->get_cards_in_zone(cset, column_szone, p, LOCATION_SZONE);
pduel->game_field->get_cards_in_zone(cset, column_szone >> 16, 1 - p, LOCATION_SZONE);
pduel->game_field->get_cards_in_zone(cset, column_szone >> 8, p, LOCATION_SZONE);
pduel->game_field->get_cards_in_zone(cset, column_szone >> 24, 1 - p, LOCATION_SZONE);
}
int32 card::is_all_column() {
if(!(current.location & LOCATION_ONFIELD))
return FALSE;
card_set cset;
get_column_cards(&cset, 0, 0);
get_column_cards(&cset);
int32 full = 3;
if(pduel->game_field->core.duel_rule >= 4 && (current.sequence == 1 || current.sequence == 3))
full++;
......
......@@ -233,8 +233,8 @@ public:
void set_status(uint32 status, int32 enabled);
int32 get_status(uint32 status);
int32 is_status(uint32 status);
uint32 get_column_zone(int32 loc1, int32 left, int32 right);
void get_column_cards(card_set* cset, int32 left, int32 right);
uint32 get_column_zone(int32 location);
void get_column_cards(card_set* cset);
int32 is_all_column();
void equip(card *target, uint32 send_msg = TRUE);
......
......@@ -192,8 +192,6 @@ struct processor {
event_list sub_solving_event;
chain_array select_chains;
chain_array current_chain;
chain_list tpchain;
chain_list ntpchain;
chain_list continuous_chain;
chain_list desrep_chain;
chain_list new_fchain;
......@@ -498,7 +496,6 @@ public:
int32 process_turn(uint16 step, uint8 turn_player);
int32 add_chain(uint16 step);
int32 sort_chain(uint16 step, uint8 tp);
int32 solve_continuous(uint16 step, effect* peffect, uint8 triggering_player);
int32 solve_chain(uint16 step, uint32 chainend_arg1, uint32 chainend_arg2);
int32 break_effect();
......@@ -687,7 +684,7 @@ public:
#define PROCESSOR_SELECT_PLACE 18
#define PROCESSOR_SELECT_POSITION 19
#define PROCESSOR_SELECT_TRIBUTE_P 20
#define PROCESSOR_SORT_CHAIN 21
//#define PROCESSOR_SORT_CHAIN 21
#define PROCESSOR_SELECT_COUNTER 22
#define PROCESSOR_SELECT_SUM 23
#define PROCESSOR_SELECT_DISFIELD 24
......
......@@ -424,14 +424,8 @@ int32 scriptlib::card_get_column_group(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
int32 left = 0;
int32 right = 0;
if(lua_gettop(L) >= 2)
left = lua_tointeger(L, 2);
if(lua_gettop(L) >= 3)
right = lua_tointeger(L, 3);
card::card_set cset;
pcard->get_column_cards(&cset, left, right);
pcard->get_column_cards(&cset);
group* pgroup = pcard->pduel->new_group(cset);
interpreter::group2value(L, pgroup);
return 1;
......@@ -440,14 +434,8 @@ int32 scriptlib::card_get_column_group_count(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
int32 left = 0;
int32 right = 0;
if(lua_gettop(L) >= 2)
left = lua_tointeger(L, 2);
if(lua_gettop(L) >= 3)
right = lua_tointeger(L, 3);
card::card_set cset;
pcard->get_column_cards(&cset, left, right);
pcard->get_column_cards(&cset);
lua_pushinteger(L, cset.size());
return 1;
}
......@@ -456,16 +444,10 @@ int32 scriptlib::card_get_column_zone(lua_State *L) {
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
int32 loc = lua_tointeger(L, 2);
int32 left = 0;
int32 right = 0;
int32 cp = pcard->current.controler;
if(lua_gettop(L) >= 3)
left = lua_tointeger(L, 3);
if(lua_gettop(L) >= 4)
right = lua_tointeger(L, 4);
if(lua_gettop(L) >= 5 && !lua_isnil(L, 5))
cp = lua_tointeger(L, 5);
uint32 zone = pcard->get_column_zone(loc, left, right);
if(lua_gettop(L) >= 3 && !lua_isnil(L, 3))
cp = lua_tointeger(L, 3);
uint32 zone = pcard->get_column_zone(loc);
if(cp == 1 - pcard->current.controler)
lua_pushinteger(L, (((zone & 0xffff) << 16) | (zone >> 16)));
else
......
......@@ -1516,8 +1516,6 @@ int32 field::summon(uint16 step, uint8 sumplayer, card* target, effect* proc, ui
}
effect* peffect = core.select_effects[returns.ivalue[0]];
core.units.begin()->peffect = peffect;
int32 unlimited = -1;
bool force_select = false;
core.select_effects.clear();
core.select_options.clear();
if(ignore_count || core.summon_count[sumplayer] < get_summon_count_limit(sumplayer)) {
......@@ -1532,12 +1530,9 @@ int32 field::summon(uint16 step, uint8 sumplayer, card* target, effect* proc, ui
int32 new_zone = retval.size() > 1 ? retval[1] : 0x1f;
int32 releasable = retval.size() > 2 ? (retval[2] < 0 ? 0xff00ff + retval[2] : retval[2]) : 0xff00ff;
new_zone &= zone;
bool unchanged = (new_zone == zone);
if(peffect) {
if(new_min_tribute < (int32)min_tribute) {
if(new_min_tribute < (int32)min_tribute)
new_min_tribute = min_tribute;
unchanged = false;
}
if(!target->is_summonable(peffect, new_min_tribute, new_zone, releasable))
continue;
} else {
......@@ -1550,25 +1545,17 @@ int32 field::summon(uint16 step, uint8 sumplayer, card* target, effect* proc, ui
min = min_tribute;
if(max < min)
continue;
if(min < new_min_tribute) {
if(min < new_min_tribute)
min = new_min_tribute;
unchanged = false;
}
if(!check_tribute(target, min, max, 0, target->current.controler, new_zone, releasable))
continue;
}
if(unlimited < 0 && unchanged)
unlimited = (int32)core.select_effects.size();
if(eset[i]->operation)
force_select = true;
core.select_effects.push_back(eset[i]);
core.select_options.push_back(eset[i]->description);
}
}
if(core.select_options.size() == 1)
returns.ivalue[0] = 0;
else if(!force_select && unlimited >= 0)
returns.ivalue[0] = unlimited;
else
add_process(PROCESSOR_SELECT_OPTION, 0, 0, 0, sumplayer, 0);
return FALSE;
......@@ -2062,8 +2049,6 @@ int32 field::mset(uint16 step, uint8 setplayer, card* target, effect* proc, uint
}
effect* peffect = core.select_effects[returns.ivalue[0]];
core.units.begin()->peffect = peffect;
int32 unlimited = -1;
bool force_select = false;
core.select_effects.clear();
core.select_options.clear();
if(ignore_count || core.summon_count[setplayer] < get_summon_count_limit(setplayer)) {
......@@ -2078,12 +2063,9 @@ int32 field::mset(uint16 step, uint8 setplayer, card* target, effect* proc, uint
int32 new_zone = retval.size() > 1 ? retval[1] : 0x1f;
int32 releasable = retval.size() > 2 ? (retval[2] < 0 ? 0xff00ff + retval[2] : retval[2]) : 0xff00ff;
new_zone &= zone;
bool unchanged = (new_zone == zone);
if(peffect) {
if(new_min_tribute < (int32)min_tribute) {
if(new_min_tribute < (int32)min_tribute)
new_min_tribute = min_tribute;
unchanged = false;
}
if(!target->is_summonable(peffect, new_min_tribute, new_zone, releasable))
continue;
} else {
......@@ -2096,25 +2078,17 @@ int32 field::mset(uint16 step, uint8 setplayer, card* target, effect* proc, uint
min = min_tribute;
if(max < min)
continue;
if(min < new_min_tribute) {
if(min < new_min_tribute)
min = new_min_tribute;
unchanged = false;
}
if(!check_tribute(target, min, max, 0, target->current.controler, new_zone, releasable, POS_FACEDOWN_DEFENSE))
continue;
}
if(unlimited < 0 && unchanged)
unlimited = (int32)core.select_effects.size();
if(eset[i]->operation)
force_select = true;
core.select_effects.push_back(eset[i]);
core.select_options.push_back(eset[i]->description);
}
}
if(core.select_options.size() == 1)
returns.ivalue[0] = 0;
else if(!force_select && unlimited >= 0)
returns.ivalue[0] = unlimited;
else
add_process(PROCESSOR_SELECT_OPTION, 0, 0, 0, setplayer, 0);
return FALSE;
......
This diff is collapsed.
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