Re: Card Creation Request Thread
Posted: 01 Nov 2014, 19:20
A possible way to do this is to loop through the top 3 cards and see how many instants or sorceries are there, then you use that number for SetPortion. I'm trying to write some code, but I can't guarantee its correctness since I'm not used to DotP2012 anymore, I hope you get the idea anyway:NEMESiS wrote:Thefiremind had the right idea of first creating a section where we just look at the top 3 cards, after that we make a distinction of just being able to get instants and sorceries from among then. I am having issues making that distinction.
- Code: Select all
local instants_or_sorceries = 0
for i=0,2 do
local card = Object():GetPlayer():Library_GetNth(i)
if card ~= nil and (card:GetCardType():Test( CARD_TYPE_SORCERY ) ~= 0 or card:GetCardType():Test( CARD_TYPE_INSTANT ) ~= 0) then
instants_or_sorceries = instants_or_sorceries + 1
end
end
if instants_or_sorceries > 0 then
local filter = Object():GetFilter()
filter:Clear()
filter:NotTargetted()
filter:SetPlayer( Object():GetPlayer() )
filter:SetZone( ZONE_LIBRARY )
filter:SetPortion( instants_or_sorceries )
filter:AddCardType( CARD_TYPE_SORCERY )
filter:AddCardType( CARD_TYPE_INSTANT )
ChooseTarget( "CARD_QUERY_CHOOSE_INSTANT_OR_SORCERY_TO_PUT_INTO_HAND" )
end