Board index Programs with AI or Rules Enforcement Magic: The Gathering - Duels of the Planeswalkers Programming Talk
New card - Triumph of Ferocity
Moderator: CCGHQ Admins
New card - Triumph of Ferocity
by PhilistineAu » 30 May 2014, 05:23
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>
- PhilistineAu
- Posts: 22
- Joined: 29 Sep 2012, 19:37
- Has thanked: 0 time
- Been thanked: 1 time
Re: New card - Triumph of Ferocity
by PhilistineAu » 30 May 2014, 05:31
Also, I need to add an "end" after the "if" statement for card draw, just before </RESOLUTION_TIME_ACTION>.
- PhilistineAu
- Posts: 22
- Joined: 29 Sep 2012, 19:37
- Has thanked: 0 time
- Been thanked: 1 time
Re: New card - Triumph of Ferocity
by thefiremind » 30 May 2014, 08:21
This is how I code Triumph of Ferocity:
By the way, this card doesn't need a MAY, the card drawing is mandatory.
- Code: Select all
<TRIGGER value="BEGINNING_OF_PLAYERS_STEP" simple_qualifier="controller">
return MTG():GetStep() == STEP_UPKEEP
</TRIGGER>
<RESOLUTION_TIME_ACTION>
local player = EffectController()
local filter = ClearFilter()
filter:Add(FE_TYPE, OP_IS, CARD_TYPE_CREATURE)
local count = filter:CountStopAt(1)
if count == 1 then
local power = -1
while count == 1 do
power = power + 1
filter:Clear()
filter:Add(FE_TYPE, OP_IS, CARD_TYPE_CREATURE)
filter:Add(FE_POWER, OP_GREATER_THAN, power)
count = filter:CountStopAt(1)
end
-- now "power" is equal to the greatest power
filter:Clear()
filter:Add(FE_TYPE, OP_IS, CARD_TYPE_CREATURE)
filter:Add(FE_POWER, OP_GREATER_THAN_OR_EQUAL_TO, power)
filter:Add(FE_CONTROLLER, OP_IS, player)
if filter:CountStopAt(1) == 1 then
player:DrawCards(1)
end
end
</RESOLUTION_TIME_ACTION>
By the way, this card doesn't need a MAY, the card drawing is mandatory.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
Currently busy with life...
-
thefiremind - Programmer
- Posts: 3515
- Joined: 07 Nov 2011, 10:55
- Has thanked: 118 times
- Been thanked: 721 times
Re: New card - Triumph of Ferocity
by PhilistineAu » 30 May 2014, 12:55
Thank you!
Is this in one of your packs and I just missed it?
Best regards,
Phil
Is this in one of your packs and I just missed it?
Best regards,
Phil
- PhilistineAu
- Posts: 22
- Joined: 29 Sep 2012, 19:37
- Has thanked: 0 time
- Been thanked: 1 time
Re: New card - Triumph of Ferocity
by thefiremind » 30 May 2014, 14:44
No, don't worry... at first I thought it was, but then after a search on my DotP folder I found it among the cards that were meant to be in decks that I have never finished.PhilistineAu wrote:Is this in one of your packs and I just missed it?
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
Currently busy with life...
-
thefiremind - Programmer
- Posts: 3515
- Joined: 07 Nov 2011, 10:55
- Has thanked: 118 times
- Been thanked: 721 times
5 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 49 guests