Commit c5909e9e authored by mercury233's avatar mercury233

update ocgcore

parent 7958581b
...@@ -757,6 +757,14 @@ int32 scriptlib::card_get_previous_controler(lua_State *L) { ...@@ -757,6 +757,14 @@ int32 scriptlib::card_get_previous_controler(lua_State *L) {
lua_pushinteger(L, pcard->previous.controler); lua_pushinteger(L, pcard->previous.controler);
return 1; return 1;
} }
int32 scriptlib::card_set_reason(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**)lua_touserdata(L, 1);
uint32 reason = (uint32)lua_tointeger(L, 2);
pcard->current.reason = reason;
return 0;
}
int32 scriptlib::card_get_reason(lua_State *L) { int32 scriptlib::card_get_reason(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);
...@@ -1724,22 +1732,18 @@ int32 scriptlib::card_is_has_effect(lua_State *L) { ...@@ -1724,22 +1732,18 @@ int32 scriptlib::card_is_has_effect(lua_State *L) {
} }
effect_set eset; effect_set eset;
pcard->filter_effect(code, &eset); pcard->filter_effect(code, &eset);
int32 size = eset.size();
if(!size) {
lua_pushnil(L);
return 1;
}
int32 check_player = PLAYER_NONE; int32 check_player = PLAYER_NONE;
if(lua_gettop(L) >= 3) { if(lua_gettop(L) >= 3) {
check_player = (int32)lua_tointeger(L, 3); check_player = (int32)lua_tointeger(L, 3);
if(check_player > PLAYER_NONE) if(check_player > PLAYER_NONE)
check_player = PLAYER_NONE; check_player = PLAYER_NONE;
} }
int32 size = 0;
for(int32 i = 0; i < eset.size(); ++i) { for(int32 i = 0; i < eset.size(); ++i) {
if(check_player == PLAYER_NONE || eset[i]->check_count_limit(check_player)) if(check_player == PLAYER_NONE || eset[i]->check_count_limit(check_player)) {
interpreter::effect2value(L, eset[i]); interpreter::effect2value(L, eset[i]);
else size++;
size--; }
} }
if(!size) { if(!size) {
lua_pushnil(L); lua_pushnil(L);
...@@ -3292,6 +3296,7 @@ static const struct luaL_Reg cardlib[] = { ...@@ -3292,6 +3296,7 @@ static const struct luaL_Reg cardlib[] = {
{ "GetOwner", scriptlib::card_get_owner }, { "GetOwner", scriptlib::card_get_owner },
{ "GetControler", scriptlib::card_get_controler }, { "GetControler", scriptlib::card_get_controler },
{ "GetPreviousControler", scriptlib::card_get_previous_controler }, { "GetPreviousControler", scriptlib::card_get_previous_controler },
{ "SetReason", scriptlib::card_set_reason },
{ "GetReason", scriptlib::card_get_reason }, { "GetReason", scriptlib::card_get_reason },
{ "GetReasonCard", scriptlib::card_get_reason_card }, { "GetReasonCard", scriptlib::card_get_reason_card },
{ "GetReasonPlayer", scriptlib::card_get_reason_player }, { "GetReasonPlayer", scriptlib::card_get_reason_player },
......
...@@ -3951,13 +3951,17 @@ int32 scriptlib::duel_is_player_affected_by_effect(lua_State *L) { ...@@ -3951,13 +3951,17 @@ int32 scriptlib::duel_is_player_affected_by_effect(lua_State *L) {
int32 code = (int32)lua_tointeger(L, 2); int32 code = (int32)lua_tointeger(L, 2);
effect_set eset; effect_set eset;
pduel->game_field->filter_player_effect(playerid, code, &eset); pduel->game_field->filter_player_effect(playerid, code, &eset);
int32 size = eset.size(); int32 size = 0;
for(int32 i = 0; i < eset.size(); ++i) {
if(eset[i]->check_count_limit(playerid)) {
interpreter::effect2value(L, eset[i]);
size++;
}
}
if(!size) { if(!size) {
lua_pushnil(L); lua_pushnil(L);
return 1; return 1;
} }
for(int32 i = 0; i < size; ++i)
interpreter::effect2value(L, eset[i]);
return size; return size;
} }
int32 scriptlib::duel_is_player_can_draw(lua_State * L) { int32 scriptlib::duel_is_player_can_draw(lua_State * L) {
......
...@@ -432,16 +432,23 @@ int32 field::select_place(uint16 step, uint8 playerid, uint32 flag, uint8 count) ...@@ -432,16 +432,23 @@ int32 field::select_place(uint16 step, uint8 playerid, uint32 flag, uint8 count)
return FALSE; return FALSE;
} else { } else {
uint8 pt = 0; uint8 pt = 0;
uint32 selected = 0;
for(int8 i = 0; i < count; ++i) { for(int8 i = 0; i < count; ++i) {
uint8 p = returns.bvalue[pt]; uint8 p = returns.bvalue[pt];
uint8 l = returns.bvalue[pt + 1]; uint8 l = returns.bvalue[pt + 1];
uint8 s = returns.bvalue[pt + 2]; uint8 s = returns.bvalue[pt + 2];
uint32 sel = 0x1u << (s + (p == playerid ? 0 : 16) + (l == LOCATION_MZONE ? 0 : 8));
if((p != 0 && p != 1) if((p != 0 && p != 1)
|| ((l != LOCATION_MZONE) && (l != LOCATION_SZONE)) || ((l != LOCATION_MZONE) && (l != LOCATION_SZONE))
|| ((0x1u << s) & (flag >> (((p == playerid) ? 0 : 16) + ((l == LOCATION_MZONE) ? 0 : 8))))) { || (sel & flag) || (sel & selected)) {
pduel->write_buffer8(MSG_RETRY); pduel->write_buffer8(MSG_RETRY);
return FALSE; return FALSE;
} }
if(sel & (0x1 << 5))
sel |= 0x1 << (16 + 6);
if(sel & (0x1 << 6))
sel |= 0x1 << (16 + 5);
selected |= sel;
pt += 3; pt += 3;
} }
return TRUE; return TRUE;
......
...@@ -88,6 +88,7 @@ public: ...@@ -88,6 +88,7 @@ public:
static int32 card_get_owner(lua_State *L); static int32 card_get_owner(lua_State *L);
static int32 card_get_controler(lua_State *L); static int32 card_get_controler(lua_State *L);
static int32 card_get_previous_controler(lua_State *L); static int32 card_get_previous_controler(lua_State *L);
static int32 card_set_reason(lua_State *L);
static int32 card_get_reason(lua_State *L); static int32 card_get_reason(lua_State *L);
static int32 card_get_reason_card(lua_State *L); static int32 card_get_reason_card(lua_State *L);
static int32 card_get_reason_player(lua_State *L); static int32 card_get_reason_player(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