Commit eb60ed28 authored by nanahira's avatar nanahira

another

parent 27e3f6b0
......@@ -16,6 +16,7 @@
#include <iostream>
#include <algorithm>
//222DIY
uint32 card::set_entity_code(uint32 entity_code) {
card_data dat;
......@@ -1179,8 +1180,8 @@ void card::get_linked_cards(card_set* cset) {
return;
int32 p = current.controler;
uint32 linked_zone = get_linked_zone();
pduel->game_field->get_cards_in_zone(cset, linked_zone, p);
pduel->game_field->get_cards_in_zone(cset, linked_zone >> 16, 1 - p);
pduel->game_field->get_cards_in_zone(cset, linked_zone, p, LOCATION_MZONE);
pduel->game_field->get_cards_in_zone(cset, linked_zone >> 16, 1 - p, LOCATION_MZONE);
}
uint32 card::get_mutual_linked_zone() {
if(!(data.type & TYPE_LINK) || current.location != LOCATION_MZONE)
......@@ -1318,8 +1319,8 @@ void card::get_mutual_linked_cards(card_set* cset) {
return;
int32 p = current.controler;
uint32 mutual_linked_zone = get_mutual_linked_zone();
pduel->game_field->get_cards_in_zone(cset, mutual_linked_zone, p);
pduel->game_field->get_cards_in_zone(cset, mutual_linked_zone >> 16, 1 - p);
pduel->game_field->get_cards_in_zone(cset, mutual_linked_zone, p, LOCATION_MZONE);
pduel->game_field->get_cards_in_zone(cset, mutual_linked_zone >> 16, 1 - p, LOCATION_MZONE);
}
int32 card::is_link_state() {
if(current.location != LOCATION_MZONE)
......@@ -1353,6 +1354,83 @@ int32 card::is_status(uint32 status) {
return TRUE;
return FALSE;
}
uint32 card::get_column_zone(int32 loc1, int32 left, int32 right) {
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)
return 0;
if(s <= 4) {
if(loc1 != loc2)
zones |= 1u << s;
zones |= 1u << (16 + (4 - s));
if(s == 1)
zones |= (1u << 5) | (1u << (16 + 6));
if(s == 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(seq >= 0) {
if(seq <= 4) {
zones |= 1u << seq | 1u << (16 + (4 - seq));
if(seq == 1)
zones |= (1u << 5) | (1u << (16 + 6));
if(seq == 3)
zones |= (1u << 6) | (1u << (16 + 5));
}
if(seq == 5)
zones |= (1u << 1) | (1u << (16 + 3));
if(seq == 6)
zones |= (1u << 3) | (1u << (16 + 1));
}
}
for (int32 i = 1; i <= right; ++i) {
int32 seq = s + i;
if(seq <= 6) {
if(seq <= 4) {
zones |= 1u << seq | 1u << (16 + (4 - seq));
if(seq == 1)
zones |= (1u << 5) | (1u << (16 + 6));
if(seq == 3)
zones |= (1u << 6) | (1u << (16 + 5));
}
if(seq == 5)
zones |= (1u << 1) | (1u << (16 + 3));
if(seq == 6)
zones |= (1u << 3) | (1u << (16 + 1));
}
}
return zones;
}
void card::get_column_cards(card_set* cset, int32 left, int32 right) {
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);
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);
}
int32 card::is_all_column() {
if(!(current.location & LOCATION_ONFIELD))
return FALSE;
card_set cset;
get_column_cards(&cset, 0, 0);
int32 full = 3;
if(pduel->game_field->core.duel_rule >= 4 && (current.sequence == 1 || current.sequence == 3))
full++;
if(cset.size() == full)
return TRUE;
return FALSE;
}
void card::equip(card *target, uint32 send_msg) {
if (equiping_target)
return;
......
......@@ -211,6 +211,9 @@ 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);
int32 is_all_column();
void equip(card *target, uint32 send_msg = TRUE);
void unequip();
......
......@@ -710,7 +710,7 @@ void field::get_linked_cards(uint8 self, uint8 s, uint8 o, card_set* cset) {
for(int32 p = 0; p < 2; ++p) {
if(c) {
uint32 linked_zone = get_linked_zone(self);
get_cards_in_zone(cset, linked_zone, self);
get_cards_in_zone(cset, linked_zone, self, LOCATION_MZONE);
}
self = 1 - self;
c = o;
......@@ -773,9 +773,12 @@ int32 field::check_extra_link(int32 playerid, card* pcard, int32 sequence) {
pcard->current.sequence = cur_sequence;
return ret;
}
void field::get_cards_in_zone(card_set* cset, uint32 zone, int32 playerid) {
void field::get_cards_in_zone(card_set* cset, uint32 zone, int32 playerid, int32 location) {
if(!(location & LOCATION_ONFIELD))
return;
card_vector& svector = (location == LOCATION_MZONE) ? player[playerid].list_mzone : player[playerid].list_szone;
uint32 icheck = 0x1;
for(auto it = player[playerid].list_mzone.begin(); it != player[playerid].list_mzone.end(); ++it) {
for(auto it = svector.begin(); it != svector.end(); ++it) {
if(zone & icheck) {
card* pcard = *it;
if(pcard)
......@@ -2440,7 +2443,7 @@ int32 field::check_tuner_material(card* pcard, card* tuner, int32 findex1, int32
card_set linked_cards;
if(ct <= 0) {
uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f;
get_cards_in_zone(&linked_cards, linked_zone, playerid);
get_cards_in_zone(&linked_cards, linked_zone, playerid, LOCATION_MZONE);
if(linked_cards.find(tuner) != linked_cards.end())
ct++;
}
......@@ -2741,7 +2744,7 @@ int32 field::check_xyz_material(card* scard, int32 findex, int32 lv, int32 min,
if(ct <= 0) {
int32 ft = ct;
uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f;
get_cards_in_zone(&linked_cards, linked_zone, playerid);
get_cards_in_zone(&linked_cards, linked_zone, playerid, LOCATION_MZONE);
for(auto cit = core.xmaterial_lst.begin(); cit != core.xmaterial_lst.end(); ++cit) {
card* pcard = cit->second;
if(linked_cards.find(pcard) != linked_cards.end())
......
......@@ -358,7 +358,7 @@ public:
void get_linked_cards(uint8 self, uint8 s, uint8 o, card_set* cset);
int32 check_extra_link(int32 playerid);
int32 check_extra_link(int32 playerid, card* pcard, int32 sequence);
void get_cards_in_zone(card_set* cset, uint32 zone, int32 playerid);
void get_cards_in_zone(card_set* cset, uint32 zone, int32 playerid, int32 location);
void shuffle(uint8 playerid, uint8 location);
void reset_sequence(uint8 playerid, uint8 location);
void swap_deck_and_grave(uint8 playerid);
......
......@@ -56,6 +56,9 @@ static const struct luaL_Reg cardlib[] = {
{ "GetMutualLinkedGroupCount", scriptlib::card_get_mutual_linked_group_count },
{ "GetMutualLinkedZone", scriptlib::card_get_mutual_linked_zone },
{ "IsLinkState", scriptlib::card_is_link_state },
{ "GetColumnGroup", scriptlib::card_get_column_group },
{ "GetColumnGroupCount", scriptlib::card_get_column_group_count },
{ "IsAllColumn", scriptlib::card_is_all_column },
{ "GetAttribute", scriptlib::card_get_attribute },
{ "GetOriginalAttribute", scriptlib::card_get_origin_attribute },
{ "GetFusionAttribute", scriptlib::card_get_fusion_attribute },
......
......@@ -383,6 +383,44 @@ int32 scriptlib::card_is_link_state(lua_State *L) {
lua_pushboolean(L, pcard->is_link_state());
return 1;
}
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);
group* pgroup = pcard->pduel->new_group(cset);
interpreter::group2value(L, pgroup);
return 1;
}
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);
lua_pushinteger(L, cset.size());
return 1;
}
int32 scriptlib::card_is_all_column(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
lua_pushboolean(L, pcard->is_all_column());
return 1;
}
int32 scriptlib::card_get_attribute(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
......@@ -2618,7 +2656,7 @@ int32 scriptlib::card_check_mzone_from_ex(lua_State *L) {
duel* pduel = pcard->pduel;
field::card_set linked_cards;
uint32 linked_zone = pduel->game_field->core.duel_rule >= 4 ? pduel->game_field->get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f;
pduel->game_field->get_cards_in_zone(&linked_cards, linked_zone, playerid);
pduel->game_field->get_cards_in_zone(&linked_cards, linked_zone, playerid, LOCATION_MZONE);
if(linked_cards.find(pcard) != linked_cards.end())
lua_pushboolean(L, 1);
else
......
......@@ -4853,7 +4853,7 @@ int32 field::select_synchro_material(int16 step, uint8 playerid, card* pcard, in
}
card_set linked_cards;
uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f;
get_cards_in_zone(&linked_cards, linked_zone, playerid);
get_cards_in_zone(&linked_cards, linked_zone, playerid, LOCATION_MZONE);
if(linked_cards.find(tuner) != linked_cards.end())
ct++;
if(smat && linked_cards.find(smat) != linked_cards.end())
......@@ -5021,7 +5021,7 @@ int32 field::select_xyz_material(int16 step, uint8 playerid, uint32 lv, card* sc
card_set linked_cards;
if(ct <= 0) {
uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f;
get_cards_in_zone(&linked_cards, linked_zone, playerid);
get_cards_in_zone(&linked_cards, linked_zone, playerid, LOCATION_MZONE);
}
for(auto cit = core.xmaterial_lst.begin(); cit != core.xmaterial_lst.end(); ++cit)
cit->second->sum_param = 0;
......@@ -5089,7 +5089,7 @@ int32 field::select_xyz_material(int16 step, uint8 playerid, uint32 lv, card* sc
}
card_set linked_cards;
uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f;
get_cards_in_zone(&linked_cards, linked_zone, playerid);
get_cards_in_zone(&linked_cards, linked_zone, playerid, LOCATION_MZONE);
int32 mmax = 0;
core.select_cards.clear();
for(auto iter = core.xmaterial_lst.begin(); iter != core.xmaterial_lst.end(); ++iter) {
......@@ -5265,7 +5265,7 @@ int32 field::select_xyz_material(int16 step, uint8 playerid, uint32 lv, card* sc
return FALSE;
card_set linked_cards;
uint32 linked_zone = core.duel_rule >= 4 ? get_linked_zone(playerid) | (1u << 5) | (1u << 6) : 0x1f;
get_cards_in_zone(&linked_cards, linked_zone, playerid);
get_cards_in_zone(&linked_cards, linked_zone, playerid, LOCATION_MZONE);
core.select_cards.clear();
for(auto iter = core.xmaterial_lst.begin(); iter != core.xmaterial_lst.end(); ++iter) {
card* pcard = iter->second;
......
......@@ -62,6 +62,9 @@ public:
static int32 card_get_mutual_linked_group_count(lua_State *L);
static int32 card_get_mutual_linked_zone(lua_State *L);
static int32 card_is_link_state(lua_State *L);
static int32 card_get_column_group(lua_State *L);
static int32 card_get_column_group_count(lua_State *L);
static int32 card_is_all_column(lua_State *L);
static int32 card_get_attribute(lua_State *L);
static int32 card_get_origin_attribute(lua_State *L);
static int32 card_get_fusion_attribute(lua_State *L);
......
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