It is currently 26 Apr 2024, 10:58
   
Text Size

New card - Triumph of Ferocity

Moderator: CCGHQ Admins

New card - Triumph of Ferocity

Postby 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


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 &gt; 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 &gt; max_player_power then
                   max_player_power = current_power
                end
             end
          end
       end
    end
    if max_player_power &gt;= 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

Postby 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

Postby thefiremind » 30 May 2014, 08:21

This is how I code Triumph of Ferocity:
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>
I see if there's at least a creature with more than 0 power, then more than 1 power, then more than 2, and so on. When I find no creatures it means the latest power I had was the greatest one, so I just have to verify if I control at least a creature with such power.

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...
User avatar
thefiremind
Programmer
 
Posts: 3515
Joined: 07 Nov 2011, 10:55
Has thanked: 118 times
Been thanked: 721 times

Re: New card - Triumph of Ferocity

Postby PhilistineAu » 30 May 2014, 12:55

Thank you!

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

Postby thefiremind » 30 May 2014, 14:44

PhilistineAu wrote:Is this in one of your packs and I just missed it?
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.
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
User avatar
thefiremind
Programmer
 
Posts: 3515
Joined: 07 Nov 2011, 10:55
Has thanked: 118 times
Been thanked: 721 times


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 49 guests


Who is online

In total there are 49 users online :: 0 registered, 0 hidden and 49 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 49 guests

Login Form