Commit dc8993f4 authored by VanillaSalt's avatar VanillaSalt

fix

parent 33f25c73
......@@ -205,6 +205,8 @@ const wchar_t* DataManager::FormatAttribute(int attribute) {
}
if(p != attBuffer)
*(p - 1) = 0;
else
return unknown_string;
return attBuffer;
}
const wchar_t* DataManager::FormatRace(int race) {
......@@ -219,6 +221,8 @@ const wchar_t* DataManager::FormatRace(int race) {
}
if(p != racBuffer)
*(p - 1) = 0;
else
return unknown_string;
return racBuffer;
}
const wchar_t* DataManager::FormatType(int type) {
......@@ -233,6 +237,8 @@ const wchar_t* DataManager::FormatType(int type) {
}
if(p != tpBuffer)
*(p - 1) = 0;
else
return unknown_string;
return tpBuffer;
}
int DataManager::CardReader(int code, void* pData) {
......
......@@ -34,9 +34,10 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break;
}
case BUTTON_SAVE_DECK: {
deckManager.SaveDeck(deckManager.current_deck, mainGame->cbDBDecks->getItem(mainGame->cbDBDecks->getSelected()));
mainGame->stACMessage->setText(dataManager.GetSysString(1335));
mainGame->PopupElement(mainGame->wACMessage, 20);
if(deckManager.SaveDeck(deckManager.current_deck, mainGame->cbDBDecks->getItem(mainGame->cbDBDecks->getSelected()))) {
mainGame->stACMessage->setText(dataManager.GetSysString(1335));
mainGame->PopupElement(mainGame->wACMessage, 20);
}
break;
}
case BUTTON_SAVE_DECK_AS: {
......@@ -56,9 +57,10 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
mainGame->cbDBDecks->addItem(dname);
mainGame->cbDBDecks->setSelected(mainGame->cbDBDecks->getItemCount() - 1);
}
deckManager.SaveDeck(deckManager.current_deck, dname);
mainGame->stACMessage->setText(dataManager.GetSysString(1335));
mainGame->PopupElement(mainGame->wACMessage, 20);
if(deckManager.SaveDeck(deckManager.current_deck, dname)) {
mainGame->stACMessage->setText(dataManager.GetSysString(1335));
mainGame->PopupElement(mainGame->wACMessage, 20);
}
break;
}
case BUTTON_DBEXIT: {
......
......@@ -206,7 +206,7 @@ bool DeckManager::LoadDeck(const wchar_t* file) {
LoadDeck(current_deck, cardlist, mainc, sidec);
return true;
}
void DeckManager::SaveDeck(Deck& deck, const wchar_t* name) {
bool DeckManager::SaveDeck(Deck& deck, const wchar_t* name) {
wchar_t file[64];
myswprintf(file, L"./deck/%ls.ydk", name);
#ifdef WIN32
......@@ -217,7 +217,7 @@ void DeckManager::SaveDeck(Deck& deck, const wchar_t* name) {
FILE* fp = fopen(filefn, "w");
#endif
if(!fp)
return;
return false;
fprintf(fp, "#created by ...\n#main\n");
for(int i = 0; i < deck.main.size(); ++i)
fprintf(fp, "%d\n", deck.main[i]->first);
......@@ -228,5 +228,6 @@ void DeckManager::SaveDeck(Deck& deck, const wchar_t* name) {
for(int i = 0; i < deck.side.size(); ++i)
fprintf(fp, "%d\n", deck.side[i]->first);
fclose(fp);
return true;
}
}
......@@ -41,7 +41,7 @@ public:
void LoadDeck(Deck& deck, int* dbuf, int mainc, int sidec);
bool LoadSide(Deck& deck, int* dbuf, int mainc, int sidec);
bool LoadDeck(const wchar_t* file);
void SaveDeck(Deck& deck, const wchar_t* name);
bool SaveDeck(Deck& deck, const wchar_t* name);
};
extern DeckManager deckManager;
......
......@@ -735,12 +735,14 @@ void Game::LoadConfig() {
BufferIO::CopyWStr(wstr, gameConf.lastdeck, 64);
} else if(!strcmp(strbuf, "textfont")) {
BufferIO::DecodeUTF8(valbuf, wstr);
sscanf(linebuf, "%s = %s %d", strbuf, valbuf, &gameConf.textfontsize);
int textfontsize;
sscanf(linebuf, "%s = %s %d", strbuf, valbuf, &textfontsize);
gameConf.textfontsize = textfontsize;
BufferIO::CopyWStr(wstr, gameConf.textfont, 256);
} else if(!strcmp(strbuf, "numfont")) {
BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.numfont, 256);
} else if(!strcmp(strbuf, "servport")) {
} else if(!strcmp(strbuf, "serverport")) {
gameConf.serverport = atoi(valbuf);
} else if(!strcmp(strbuf, "lastip")) {
BufferIO::DecodeUTF8(valbuf, wstr);
......@@ -783,7 +785,8 @@ void Game::SaveConfig() {
void Game::ShowCardInfo(int code) {
CardData cd;
wchar_t formatBuffer[256];
dataManager.GetData(code, &cd);
if(!dataManager.GetData(code, &cd))
memset(&cd, 0, sizeof(CardData));
imgCard->setImage(imageManager.GetTexture(code));
imgCard->setScaleImage(true);
if(cd.alias != 0 && (cd.alias - code < 10 || code - cd.alias < 10))
......
......@@ -1032,7 +1032,7 @@ void card::release_relation(card* target) {
relations.erase(target);
}
void card::release_relation(effect* peffect) {
if (relate_effect.find(peffect) != relate_effect.end())
if (relate_effect.find(peffect) == relate_effect.end())
return;
relate_effect.erase(peffect);
}
......
......@@ -49,10 +49,13 @@ function c102380.damcon(e,tp,eg,ep,ev,re,r,rp)
end
function c102380.damtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetTargetPlayer(tp)
Duel.SetTargetParam(1000)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,0,0,tp,1000)
end
function c102380.damop(e,tp,eg,ep,ev,re,r,rp)
Duel.Damage(e:GetHandler():GetControler(),1000,REASON_EFFECT)
local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM)
Duel.Damage(p,d,REASON_EFFECT)
end
function c102380.spcost(e,c,tp)
return not Duel.CheckNormalSummonActivity(tp)
......
......@@ -21,10 +21,11 @@ function c1281505.initial_effect(c)
c:RegisterEffect(e2)
--destroy sub
local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_EQUIP)
e3:SetType(EFFECT_TYPE_EQUIP+EFFECT_TYPE_CONTINUOUS)
e3:SetProperty(EFFECT_FLAG_IGNORE_IMMUNE)
e3:SetCode(EFFECT_DESTROY_SUBSTITUTE)
e3:SetValue(1)
e3:SetCode(EFFECT_DESTROY_REPLACE)
e3:SetTarget(c1281505.reptg)
e3:SetOperation(c1281505.repop)
c:RegisterEffect(e3)
end
function c1281505.eqcon(e,tp,eg,ep,ev,re,r,rp)
......@@ -52,3 +53,10 @@ end
function c1281505.eqlimit(e,c)
return c:GetControler()==e:GetHandler():GetControler()
end
function c1281505.reptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
return Duel.SelectYesNo(tp,aux.Stringid(1281505,1))
end
function c1281505.repop(e,tp,eg,ep,ev,re,r,rp)
Duel.Destroy(e:GetHandler(),REASON_EFFECT+REASON_REPLACE)
end
......@@ -22,9 +22,35 @@ function c12958919.initial_effect(c)
e2:SetRange(LOCATION_MZONE)
e2:SetCountLimit(1)
e2:SetCondition(c12958919.damcon)
e2:SetCost(c12958919.damcost)
e2:SetTarget(c12958919.damtg)
e2:SetOperation(c12958919.damop)
c:RegisterEffect(e2)
if not c12958919.global_check then
c12958919.global_check=true
c12958919[0]=true
c12958919[1]=true
local ge1=Effect.CreateEffect(c)
ge1:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
ge1:SetCode(EVENT_ATTACK_ANNOUNCE)
ge1:SetOperation(c12958919.checkop)
Duel.RegisterEffect(ge1,0)
local ge2=Effect.CreateEffect(c)
ge2:SetType(EFFECT_TYPE_FIELD+EFFECT_TYPE_CONTINUOUS)
ge2:SetCode(EVENT_PHASE_START+PHASE_DRAW)
ge2:SetOperation(c12958919.clear)
Duel.RegisterEffect(ge2,0)
end
end
function c12958919.checkop(e,tp,eg,ep,ev,re,r,rp)
local tc=eg:GetFirst()
if tc:IsSetCard(0x49) then
c12958919[tc:GetControler()]=false
end
end
function c12958919.clear(e,tp,eg,ep,ev,re,r,rp)
c12958919[0]=true
c12958919[1]=true
end
function c12958919.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
......@@ -50,6 +76,17 @@ end
function c12958919.damcon(e,tp,eg,ep,ev,re,r,rp)
return tp==Duel.GetTurnPlayer()
end
function c12958919.damcost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return c12958919[tp] end
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_CANNOT_ATTACK_ANNOUNCE)
e1:SetProperty(EFFECT_FLAG_OATH)
e1:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0x49))
e1:SetTargetRange(LOCATION_MZONE,0)
e1:SetReset(RESET_PHASE+RESET_END)
Duel.RegisterEffect(e1,tp)
end
function c12958919.damfilter(c)
return c:IsFaceup() and c:IsSetCard(0x49)
end
......@@ -57,14 +94,7 @@ function c12958919.damtg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
local ct=Duel.GetMatchingGroupCount(c12958919.damfilter,tp,LOCATION_MZONE,0,nil)
Duel.SetTargetPlayer(1-tp)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,tp,ct*300)
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_CANNOT_ATTACK)
e1:SetTarget(aux.TargetBoolFunction(Card.IsSetCard,0x49))
e1:SetTargetRange(LOCATION_MZONE,0)
e1:SetReset(RESET_PHASE+PHASE_END)
Duel.RegisterEffect(e1,tp)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,1-tp,ct*300)
end
function c12958919.damop(e,tp,eg,ep,ev,re,r,rp)
local p=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER)
......
......@@ -22,7 +22,7 @@ end
function c16111820.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),0,0,0)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0)
end
function c16111820.operation(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
......
......@@ -28,7 +28,7 @@ function c21843307.activate(e,tp,eg,ep,ev,re,r,rp)
if not c:IsRelateToEffect(e) then return end
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0
or not Duel.IsPlayerCanSpecialSummonMonster(tp,ec:GetCode(),0,0x11,0,0,ec:GetLevel(),RACE_WARRIOR,ATTRIBUTE_LIGHT) then return end
c:AddTrapMonsterAttribute(true,ATTRIBUTE_LIGHT,RACE_WARRIOR,ec:GetLevel(),0,0)
c:AddTrapMonsterAttribute(false,ATTRIBUTE_LIGHT,RACE_WARRIOR,ec:GetLevel(),0,0)
Duel.SpecialSummonStep(c,0,tp,tp,true,false,POS_FACEUP)
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE)
......
......@@ -37,7 +37,7 @@ function c45985838.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end
Duel.SetTargetPlayer(1-tp)
Duel.SetTargetParam(500)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,tp,500)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,1-tp,500)
end
function c45985838.operation(e,tp,eg,ep,ev,re,r,rp)
local p,d=Duel.GetChainInfo(0,CHAININFO_TARGET_PLAYER,CHAININFO_TARGET_PARAM)
......
......@@ -50,7 +50,7 @@ end
function c46668237.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),0,0,0)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0)
end
function c46668237.operation(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
......
......@@ -20,15 +20,13 @@ function c62279055.target(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chk==0 then return tg:IsOnField() and tg:IsCanBeEffectTarget(e) end
Duel.SetTargetCard(tg)
local dam=tg:GetAttack()
Duel.SetTargetParam(dam)
Duel.SetOperationInfo(0,CATEGORY_DAMAGE,nil,0,1-tp,dam)
end
function c62279055.activate(e,tp,eg,ep,ev,re,r,rp)
local tg,d=Duel.GetChainInfo(0,CHAININFO_TARGET_CARDS,CHAININFO_TARGET_PARAM)
local tc=tg:GetFirst()
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and tc:IsFaceup() and tc:IsAttackable() then
if Duel.NegateAttack(tc) then
Duel.Damage(1-tp,d,REASON_EFFECT)
Duel.Damage(1-tp,tc:GetAttack(),REASON_EFFECT)
end
end
end
--レッドアイズ·ブラックメタルドラゴン
function c64335804.initial_effect(c)
c:EnableReviveLimit()
--spsummon proc
local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_FIELD)
e1:SetCode(EFFECT_SPSUMMON_PROC)
e1:SetProperty(EFFECT_FLAG_UNCOPYABLE)
e1:SetRange(LOCATION_HAND+LOCATION_DECK)
e1:SetRange(LOCATION_DECK)
e1:SetCondition(c64335804.spcon)
e1:SetOperation(c64335804.spop)
c:RegisterEffect(e1)
......
......@@ -54,7 +54,7 @@ end
function c65303664.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and e:GetHandler():IsCanBeSpecialSummoned(e,0,tp,false,false) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),0,0,0)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,e:GetHandler(),1,0,0)
end
function c65303664.operation(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
......
......@@ -23,7 +23,7 @@ function c68450517.descost(e,tp,eg,ep,ev,re,r,rp,chk)
e:GetHandler():RegisterEffect(e1)
end
function c68450517.filter(c,att)
return c:IsFaceup() and c:IsAttribute(att) and c:IsDestructable()
return c:IsPosition(POS_FACEUP_ATTACK) and c:IsAttribute(att) and c:IsDestructable()
end
function c68450517.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_MZONE) and chkc:IsControler(1-tp)
......@@ -34,8 +34,9 @@ function c68450517.destg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
Duel.SetOperationInfo(0,CATEGORY_DESTROY,g,1,0,0)
end
function c68450517.desop(e,tp,eg,ep,ev,re,r,rp)
local c=e:GetHandler()
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and tc:IsFaceup() and tc:IsAttribute(e:GetHandler():GetAttribute()) then
if c:IsFaceup() and tc:IsRelateToEffect(e) and tc:IsControler(1-tp) and c68450517.filter(tc,c:GetAttribute()) then
Duel.Destroy(tc,REASON_EFFECT)
end
end
......@@ -60,7 +60,7 @@ function c7165085.activate(e,tp,eg,ep,ev,re,r,rp)
tg:CreateEffectRelation(te)
tg=g:GetNext()
end
operation(te,tep,eg,ep,ev,re,r,rp)
if operation then operation(te,tep,eg,ep,ev,re,r,rp) end
tc:ReleaseEffectRelation(te)
tg=g:GetFirst()
while tg do
......
......@@ -19,7 +19,7 @@ function c97170107.initial_effect(c)
c:RegisterEffect(e2)
end
function c97170107.filter(c,e,tp)
return c:IsFaceup() and c:IsControler(1-tp) and (not e or c:IsRelateToEffect(e))
return c:IsFaceup() and c:IsControler(1-tp) and c:GetAttack()>0 and (not e or c:IsRelateToEffect(e))
end
function c97170107.cost(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return e:GetHandler():CheckRemoveOverlayCard(tp,1,REASON_COST) end
......@@ -28,7 +28,6 @@ end
function c97170107.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return eg:IsExists(c97170107.filter,1,nil,nil,tp) end
Duel.SetTargetCard(eg)
Duel.SetOperationInfo(0,CATEGORY_POSITION,eg,eg:GetCount(),0,0)
end
function c97170107.operation(e,tp,eg,ep,ev,re,r,rp)
local g=eg:Filter(c97170107.filter,nil,e,tp)
......
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