Commit 64739171 authored by nanahira's avatar nanahira

fix merge

parent 3f924bbf
...@@ -143,137 +143,6 @@ int32_t scriptlib::card_get_removed_overlay_count(lua_State *L) { ...@@ -143,137 +143,6 @@ int32_t scriptlib::card_get_removed_overlay_count(lua_State *L) {
return 1; return 1;
} }
int32_t scriptlib::card_is_ritual_type(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
uint32_t ttype = lua_tointeger(L, 2);
if(pcard->get_ritual_type() & ttype)
lua_pushboolean(L, 1);
else
lua_pushboolean(L, 0);
return 1;
}
int32_t scriptlib::card_set_entity_code(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
uint32_t trace = lua_tointeger(L, 2);
bool remove_alias = false;
int32_t enable = lua_toboolean(L, 3);
if (enable)
remove_alias = true;
lua_pushinteger(L, pcard->set_entity_code(trace, remove_alias));
return 1;
}
int32_t scriptlib::card_set_card_data(lua_State *L) {
check_param_count(L, 3);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
duel* pduel = pcard->pduel;
int32_t stype = lua_tointeger(L, 2);
switch(stype) {
case CARDDATA_CODE:
pcard->data.code = lua_tointeger(L, 3);
break;
case CARDDATA_ALIAS:
pcard->data.alias = lua_tointeger(L, 3);
break;
case CARDDATA_SETCODE: {
unsigned long setcode = lua_tointeger(L, 3);
for (int i = 0 ;; ++i)
{
if(setcode == 0)
break;
pcard->data.setcode[i] = setcode & 0xffff;
setcode >>= 16;
}
break;
}
case CARDDATA_TYPE:
pcard->data.type = lua_tointeger(L, 3);
break;
case CARDDATA_LEVEL:
pcard->data.level = lua_tointeger(L, 3);
break;
case CARDDATA_ATTRIBUTE:
pcard->data.attribute = lua_tointeger(L, 3);
break;
case CARDDATA_RACE:
pcard->data.race = lua_tointeger(L, 3);
break;
case CARDDATA_ATTACK:
pcard->data.attack = lua_tointeger(L, 3);
break;
case CARDDATA_DEFENSE:
pcard->data.defense = lua_tointeger(L, 3);
break;
case CARDDATA_LSCALE:
pcard->data.lscale = lua_tointeger(L, 3);
break;
case CARDDATA_RSCALE:
pcard->data.rscale = lua_tointeger(L, 3);
break;
case CARDDATA_LINK_MARKER:
pcard->data.link_marker = lua_tointeger(L, 3);
break;
}
pduel->write_buffer8(MSG_MOVE);
pduel->write_buffer32(pcard->data.code);
pduel->write_buffer32(pcard->get_info_location());
pduel->write_buffer32(pcard->get_info_location());
pduel->write_buffer32(0);
return 0;
}
int32_t scriptlib::card_get_link_marker(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
lua_pushinteger(L, pcard->get_link_marker());
return 1;
}
int32_t scriptlib::card_get_origin_link_marker(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
if(pcard->status & STATUS_NO_LEVEL)
lua_pushinteger(L, 0);
else
lua_pushinteger(L, pcard->data.link_marker);
return 1;
}
int32_t scriptlib::card_is_xyz_summonable_by_rose(lua_State *L) {
check_param_count(L, 3);
check_param(L, PARAM_TYPE_CARD, 1);
check_param(L, PARAM_TYPE_CARD, 2);
check_param(L, PARAM_TYPE_CARD, 3);
card* pcard = *(card**) lua_touserdata(L, 1);
if(!(pcard->data.type & TYPE_XYZ))
return 0;
card* rcard = *(card**) lua_touserdata(L, 2);
card* mcard = *(card**) lua_touserdata(L, 3);
group* materials = pcard->pduel->new_group(rcard);
materials->container.insert(mcard);
uint32_t p = pcard->pduel->game_field->core.reason_player;
pcard->pduel->game_field->core.limit_xyz = materials;
pcard->pduel->game_field->core.limit_xyz_minc = 2;
pcard->pduel->game_field->core.limit_xyz_maxc = 2;
pcard->pduel->game_field->rose_card = rcard;
pcard->pduel->game_field->rose_level = mcard->get_level();
int32_t result = pcard->is_special_summonable(p, SUMMON_TYPE_XYZ);
pcard->pduel->game_field->rose_card = 0;
pcard->pduel->game_field->rose_level = 0;
lua_pushboolean(L, result);
return 1;
}
int32_t scriptlib::card_get_removed_overlay_count(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1);
lua_pushinteger(L, pcard->removed_overlay_count);
return 1;
}
int32_t scriptlib::card_get_code(lua_State *L) { int32_t scriptlib::card_get_code(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
......
...@@ -229,222 +229,6 @@ int32_t scriptlib::duel_get_random_number(lua_State * L) { ...@@ -229,222 +229,6 @@ int32_t scriptlib::duel_get_random_number(lua_State * L) {
return 1; return 1;
} }
int32_t scriptlib::duel_get_master_rule(lua_State * L) {
duel* pduel = interpreter::get_duel_info(L);
lua_pushinteger(L, pduel->game_field->core.duel_rule);
return 1;
}
int32_t scriptlib::duel_read_card(lua_State *L) {
check_param_count(L, 2);
card_data dat;
if(check_param(L, PARAM_TYPE_CARD, 1, TRUE)) {
card* pcard = *(card**) lua_touserdata(L, 1);
dat = pcard->data;
} else {
int32_t code = lua_tointeger(L, 1);
::read_card(code, &dat);
}
if(!dat.code)
return 0;
uint32_t args = lua_gettop(L) - 1;
for(uint32_t i = 0; i < args; ++i) {
int32_t flag = lua_tointeger(L, 2 + i);
switch(flag) {
case CARDDATA_CODE:
lua_pushinteger(L, dat.code);
break;
case CARDDATA_ALIAS:
lua_pushinteger(L, dat.alias);
break;
case CARDDATA_SETCODE: {
unsigned long setcode = 0;
for (int i = 0;; ++i) {
uint16_t sc = dat.setcode[i];
if (!sc)
break;
setcode |= sc << (16 * i);
}
lua_pushinteger(L, setcode);
break;
}
case CARDDATA_TYPE:
lua_pushinteger(L, dat.type);
break;
case CARDDATA_LEVEL:
lua_pushinteger(L, dat.level);
break;
case CARDDATA_ATTRIBUTE:
lua_pushinteger(L, dat.attribute);
break;
case CARDDATA_RACE:
lua_pushinteger(L, dat.race);
break;
case CARDDATA_ATTACK:
lua_pushinteger(L, dat.attack);
break;
case CARDDATA_DEFENSE:
lua_pushinteger(L, dat.defense);
break;
case CARDDATA_LSCALE:
lua_pushinteger(L, dat.lscale);
break;
case CARDDATA_RSCALE:
lua_pushinteger(L, dat.rscale);
break;
case CARDDATA_LINK_MARKER:
lua_pushinteger(L, dat.link_marker);
break;
default:
lua_pushinteger(L, 0);
break;
}
}
return args;
}
int32_t scriptlib::duel_exile(lua_State *L) {
check_action_permission(L);
check_param_count(L, 2);
card* pcard = 0;
group* pgroup = 0;
duel* pduel = 0;
if(check_param(L, PARAM_TYPE_CARD, 1, TRUE)) {
pcard = *(card**) lua_touserdata(L, 1);
pduel = pcard->pduel;
} else if(check_param(L, PARAM_TYPE_GROUP, 1, TRUE)) {
pgroup = *(group**) lua_touserdata(L, 1);
pduel = pgroup->pduel;
} else
luaL_error(L, "Parameter %d should be \"Card\" or \"Group\".", 1);
uint32_t reason = lua_tointeger(L, 2);
if(pcard)
pduel->game_field->send_to(pcard, pduel->game_field->core.reason_effect, reason, pduel->game_field->core.reason_player, PLAYER_NONE, 0, 0, POS_FACEUP);
else
pduel->game_field->send_to(pgroup->container, pduel->game_field->core.reason_effect, reason, pduel->game_field->core.reason_player, PLAYER_NONE, 0, 0, POS_FACEUP);
return lua_yieldk(L, 0, (lua_KContext)pduel, [](lua_State *L, int32_t status, lua_KContext ctx) {
duel* pduel = (duel*)ctx;
lua_pushinteger(L, pduel->game_field->returns.ivalue[0]);
return 1;
});
}
int32_t scriptlib::duel_disable_action_check(lua_State *L) {
check_param_count(L, 1);
int32_t dis = lua_toboolean(L, 1);
duel* pduel = interpreter::get_duel_info(L);
pduel->lua->disable_action_check = dis;
return 0;
}
int32_t scriptlib::duel_setmetatable(lua_State *L) {
check_param_count(L, 2);
if(!lua_isuserdata(L, 1))
luaL_error(L, "Parameter 1 should be \"Card\" or \"Effect\" or \"Group\".");
if(!lua_istable(L, 2))
luaL_error(L, "Parameter 2 should be \"Table\".");
lua_settop(L, 2);
lua_setmetatable(L, 1);
return 0;
}
int32_t scriptlib::duel_move_turn_count(lua_State *L) {
duel* pduel = interpreter::get_duel_info(L);
int32_t turn_player = pduel->game_field->infos.turn_player;
pduel->game_field->infos.turn_id++;
pduel->game_field->infos.turn_id_by_player[turn_player]++;
pduel->write_buffer8(MSG_NEW_TURN);
pduel->write_buffer8(turn_player | 0x2);
return 0;
}
int32_t scriptlib::duel_get_cards_in_zone(lua_State *L) {
check_param_count(L, 2);
uint32_t rplayer = lua_tointeger(L, 1);
if(rplayer != 0 && rplayer != 1)
return 0;
uint32_t zone = lua_tointeger(L, 2);
duel* pduel = interpreter::get_duel_info(L);
card_set cset;
pduel->game_field->get_cards_in_zone(&cset, zone, rplayer, LOCATION_MZONE);
pduel->game_field->get_cards_in_zone(&cset, zone >> 8, rplayer, LOCATION_SZONE);
pduel->game_field->get_cards_in_zone(&cset, zone >> 16, 1 - rplayer, LOCATION_MZONE);
pduel->game_field->get_cards_in_zone(&cset, zone >> 24, 1 - rplayer, LOCATION_SZONE);
group* pgroup = pduel->new_group(cset);
interpreter::group2value(L, pgroup);
return 1;
}
int32_t scriptlib::duel_xyz_summon_by_rose(lua_State *L) {
check_action_permission(L);
check_param_count(L, 4);
check_param(L, PARAM_TYPE_CARD, 2);
check_param(L, PARAM_TYPE_CARD, 3);
check_param(L, PARAM_TYPE_CARD, 4);
uint32_t playerid = lua_tointeger(L, 1);
if(playerid != 0 && playerid != 1)
return 0;
card* pcard = *(card**)lua_touserdata(L, 2);
card* rcard = *(card**) lua_touserdata(L, 3);
card* mcard = *(card**) lua_touserdata(L, 4);
duel* pduel = pcard->pduel;
group* materials = pduel->new_group(rcard);
materials->container.insert(mcard);
pduel->game_field->core.limit_xyz = materials;
pduel->game_field->core.limit_xyz_minc = 0;
pduel->game_field->core.limit_xyz_maxc = 0;
pduel->game_field->core.summon_cancelable = FALSE;
pduel->game_field->rose_card = rcard;
pduel->game_field->rose_level = mcard->get_level();
pduel->game_field->special_summon_rule(playerid, pcard, SUMMON_TYPE_XYZ);
return lua_yield(L, 0);
}
int32_t scriptlib::duel_load_script(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_STRING, 1);
duel* pduel = interpreter::get_duel_info(L);
const char* pstr = lua_tostring(L, 1);
char filename[64];
sprintf(filename, "./script/%s", pstr);
lua_pushboolean(L, pduel->lua->load_script(filename));
return 1;
}
int32_t scriptlib::duel_reset_time_limit(lua_State * L) {
check_param_count(L, 1);
int32_t p = lua_tointeger(L, 1);
int32_t time = 0;
if(p != 0 && p != 1)
luaL_error(L, "Parameter 1 should be 0 or 1.", 2);
if(lua_gettop(L) >= 2)
time = lua_tointeger(L, 2);
if(time < 0 || time > 0x7fff)
luaL_error(L, "Invalid time value.", 2);
duel* pduel = interpreter::get_duel_info(L);
pduel->write_buffer8(MSG_RESET_TIME);
pduel->write_buffer8(p);
pduel->write_buffer16(time);
return 0;
}
int32_t scriptlib::duel_set_summon_cancelable(lua_State *L) {
check_param_count(L, 1);
duel* pduel = interpreter::get_duel_info(L);
pduel->game_field->core.summon_cancelable = lua_toboolean(L, 1);
return 0;
}
int32_t scriptlib::duel_get_random_number(lua_State * L) {
//check_action_permission(L); Don't check action permission
duel* pduel = interpreter::get_duel_info(L);
int32_t min = 0;
int32_t max = 2147483647;
uint32_t count = lua_gettop(L);
//Duel.GetRandomNumber() returns a number from [0,2147483647]
if(count > 1) {
//Duel.GetRandomNumber(n,m) returns a number from [n,m]
min = lua_tointeger(L, 1);
max = lua_tointeger(L, 2);
}
else if(count > 0) {
// Duel.GetRandomNumber(n) returns a number from [1,n]
min = 1;
max = lua_tointeger(L, 1);
}
lua_pushinteger(L, pduel->get_next_integer(min, max));
return 1;
}
int32_t scriptlib::duel_enable_global_flag(lua_State *L) { int32_t scriptlib::duel_enable_global_flag(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
int32_t flag = (int32_t)lua_tointeger(L, 1); int32_t flag = (int32_t)lua_tointeger(L, 1);
...@@ -4542,7 +4326,7 @@ int32_t scriptlib::duel_announce_card(lua_State * L) { ...@@ -4542,7 +4326,7 @@ int32_t scriptlib::duel_announce_card(lua_State * L) {
if(lua_gettop(L) == 1) { if(lua_gettop(L) == 1) {
pduel->game_field->core.select_options.push_back(TRUE); pduel->game_field->core.select_options.push_back(TRUE);
} else if(lua_gettop(L) == 2) { } else if(lua_gettop(L) == 2) {
pduel->game_field->core.select_options.push_back((uint32)lua_tointeger(L, 2)); pduel->game_field->core.select_options.push_back((uint32_t)lua_tointeger(L, 2));
pduel->game_field->core.select_options.push_back(OPCODE_ISTYPE); pduel->game_field->core.select_options.push_back(OPCODE_ISTYPE);
} else { } else {
for(int32_t i = 2; i <= lua_gettop(L); ++i) for(int32_t i = 2; i <= lua_gettop(L); ++i)
......
...@@ -726,32 +726,6 @@ int32_t scriptlib::group_remove(lua_State *L) { ...@@ -726,32 +726,6 @@ int32_t scriptlib::group_remove(lua_State *L) {
} }
return 0; return 0;
} }
int32_t scriptlib::group_merge(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_GROUP, 1);
check_param(L, PARAM_TYPE_GROUP, 2);
group* pgroup = *(group**) lua_touserdata(L, 1);
group* mgroup = *(group**) lua_touserdata(L, 2);
if(pgroup->is_readonly == GTYPE_READ_ONLY)
return 0;
pgroup->is_iterator_dirty = true;
pgroup->container.insert(mgroup->container.begin(), mgroup->container.end());
return 0;
}
int32_t scriptlib::group_sub(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_GROUP, 1);
check_param(L, PARAM_TYPE_GROUP, 2);
group* pgroup = *(group**) lua_touserdata(L, 1);
group* sgroup = *(group**) lua_touserdata(L, 2);
if(pgroup->is_readonly == GTYPE_READ_ONLY)
return 0;
pgroup->is_iterator_dirty = true;
for (auto& pcard : sgroup->container) {
pgroup->container.erase(pcard);
}
return 0;
}
int32_t scriptlib::group_equal(lua_State *L) { int32_t scriptlib::group_equal(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
check_param(L, PARAM_TYPE_GROUP, 1); check_param(L, PARAM_TYPE_GROUP, 1);
......
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