Commit c32963b2 authored by Edoardo Lolletti's avatar Edoardo Lolletti Committed by mercury233

Merge MSG_ANNOUNCE_CARD with MSG_ANNOUNCE_CARD_FILTER (#216)

parent 9e1dc567
......@@ -315,7 +315,6 @@ struct card_sort {
#define MSG_ANNOUNCE_ATTRIB 141
#define MSG_ANNOUNCE_CARD 142
#define MSG_ANNOUNCE_NUMBER 143
#define MSG_ANNOUNCE_CARD_FILTER 144
#define MSG_CARD_HINT 160
#define MSG_TAG_SWAP 161
#define MSG_RELOAD_FIELD 162 // Debug.ReloadFieldEnd()
......
......@@ -607,7 +607,7 @@ public:
int32 sort_card(int16 step, uint8 playerid, uint8 is_chain);
int32 announce_race(int16 step, uint8 playerid, int32 count, int32 available);
int32 announce_attribute(int16 step, uint8 playerid, int32 count, int32 available);
int32 announce_card(int16 step, uint8 playerid, uint32 ttype);
int32 announce_card(int16 step, uint8 playerid);
int32 announce_number(int16 step, uint8 playerid);
};
......
......@@ -537,7 +537,6 @@ static const struct luaL_Reg duellib[] = {
{ "AnnounceAttribute", scriptlib::duel_announce_attribute },
{ "AnnounceLevel", scriptlib::duel_announce_level },
{ "AnnounceCard", scriptlib::duel_announce_card },
{ "AnnounceCardFilter", scriptlib::duel_announce_card_filter },
{ "AnnounceType", scriptlib::duel_announce_type },
{ "AnnounceNumber", scriptlib::duel_announce_number },
{ "AnnounceCoin", scriptlib::duel_announce_coin },
......
......@@ -3555,24 +3555,15 @@ int32 scriptlib::duel_announce_card(lua_State * L) {
int32 playerid = lua_tointeger(L, 1);
duel* pduel = interpreter::get_duel_info(L);
pduel->game_field->core.select_options.clear();
uint32 ttype = TYPE_MONSTER | TYPE_SPELL | TYPE_TRAP;
if(lua_gettop(L) >= 2)
ttype = lua_tointeger(L, 2);
pduel->game_field->add_process(PROCESSOR_ANNOUNCE_CARD, 0, 0, 0, playerid, ttype);
return lua_yieldk(L, 0, (lua_KContext)pduel, [](lua_State *L, int32 status, lua_KContext ctx) {
duel* pduel = (duel*)ctx;
lua_pushinteger(L, pduel->game_field->returns.ivalue[0]);
return 1;
});
}
int32 scriptlib::duel_announce_card_filter(lua_State * L) {
check_action_permission(L);
check_param_count(L, 2);
int32 playerid = lua_tointeger(L, 1);
duel* pduel = interpreter::get_duel_info(L);
pduel->game_field->core.select_options.clear();
for(int32 i = 2; i <= lua_gettop(L); ++i)
pduel->game_field->core.select_options.push_back(lua_tointeger(L, i));
if(lua_gettop(L) == 1) {
pduel->game_field->core.select_options.push_back(TRUE);
} else if(lua_gettop(L) == 2) {
pduel->game_field->core.select_options.push_back(lua_tointeger(L, 2));
pduel->game_field->core.select_options.push_back(OPCODE_ISTYPE);
} else {
for(int32 i = 2; i <= lua_gettop(L); ++i)
pduel->game_field->core.select_options.push_back(lua_tointeger(L, i));
}
pduel->game_field->add_process(PROCESSOR_ANNOUNCE_CARD, 0, 0, 0, playerid, 0);
return lua_yieldk(L, 0, (lua_KContext)pduel, [](lua_State *L, int32 status, lua_KContext ctx) {
duel* pduel = (duel*)ctx;
......
......@@ -965,19 +965,13 @@ static int32 is_declarable(card_data const& cd, const std::vector<uint32>& opcod
return cd.code == CARD_MARINE_DOLPHIN || cd.code == CARD_TWINKLE_MOSS
|| (!cd.alias && (cd.type & (TYPE_MONSTER + TYPE_TOKEN)) != (TYPE_MONSTER + TYPE_TOKEN));
}
int32 field::announce_card(int16 step, uint8 playerid, uint32 ttype) {
int32 field::announce_card(int16 step, uint8 playerid) {
if(step == 0) {
if(core.select_options.size() == 0) {
pduel->write_buffer8(MSG_ANNOUNCE_CARD);
pduel->write_buffer8(playerid);
pduel->write_buffer32(ttype);
} else {
pduel->write_buffer8(MSG_ANNOUNCE_CARD_FILTER);
pduel->write_buffer8(playerid);
pduel->write_buffer8(core.select_options.size());
for(auto& option : core.select_options)
pduel->write_buffer32(option);
}
pduel->write_buffer8(MSG_ANNOUNCE_CARD);
pduel->write_buffer8(playerid);
pduel->write_buffer8(core.select_options.size());
for(auto& option : core.select_options)
pduel->write_buffer32(option);
return FALSE;
} else {
int32 code = returns.ivalue[0];
......@@ -986,12 +980,6 @@ int32 field::announce_card(int16 step, uint8 playerid, uint32 ttype) {
if(!data.code) {
pduel->write_buffer8(MSG_RETRY);
return FALSE;
}
if(core.select_options.size() == 0) {
if(!(data.type & ttype)) {
pduel->write_buffer8(MSG_RETRY);
return FALSE;
}
} else {
if(!is_declarable(data, core.select_options)) {
pduel->write_buffer8(MSG_RETRY);
......
......@@ -543,7 +543,7 @@ int32 field::process() {
return PROCESSOR_WAITING + pduel->bufferlen;
}
case PROCESSOR_ANNOUNCE_CARD: {
if(announce_card(it->step, it->arg1, it->arg2)) {
if(announce_card(it->step, it->arg1)) {
core.units.pop_front();
} else {
it->step++;
......
......@@ -532,7 +532,6 @@ public:
static int32 duel_announce_attribute(lua_State *L);
static int32 duel_announce_level(lua_State *L);
static int32 duel_announce_card(lua_State *L);
static int32 duel_announce_card_filter(lua_State *L);
static int32 duel_announce_type(lua_State *L);
static int32 duel_announce_number(lua_State *L);
static int32 duel_announce_coin(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