Commit 3d7a07db authored by nanahira's avatar nanahira

support multi pools

parent 6a222e91
os=require("os") os=require("os")
io=require("io") io=require("io")
--globals --globals
local main={} local main={[0]={},[1]={}}
local extra={} local extra={[0]={},[1]={}}
local main_monster={} local main_monster={[0]={},[1]={}}
local main_spell={} local main_spell={[0]={},[1]={}}
local main_trap={} local main_trap={[0]={},[1]={}}
local main_plain={} local main_plain={[0]={},[1]={}}
local main_adv={} local main_adv={[0]={},[1]={}}
local extra_sp={ local extra_sp={
[TYPE_FUSION]={}, [TYPE_FUSION]={[0]={},[1]={}},
[TYPE_SYNCHRO]={}, [TYPE_SYNCHRO]={[0]={},[1]={}},
[TYPE_XYZ]={}, [TYPE_XYZ]={[0]={},[1]={}},
[TYPE_LINK]={}, [TYPE_LINK]={[0]={},[1]={}},
} }
function Auxiliary.SplitData(inputstr) function Auxiliary.SplitData(inputstr)
...@@ -25,37 +25,43 @@ function Auxiliary.SplitData(inputstr) ...@@ -25,37 +25,43 @@ function Auxiliary.SplitData(inputstr)
end end
return t return t
end end
function Auxiliary.LoadDB() function Auxiliary.LoadDB(p,pool)
os.execute("sqlite3 2pick/2pick.cdb < 2pick/sqlite_cmd.txt") os.execute("sqlite3 2pick/"..pool.."/card_pool.cdb < 2pick/"..pool.."/sqlite_cmd.txt")
for line in io.lines("card_list.txt") do for line in io.lines("card_list_"..pool..".txt") do
local data=Auxiliary.SplitData(line) local data=Auxiliary.SplitData(line)
local code=data[1] local code=data[1]
local cat=data[5] local cat=data[5]
local lv=data[8] local lv=data[8]
if (cat & TYPE_FUSION+TYPE_SYNCHRO+TYPE_XYZ+TYPE_LINK)>0 then if (cat & TYPE_FUSION+TYPE_SYNCHRO+TYPE_XYZ+TYPE_LINK)>0 then
table.insert(extra,code) table.insert(extra[p],code)
for tp,list in pairs(extra_sp) do for tp,list in pairs(extra_sp[p]) do
if (cat & tp)>0 then if (cat & tp)>0 then
table.insert(list,code) table.insert(list,code)
end end
end end
elseif (cat & TYPE_TOKEN)==0 then elseif (cat & TYPE_TOKEN)==0 then
if (cat & TYPE_MONSTER)>0 then if (cat & TYPE_MONSTER)>0 then
table.insert(main_monster,code) table.insert(main_monster[p],code)
if lv>5 then if lv>5 then
table.insert(main_adv,code) table.insert(main_adv[p],code)
else else
table.insert(main_plain,code) table.insert(main_plain[p],code)
end end
elseif (cat & TYPE_SPELL)>0 then elseif (cat & TYPE_SPELL)>0 then
table.insert(main_spell,code) table.insert(main_spell[p],code)
elseif (cat & TYPE_TRAP)>0 then elseif (cat & TYPE_TRAP)>0 then
table.insert(main_trap,code) table.insert(main_trap[p],code)
end end
table.insert(main,code) table.insert(main[p],code)
end end
end end
end end
--to do: multi card pools
function Auxiliary.LoadCardPools()
for p=0,1 do
Auxiliary.LoadDB(p,"default")
end
end
function Auxiliary.SaveDeck() function Auxiliary.SaveDeck()
for p=0,1 do for p=0,1 do
...@@ -93,14 +99,16 @@ function Auxiliary.SinglePickForMain(p,list,count,ex_list,ex_count) ...@@ -93,14 +99,16 @@ function Auxiliary.SinglePickForMain(p,list,count,ex_list,ex_count)
if not Duel.IsPlayerNeedToPickDeck(p) then return end if not Duel.IsPlayerNeedToPickDeck(p) then return end
local g1=Group.CreateGroup() local g1=Group.CreateGroup()
local g2=Group.CreateGroup() local g2=Group.CreateGroup()
local plist=list[p]
for _,g in ipairs({g1,g2}) do for _,g in ipairs({g1,g2}) do
for i=1,count do for i=1,count do
local code=list[math.random(#list)] local code=plist[math.random(#plist)]
g:AddCard(Duel.CreateToken(p,code)) g:AddCard(Duel.CreateToken(p,code))
end end
if ex_list and ex_count then if ex_list and ex_count then
local ex_plist=ex_list[p]
for i=1,ex_count do for i=1,ex_count do
local code=ex_list[math.random(#ex_list)] local code=ex_plist[math.random(#ex_plist)]
g:AddCard(Duel.CreateToken(p,code)) g:AddCard(Duel.CreateToken(p,code))
end end
end end
...@@ -174,7 +182,7 @@ function Auxiliary.StartPick(e) ...@@ -174,7 +182,7 @@ function Auxiliary.StartPick(e)
end end
function Auxiliary.Load2PickRule() function Auxiliary.Load2PickRule()
Auxiliary.LoadDB() Auxiliary.LoadCardPools()
local e1=Effect.GlobalEffect() local e1=Effect.GlobalEffect()
e1:SetType(EFFECT_TYPE_FIELD | EFFECT_TYPE_CONTINUOUS) e1:SetType(EFFECT_TYPE_FIELD | EFFECT_TYPE_CONTINUOUS)
e1:SetCode(EVENT_ADJUST) e1:SetCode(EVENT_ADJUST)
......
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