I hadn't yet tested it. I noticed a number of issues but I think I got them all fixed, along with splitting it into two functions. However, I still can't manage a test which confirms a change in cost. How did you manage that Neo? (Note: I AM using the two pieces of code you just posted.) I'm not getting any errors, it but the cost function always return 0. Since you didn't post the code cut up into 2 functions, I'll post my version.
That leads to a useful question: how do you guys debug your code? Because the only way I know to do it is to put in something like GainLife(VariableToDebug). That's really clunky, though. Is there a better way?
- | Open
- Code: Select all
ABILITIES_ACTIVE = 909001
GetColorlessCostModification = function(oTarget)
-- Returns an integer number for how much oModifier modifies oTarget's colorless mana most
if ( oTarget == nil ) then
return 0
end
local iMod = 0
local filter = ClearFilter()
local subfilter = filter:AddSubFilter_Or()
subfilter:Add( FE_TYPE, OP_IS, CARD_TYPE_ARTIFACT )
subfilter:Add( FE_TYPE, OP_IS, CARD_TYPE_CREATURE )
subfilter:Add( FE_TYPE, OP_IS, CARD_TYPE_ENCHANTMENT )
subfilter:Add( FE_TYPE, OP_IS, CARD_TYPE_LAND )
subfilter:Add( FE_TYPE, OP_IS, CARD_TYPE_PLANESWALKER )
local Count = filter:Count()
for i=0,(Count-1) do
local oModifier = filter:GetNthEvaluatedObject(i)
if ( oModifier ~= nil and ( oModifier ~= oTarget ) and RSN_Characteristics_Get( oModifier, ABILITIES_ACTIVE ) ) then
iMod = iMod + GetColorlessCostModificationTargeted(oTarget, oModifier)
end
end
return iMod
end
GetColorlessCostModificationTargeted = function(oTarget, oModifier)
if ( oTarget == nil or oModifier == nil or ( RSN_Characteristics_Get( oModifier, ABILITIES_ACTIVE ) == false ) ) then
return 0
end
local sName = oModifier:GetCardName()
local bYours = ( oModifier:GetController() == oTarget:GetController() )
if ( bYours ) then
if ( sName == "ANIMAR_SOUL_OF_ELEMENTS" and oTarget:GetCardType():Test(CARD_TYPE_CREATURE) ) then
return oModifier:CountCounters(MTG():PlusOnePlusOneCounters())*-1
elseif ( sName == "BALLYRUSH_BANNERET" and ( oTarget:GetSubType():Test(CREATURE_TYPE_KITHKIN) or oTarget:GetSubType():Test(CREATURE_TYPE_SOLDIER) ) ) then
return -1
elseif ( sName == "BLOOD_FUNNEL" and ( oTarget:GetCardType():Test(CARD_TYPE_CREATURE) == false ) ) then
return -2
elseif ( sName == "BOSK_BANNERET" and ( oTarget:GetSubType():Test(CREATURE_TYPE_TREEFOLK) or oTarget:GetSubType():Test(CREATURE_TYPE_SHAMAN) ) ) then
return -1
elseif ( sName == "BRIGHTHEARTH_BANNERET" and ( oTarget:GetSubType():Test(CREATURE_TYPE_ELEMENTAL) or oTarget:GetSubType():Test(CREATURE_TYPE_WARRIOR) ) ) then
return -1
elseif ( sName == "CENTAUR_OMENREADER" and oModifier:IsTapped() and oTarget:GetCardType():Test(CARD_TYPE_CREATURE) ) then
return -2
-- elseif ( sName == "CLOUD_KEY" and !!!CHOSEN_TYPE!!!) then
-- return -1
-- elseif ( sName == "COUNCIL_OF_THE_ABSOLUTE" and !!!CHOSEN_NAME!!!) then
-- return -2
elseif ( sName == "DARU_WARCHIEF" and oTarget:GetSubType():Test(CREATURE_TYPE_SOLDIER) ) then
return -1
elseif ( sName == "DRAGONSPEAKER_SHAMAN" and oTarget:GetSubType():Test(CREATURE_TYPE_DRAGON) ) then
return -2
-- elseif ( sName == "DREAM_CHISEL" and oTarget:GetCardType():Test(CARD_TYPE_CREATURE) and !!!FACE_DOWN!!! ) then
-- return -1
elseif ( sName == "EMERALD_MEDALLION" and oTarget:GetColour():Test(COLOUR_GREEN) ) then
return -1
elseif ( sName == "ETHERIUM_SCULPTOR" and oTarget:GetCardType():Test(CARD_TYPE_ARTIFACT) ) then
return -1
elseif ( sName == "EYE_OF_UGIN" and oTarget:GetSubType():Test(GetColour():Test(COLOUR_COLOURLESS) and oTarget:GetSubType():Test(CREATURE_TYPE_ELDRAZI) ) ) then
return -2
elseif ( sName == "FROGTOSSER_BANNERET" and ( oTarget:GetSubType():Test(CREATURE_TYPE_GOBLIN) or oTarget:GetSubType():Test(CREATURE_TYPE_ROGUE) ) ) then
return -1
elseif ( sName == "GOBLIN_ELECTROMANCER" and ( oTarget:GetCardType():Test(CARD_TYPE_INSTANT) or oTarget:GetCardType():Test(CARD_TYPE_SORCERY) ) ) then
return -1
elseif ( sName == "GOBLIN_WARCHIEF" and oTarget:GetSubType():Test(CREATURE_TYPE_GOBLIN) ) then
return -1
elseif ( sName == "GRAND_ARBITER_AUGUSTIN_IV" and oTarget:GetColour():Test(COLOUR_BLUE) and oTarget:GetColour():Test(COLOUR_WHITE) ) then
return -2
elseif ( sName == "GRAND_ARBITER_AUGUSTIN_IV" and oTarget:GetColour():Test(COLOUR_BLUE) ) then
return -1
elseif ( sName == "GRAND_ARBITER_AUGUSTIN_IV" and oTarget:GetColour():Test(COLOUR_WHITE) ) then
return -1
elseif ( sName == "HEARTLESS_SUMMONING" and oTarget:GetCardType():Test(CARD_TYPE_CREATURE) ) then
return -2
elseif ( sName == "HERALD_OF_WAR" and ( oTarget:GetSubType():Test(CREATURE_TYPE_ANGEL) or oTarget:GetSubType():Test(CREATURE_TYPE_HUMAN) ) ) then
return oModifier:CountCounters(MTG():PlusOnePlusOneCounters())*-1
elseif ( sName == "HERO_OF_IROAS" and oTarget:GetSubType():Test(ENCHANTMENT_TYPE_AURA) ) then
return -1
elseif ( sName == "JET_MEDALLION" and oTarget:GetColour():Test(COLOUR_BLACK) ) then
return -1
elseif ( sName == "KROSAN_DROVER" and oTarget:GetCardType():Test(CARD_TYPE_CREATURE) and oTarget:GetConvertedManaCost() >= 6 ) then
return -2
elseif ( sName == "KROSAN_WARCHIEF" and oTarget:GetSubType():Test(CREATURE_TYPE_BEAST) ) then
return -1
elseif ( sName == "LOCKET_OF_YESTERDAYS" ) then
local filter = ClearFilter()
filter:Add(FE_CARD_NAME, OP_IS, oTarget:GetCardName())
filter:Add(FE_CARD_INSTANCE, OP_NOT, oTarget)
filter:SetZone( ZONE_GRAVEYARD, EffectController() )
return filter:Count()*-1
-- elseif ( sName == "LONG_FORGOTTEN_GOHEI" and !!!SUBTYPE_ARCANE!!! ) then
-- return -1
elseif ( sName == "MANA_MATRIX" and ( oTarget:GetCardType():Test(CARD_TYPE_INSTANT) or oTarget:GetCardType():Test(CARD_TYPE_ENCHANTMENT) ) ) then
return -2
-- elseif ( sName == "MISTFORM_WARCHIEF" and oTarget:GetCardType():Test(CARD_TYPE_CREATURE) and !!!SHARES_A_TYPE_WITH_oModifier!!!) then
-- return -1
elseif ( sName == "MYCOSYNTH_GOLEM" and oTarget:GetCardType():Test(CARD_TYPE_ARTIFACT) and oTarget:GetCardType():Test(CARD_TYPE_CREATURE) ) then
local filter = ClearFilter()
filter:Add( FE_TYPE, OP_IS, CARD_TYPE_ARTIFACT )
filter:Add( FE_CONTROLLER, OP_IS, oTarget:GetController() )
return filter:Count()*-1
elseif ( sName == "NIGHTSCAPE_FAMILIAR" and ( oTarget:GetColour():Test(COLOUR_BLUE) or oTarget:GetColour():Test(COLOUR_RED) ) ) then
return -1
elseif ( sName == "PEARL_MEDALLION" and oTarget:GetColour():Test(COLOUR_WHITE) ) then
return -1
elseif ( sName == "PLANAR_GATE" and oTarget:GetCardType():Test(CARD_TYPE_CREATURE) ) then
return -2
elseif ( sName == "RAKDOS_LORD_OF_RIOTS" and oTarget:GetCardType():Test(CARD_TYPE_CREATURE)) then
local num_starting_players = MTG():GetNumberOfStartingPlayers()
local life_lost = 0
for i=0,(num_starting_players-1) do
local player = MTG():GetNthStartingPlayer(i)
if (player ~= nil and player:GetTeam() ~= EffectController():GetTeam()) then
local interrogation = MTG():ClearInterrogationQuery()
interrogation:SetPlayer(player)
life_lost = life_lost + interrogation:Count( INTERROGATE_LIFE_LOST, INTERROGATE_THIS_TURN )
end
end
return life_lost*-1
elseif ( sName == "RUBY_MEDALLION" and oTarget:GetColour():Test(COLOUR_RED) ) then
return -1
elseif ( sName == "SAPPHIRE_MEDALLION" and oTarget:GetColour():Test(COLOUR_BLUE) ) then
return -1
-- elseif ( sName == "SEMBLANCE_ANVIL" and !!!SHARES_TYPE_WITH_EXILED_CARD!!! ) then
-- return -2
elseif ( sName == "STINKDRINKER_DAREDEVIL" and oTarget:GetSubType():Test(CREATURE_TYPE_GIANT) ) then
return -2
elseif ( sName == "STONE_CALENDAR" ) then
return -1
elseif ( sName == "STONYBROOK_BANNERET" and ( oTarget:GetSubType():Test(CREATURE_TYPE_MERFOLK) or oTarget:GetSubType():Test(CREATURE_TYPE_WIZARD) ) ) then
return -1
elseif ( sName == "STORMSCAPE_FAMILIAR" and ( oTarget:GetColour():Test(COLOUR_WHITE) or oTarget:GetColour():Test(COLOUR_BLACK) ) ) then
return -1
elseif ( sName == "SUNSCAPE_FAMILIAR" and ( oTarget:GetColour():Test(COLOUR_GREEN) or oTarget:GetColour():Test(COLOUR_BLUE) ) ) then
return -1
elseif ( sName == "THORNSCAPE_FAMILIAR" and ( oTarget:GetColour():Test(COLOUR_RED) or oTarget:GetColour():Test(COLOUR_WHITE) ) ) then
return -1
elseif ( sName == "THUNDERSCAPE_FAMILIAR" and ( oTarget:GetColour():Test(COLOUR_BLACK) or oTarget:GetColour():Test(COLOUR_GREEN) ) ) then
return -1
elseif ( sName == "UNDEAD_WARCHIEF" and oTarget:GetSubType():Test(CREATURE_TYPE_ZOMBIE) ) then
return -1
elseif ( sName == "WARDEN_OF_EVOS_ISLE" and oTarget:GetCardType():Test(CARD_TYPE_CREATURE) and oTarget:GetCurrentCharacteristics():Test(CHARACTERISTIC_FLYING) ) then
return -1
end
else
if ( sName == "AURA_OF_SILENCE" and ( oTarget:GetCardType():Test(CARD_TYPE_ARTIFACT) or oTarget:GetCardType():Test(CARD_TYPE_ENCHANTMENT) ) ) then
return 2
elseif ( sName == "GRAND_ARBITER_AUGUSTIN_IV" ) then
return 1
end
end
if ( sName == "ARCANE_MELEE" and ( oTarget:GetCardType():Test(CARD_TYPE_INSTANT) or oTarget:GetCardType():Test(CARD_TYPE_SORCERY) ) ) then
return -2
elseif ( sName == "CHILL" and oTarget:GetColour():Test(COLOUR_RED) ) then
return 2
elseif ( sName == "DEFENSE_GRID" and ( oTarget:GetController():MyTurn() == False ) ) then
return 3
elseif ( sName == "FEROZS_BAN" and oTarget:GetCardType():Test(CARD_TYPE_CREATURE) ) then
return 2
elseif ( sName == "GLOOM" and oTarget:GetColour():Test(COLOUR_WHITE) ) then
return 3
elseif ( sName == "GLOWRIDER" and ( oTarget:GetCardType():Test(CARD_TYPE_CREATURE) == false ) ) then
return 1
elseif ( sName == "HELM_OF_AWAKENING" ) then
return -1
elseif ( sName == "HIGH_SEAS" and oTarget:GetCardType():Test(CARD_TYPE_CREATURE) and ( oTarget:GetColour():Test(COLOUR_RED) or oTarget:GetColour():Test(COLOUR_GREEN) ) ) then
return 1
elseif ( sName == "HUM_OF_THE_RADIX" and oTarget:GetCardType():Test(CARD_TYPE_ARTIFACT) ) then
local filter = ClearFilter()
filter:Add( FE_TYPE, OP_IS, CARD_TYPE_ARTIFACT )
filter:Add( FE_CONTROLLER, OP_IS, oTarget:GetController() )
return filter:Count()
elseif ( sName == "IRINI_SENGIR" and oTarget:GetCardType():Test(CARD_TYPE_ENCHANTMENT) and ( oTarget:GetColour():Test(COLOUR_GREEN) or oTarget:GetColour():Test(COLOUR_WHITE) ) ) then
return 2
elseif ( sName == "LODESTONE_GOLEM" and ( oTarget:GetCardType():Test(CARD_TYPE_ARTIFACT) == false ) ) then
return 1
elseif ( sName == "SPHERE_OF_RESISTANCE" ) then
return 1
elseif ( sName == "SQUEEZE" and oTarget:GetCardType():Test(CARD_TYPE_SORCERY) ) then
return 3
elseif ( sName == "THALIA_GUARDIAN_OF_THRABEN" and ( oTarget:GetCardType():Test(CARD_TYPE_CREATURE) == false ) ) then
return 1
elseif ( sName == "THORN_OF_AMETHYST" and ( oTarget:GetCardType():Test(CARD_TYPE_CREATURE) == false ) ) then
return 1
elseif ( sName == "URZAS_FILTER" and oTarget:GetColour():GetNumColours() > 1 ) then
return -2
-- elseif ( sName == "URZAS_INCUBATOR" and !!!CHOSEN_SUBTYPE!!! ) then
-- return -2
end
end
Note that this does not work. I've narrowed it down to a section in the first function. Count is correct and the for loop runs correctly. However, oModified always seems to be nil and "RSN_Characteristics_Get( oModifier, ABILITIES_ACTIVE )" never seems to be true or false (I checked both, I did NOT check nil), but the cards DO have the text showing.
EDIT:
NVM. If you've got it, Neo, that's good enough for me. As for which would be better, I would go with whichever is most reliable. Alternative should be acceptable.