Commit 1ebf1261 authored by VanillaSalt's avatar VanillaSalt

fix

parent e6125867
...@@ -1266,8 +1266,8 @@ int32 card::destination_redirect(uint8 destination, uint32 reason) { ...@@ -1266,8 +1266,8 @@ int32 card::destination_redirect(uint8 destination, uint32 reason) {
} }
return 0; return 0;
} }
int32 card::add_counter(uint16 countertype, uint16 count) { int32 card::add_counter(uint8 playerid, uint16 countertype, uint16 count) {
if(!is_can_add_counter(countertype, count)) if(!is_can_add_counter(playerid, countertype, count))
return FALSE; return FALSE;
counters[countertype] += count; counters[countertype] += count;
pduel->write_buffer8(MSG_ADD_COUNTER); pduel->write_buffer8(MSG_ADD_COUNTER);
...@@ -1293,8 +1293,10 @@ int32 card::remove_counter(uint16 countertype, uint16 count) { ...@@ -1293,8 +1293,10 @@ int32 card::remove_counter(uint16 countertype, uint16 count) {
pduel->write_buffer8(count); pduel->write_buffer8(count);
return TRUE; return TRUE;
} }
int32 card::is_can_add_counter(uint16 countertype, uint16 count) { int32 card::is_can_add_counter(uint8 playerid, uint16 countertype, uint16 count) {
effect_set eset; effect_set eset;
if(!pduel->game_field->is_player_can_place_counter(playerid, this, countertype, count))
return FALSE;
if(!(current.location & LOCATION_ONFIELD) || !is_position(POS_FACEUP)) if(!(current.location & LOCATION_ONFIELD) || !is_position(POS_FACEUP))
return FALSE; return FALSE;
if((countertype & COUNTER_NEED_ENABLE) && is_status(STATUS_DISABLED)) if((countertype & COUNTER_NEED_ENABLE) && is_status(STATUS_DISABLED))
......
...@@ -186,9 +186,9 @@ public: ...@@ -186,9 +186,9 @@ public:
void release_relation(effect* peffect); void release_relation(effect* peffect);
int32 leave_field_redirect(uint32 reason); int32 leave_field_redirect(uint32 reason);
int32 destination_redirect(uint8 destination, uint32 reason); int32 destination_redirect(uint8 destination, uint32 reason);
int32 add_counter(uint16 countertype, uint16 count); int32 add_counter(uint8 playerid, uint16 countertype, uint16 count);
int32 remove_counter(uint16 countertype, uint16 count); int32 remove_counter(uint16 countertype, uint16 count);
int32 is_can_add_counter(uint16 countertype, uint16 count); int32 is_can_add_counter(uint8 playerid, uint16 countertype, uint16 count);
int32 get_counter(uint16 countertype); int32 get_counter(uint16 countertype);
void set_material(card_set* materials); void set_material(card_set* materials);
void add_card_target(card* pcard); void add_card_target(card* pcard);
......
...@@ -1854,7 +1854,18 @@ int32 field::is_player_can_release(uint8 playerid, card * pcard) { ...@@ -1854,7 +1854,18 @@ int32 field::is_player_can_release(uint8 playerid, card * pcard) {
return TRUE; return TRUE;
} }
int32 field::is_player_can_place_counter(uint8 playerid, card * pcard, uint16 countertype, uint16 count) { int32 field::is_player_can_place_counter(uint8 playerid, card * pcard, uint16 countertype, uint16 count) {
return !is_player_affected_by_effect(playerid,EFFECT_CANNOT_PLACE_COUNTER); effect_set eset;
filter_player_effect(playerid, EFFECT_CANNOT_PLACE_COUNTER, &eset);
for(int32 i = 0; i < eset.count; ++i) {
if(!eset[i]->target)
return FALSE;
pduel->lua->add_param(eset[i], PARAM_TYPE_EFFECT);
pduel->lua->add_param(pcard, PARAM_TYPE_CARD);
pduel->lua->add_param(playerid, PARAM_TYPE_INT);
if (pduel->lua->check_condition(eset[i]->target, 3))
return FALSE;
}
return TRUE;
} }
int32 field::is_player_can_remove_counter(uint8 playerid, card * pcard, uint8 s, uint8 o, uint16 countertype, uint16 count, uint32 reason) { int32 field::is_player_can_remove_counter(uint8 playerid, card * pcard, uint8 s, uint8 o, uint16 countertype, uint16 count, uint32 reason) {
if((pcard && pcard->get_counter(countertype) >= count) || (!pcard && get_field_counter(playerid, s, o, countertype) >= count)) if((pcard && pcard->get_counter(countertype) >= count) || (!pcard && get_field_counter(playerid, s, o, countertype) >= count))
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <map> #include <map>
#include <list> #include <list>
#include <array> #include <array>
#include <functional>
#include <unordered_map> #include <unordered_map>
#include <unordered_set> #include <unordered_set>
...@@ -212,7 +213,7 @@ struct processor { ...@@ -212,7 +213,7 @@ struct processor {
std::unordered_map<card*, uint32> readjust_map; std::unordered_map<card*, uint32> readjust_map;
std::unordered_set<card*> unique_cards[2]; std::unordered_set<card*> unique_cards[2];
std::unordered_map<uint32, uint32> effect_count_code; std::unordered_map<uint32, uint32> effect_count_code;
std::multimap<int32, card*,std::greater<int32> > xmaterial_lst; std::multimap<int32, card*, std::greater<int32> > xmaterial_lst;
ptr temp_var[4]; ptr temp_var[4];
uint32 global_flag; uint32 global_flag;
uint16 pre_field[2]; uint16 pre_field[2];
......
...@@ -1617,11 +1617,8 @@ int32 scriptlib::card_add_counter(lua_State *L) { ...@@ -1617,11 +1617,8 @@ int32 scriptlib::card_add_counter(lua_State *L) {
card* pcard = *(card**) lua_touserdata(L, 1); card* pcard = *(card**) lua_touserdata(L, 1);
uint32 countertype = lua_tointeger(L, 2); uint32 countertype = lua_tointeger(L, 2);
uint32 count = lua_tointeger(L, 3); uint32 count = lua_tointeger(L, 3);
field* game_field = pcard->pduel->game_field; if(pcard->is_affect_by_effect(pcard->pduel->game_field->core.reason_effect))
uint8 player = game_field->core.reason_player; lua_pushboolean(L, pcard->add_counter(pcard->pduel->game_field->core.reason_player, countertype, count));
if(pcard->is_affect_by_effect(game_field->core.reason_effect)
&& game_field->is_player_can_place_counter(player,pcard,countertype,count))
lua_pushboolean(L, pcard->add_counter(countertype, count));
else lua_pushboolean(L, 0); else lua_pushboolean(L, 0);
return 1; return 1;
} }
...@@ -1703,7 +1700,7 @@ int32 scriptlib::card_is_can_add_counter(lua_State *L) { ...@@ -1703,7 +1700,7 @@ int32 scriptlib::card_is_can_add_counter(lua_State *L) {
card* pcard = *(card**) lua_touserdata(L, 1); card* pcard = *(card**) lua_touserdata(L, 1);
uint32 countertype = lua_tointeger(L, 2); uint32 countertype = lua_tointeger(L, 2);
uint32 count = lua_tointeger(L, 3); uint32 count = lua_tointeger(L, 3);
lua_pushboolean(L, pcard->is_can_add_counter(countertype, count)); lua_pushboolean(L, pcard->is_can_add_counter(pcard->pduel->game_field->core.reason_player, countertype, count));
return 1; return 1;
} }
int32 scriptlib::card_is_can_remove_counter(lua_State *L) { int32 scriptlib::card_is_can_remove_counter(lua_State *L) {
......
...@@ -34,7 +34,7 @@ function c26270847.atktg(e,c) ...@@ -34,7 +34,7 @@ function c26270847.atktg(e,c)
return c:IsSetCard(0x9f) return c:IsSetCard(0x9f)
end end
function c26270847.filter(c) function c26270847.filter(c)
return c:IsFaceup() and c:IsSetCard(0x9d) return c:IsFaceup() and c:IsSetCard(0x9f)
end end
function c26270847.target(e,tp,eg,ep,ev,re,r,rp,chk) function c26270847.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c26270847.filter,tp,LOCATION_MZONE,0,1,nil) end if chk==0 then return Duel.IsExistingMatchingCard(c26270847.filter,tp,LOCATION_MZONE,0,1,nil) end
......
...@@ -303,7 +303,7 @@ EFFECT_UNRELEASABLE_SUM =43 -- ...@@ -303,7 +303,7 @@ EFFECT_UNRELEASABLE_SUM =43 --
EFFECT_UNRELEASABLE_NONSUM =44 -- EFFECT_UNRELEASABLE_NONSUM =44 --
EFFECT_DESTROY_SUBSTITUTE =45 -- EFFECT_DESTROY_SUBSTITUTE =45 --
EFFECT_CANNOT_RELEASE =46 -- EFFECT_CANNOT_RELEASE =46 --
EFFECT_INDESTRUCTABLE_COUNT =47 -- EFFECT_INDESTRUCTABLE_COUNT =47 --
EFFECT_UNRELEASABLE_EFFECT =48 -- EFFECT_UNRELEASABLE_EFFECT =48 --
EFFECT_DESTROY_REPLACE =50 -- EFFECT_DESTROY_REPLACE =50 --
EFFECT_RELEASE_REPLACE =51 -- EFFECT_RELEASE_REPLACE =51 --
...@@ -311,7 +311,7 @@ EFFECT_SEND_REPLACE =52 -- ...@@ -311,7 +311,7 @@ EFFECT_SEND_REPLACE =52 --
EFFECT_CANNOT_DISCARD_HAND =55 -- EFFECT_CANNOT_DISCARD_HAND =55 --
EFFECT_CANNOT_DISCARD_DECK =56 -- EFFECT_CANNOT_DISCARD_DECK =56 --
EFFECT_CANNOT_USE_AS_COST =57 -- EFFECT_CANNOT_USE_AS_COST =57 --
EFFECT_CANNOT_PLACE_COUNTER =58 -- EFFECT_CANNOT_PLACE_COUNTER =58 --
EFFECT_LEAVE_FIELD_REDIRECT =60 -- EFFECT_LEAVE_FIELD_REDIRECT =60 --
EFFECT_TO_HAND_REDIRECT =61 -- EFFECT_TO_HAND_REDIRECT =61 --
......
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