Commit f7febc12 authored by Momobako's avatar Momobako

update_core

parent cc5e6d8d
...@@ -215,10 +215,13 @@ void field::add_card(uint8 playerid, card* pcard, uint8 location, uint8 sequence ...@@ -215,10 +215,13 @@ void field::add_card(uint8 playerid, card* pcard, uint8 location, uint8 sequence
break; break;
} }
case LOCATION_EXTRA: { case LOCATION_EXTRA: {
player[playerid].list_extra.push_back(pcard); if(player[playerid].extra_p_count == 0 || (pcard->data.type & TYPE_PENDULUM) && (pcard->sendto_param.position & POS_FACEUP))
pcard->current.sequence = player[playerid].list_extra.size() - 1; player[playerid].list_extra.push_back(pcard);
else
player[playerid].list_extra.insert(player[playerid].list_extra.end() - player[playerid].extra_p_count, pcard);
if((pcard->data.type & TYPE_PENDULUM) && (pcard->sendto_param.position & POS_FACEUP)) if((pcard->data.type & TYPE_PENDULUM) && (pcard->sendto_param.position & POS_FACEUP))
++player[playerid].extra_p_count; ++player[playerid].extra_p_count;
reset_sequence(playerid, LOCATION_EXTRA);
break; break;
} }
} }
...@@ -825,9 +828,9 @@ void field::get_cards_in_zone(card_set* cset, uint32 zone, int32 playerid, int32 ...@@ -825,9 +828,9 @@ void field::get_cards_in_zone(card_set* cset, uint32 zone, int32 playerid, int32
} }
} }
void field::shuffle(uint8 playerid, uint8 location) { void field::shuffle(uint8 playerid, uint8 location) {
if(!(location & (LOCATION_HAND | LOCATION_DECK))) if(!(location & (LOCATION_HAND | LOCATION_DECK | LOCATION_EXTRA)))
return; return;
card_vector& svector = (location == LOCATION_HAND) ? player[playerid].list_hand : player[playerid].list_main; card_vector& svector = (location == LOCATION_HAND) ? player[playerid].list_hand : (location == LOCATION_DECK) ? player[playerid].list_main : player[playerid].list_extra;
if(svector.size() == 0) if(svector.size() == 0)
return; return;
if(location == LOCATION_HAND) { if(location == LOCATION_HAND) {
...@@ -841,8 +844,11 @@ void field::shuffle(uint8 playerid, uint8 location) { ...@@ -841,8 +844,11 @@ void field::shuffle(uint8 playerid, uint8 location) {
} }
} }
if(location == LOCATION_HAND || !(core.duel_options & DUEL_PSEUDO_SHUFFLE)) { if(location == LOCATION_HAND || !(core.duel_options & DUEL_PSEUDO_SHUFFLE)) {
if(svector.size() > 1) { uint32 s = svector.size();
uint32 i = 0, s = svector.size(), r; if(location == LOCATION_EXTRA)
s = s - player[playerid].extra_p_count;
if(s > 1) {
uint32 i = 0, r;
for(i = 0; i < s - 1; ++i) { for(i = 0; i < s - 1; ++i) {
r = pduel->get_next_integer(i, s - 1); r = pduel->get_next_integer(i, s - 1);
card* t = svector[i]; card* t = svector[i];
...@@ -852,13 +858,14 @@ void field::shuffle(uint8 playerid, uint8 location) { ...@@ -852,13 +858,14 @@ void field::shuffle(uint8 playerid, uint8 location) {
reset_sequence(playerid, location); reset_sequence(playerid, location);
} }
} }
if(location == LOCATION_HAND) { if(location == LOCATION_HAND || location == LOCATION_EXTRA) {
pduel->write_buffer8(MSG_SHUFFLE_HAND); pduel->write_buffer8((location == LOCATION_HAND) ? MSG_SHUFFLE_HAND : MSG_SHUFFLE_EXTRA);
pduel->write_buffer8(playerid); pduel->write_buffer8(playerid);
pduel->write_buffer8(player[playerid].list_hand.size()); pduel->write_buffer8(svector.size());
for(auto cit = svector.begin(); cit != svector.end(); ++cit) for(auto cit = svector.begin(); cit != svector.end(); ++cit)
pduel->write_buffer32((*cit)->data.code); pduel->write_buffer32((*cit)->data.code);
core.shuffle_hand_check[playerid] = FALSE; if(location == LOCATION_HAND)
core.shuffle_hand_check[playerid] = FALSE;
} else { } else {
pduel->write_buffer8(MSG_SHUFFLE_DECK); pduel->write_buffer8(MSG_SHUFFLE_DECK);
pduel->write_buffer8(playerid); pduel->write_buffer8(playerid);
......
...@@ -839,8 +839,10 @@ public: ...@@ -839,8 +839,10 @@ public:
#define MSG_SHUFFLE_SET_CARD 36 #define MSG_SHUFFLE_SET_CARD 36
#define MSG_REVERSE_DECK 37 #define MSG_REVERSE_DECK 37
#define MSG_DECK_TOP 38 #define MSG_DECK_TOP 38
#define MSG_SHUFFLE_EXTRA 39
#define MSG_NEW_TURN 40 #define MSG_NEW_TURN 40
#define MSG_NEW_PHASE 41 #define MSG_NEW_PHASE 41
#define MSG_CONFIRM_EXTRATOP 42
#define MSG_MOVE 50 #define MSG_MOVE 50
#define MSG_POS_CHANGE 53 #define MSG_POS_CHANGE 53
#define MSG_SET 54 #define MSG_SET 54
......
...@@ -399,6 +399,7 @@ static const struct luaL_Reg duellib[] = { ...@@ -399,6 +399,7 @@ static const struct luaL_Reg duellib[] = {
{ "SetChainLimitTillChainEnd", scriptlib::duel_set_chain_limit_p }, { "SetChainLimitTillChainEnd", scriptlib::duel_set_chain_limit_p },
{ "GetChainMaterial", scriptlib::duel_get_chain_material }, { "GetChainMaterial", scriptlib::duel_get_chain_material },
{ "ConfirmDecktop", scriptlib::duel_confirm_decktop }, { "ConfirmDecktop", scriptlib::duel_confirm_decktop },
{ "ConfirmExtratop", scriptlib::duel_confirm_extratop },
{ "ConfirmCards", scriptlib::duel_confirm_cards }, { "ConfirmCards", scriptlib::duel_confirm_cards },
{ "SortDecktop", scriptlib::duel_sort_decktop }, { "SortDecktop", scriptlib::duel_sort_decktop },
{ "CheckEvent", scriptlib::duel_check_event }, { "CheckEvent", scriptlib::duel_check_event },
...@@ -422,6 +423,7 @@ static const struct luaL_Reg duellib[] = { ...@@ -422,6 +423,7 @@ static const struct luaL_Reg duellib[] = {
{ "DiscardHand", scriptlib::duel_discard_hand }, { "DiscardHand", scriptlib::duel_discard_hand },
{ "DisableShuffleCheck", scriptlib::duel_disable_shuffle_check }, { "DisableShuffleCheck", scriptlib::duel_disable_shuffle_check },
{ "ShuffleDeck", scriptlib::duel_shuffle_deck }, { "ShuffleDeck", scriptlib::duel_shuffle_deck },
{ "ShuffleExtra", scriptlib::duel_shuffle_extra },
{ "ShuffleHand", scriptlib::duel_shuffle_hand }, { "ShuffleHand", scriptlib::duel_shuffle_hand },
{ "ShuffleSetCard", scriptlib::duel_shuffle_setcard }, { "ShuffleSetCard", scriptlib::duel_shuffle_setcard },
{ "ChangeAttacker", scriptlib::duel_change_attacker }, { "ChangeAttacker", scriptlib::duel_change_attacker },
...@@ -465,6 +467,7 @@ static const struct luaL_Reg duellib[] = { ...@@ -465,6 +467,7 @@ static const struct luaL_Reg duellib[] = {
{ "GetFieldGroup", scriptlib::duel_get_field_group }, { "GetFieldGroup", scriptlib::duel_get_field_group },
{ "GetFieldGroupCount", scriptlib::duel_get_field_group_count }, { "GetFieldGroupCount", scriptlib::duel_get_field_group_count },
{ "GetDecktopGroup", scriptlib::duel_get_decktop_group }, { "GetDecktopGroup", scriptlib::duel_get_decktop_group },
{ "GetExtraTopGroup", scriptlib::duel_get_extratop_group },
{ "GetMatchingGroup", scriptlib::duel_get_matching_group }, { "GetMatchingGroup", scriptlib::duel_get_matching_group },
{ "GetMatchingGroupCount", scriptlib::duel_get_matching_count }, { "GetMatchingGroupCount", scriptlib::duel_get_matching_count },
{ "GetFirstMatchingCard", scriptlib::duel_get_first_matching_card }, { "GetFirstMatchingCard", scriptlib::duel_get_first_matching_card },
......
...@@ -805,6 +805,28 @@ int32 scriptlib::duel_confirm_decktop(lua_State *L) { ...@@ -805,6 +805,28 @@ int32 scriptlib::duel_confirm_decktop(lua_State *L) {
pduel->game_field->add_process(PROCESSOR_WAIT, 0, 0, 0, 0, 0); pduel->game_field->add_process(PROCESSOR_WAIT, 0, 0, 0, 0, 0);
return lua_yield(L, 0); return lua_yield(L, 0);
} }
int32 scriptlib::duel_confirm_extratop(lua_State *L) {
check_param_count(L, 2);
int32 playerid = lua_tonumberint(L, 1);
if(playerid != 0 && playerid != 1)
return 0;
uint32 count = lua_tonumberint(L, 2);
duel* pduel = interpreter::get_duel_info(L);
if(count >= pduel->game_field->player[playerid].list_extra.size() - pduel->game_field->player[playerid].extra_p_count)
count = pduel->game_field->player[playerid].list_extra.size() - pduel->game_field->player[playerid].extra_p_count;
auto cit = pduel->game_field->player[playerid].list_extra.rbegin() + pduel->game_field->player[playerid].extra_p_count;
pduel->write_buffer8(MSG_CONFIRM_EXTRATOP);
pduel->write_buffer8(playerid);
pduel->write_buffer8(count);
for(uint32 i = 0; i < count && cit != pduel->game_field->player[playerid].list_extra.rend(); ++i, ++cit) {
pduel->write_buffer32((*cit)->data.code);
pduel->write_buffer8((*cit)->current.controler);
pduel->write_buffer8((*cit)->current.location);
pduel->write_buffer8((*cit)->current.sequence);
}
pduel->game_field->add_process(PROCESSOR_WAIT, 0, 0, 0, 0, 0);
return lua_yield(L, 0);
}
int32 scriptlib::duel_confirm_cards(lua_State *L) { int32 scriptlib::duel_confirm_cards(lua_State *L) {
check_param_count(L, 2); check_param_count(L, 2);
int32 playerid = lua_tonumberint(L, 1); int32 playerid = lua_tonumberint(L, 1);
...@@ -1287,6 +1309,15 @@ int32 scriptlib::duel_shuffle_deck(lua_State *L) { ...@@ -1287,6 +1309,15 @@ int32 scriptlib::duel_shuffle_deck(lua_State *L) {
pduel->game_field->shuffle(playerid, LOCATION_DECK); pduel->game_field->shuffle(playerid, LOCATION_DECK);
return 0; return 0;
} }
int32 scriptlib::duel_shuffle_extra(lua_State *L) {
check_param_count(L, 1);
uint32 playerid = lua_tonumberint(L, 1);
if (playerid != 0 && playerid != 1)
return 0;
duel* pduel = interpreter::get_duel_info(L);
pduel->game_field->shuffle(playerid, LOCATION_EXTRA);
return 0;
}
int32 scriptlib::duel_shuffle_hand(lua_State *L) { int32 scriptlib::duel_shuffle_hand(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
uint32 playerid = lua_tonumberint(L, 1); uint32 playerid = lua_tonumberint(L, 1);
...@@ -2033,6 +2064,23 @@ int32 scriptlib::duel_get_decktop_group(lua_State *L) { ...@@ -2033,6 +2064,23 @@ int32 scriptlib::duel_get_decktop_group(lua_State *L) {
interpreter::group2value(L, pgroup); interpreter::group2value(L, pgroup);
return 1; return 1;
} }
/**
* \brief Duel.GetExtraTopGroup
* \param playerid, count
* \return Group
*/
int32 scriptlib::duel_get_extratop_group(lua_State *L) {
check_param_count(L, 2);
uint32 playerid = lua_tonumberint(L, 1);
uint32 count = lua_tonumberint(L, 2);
duel* pduel = interpreter::get_duel_info(L);
group* pgroup = pduel->new_group();
auto cit = pduel->game_field->player[playerid].list_extra.rbegin() + pduel->game_field->player[playerid].extra_p_count;
for(uint32 i = 0; i < count && cit != pduel->game_field->player[playerid].list_extra.rend(); ++i, ++cit)
pgroup->container.insert(*cit);
interpreter::group2value(L, pgroup);
return 1;
}
/** /**
* \brief Duel.GetMatchingGroup * \brief Duel.GetMatchingGroup
* \param filter_func, self, location1, location2, exception card, (extraargs...) * \param filter_func, self, location1, location2, exception card, (extraargs...)
......
...@@ -395,6 +395,7 @@ public: ...@@ -395,6 +395,7 @@ public:
static int32 duel_set_chain_limit_p(lua_State *L); static int32 duel_set_chain_limit_p(lua_State *L);
static int32 duel_get_chain_material(lua_State *L); static int32 duel_get_chain_material(lua_State *L);
static int32 duel_confirm_decktop(lua_State *L); static int32 duel_confirm_decktop(lua_State *L);
static int32 duel_confirm_extratop(lua_State *L);
static int32 duel_confirm_cards(lua_State *L); static int32 duel_confirm_cards(lua_State *L);
static int32 duel_sort_decktop(lua_State *L); static int32 duel_sort_decktop(lua_State *L);
static int32 duel_check_event(lua_State *L); static int32 duel_check_event(lua_State *L);
...@@ -419,6 +420,7 @@ public: ...@@ -419,6 +420,7 @@ public:
static int32 duel_discard_hand(lua_State *L); static int32 duel_discard_hand(lua_State *L);
static int32 duel_disable_shuffle_check(lua_State *L); static int32 duel_disable_shuffle_check(lua_State *L);
static int32 duel_shuffle_deck(lua_State *L); static int32 duel_shuffle_deck(lua_State *L);
static int32 duel_shuffle_extra(lua_State *L);
static int32 duel_shuffle_hand(lua_State *L); static int32 duel_shuffle_hand(lua_State *L);
static int32 duel_shuffle_setcard(lua_State *L); static int32 duel_shuffle_setcard(lua_State *L);
static int32 duel_change_attacker(lua_State *L); static int32 duel_change_attacker(lua_State *L);
...@@ -463,6 +465,7 @@ public: ...@@ -463,6 +465,7 @@ public:
static int32 duel_get_field_group(lua_State *L); static int32 duel_get_field_group(lua_State *L);
static int32 duel_get_field_group_count(lua_State *L); static int32 duel_get_field_group_count(lua_State *L);
static int32 duel_get_decktop_group(lua_State *L); static int32 duel_get_decktop_group(lua_State *L);
static int32 duel_get_extratop_group(lua_State *L);
static int32 duel_get_matching_group(lua_State *L); static int32 duel_get_matching_group(lua_State *L);
static int32 duel_get_matching_count(lua_State *L); static int32 duel_get_matching_count(lua_State *L);
static int32 duel_get_first_matching_card(lua_State *L); static int32 duel_get_first_matching_card(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