Commit 6989d65c authored by mercury233's avatar mercury233

Merge branch 'master' into patch-synchro-1

parents 4862a9d8 6a650623
...@@ -498,13 +498,44 @@ int32_t field::get_pzone_sequence(uint8_t pseq) const { ...@@ -498,13 +498,44 @@ int32_t field::get_pzone_sequence(uint8_t pseq) const {
return 7; return 7;
} }
} }
const card_vector* field::get_field_vector(uint8_t playerid, uint8_t location) const {
if (!check_playerid(playerid))
return nullptr;
switch (location) {
case LOCATION_MZONE:
return &player[playerid].list_mzone;
case LOCATION_SZONE:
return &player[playerid].list_szone;
case LOCATION_DECK:
return &player[playerid].list_main;
case LOCATION_HAND:
return &player[playerid].list_hand;
case LOCATION_GRAVE:
return &player[playerid].list_grave;
case LOCATION_REMOVED:
return &player[playerid].list_remove;
case LOCATION_EXTRA:
return &player[playerid].list_extra;
default:
return nullptr;
}
}
card* field::get_field_card(uint8_t playerid, uint32_t general_location, uint8_t sequence) const { card* field::get_field_card(uint8_t playerid, uint32_t general_location, uint8_t sequence) const {
if (!check_playerid(playerid)) if (!check_playerid(playerid))
return nullptr; return nullptr;
switch(general_location) { switch(general_location) {
case LOCATION_MZONE: { case LOCATION_MZONE:
if(sequence < (int32_t)player[playerid].list_mzone.size()) case LOCATION_DECK:
return player[playerid].list_mzone[sequence]; case LOCATION_HAND:
case LOCATION_GRAVE:
case LOCATION_REMOVED:
case LOCATION_EXTRA: {
auto ptr = get_field_vector(playerid, general_location);
if (!ptr)
return nullptr;
auto& container = *ptr;
if (sequence < container.size())
return container[sequence];
else else
return nullptr; return nullptr;
break; break;
...@@ -531,41 +562,6 @@ card* field::get_field_card(uint8_t playerid, uint32_t general_location, uint8_t ...@@ -531,41 +562,6 @@ card* field::get_field_card(uint8_t playerid, uint32_t general_location, uint8_t
return nullptr; return nullptr;
break; break;
} }
case LOCATION_DECK: {
if(sequence < player[playerid].list_main.size())
return player[playerid].list_main[sequence];
else
return nullptr;
break;
}
case LOCATION_HAND: {
if(sequence < player[playerid].list_hand.size())
return player[playerid].list_hand[sequence];
else
return nullptr;
break;
}
case LOCATION_GRAVE: {
if(sequence < player[playerid].list_grave.size())
return player[playerid].list_grave[sequence];
else
return nullptr;
break;
}
case LOCATION_REMOVED: {
if(sequence < player[playerid].list_remove.size())
return player[playerid].list_remove[sequence];
else
return nullptr;
break;
}
case LOCATION_EXTRA: {
if(sequence < player[playerid].list_extra.size())
return player[playerid].list_extra[sequence];
else
return nullptr;
break;
}
} }
return nullptr; return nullptr;
} }
...@@ -2692,7 +2688,7 @@ int32_t field::check_tuner_material(lua_State* L, card* pcard, card* tuner, int3 ...@@ -2692,7 +2688,7 @@ int32_t field::check_tuner_material(lua_State* L, card* pcard, card* tuner, int3
++location_count; ++location_count;
} }
if(min == 0) { if(min == 0) {
if(location_count > 0 && check_with_sum_limit_m(nsyn, lv, 0, 0, 0, 0xffff, 2)) { if(location_count > 0 && must_list.size() == 0 && check_with_sum_limit_m(nsyn, lv, 0, 0, 0, 0xffff, 2)) {
pduel->restore_assumes(); pduel->restore_assumes();
return TRUE; return TRUE;
} }
...@@ -2704,6 +2700,12 @@ int32_t field::check_tuner_material(lua_State* L, card* pcard, card* tuner, int3 ...@@ -2704,6 +2700,12 @@ int32_t field::check_tuner_material(lua_State* L, card* pcard, card* tuner, int3
} }
if(must_list.size()) { if(must_list.size()) {
for(auto& mcard : must_list) { for(auto& mcard : must_list) {
if(mg) {
if(!mg->has_card(mcard)) {
pduel->restore_assumes();
return FALSE;
}
}
if(pcheck) if(pcheck)
pcheck->get_value(mcard); pcheck->get_value(mcard);
if((mcard->current.location == LOCATION_MZONE && !mcard->is_position(POS_FACEUP)) || !mcard->is_can_be_synchro_material(pcard, tuner)) { if((mcard->current.location == LOCATION_MZONE && !mcard->is_position(POS_FACEUP)) || !mcard->is_can_be_synchro_material(pcard, tuner)) {
......
...@@ -383,6 +383,7 @@ public: ...@@ -383,6 +383,7 @@ public:
void set_control(card* pcard, uint8_t playerid, uint16_t reset_phase, uint8_t reset_count); void set_control(card* pcard, uint8_t playerid, uint16_t reset_phase, uint8_t reset_count);
int32_t get_pzone_sequence(uint8_t pseq) const; int32_t get_pzone_sequence(uint8_t pseq) const;
const card_vector* get_field_vector(uint8_t playerid, uint8_t location) const;
card* get_field_card(uint8_t playerid, uint32_t general_location, uint8_t sequence) const; card* get_field_card(uint8_t playerid, uint32_t general_location, uint8_t sequence) const;
int32_t is_location_useable(uint8_t playerid, uint32_t general_location, uint8_t sequence) const; int32_t is_location_useable(uint8_t playerid, uint32_t general_location, uint8_t sequence) const;
int32_t get_useable_count(card* pcard, uint8_t playerid, uint8_t location, uint8_t uplayer, uint32_t reason, uint32_t zone = 0xff, uint32_t* list = nullptr); int32_t get_useable_count(card* pcard, uint8_t playerid, uint8_t location, uint8_t uplayer, uint32_t reason, uint32_t zone = 0xff, uint32_t* list = nullptr);
......
...@@ -204,7 +204,7 @@ OCGCORE_API void new_tag_card(intptr_t pduel, uint32_t code, uint8_t owner, uint ...@@ -204,7 +204,7 @@ OCGCORE_API void new_tag_card(intptr_t pduel, uint32_t code, uint8_t owner, uint
* @param buf int32_t array * @param buf int32_t array
* @return buffer length in bytes * @return buffer length in bytes
*/ */
OCGCORE_API int32_t query_card(intptr_t pduel, uint8_t playerid, uint8_t location, uint8_t sequence, int32_t query_flag, byte* buf, int32_t use_cache) { OCGCORE_API int32_t query_card(intptr_t pduel, uint8_t playerid, uint8_t location, uint8_t sequence, uint32_t query_flag, byte* buf, int32_t use_cache) {
if (!check_playerid(playerid)) if (!check_playerid(playerid))
return LEN_FAIL; return LEN_FAIL;
duel* ptduel = (duel*)pduel; duel* ptduel = (duel*)pduel;
...@@ -213,22 +213,13 @@ OCGCORE_API int32_t query_card(intptr_t pduel, uint8_t playerid, uint8_t locatio ...@@ -213,22 +213,13 @@ OCGCORE_API int32_t query_card(intptr_t pduel, uint8_t playerid, uint8_t locatio
if (location == LOCATION_MZONE || location == LOCATION_SZONE) if (location == LOCATION_MZONE || location == LOCATION_SZONE)
pcard = ptduel->game_field->get_field_card(playerid, location, sequence); pcard = ptduel->game_field->get_field_card(playerid, location, sequence);
else { else {
card_vector* lst = nullptr; auto ptr = ptduel->game_field->get_field_vector(playerid, location);
if (location == LOCATION_HAND) if(!ptr)
lst = &ptduel->game_field->player[playerid].list_hand;
else if (location == LOCATION_GRAVE)
lst = &ptduel->game_field->player[playerid].list_grave;
else if (location == LOCATION_REMOVED)
lst = &ptduel->game_field->player[playerid].list_remove;
else if (location == LOCATION_EXTRA)
lst = &ptduel->game_field->player[playerid].list_extra;
else if (location == LOCATION_DECK)
lst = &ptduel->game_field->player[playerid].list_main;
else
return LEN_FAIL; return LEN_FAIL;
if (sequence >= (int32_t)lst->size()) auto& lst = *ptr;
if (sequence >= lst.size())
return LEN_FAIL; return LEN_FAIL;
pcard = (*lst)[sequence]; pcard = lst[sequence];
} }
if (pcard) { if (pcard) {
return pcard->get_infos(buf, query_flag, use_cache); return pcard->get_infos(buf, query_flag, use_cache);
......
...@@ -53,7 +53,7 @@ OCGCORE_API int32_t get_message(intptr_t pduel, byte* buf); ...@@ -53,7 +53,7 @@ OCGCORE_API int32_t get_message(intptr_t pduel, byte* buf);
OCGCORE_API uint32_t process(intptr_t pduel); OCGCORE_API uint32_t process(intptr_t pduel);
OCGCORE_API void new_card(intptr_t pduel, uint32_t code, uint8_t owner, uint8_t playerid, uint8_t location, uint8_t sequence, uint8_t position); OCGCORE_API void new_card(intptr_t pduel, uint32_t code, uint8_t owner, uint8_t playerid, uint8_t location, uint8_t sequence, uint8_t position);
OCGCORE_API void new_tag_card(intptr_t pduel, uint32_t code, uint8_t owner, uint8_t location); OCGCORE_API void new_tag_card(intptr_t pduel, uint32_t code, uint8_t owner, uint8_t location);
OCGCORE_API int32_t query_card(intptr_t pduel, uint8_t playerid, uint8_t location, uint8_t sequence, int32_t query_flag, byte* buf, int32_t use_cache); OCGCORE_API int32_t query_card(intptr_t pduel, uint8_t playerid, uint8_t location, uint8_t sequence, uint32_t query_flag, byte* buf, int32_t use_cache);
OCGCORE_API int32_t query_field_count(intptr_t pduel, uint8_t playerid, uint8_t location); OCGCORE_API int32_t query_field_count(intptr_t pduel, uint8_t playerid, uint8_t location);
OCGCORE_API int32_t query_field_card(intptr_t pduel, uint8_t playerid, uint8_t location, uint32_t query_flag, byte* buf, int32_t use_cache); OCGCORE_API int32_t query_field_card(intptr_t pduel, uint8_t playerid, uint8_t location, uint32_t query_flag, byte* buf, int32_t use_cache);
OCGCORE_API int32_t query_field_info(intptr_t pduel, byte* buf); OCGCORE_API int32_t query_field_info(intptr_t pduel, byte* buf);
......
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