Board index Programs with AI or Rules Enforcement Magic: The Gathering - Duels of the Planeswalkers Programming Talk
Upkeep manager
Moderator: CCGHQ Admins
Upkeep manager
by 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 :
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>
- 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
- Code: Select all
NEO_UPKEEP_MANAGER_CHEST_ID = 4000 -- for cards who have upkeep activations
- NeoAnderson
- Posts: 914
- Joined: 10 Sep 2013, 07:49
- Has thanked: 18 times
- Been thanked: 139 times
1 post
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 25 guests