Page 1 of 1

Upkeep manager

PostPosted: 09 Jan 2014, 17:14
by NeoAnderson
Some days ago i was discussing with Riiak about the possibility to manage the cards who have ability that require an activation during the upkeep, how to make just one card to trigger to let us to use each abilities we prefer without wait multiple triggers.

I have implemented the follow code :
Code: Select all
<TRIGGERED_ABILITY>
<TRIGGER value="BEGINNING_OF_PLAYERS_STEP" simple_qualifier="controller">
if (MTG():GetStep() == STEP_UPKEEP) then
    local status = NEO_PlayerUpkeepDCStatus(EffectController())
   if (status == 0) then
    local chest = NEO_SetPlayerUpkeepDC(EffectController(), Object())
      return  true
   elseif (status == 1) then
          local chest  = NEO_GetPlayerUpkeepDC(EffectController())
          local card = chest:Get_CardPtr(2)           
        if TriggerObject() == card then
           return true
        else
           return false
        end
   end
else
   return false
end
    </TRIGGER>
<RESOLUTION_TIME_ACTION />
</TRIGGERED_ABILITY>
Using this trigger inside that cards we will have just one of them trigger during the upkeep.Are also needed the follow Functions :
Code: Select all
NEO_PlayerUpkeepDCStatus = function(player)
-- return Value, 0 if it is not used.
   local chest = nil
        local Value = 0
   if player ~= nil then
      chest = player:PlayerDataChest():Get_Chest(NEO_UPKEEP_MANAGER_CHEST_ID)
      if chest ~= nil then
                   Value = chest:Get_Int(1)
                end
   end
   return Value
end


NEO_SetPlayerUpkeepDC = function(player, card)
   local chest = nil
   if player ~= nil then
      chest = player:PlayerDataChest():Get_Chest(NEO_UPKEEP_MANAGER_CHEST_ID)
      if chest == nil then
         chest = player:PlayerDataChest():Make_Chest(NEO_UPKEEP_MANAGER_CHEST_ID)
         chest:Set_Int(1,1)
         chest:Set_CardPtr(2,card)
      end
   end
   return chest
end

NEO_GetPlayerUpkeepDC = function(player)
   local chest = nil
   if player ~= nil then
      chest = player:PlayerDataChest():Get_Chest(NEO_UPKEEP_MANAGER_CHEST_ID)
   end
   return chest
end
And also this Costant assignment :
Code: Select all
NEO_UPKEEP_MANAGER_CHEST_ID = 4000 -- for cards who have upkeep activations
I would be glad if some skilled friend will share his opinion about this idea with me. :-)