Commit 7be39515 authored by VanillaSalt's avatar VanillaSalt

divide

parent a3bab1dd
......@@ -408,6 +408,7 @@ static const struct luaL_Reg duellib[] = {
{ "CheckSummonedCount", scriptlib::duel_check_summon_count },
{ "GetLocationCount", scriptlib::duel_get_location_count },
{ "GetLocationCountFromEx", scriptlib::duel_get_location_count_fromex },
{ "GetUsableMZoneCount", scriptlib::duel_get_usable_mzone_count },
{ "GetLinkedZone", scriptlib::duel_get_linked_zone },
{ "GetFieldCard", scriptlib::duel_get_field_card },
{ "CheckLocation", scriptlib::duel_check_location },
......
......@@ -1494,25 +1494,8 @@ int32 scriptlib::duel_get_location_count(lua_State *L) {
if(lua_gettop(L) > 3)
reason = lua_tointeger(L, 4);
uint32 zone = 0xff;
if(location == LOCATION_MZONE) {
uint32 flag1, flag2;
int32 ct1 = pduel->game_field->get_useable_count(playerid, location, uplayer, reason, zone, &flag1);
if(pduel->game_field->core.duel_rule >= 4) {
int32 ct2 = pduel->game_field->get_useable_count_fromex(0, playerid, uplayer, zone, &flag2);
int32 ct3 = field::field_used_count[~(flag1 | flag2) & 0x1f];
lua_pushinteger(L, ct1);
lua_pushinteger(L, ct2);
lua_pushinteger(L, ct1 + ct2 - ct3);
} else {
lua_pushinteger(L, ct1);
lua_pushinteger(L, ct1);
lua_pushinteger(L, ct1);
}
return 3;
} else {
lua_pushinteger(L, pduel->game_field->get_useable_count(playerid, location, uplayer, reason));
lua_pushinteger(L, pduel->game_field->get_useable_count(playerid, location, uplayer, reason, zone));
return 1;
}
}
int32 scriptlib::duel_get_location_count_fromex(lua_State *L) {
check_param_count(L, 1);
......@@ -1524,14 +1507,35 @@ int32 scriptlib::duel_get_location_count_fromex(lua_State *L) {
if(lua_gettop(L) >= 2)
uplayer = lua_tointeger(L, 2);
uint32 zone = 0xff;
if(pduel->game_field->core.duel_rule >= 4) {
if(pduel->game_field->core.duel_rule >= 4)
lua_pushinteger(L, pduel->game_field->get_useable_count_fromex(0, playerid, uplayer, zone));
lua_pushinteger(L, pduel->game_field->get_spsummonable_count_fromex(0, playerid, uplayer, zone));
} else {
else
lua_pushinteger(L, pduel->game_field->get_useable_count(playerid, LOCATION_MZONE, uplayer, LOCATION_REASON_TOFIELD, zone));
lua_pushinteger(L, pduel->game_field->get_tofield_count(playerid, LOCATION_MZONE, uplayer, zone));
}
return 2;
return 1;
}
int32 scriptlib::duel_get_usable_mzone_count(lua_State *L) {
check_param_count(L, 2);
uint32 playerid = lua_tointeger(L, 1);
if(playerid != 0 && playerid != 1)
return 0;
duel* pduel = interpreter::get_duel_info(L);
uint32 uplayer = pduel->game_field->core.reason_player;
if(lua_gettop(L) >= 2)
uplayer = lua_tointeger(L, 2);
uint32 zone = 0xff;
if(pduel->game_field->core.duel_rule >= 4) {
uint32 flag1, flag2;
int32 ct1 = pduel->game_field->get_tofield_count(playerid, LOCATION_MZONE, uplayer, zone, &flag1);
int32 ct2 = pduel->game_field->get_spsummonable_count_fromex(0, playerid, uplayer, zone, &flag2);
int32 ct3 = field::field_used_count[~(flag1 | flag2) & 0x1f];
int32 count = ct1 + ct2 - ct3;
int32 limit = pduel->game_field->get_mzone_limit(playerid, uplayer, LOCATION_REASON_TOFIELD);
if(count > limit)
count = limit;
lua_pushinteger(L, count);
} else
lua_pushinteger(L, pduel->game_field->get_useable_count(playerid, LOCATION_MZONE, uplayer, LOCATION_REASON_TOFIELD, zone));
return 1;
}
int32 scriptlib::duel_get_linked_zone(lua_State *L) {
check_param_count(L, 1);
......
......@@ -405,6 +405,7 @@ public:
static int32 duel_check_summon_count(lua_State *L);
static int32 duel_get_location_count(lua_State *L);
static int32 duel_get_location_count_fromex(lua_State *L);
static int32 duel_get_usable_mzone_count(lua_State *L);
static int32 duel_get_linked_zone(lua_State *L);
static int32 duel_get_field_card(lua_State *L);
static int32 duel_check_location(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