Commit efac21cf authored by argon.sun's avatar argon.sun

single

parent a3cd3967
......@@ -657,6 +657,31 @@ void Game::RefreshReplay() {
#endif
}
void Game::RefreshSingleplay() {
lstSinglePlayList->clear();
#ifdef _WIN32
WIN32_FIND_DATAW fdataw;
HANDLE fh = FindFirstFileW(L"./single/*.lua", &fdataw);
if(fh == INVALID_HANDLE_VALUE)
return;
do {
if(!(fdataw.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
lstSinglePlayList->addItem(fdataw.cFileName);
} while(FindNextFileW(fh, &fdataw));
FindClose(fh);
#else
DIR * dir;
struct dirent * dirp;
if((dir = opendir("./single/")) == NULL)
return;
while((dirp = readdir(dir)) != NULL) {
size_t len = strlen(dirp->d_name);
if(len < 5 || strcasecmp(dirp->d_name + len - 4, ".lua") != 0)
continue;
wchar_t wname[256];
BufferIO::DecodeUTF8(dirp->d_name, wname);
lstSinglePlayList->addItem(wname);
}
#endif
}
void Game::LoadConfig() {
FILE* fp = fopen("system.conf", "r");
......
......@@ -190,6 +190,7 @@ static const struct luaL_Reg cardlib[] = {
static const struct luaL_Reg effectlib[] = {
{ "CreateEffect", scriptlib::effect_new },
{ "GlobalEffect", scriptlib::effect_newex },
{ "Clone", scriptlib::effect_clone },
{ "Reset", scriptlib::effect_reset },
{ "SetDescription", scriptlib::effect_set_description },
......@@ -461,6 +462,8 @@ static const struct luaL_Reg debuglib[] = {
{ "Message", scriptlib::debug_message },
{ "AddCard", scriptlib::debug_add_card },
{ "SetPlayerInfo", scriptlib::debug_set_player_info },
{ "ReloadFieldBegin", scriptlib::debug_reload_field_begin },
{ "ReloadFieldEnd", scriptlib::debug_reload_field_end },
{ NULL, NULL }
};
......
......@@ -717,6 +717,8 @@ int32 scriptlib::card_register_effect(lua_State *L) {
effect* peffect = *(effect**) lua_touserdata(L, 2);
int32 forced = lua_toboolean(L, 3);
duel* pduel = pcard->pduel;
if(peffect->owner == pduel->game_field->temp_card)
return 0;
if(!forced && pduel->game_field->core.reason_effect && !pcard->is_affect_by_effect(pduel->game_field->core.reason_effect))
return 0;
int32 id;
......
......@@ -66,3 +66,7 @@ int32 scriptlib::debug_set_player_info(lua_State *L) {
pd->game_field->player[playerid].draw_count = drawcount;
return 0;
}
int32 scriptlib::debug_reload_field_begin(lua_State *L) {
}
int32 scriptlib::debug_reload_field_end(lua_State *L) {
}
......@@ -22,6 +22,14 @@ int32 scriptlib::effect_new(lua_State *L) {
interpreter::effect2value(L, peffect);
return 1;
}
int32 scriptlib::effect_newex(lua_State *L) {
duel* pduel = interpreter::get_duel_info(L);
effect* peffect = pduel->new_effect();
peffect->effect_owner = 0;
peffect->owner = pduel->game_field->temp_card;
interpreter::effect2value(L, peffect);
return 1;
}
int32 scriptlib::effect_clone(lua_State *L) {
check_param_count(L, 1);
check_param(L, PARAM_TYPE_EFFECT, 1);
......
......@@ -189,6 +189,7 @@ public:
static int32 card_set_hint(lua_State *L);
//Effect functions
static int32 effect_new(lua_State *L);
static int32 effect_newex(lua_State *L);
static int32 effect_clone(lua_State *L);
static int32 effect_reset(lua_State *L);
static int32 effect_set_description(lua_State *L);
......@@ -460,6 +461,8 @@ public:
static int32 debug_message(lua_State *L);
static int32 debug_add_card(lua_State *L);
static int32 debug_set_player_info(lua_State *L);
static int32 debug_reload_field_begin(lua_State *L);
static int32 debug_reload_field_end(lua_State *L);
};
#endif /* SCRIPTLIB_H_ */
......@@ -26,7 +26,7 @@ function c10925955.target(e,tp,eg,ep,ev,re,r,rp,chk)
if sel==1 then
ac=Duel.SelectOption(tp,aux.Stringid(10925955,0))
elseif sel==2 then
ac=Duel.SelectOption(tp,aux.Stringid(10925955,1))
ac=Duel.SelectOption(tp,aux.Stringid(10925955,1))+1
elseif Duel.IsExistingMatchingCard(c10925955.cfilter,tp,LOCATION_MZONE,0,1,nil,true) then
ac=Duel.SelectOption(tp,aux.Stringid(10925955,0),aux.Stringid(10925955,1),aux.Stringid(10925955,2))
else
......
--BF-煌星のグラム
function c17377751.initial_effect(c)
--synchro summon
aux.AddSynchroProcedure(c,nil,aux.NonTuner(nil),1)
c:EnableReviveLimit()
--cannot special summon
local e1=Effect.CreateEffect(c)
e1:SetProperty(EFFECT_FLAG_CANNOT_DISABLE+EFFECT_FLAG_UNCOPYABLE)
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_SINGLE_RANGE)
e1:SetRange(LOCATION_EXTRA)
e1:SetCode(EFFECT_SPSUMMON_CONDITION)
c:RegisterEffect(e1)
--Special Summon
local e2=Effect.CreateEffect(c)
e2:SetDescription(aux.Stringid(17377751,0))
e2:SetType(EFFECT_TYPE_SINGLE+EFFECT_TYPE_TRIGGER_O)
e2:SetCategory(CATEGORY_SPECIAL_SUMMON)
e2:SetCode(EVENT_SPSUMMON_SUCCESS)
e2:SetCondition(c17377751.spcon)
e2:SetTarget(c17377751.sptg)
e2:SetOperation(c17377751.spop)
c:RegisterEffect(e2)
end
function c17377751.spcon(e,tp,eg,ep,ev,re,r,rp,chk)
return e:GetHandler():GetSummonType()==SUMMON_TYPE_SYNCHRO
end
function c17377751.filter(c,e,tp)
return not c:IsType(TYPE_TUNER) and c:IsLevelBelow(4) and c:IsSetCard(0x33) and c:IsCanBeSpecialSummoned(e,0,tp,false,true)
end
function c17377751.sptg(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingMatchingCard(c17377751.filter,tp,LOCATION_HAND,0,1,nil,e,tp) end
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,nil,1,tp,LOCATION_HAND)
end
function c17377751.spop(e,tp,eg,ep,ev,re,r,rp)
if Duel.GetLocationCount(tp,LOCATION_MZONE)<=0 then return end
local g=Duel.SelectMatchingCard(tp,c17377751.filter,tp,LOCATION_HAND,0,1,1,nil,e,tp)
local tc=g:GetFirst()
if tc and Duel.SpecialSummonStep(tc,0,tp,tp,false,true,POS_FACEUP) then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(EFFECT_DISABLE)
e1:SetReset(RESET_EVENT+0x1fe0000)
tc:RegisterEffect(e1,true)
local e2=Effect.CreateEffect(e:GetHandler())
e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetCode(EFFECT_DISABLE_EFFECT)
e2:SetReset(RESET_EVENT+0x1fe0000)
tc:RegisterEffect(e2,true)
Duel.SpecialSummonComplete()
end
end
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