Commit 1bcbcdfe authored by argon.sun's avatar argon.sun

fix

parent 42c400f5
......@@ -152,6 +152,8 @@ bool DeckManager::LoadSide(Deck& deck, int* dbuf, int mainc, int sidec) {
pcount[deck.side[i]->first]++;
Deck ndeck;
LoadDeck(ndeck, dbuf, mainc, sidec);
if(ndeck.main.size() != deck.main.size() || ndeck.extra.size() != deck.extra.size())
return false;
for(int i = 0; i < ndeck.main.size(); ++i)
ncount[ndeck.main[i]->first]++;
for(int i = 0; i < ndeck.extra.size(); ++i)
......
......@@ -35,7 +35,7 @@ bool NetServer::StartServer(unsigned short port) {
void NetServer::StopServer() {
if(!net_evbase)
return;
event_base_loopbreak(net_evbase);
event_base_loopexit(net_evbase, 0);
}
void NetServer::StopListen() {
evconnlistener_disable(listener);
......@@ -51,7 +51,7 @@ void NetServer::ServerAccept(evconnlistener* listener, evutil_socket_t fd, socka
bufferevent_enable(bev, EV_READ);
}
void NetServer::ServerAcceptError(evconnlistener* listener, void* ctx) {
event_base_loopbreak(net_evbase);
event_base_loopexit(net_evbase, 0);
}
void NetServer::ServerEchoRead(bufferevent *bev, void *ctx) {
evbuffer* input = bufferevent_get_input(bev);
......
......@@ -284,6 +284,7 @@ void SingleDuel::HandResult(DuelPlayer* dp, unsigned char res) {
void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
if(dp->state != CTOS_TP_RESULT)
return;
bool swapped = false;
if((tp && dp->type == 1) || (!tp && dp->type == 0)) {
DuelPlayer* p = players[0];
players[0] = players[1];
......@@ -293,6 +294,7 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
Deck d = pdeck[0];
pdeck[0] = pdeck[1];
pdeck[1] = d;
swapped = true;
}
dp->state = CTOS_RESPONSE;
ReplayHeader rh;
......@@ -362,10 +364,14 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
BufferIO::WriteInt16(pbuf, query_field_count(pduel, 1, 0x1));
BufferIO::WriteInt16(pbuf, query_field_count(pduel, 1, 0x40));
NetServer::SendBufferToPlayer(players[0], STOC_GAME_MSG, startbuf, 18);
if(!swapped)
for(auto oit = observers.begin(); oit != observers.end(); ++oit)
NetServer::ReSendToPlayer(*oit);
startbuf[1] = 1;
NetServer::SendBufferToPlayer(players[1], STOC_GAME_MSG, startbuf, 18);
if(swapped)
for(auto oit = observers.begin(); oit != observers.end(); ++oit)
NetServer::ReSendToPlayer(*oit);
RefreshExtra(0);
RefreshExtra(1);
start_duel(pduel, opt);
......
......@@ -1389,6 +1389,7 @@ int32 scriptlib::duel_get_decktop_group(lua_State *L) {
*/
int32 scriptlib::duel_get_matching_group(lua_State *L) {
check_param_count(L, 5);
if(!lua_isnil(L, 1))
check_param(L, PARAM_TYPE_FUNCTION, 1);
card* pexception = 0;
uint32 extraargs = 0;
......@@ -1413,6 +1414,7 @@ int32 scriptlib::duel_get_matching_group(lua_State *L) {
*/
int32 scriptlib::duel_get_matching_count(lua_State *L) {
check_param_count(L, 5);
if(!lua_isnil(L, 1))
check_param(L, PARAM_TYPE_FUNCTION, 1);
card* pexception = 0;
uint32 extraargs = 0;
......@@ -1438,6 +1440,7 @@ int32 scriptlib::duel_get_matching_count(lua_State *L) {
*/
int32 scriptlib::duel_get_first_matching_card(lua_State *L) {
check_param_count(L, 5);
if(!lua_isnil(L, 1))
check_param(L, PARAM_TYPE_FUNCTION, 1);
card* pexception = 0;
uint32 extraargs = 0;
......
......@@ -7,6 +7,7 @@ function c46363422.initial_effect(c)
e1:SetType(EFFECT_TYPE_CONTINUOUS+EFFECT_TYPE_FIELD)
e1:SetCode(EVENT_CHAIN_SOLVING)
e1:SetProperty(EFFECT_FLAG_DELAY)
e1:SetRange(LOCATION_MZONE)
e1:SetOperation(c46363422.acop)
c:RegisterEffect(e1)
--special summon
......@@ -21,9 +22,8 @@ function c46363422.initial_effect(c)
c:RegisterEffect(e2)
end
function c46363422.acop(e,tp,eg,ep,ev,re,r,rp)
local te=Duel.GetChainInfo(ev,CHAININFO_TRIGGERING_EFFECT)
local c=te:GetHandler()
if te:IsHasType(EFFECT_TYPE_ACTIVATE) and c:IsType(TYPE_SPELL) and c~=e:GetHandler() then
local c=re:GetHandler()
if re:IsHasType(EFFECT_TYPE_ACTIVATE) and c:IsType(TYPE_SPELL) then
e:GetHandler():AddCounter(0x3001,1)
end
end
......@@ -44,6 +44,5 @@ function c46363422.spop(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.SelectMatchingCard(tp,c46363422.filter,tp,0x13,0,1,1,nil,e,tp)
if g:GetCount()>0 then
Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)
Duel.ShuffleDeck(tp)
end
end
......@@ -2,7 +2,6 @@
function c47297616.initial_effect(c)
--cannot special summon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(47297616,0))
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetCode(EFFECT_SPSUMMON_CONDITION)
......@@ -10,7 +9,6 @@ function c47297616.initial_effect(c)
c:RegisterEffect(e1)
--Attribute Dark
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(47297616,1))
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e2:SetCode(EFFECT_ADD_ATTRIBUTE)
......@@ -32,7 +30,7 @@ function c47297616.initial_effect(c)
--Special summon
local e4=Effect.CreateEffect(c)
e4:SetDescription(aux.Stringid(47297616,4))
e4:SetCategory(CATEGORY_SPECIAL_SUMMON)
e4:SetCategory(CATEGORY_SPECIAL_SUMMON+CATEGORY_DESTROY)
e4:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_F)
e4:SetCode(EVENT_TO_GRAVE)
e4:SetProperty(EFFECT_FLAG_CARD_TARGET)
......@@ -84,8 +82,10 @@ function c47297616.tgspsum(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,Card.IsCanBeSpecialSummoned,tp,LOCATION_GRAVE,0,1,1,nil,e,0,PLAYER_NONE,false,false,POS_FACEUP,tp)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,g:GetCount(),0,0)
local dg=Duel.GetMatchingGroup(Card.IsDestructable,tp,LOCATION_ONFIELD,0,nil)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,dg,dg:GetCount(),0,0)
end
function c47297616.opspsum(e,tp,eg,ep,ev,re,r,rp,chk)
function c47297616.opspsum(e,tp,eg,ep,ev,re,r,rp)
local dg=Duel.GetMatchingGroup(nil,tp,LOCATION_ONFIELD,0,nil)
Duel.Destroy(dg,REASON_EFFECT)
local tc=Duel.GetFirstTarget()
......
......@@ -55,7 +55,11 @@ end
function c47355498.conntp(e)
return not Duel.IsPlayerAffectedByEffect(1-e:GetHandler():GetControler(),EFFECT_NECRO_VALLEY_IM)
end
function c47355498.disfilter(c,im0,im1)
function c47355498.disfilter1(c,im0,im1,tg)
if c:IsControler(0) then return im0 and tg:IsContains(c) and c:IsHasEffect(EFFECT_NECRO_VALLEY)
else return im1 and and tg:IsContains(c) and c:IsHasEffect(EFFECT_NECRO_VALLEY) end
end
function c47355498.disfilter2(c,im0,im1)
if c:IsControler(0) then return im0 and c:IsHasEffect(EFFECT_NECRO_VALLEY)
else return im1 and c:IsHasEffect(EFFECT_NECRO_VALLEY) end
end
......@@ -64,9 +68,10 @@ function c47355498.discheck(ev,category,re,im0,im1)
if not ex then return false end
if tg and tg:GetCount()>0 then
if re:IsHasProperty(EFFECT_FLAG_CARD_TARGET) then
return tg:IsExists(c47355498.disfilter,1,nil,im0,im1)
local targets=Duel.GetChainInfo(ev,CHAININFO_TARGET_CARDS)
return tg:IsExists(c47355498.disfilter1,1,nil,im0,im1,targets)
else
return tg:IsExists(c47355498.disfilter,1,re:GetHandler(),im0,im1)
return tg:IsExists(c47355498.disfilter2,1,re:GetHandler(),im0,im1)
end
end
if v~=LOCATION_GRAVE then return false end
......
......@@ -7,17 +7,17 @@ function c49633574.initial_effect(c)
e1:SetType(EFFECT_TYPE_IGNITION)
e1:SetCountLimit(1)
e1:SetRange(LOCATION_MZONE)
e1:SetTarget(c12235475.tg)
e1:SetOperation(c12235475.op)
e1:SetTarget(c49633574.tg)
e1:SetOperation(c49633574.op)
c:RegisterEffect(e1)
end
function c12235475.spfilter(c,e,tp)
function c49633574.spfilter(c,e,tp)
return c:IsSetCard(0x35) and c:GetLevel()==3 and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
end
function c12235475.tg(e,tp,eg,ep,ev,re,r,rp,chk)
function c49633574.tg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then
if Duel.GetLocationCount(tp,LOCATION_MZONE)==0 then return false end
local g=Duel.GetMatchingGroup(c12235475.spfilter,tp,LOCATION_HAND,0,nil,e,tp)
local g=Duel.GetMatchingGroup(c49633574.spfilter,tp,LOCATION_HAND,0,nil,e,tp)
local res=nil
if g:GetCount()==0 then
res=false
......@@ -26,7 +26,7 @@ function c12235475.tg(e,tp,eg,ep,ev,re,r,rp,chk)
else res=Duel.IsExistingMatchingCard(Card.IsAbleToGraveAsCost,tp,LOCATION_HAND,0,1,nil) end
return res
end
local g=Duel.GetMatchingGroup(c12235475.spfilter,tp,LOCATION_HAND,0,nil,e,tp)
local g=Duel.GetMatchingGroup(c49633574.spfilter,tp,LOCATION_HAND,0,nil,e,tp)
local cg=nil
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
if g:GetCount()==1 then
......@@ -35,10 +35,10 @@ function c12235475.tg(e,tp,eg,ep,ev,re,r,rp,chk)
Duel.SendtoGrave(cg,REASON_COST)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND)
end
function c12235475.op(e,tp,eg,ep,ev,re,r,rp)
function c49633574.op(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_MZONE)==0 then return end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectMatchingCard(tp,c12235475.spfilter,tp,LOCATION_HAND,0,1,1,nil,e,tp)
local g=Duel.SelectMatchingCard(tp,c49633574.spfilter,tp,LOCATION_HAND,0,1,1,nil,e,tp)
if g:GetCount()>0 then
Duel.SpecialSummon(g,0,tp,tp,flse,false,POS_FACEUP)
end
......
......@@ -22,7 +22,7 @@ function c51554871.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsExistingMatchingCard(c51554871.filter,tp,LOCATION_MZONE,0,1,nil) end
end
function c51554871.operation(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.GetMatchingGroup(c15169262.filter,tp,LOCATION_MZONE,0,nil)
local g=Duel.GetMatchingGroup(c51554871.filter,tp,LOCATION_MZONE,0,nil)
local tc=g:GetFirst()
if not tc then return end
local c=e:GetHandler()
......
......@@ -22,7 +22,7 @@ function c67779172.cost(e,tp,eg,ep,ev,re,r,rp,chk)
end
function c67779172.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1-tp) and chkc:IsDefence() end
f chk==0 then return Duel.IsExistingTarget(Card.IsDefence,tp,0,LOCATION_MZONE,1,nil) end
if chk==0 then return Duel.IsExistingTarget(Card.IsDefence,tp,0,LOCATION_MZONE,1,nil) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TOGRAVE)
local g=Duel.SelectTarget(tp,Card.IsDefence,tp,0,LOCATION_MZONE,1,1,nil)
Duel.SetOperationInfo(0,CATEGORY_TOGRAVE,g,1,0,0)
......
......@@ -22,9 +22,8 @@ function c73752131.initial_effect(c)
c:RegisterEffect(e2)
end
function c73752131.acop(e,tp,eg,ep,ev,re,r,rp)
local te=Duel.GetChainInfo(ev,CHAININFO_TRIGGERING_EFFECT)
local c=te:GetHandler()
if te:IsHasType(EFFECT_TYPE_ACTIVATE) and c:IsType(TYPE_SPELL) and c~=e:GetHandler() then
local c=re:GetHandler()
if re:IsHasType(EFFECT_TYPE_ACTIVATE) and c:IsType(TYPE_SPELL) then
e:GetHandler():AddCounter(0x3001,1)
end
end
......@@ -45,6 +44,5 @@ function c73752131.spop(e,tp,eg,ep,ev,re,r,rp)
local g=Duel.SelectMatchingCard(tp,c73752131.filter,tp,0x13,0,1,1,nil,e,tp)
if g:GetCount()>0 then
Duel.SpecialSummon(g,0,tp,tp,false,false,POS_FACEUP)
Duel.ShuffleDeck(tp)
end
end
......@@ -64,5 +64,5 @@ function c75116619.vfilter(c)
end
function c75116619.valcon(e)
local c=e:GetHandler()
return Duel.IsExistingMatchingCard(c49721904.vfilter,c:GetControler(),LOCATION_MZONE,0,2,c)
return Duel.IsExistingMatchingCard(c75116619.vfilter,c:GetControler(),LOCATION_MZONE,0,2,c)
end
......@@ -18,8 +18,8 @@ function c85852291.target(e,tp,eg,ep,ev,re,r,rp,chk)
end
function c85852291.activate(e,tp,eg,ep,ev,re,r,rp)
local p=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER)
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_TODECK)
local g=Duel.SelectMatchingCard(p,c85852291.filter,p,LOCATION_HAND,0,1,63,nil)
Duel.Hint(HINT_SELECTMSG,p,HINTMSG_TODECK)
local g=Duel.SelectMatchingCard(p,Card.IsAbleToDeck,p,LOCATION_HAND,0,1,63,nil)
if g:GetCount()==0 then return end
Duel.SendtoDeck(g,nil,2,REASON_EFFECT)
Duel.ShuffleDeck(p)
......
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