It is currently 30 Apr 2024, 06:35
   
Text Size

CONVOKE - Alpha version

Moderator: CCGHQ Admins

CONVOKE - Alpha version

Postby NeoAnderson » 09 Oct 2014, 17:15

Starting from Delve approximation made by me, I tried to adapt the concept to the most complex CONVOKE ability.
Until now i get a partial working version but surely it still have something need to be fixed.

I release here an alpha version for testing purpose so i can receive also your suggestions and feedback.
Please don't use this version to code other cards it is not finished.


I have removed any download link because i released a test pack with an ability manager REV 1.0.
You can download it here : MTG - CONVOKE-CARDS PACK 32 CARDS


UPDATE :
CHANGELOG Ver. 0.3 :
Added Mana Functions for colored cost variation
Now is compliant with the follow cards :
Andradite Leech - Derelor - Jade Leech - Ruby Leech - Sapphire Leech - Alabaster Leech - Ragemonger - Edgewalker


IMPORTANT!! TO USE THIS VERSION YOU NEED :
Riiak ManualMana Functions
Riiak ObjectDC Functions
Riiak Characteristics Functions
Last edited by NeoAnderson on 21 Oct 2014, 00:44, edited 1 time in total.
NeoAnderson
 
Posts: 914
Joined: 10 Sep 2013, 07:49
Has thanked: 18 times
Been thanked: 139 times

Re: CONVOKE - Alpha version

Postby Xander9009 » 10 Oct 2014, 16:09

I tested it against Krufa (for a turn 6 win, even) in a deck of white/colorless creatures that cost 1 or 0. The only I noticed that seemed a little off was that when I tap an artifact creature (and I assume this would be true for creature that don't share a color), it asks which color to produce. For creatures that don't share a color, I don't imagine a red creature would be allowed to reduce a white convoke creature's cost by {R}, but technically as it's worded, that's not an impossibility (you'd just be tapping the creature but it would do nothing). I would suggest making it a bit more streamlined and making it only allowed to produce colors it shares with the convoke creature (which might be the case already, like I said, I didn't test it with other colored creatures), and if there's only one possibility (colorless), then don't ask, just produce the color.

However, that's all for ease of use and has nothing to do with whether or not it worked. I saw nothing behaving strangely. Nicely done :)

As for Jade Leech and the like, the function for obtaining the colorless cost could be converted to obtain a specific color's cost (except possibly with dual mana costs like with Slippery Bogle), couldn't it? If you think it could and would want to try it, I'll throw together the base of the code like I did for the colorless version if you want.
_______________________________
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
User avatar
Xander9009
Programmer
 
Posts: 2905
Joined: 29 Jun 2013, 07:44
Location: Indiana, United States
Has thanked: 121 times
Been thanked: 445 times

Re: CONVOKE - Alpha version

Postby NeoAnderson » 10 Oct 2014, 17:13

Xander9009 wrote:I tested it against Krufa (for a turn 6 win, even) in a deck of white/colorless creatures that cost 1 or 0. The only I noticed that seemed a little off was that when I tap an artifact creature (and I assume this would be true for creature that don't share a color), it asks which color to produce. For creatures that don't share a color, I don't imagine a red creature would be allowed to reduce a white convoke creature's cost by {R}, but technically as it's worded, that's not an impossibility (you'd just be tapping the creature but it would do nothing). I would suggest making it a bit more streamlined and making it only allowed to produce colors it shares with the convoke creature (which might be the case already, like I said, I didn't test it with other colored creatures), and if there's only one possibility (colorless), then don't ask, just produce the color.

However, that's all for ease of use and has nothing to do with whether or not it worked. I saw nothing behaving strangely. Nicely done :)

As for Jade Leech and the like, the function for obtaining the colorless cost could be converted to obtain a specific color's cost (except possibly with dual mana costs like with Slippery Bogle), couldn't it? If you think it could and would want to try it, I'll throw together the base of the code like I did for the colorless version if you want.
Xander my friend,
1. About the colour production, the card is allowed as by rules to produce one of its colour or colouless mana, anyway inside the convoke card code there is a check if the color produced is not inside the cost it will be used to reduce colourless cost.

2. About the function for colour cost change i already made it and i am also using, i started from our colourless function! :wink:
Anyway i found only few cards that can change colour cost.
here you can see that functions :
COLOUR COST CHANGE FUNCTIONS | Open
Code: Select all
UpdateWhiteCostValue = function(oTarget)
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:EvaluateObjects()
      local iMod = 0
      for i=0,(Count-1) do
         local Card = filter:GetNthEvaluatedObject(i)
         if Card ~= nil and RSN_Characteristics_GetInt( Card, NEO_ABILITIES_ACTIVE ) == 1 then
            iMod = iMod + GetWhiteCostModification(oTarget, Card)
         end
      end
      return iMod
end

GetWhiteCostModification = function(oTarget, oModifier)
-- Returns an integer number for how much oModifier modifies oTarget's colorless mana most
if oModifier ~= nil then
   local sName = oModifier:GetCardName()
   local CostChange = 0
   if oModifier:GetController() == oTarget:GetController() then
      if ( sName == "ALABASTER_LEECH" and oTarget:GetColour():Test(COLOUR_WHITE) ) then
         return 1
      end
   end
end
return 0
end

UpdateBlueCostValue = function(oTarget)
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:EvaluateObjects()
      local iMod = 0
      for i=0,(Count-1) do
         local Card = filter:GetNthEvaluatedObject(i)
         if Card ~= nil and RSN_Characteristics_GetInt( Card, NEO_ABILITIES_ACTIVE ) == 1 then
            iMod = iMod + GetBlueCostModification(oTarget, Card)
         end
      end
      return iMod
end

GetBlueCostModification = function(oTarget, oModifier)
-- Returns an integer number for how much oModifier modifies oTarget's colorless mana most
if oModifier ~= nil then
   local sName = oModifier:GetCardName()
   local CostChange = 0
   if oModifier:GetController() == oTarget:GetController() then
      if ( sName == "SAPPHIRE_LEECH" and oTarget:GetColour():Test(COLOUR_BLUE) ) then
         return 1
      end
   end
end
return 0
end

UpdateBlackCostValue = function(oTarget)
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:EvaluateObjects()
      local iMod = 0
      for i=0,(Count-1) do
         local Card = filter:GetNthEvaluatedObject(i)
         if Card ~= nil and RSN_Characteristics_GetInt( Card, NEO_ABILITIES_ACTIVE ) == 1 then
            iMod = iMod + GetBlackCostModification(oTarget, Card)
         end
      end
      return iMod
end

GetBlackCostModification = function(oTarget, oModifier)
-- Returns an integer number for how much oModifier modifies oTarget's colorless mana most
if oModifier ~= nil then
   local sName = oModifier:GetCardName()
   local CostChange = 0
   if oModifier:GetController() == oTarget:GetController() then
      if ( sName == "ANDRADITE_LEECH" and oTarget:GetColour():Test(COLOUR_BLACK) ) then
         return 1
      elseif ( sName == "DERELOR" and oTarget:GetColour():Test(COLOUR_BLACK) ) then
         return 1
      elseif ( sName == "RAGEMONGER" and oTarget:GetSubType():Test(CREATURE_TYPE_MINOTAUR) ) then
         return -1
      elseif ( sName == "EDGEWALKER" and oTarget:GetSubType():Test(CREATURE_TYPE_CLERIC) ) then
         return -1     
      end
   end
end
return 0
end


UpdateRedCostValue = function(oTarget)
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:EvaluateObjects()
      local iMod = 0
      for i=0,(Count-1) do
         local Card = filter:GetNthEvaluatedObject(i)
         if Card ~= nil and RSN_Characteristics_GetInt( Card, NEO_ABILITIES_ACTIVE ) == 1 then
            iMod = iMod + GetRedCostModification(oTarget, Card)
         end
      end
      return iMod
end

GetRedCostModification = function(oTarget, oModifier)
-- Returns an integer number for how much oModifier modifies oTarget's colorless mana most
if oModifier ~= nil then
   local sName = oModifier:GetCardName()
   local CostChange = 0
   if oModifier:GetController() == oTarget:GetController() then
      if ( sName == "RUBY_LEECH" and oTarget:GetColour():Test(COLOUR_RED) ) then
         return 1
      elseif ( sName == "RAGEMONGER" and oTarget:GetSubType():Test(CREATURE_TYPE_MINOTAUR) ) then
         return -1
      elseif ( sName == "EDGEWALKER" and oTarget:GetSubType():Test(CREATURE_TYPE_CLERIC) ) then
         return -1   
      end
   end
end
return 0
end


UpdateGreenCostValue = function(oTarget)
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:EvaluateObjects()
      local iMod = 0
      for i=0,(Count-1) do
         local Card = filter:GetNthEvaluatedObject(i)
         if Card ~= nil and RSN_Characteristics_GetInt( Card, NEO_ABILITIES_ACTIVE ) == 1 then
            iMod = iMod + GetGreenCostModification(oTarget, Card)
         end
      end
      return iMod
end

GetGreenCostModification = function(oTarget, oModifier)
-- Returns an integer number for how much oModifier modifies oTarget's colorless mana most
if oModifier ~= nil then
   local sName = oModifier:GetCardName()
   local CostChange = 0
   if oModifier:GetController() == oTarget:GetController() then
      if ( sName == "JADE_LEECH" and oTarget:GetColour():Test(COLOUR_GREEN) ) then
         return 1
      end
   end
end
return 0
end
NeoAnderson
 
Posts: 914
Joined: 10 Sep 2013, 07:49
Has thanked: 18 times
Been thanked: 139 times

Re: CONVOKE - Alpha version

Postby Xander9009 » 10 Oct 2014, 18:01

NeoAnderson wrote:Xander my friend,
1. About the colour production, the card is allowed as by rules to produce one of its colour or colouless mana, anyway inside the convoke card code there is a check if the color produced is not inside the cost it will be used to reduce colourless cost.
The reminder text is misleading. Here, assuming they're correct, in the first rule listed, it says the creature can only be tapped to reduce the colored cost if they share a color. So a Ragin Goblin cannot be tapped for {R} even though the reminder text suggests it might be. It may only be tapped for {1}. So, a Raging Goblin being tapped for the convoke ability on Conclave Equenaut should only have the option for {1}. It doesn't matter so much because of the fact that your code accounts for this, but it would make using the ability much smoother (and still rule compliant, despite what the reminder text suggests).

NeoAnderson wrote:2. About the function for colour cost change i already made it and i am also using, i started from our colourless function! :wink:
Anyway i found only few cards that can change colour cost.
here you can see that functions :
COLOUR COST CHANGE FUNCTIONS | Open
Code: Select all
UpdateWhiteCostValue = function(oTarget)
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:EvaluateObjects()
      local iMod = 0
      for i=0,(Count-1) do
         local Card = filter:GetNthEvaluatedObject(i)
         if Card ~= nil and RSN_Characteristics_GetInt( Card, NEO_ABILITIES_ACTIVE ) == 1 then
            iMod = iMod + GetWhiteCostModification(oTarget, Card)
         end
      end
      return iMod
end

GetWhiteCostModification = function(oTarget, oModifier)
-- Returns an integer number for how much oModifier modifies oTarget's colorless mana most
if oModifier ~= nil then
   local sName = oModifier:GetCardName()
   local CostChange = 0
   if oModifier:GetController() == oTarget:GetController() then
      if ( sName == "ALABASTER_LEECH" and oTarget:GetColour():Test(COLOUR_WHITE) ) then
         return 1
      end
   end
end
return 0
end

UpdateBlueCostValue = function(oTarget)
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:EvaluateObjects()
      local iMod = 0
      for i=0,(Count-1) do
         local Card = filter:GetNthEvaluatedObject(i)
         if Card ~= nil and RSN_Characteristics_GetInt( Card, NEO_ABILITIES_ACTIVE ) == 1 then
            iMod = iMod + GetBlueCostModification(oTarget, Card)
         end
      end
      return iMod
end

GetBlueCostModification = function(oTarget, oModifier)
-- Returns an integer number for how much oModifier modifies oTarget's colorless mana most
if oModifier ~= nil then
   local sName = oModifier:GetCardName()
   local CostChange = 0
   if oModifier:GetController() == oTarget:GetController() then
      if ( sName == "SAPPHIRE_LEECH" and oTarget:GetColour():Test(COLOUR_BLUE) ) then
         return 1
      end
   end
end
return 0
end

UpdateBlackCostValue = function(oTarget)
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:EvaluateObjects()
      local iMod = 0
      for i=0,(Count-1) do
         local Card = filter:GetNthEvaluatedObject(i)
         if Card ~= nil and RSN_Characteristics_GetInt( Card, NEO_ABILITIES_ACTIVE ) == 1 then
            iMod = iMod + GetBlackCostModification(oTarget, Card)
         end
      end
      return iMod
end

GetBlackCostModification = function(oTarget, oModifier)
-- Returns an integer number for how much oModifier modifies oTarget's colorless mana most
if oModifier ~= nil then
   local sName = oModifier:GetCardName()
   local CostChange = 0
   if oModifier:GetController() == oTarget:GetController() then
      if ( sName == "ANDRADITE_LEECH" and oTarget:GetColour():Test(COLOUR_BLACK) ) then
         return 1
      elseif ( sName == "DERELOR" and oTarget:GetColour():Test(COLOUR_BLACK) ) then
         return 1
      elseif ( sName == "RAGEMONGER" and oTarget:GetSubType():Test(CREATURE_TYPE_MINOTAUR) ) then
         return -1
      elseif ( sName == "EDGEWALKER" and oTarget:GetSubType():Test(CREATURE_TYPE_CLERIC) ) then
         return -1     
      end
   end
end
return 0
end


UpdateRedCostValue = function(oTarget)
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:EvaluateObjects()
      local iMod = 0
      for i=0,(Count-1) do
         local Card = filter:GetNthEvaluatedObject(i)
         if Card ~= nil and RSN_Characteristics_GetInt( Card, NEO_ABILITIES_ACTIVE ) == 1 then
            iMod = iMod + GetRedCostModification(oTarget, Card)
         end
      end
      return iMod
end

GetRedCostModification = function(oTarget, oModifier)
-- Returns an integer number for how much oModifier modifies oTarget's colorless mana most
if oModifier ~= nil then
   local sName = oModifier:GetCardName()
   local CostChange = 0
   if oModifier:GetController() == oTarget:GetController() then
      if ( sName == "RUBY_LEECH" and oTarget:GetColour():Test(COLOUR_RED) ) then
         return 1
      elseif ( sName == "RAGEMONGER" and oTarget:GetSubType():Test(CREATURE_TYPE_MINOTAUR) ) then
         return -1
      elseif ( sName == "EDGEWALKER" and oTarget:GetSubType():Test(CREATURE_TYPE_CLERIC) ) then
         return -1   
      end
   end
end
return 0
end


UpdateGreenCostValue = function(oTarget)
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:EvaluateObjects()
      local iMod = 0
      for i=0,(Count-1) do
         local Card = filter:GetNthEvaluatedObject(i)
         if Card ~= nil and RSN_Characteristics_GetInt( Card, NEO_ABILITIES_ACTIVE ) == 1 then
            iMod = iMod + GetGreenCostModification(oTarget, Card)
         end
      end
      return iMod
end

GetGreenCostModification = function(oTarget, oModifier)
-- Returns an integer number for how much oModifier modifies oTarget's colorless mana most
if oModifier ~= nil then
   local sName = oModifier:GetCardName()
   local CostChange = 0
   if oModifier:GetController() == oTarget:GetController() then
      if ( sName == "JADE_LEECH" and oTarget:GetColour():Test(COLOUR_GREEN) ) then
         return 1
      end
   end
end
return 0
end
Ah. I misread your post. I thought it said it was NOT compliant with those cards. My mistake :)

I'm really happy with this. There are a lot of cards that use convoke, especially newer ones, and the more cards we can code, the better! Thank you :)
_______________________________
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
User avatar
Xander9009
Programmer
 
Posts: 2905
Joined: 29 Jun 2013, 07:44
Location: Indiana, United States
Has thanked: 121 times
Been thanked: 445 times

Re: CONVOKE - Alpha version

Postby NeoAnderson » 10 Oct 2014, 18:47

The best solution would be to create an automatic matrix with all the possible mana combinations and check inside these combinations if there is one who can pay the card cost, if yes you choose it and apply the reduction. Doing in this way we could avoid mana producing question. But i am not sure i can make it.any help will be appreciated.
NeoAnderson
 
Posts: 914
Joined: 10 Sep 2013, 07:49
Has thanked: 18 times
Been thanked: 139 times

Re: CONVOKE - Alpha version

Postby Xander9009 » 10 Oct 2014, 22:56

Holy wow. I think I might have gotten it. I mean, it's almost definitely not going to work right away, but it should be close enough that you can get it the rest of the way. The code is actually rather short for how complex it really is. Lots of nesting of arrays within arrays. It's all commented though (101 lines, and 20 are just comments and another 5 are just empty spacing for readability. Anyway, here, try this and let me know if it works at all. Just makes sure that you feed in am array of creatures that starts at 1, not 0, and an array of costs with white first and colorless last, also starting at 1, not 0. It returns an array of numbers relating to colors. Each element lines up with an element from the array of creature passed in. So, the goal is that you could pass in two creatures like this

Code: Select all
local CreatureAssignedColors = AssignConvokePayment(Targets, Costs)
and get back
Code: Select all
CreatureAssignedColors[1] = 1
CreatureAssignedColors[2] = 3
CreatureAssignedColors[3] = 6
CreatureAssignedColors[4] = 6
Meaning the 4 creatures passed in should be used to pay for White, Black, Colorless, and Colorless, respectively. All current ones appear to only have 2. This means that any combination of creatures that CAN pay for the card WILL return a combination that works. If there were three or more, this code would not do that reliably. The code will need to be much more complicated if cards with convoke have 3 colors that need paid.

| Open
Code: Select all
AssignConvokePayment = function(oCreaturesChosen, iCardCost) --Provide list of creatures chosen and list of colored costs needed, both starting at index 1
  --Make globals so we can void passing parameters everywhere.
  oCreatures = oCreaturesChosen
  iCost = iCardCost
  bCreatureContributions = {{}, {}, {}, {}, {}}
  iCreatureContributesOnly = {}
  iAssignedPayment = {}
  iMulticolorCreatures = {}
  iColors = {COLOUR_WHITE, COLOUR_BLUE, COLOUR_BLACK, COLOUR_RED, COLOUR_GREEN, COLOUR_COLOURLESS}

  --Check that enough creatures are tapped.
  if ( table.getn(oCreatures) = ( iCost[1] + iCost[2] + iCost[3] + iCost[4] + iCost[5] + iCost[6]) then
    --Initialize payment.
    for iCreatureIndex, oCreature in pairs(oCreatures) do
      iAssignedPayment[iCreatureIndex] = 0
    end
    --Determine initial useful colors of creatures, then assign any that can only assist with one color.
    DetermineColorContributions()
    AssignSingleContributionCosts()
    DetermineMulticolorCreatures()  --Set up multicolor array so we can start the loop.
    while ( iMulticolorCreatures[1] ~= nil ) do
      AssignNextMulticolorCreature()  --As long as there's at least one unassigned multicolor creature, assign it to its first useful color.
    end
    return iAssignedPayment
  end
  return
end

DetermineColorContributions = function()
  --For each creature, determine which useful colors it can produce.
  --To do this, iterate through each creature.
  --For each creature, iterate through each color.
  --For each color, check if creature provides that color and the color is needed.
  --If so and creature has not yet provided another needed color, set color as 'only contribution'.
  --Otherwise, set 'only contribution' to -1 (produces multiple needed colors)
  for iCreatureIndex, oCreature in pairs(oCreatures) do
    -- Check if creature has been assigned to a color already. Once assigned, do not operate on it again.
    if ( iAssignedPayment[iCreatureIndex] == 0 ) then
      iCreatureContributesOnly[iCreatureIndex] = 6
      for iColorIndex, bCreatureContributionsColor in pairs(bCreatureContributions) do
        bCreatureContributionsColor[iCreatureIndex] = ( oCreature:GetColour():Test( iColors[iColorIndex] ) and iCost[iColorIndex] ~= 0 )
        if ( bCreatureContributionsColor[iCreatureIndex] and iCreatureContributesOnly[iCreatureIndex] == 6 ) then
          iCreatureContributesOnly[iCreatureIndex] = iColorIndex
        elseif ( bCreatureContributionsColor[iCreatureIndex] and iCreatureContributesOnly[iCreatureIndex] > 0 ) then
          iCreatureContributesOnly[iCreatureIndex] = -1
        end
      end
    end
  end
end

AssignSingleContributionCosts = function()
  --For each creature, check if it only contributes one useful color.
  for iCreatureIndex, oCreature in pairs(oCreatures) do
    if ( iCreatureContributesOnly[iCreatureIndex] > 0 ) then
      --If so, assign creature to that color.
      if ( iCost[iCreatureContributesOnly[iCreatureIndex]] > 0 ) then
        iAssignedPayment[iCreatureIndex] = iCreatureContributesOnly[iCreatureIndex]
        iCost[iCreatureContributesOnly[iCreatureIndex]] -= 1
      --If that color has been paid, assign creature to colorless.
      else
        iAssignedPayment[iCreatureIndex] = 6
        iCost[6] -= 1
      end
    end
  end
  DetermineColorContributions() --Refresh useful contributions.
end

DetermineMulticolorCreatures = function()
  --Empty the multicolor creature array.
  for iIndex, oCreature in pairs(oCreatures) do
    iMulticolorCreatures[iIndex] = nil
  end
  --Ensure contributions are current.
  DetermineColorContributions()
  --Now fill it back up.
  for iCreatureIndex, iCreatureContribution in pairs(iCreatureContributesOnly) do
    if ( iCreatureContribution == -1 ) then --iCreatureContributesOnly[n] is set to -1 when a creature constributes multiple colors.
      iMulticolorCreatures[table.getn(oCreatures) + 1] = iCreatureIndex
    end
  end
  DetermineColorContributions() --Refresh useful contributions.
end

AssignNextMulticolorCreature = function()
  --Assign the first creature which produces multiple useful colors to the first useful color it produces.
  --This works because the maximum number of colored mana symbols in a card with convoke is 2.
  local bPaid = false
  for iColorIndex, bCreatureContributionsColor in pairs(bCreatureContributions) do
    if ( bCreatureContributionsColor[iMulticolorCreatures[1]] ) then
      if ( ~bPaid ) then
        iAssignedPayment[iMulticolorCreatures[1]] = iColorIndex --Assign the creature.
        iCost[iColorIndex] -= 1 --Reduce the cost it helped pay.
      else
        bCreatureContributionsColor[iMulticolorCreatures[1]] = false  --Set creature to no longer be multicolored.
    end
  end
  DetermineColorContributions() --Refresh useful contributions.
  AssignSingleContributionCosts() --Attempt automated assignment again.
end
Unfortunately, this uses multiple things in LUA that I'm unfamiliar with. I wouldn't be very surprised if they were done incorrectly. Global variables, arrays, and of course NESTED arrays are all new to me. The main structure should be useful, though.
_______________________________
Community Wad - Community Wad Website - How to Help and Report Bugs
Discord: discord.gg/4AXvHzW
User avatar
Xander9009
Programmer
 
Posts: 2905
Joined: 29 Jun 2013, 07:44
Location: Indiana, United States
Has thanked: 121 times
Been thanked: 445 times

Re: CONVOKE - Alpha version

Postby NeoAnderson » 11 Oct 2014, 00:43

Xander9009 wrote:Holy wow. I think I might have gotten it. I mean, it's almost definitely not going to work right away, but it should be close enough that you can get it the rest of the way. The code is actually rather short for how complex it really is. Lots of nesting of arrays within arrays. It's all commented though (101 lines, and 20 are just comments and another 5 are just empty spacing for readability. Anyway, here, try this and let me know if it works at all. Just makes sure that you feed in am array of creatures that starts at 1, not 0, and an array of costs with white first and colorless last, also starting at 1, not 0. It returns an array of numbers relating to colors. Each element lines up with an element from the array of creature passed in. So, the goal is that you could pass in two creatures like this.
Unfortunately, this uses multiple things in LUA that I'm unfamiliar with. I wouldn't be very surprised if they were done incorrectly. Global variables, arrays, and of course NESTED arrays are all new to me. The main structure should be useful, though.
:shock: :shock: :shock: :shock: :shock: :shock: :shock: :shock: :shock: :shock: :shock: :shock:
Xander :lol: :lol: :lol: :lol: I understand your meaning but i swear i am lost inside your code, as like you i am not so familiar with Global variables, arrays, and of course NESTED arrays..But i think there are a lot of thing should be adapted to work with LUA Syntax, and honestly i am not sure i can exactly follow the 100% of what you done.
Anyway i just take a little break on Convoke today because my attention is focused on Phasing, a comment of another user about my recent discover has turned on my immagination. Anyway we will talk about convoke soon, i want to improve how it works and i am sure that togheter we will get a nice result. :wink:
NeoAnderson
 
Posts: 914
Joined: 10 Sep 2013, 07:49
Has thanked: 18 times
Been thanked: 139 times

Re: CONVOKE - Alpha version

Postby sumomole » 11 Oct 2014, 12:05

if my understanding is correct, you will decide the creatures to be tapped and the change of mana cost in the activated ability, but those creatures will be tapped after the convoke card is cast, so can I use the same creatures to pay two or more activated abilities? and I can't see any difference in these activated abilities except active zone, I think they should be merged.
User avatar
sumomole
Programmer
 
Posts: 611
Joined: 07 Jun 2011, 08:34
Has thanked: 51 times
Been thanked: 234 times

Re: CONVOKE - Alpha version

Postby NeoAnderson » 11 Oct 2014, 12:34

sumomole wrote:if my understanding is correct, you will decide the creatures to be tapped and the change of mana cost in the activated ability, but those creatures will be tapped after the convoke card is cast, so can I use the same creatures to pay two or more activated abilities? and I can't see any difference in these activated abilities except active zone, I think they should be merged.
1. The creatures can be selected just for one convoke because if you play any ability or spell after selected them and before to cast the spell the selection is reset!

2. Activated ability has some problem to works if you grant them out of battlefield. To correctly work it is needed to specify the active zone where they should work. For this reason i had to duplicate the code. There is also another problem inside ZONE_LIBRARY the activated ability cannot be granted, it is working only if already into card. So for this reason we have an intrisic activated ability for ZONE_LIBRARY.

3.As for Delve this version is more close to the old definition of MTG rules, where the action where used to reduce the cost. Now they changed to produce mana of kind, but i tried that solution, the Dotp engine cannot handle right the mana tokens production while considering for casting.
Mtg rules are changed for Delve and Convoke to avoid you can tap more creatures that spell cost, my version use old rules but include a check to avoid you can use more cards then spell cost, so i think should be acceptable.
NeoAnderson
 
Posts: 914
Joined: 10 Sep 2013, 07:49
Has thanked: 18 times
Been thanked: 139 times


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 14 guests


Who is online

In total there are 14 users online :: 0 registered, 0 hidden and 14 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 14 guests

Login Form