It is currently 04 Sep 2025, 18:06
   
Text Size

Upkeep manager

Moderator: CCGHQ Admins

Upkeep manager

Postby NeoAnderson » 09 Jan 2014, 17:14

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. :-)
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 12 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 12 users online :: 0 registered, 0 hidden and 12 guests (based on users active over the past 10 minutes)
Most users ever online was 7303 on 15 Jul 2025, 20:46

Users browsing this forum: No registered users and 12 guests

Login Form