New card - Triumph of Ferocity

Hi,
I've tried putting together a new card, "Triumph of Ferocity". The trigger is: At the beginning of your upkeep, draw a card if you control the creature with the greatest power or tied for the greatest power.
This is what I have cobbled together so far. I have the may line in there just to see if it works, but I'll need to take that out.
Right now the problem I am having is that the card works, but when I have two played it will only draw one card. It asks me twice if I want to activate the ability, and I click yes both times, but only 1 card is drawn.
As a general programming question, I'm not sure what local max_opponent_power = -10000 or the equivalent for player at -10001 is doing.... I'm assuming those are the starting values but why so negative? Is the player 1 lower to stop the player drawing a card when there are no creatures on the board?
If anyone has any suggestions for how to fix the bug / improvement I would gratefully hear them and incorporate them.
Thanks,
Phil
I've tried putting together a new card, "Triumph of Ferocity". The trigger is: At the beginning of your upkeep, draw a card if you control the creature with the greatest power or tied for the greatest power.
This is what I have cobbled together so far. I have the may line in there just to see if it works, but I'll need to take that out.
Right now the problem I am having is that the card works, but when I have two played it will only draw one card. It asks me twice if I want to activate the ability, and I click yes both times, but only 1 card is drawn.
As a general programming question, I'm not sure what local max_opponent_power = -10000 or the equivalent for player at -10001 is doing.... I'm assuming those are the starting values but why so negative? Is the player 1 lower to stop the player drawing a card when there are no creatures on the board?
If anyone has any suggestions for how to fix the bug / improvement I would gratefully hear them and incorporate them.
Thanks,
Phil
- Code: Select all
<TRIGGER value="BEGINNING_OF_PLAYERS_STEP" simple_qualifier="controller">
return MTG():GetStep() == STEP_UPKEEP
</TRIGGER>
<MAY always_prompt="1" />
<RESOLUTION_TIME_ACTION>
local num_starting_players = MTG():GetNumberOfStartingPlayers()
local max_opponent_power = -10000
local max_player_power = -10001
local filter = ClearFilter()
for i=0,(num_starting_players-1) do
local player = MTG():GetNthStartingPlayer(i)
if player ~= nil then
if player ~= EffectController() then
filter:Clear()
filter:Add( FE_TYPE, OP_IS, CARD_TYPE_CREATURE )
filter:Add( FE_CONTROLLER, OP_IS, player)
local num_creatures = filter:EvaluateObjects()
for j=0,(num_creatures-1) do
current_power = filter:GetNthEvaluatedObject(j):GetCurrentCharacteristics():Power_Get()
if current_power > max_opponent_power then
max_opponent_power = current_power
end
end
else
filter:Clear()
filter:Add( FE_TYPE, OP_IS, CARD_TYPE_CREATURE )
filter:Add( FE_CONTROLLER, OP_IS, player)
local num_creatures = filter:EvaluateObjects()
for j=0,(num_creatures-1) do
current_power = filter:GetNthEvaluatedObject(j):GetCurrentCharacteristics():Power_Get()
if current_power > max_player_power then
max_player_power = current_power
end
end
end
end
end
if max_player_power >= max_opponent_power then
filter:Clear()
EffectController():DrawCards(1)
</RESOLUTION_TIME_ACTION>
</TRIGGERED_ABILITY>