Two cards with {cost}, Sacrifice CARDNAME: Add {mana} to yo
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
12 posts
• Page 1 of 1
Two cards with {cost}, Sacrifice CARDNAME: Add {mana} to yo
by Sloth » 02 Jun 2010, 12:15
I found 2 cards that can be added to cards.txt:
PS: Little Fix: Fire-Field Ogre has an Unearth cost of U B R not 1 U B R
- Code: Select all
Implements of Sacrifice
2
Artifact
no text
1, tap, Sacrifice CARDNAME: Add W W to your mana pool.
1, tap, Sacrifice CARDNAME: Add U U to your mana pool.
1, tap, Sacrifice CARDNAME: Add B B to your mana pool.
1, tap, Sacrifice CARDNAME: Add R R to your mana pool.
1, tap, Sacrifice CARDNAME: Add G G to your mana pool.
Kaleidostone
2
Artifact
no text
When CARDNAME enters the battlefield, draw a card.
5, tap, Sacrifice CARDNAME: Add W U B R G to your mana pool.
- Code: Select all
implements_of_sacrifice.jpg http://www.wizards.com/global/images/magic/general/implements_of_sacrifice.jpg
kaleidostone.jpg http://www.wizards.com/global/images/magic/general/kaleidostone.jpg
PS: Little Fix: Fire-Field Ogre has an Unearth cost of U B R not 1 U B R
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: Two cards with {cost}, Sacrifice CARDNAME: Add {mana} t
by Chris H. » 02 Jun 2010, 19:11
Thank you for your submissions Sloth. Unfortunately, the Implements of Sacrifice card displays the same cosmetic problem as the Wild Cantor card.
Cards that have more than one copy of this keyword bring up a Choose dialog where we choose one of these spell abilities from a list. "CARDNAME" is displayed in the listing and is not being replaced automatically with the card's name.
I found several lines of code in the Ability_Mana.java class and I discovered that I could add several lines of code which would give us several versions of this keyword. We could use this version where there is only one spell ability:
and then use one of the two versions below for cards that have more than one spell ability:
This would prevent the term "CARDNAME" from appearing in the list of choices. "this card" and "this creature" might be less unsightly for our user-base.
Cards that have more than one copy of this keyword bring up a Choose dialog where we choose one of these spell abilities from a list. "CARDNAME" is displayed in the listing and is not being replaced automatically with the card's name.
I found several lines of code in the Ability_Mana.java class and I discovered that I could add several lines of code which would give us several versions of this keyword. We could use this version where there is only one spell ability:
- Code: Select all
{cost}, Sacrifice CARDNAME: Add {mana} to your mana pool.
and then use one of the two versions below for cards that have more than one spell ability:
- Code: Select all
{cost}, Sacrifice this card: Add {mana} to your mana pool.
{cost}, Sacrifice this creature: Add {mana} to your mana pool.
This would prevent the term "CARDNAME" from appearing in the list of choices. "this card" and "this creature" might be less unsightly for our user-base.
-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
Re: Two cards with {cost}, Sacrifice CARDNAME: Add {mana} t
by Rob Cashwalker » 03 Jun 2010, 02:37
Just guessing, but try modifying SpellAbility.getSpellDescription() to replace CARDNAME, just like Card.getText().
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
Re: Two cards with {cost}, Sacrifice CARDNAME: Add {mana} t
by Chris H. » 03 Jun 2010, 10:21
`Rob Cashwalker wrote:Just guessing, but try modifying SpellAbility.getSpellDescription() to replace CARDNAME, just like Card.getText().
Thank you, Rob.

I will take a look at this section of code and will see if I can figure this out.
-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
Re: Two cards with {cost}, Sacrifice CARDNAME: Add {mana} t
by Chris H. » 03 Jun 2010, 18:50
I examined the code for Card.getText() and the code for SpellAbility.setDescription() and discovered that they both include a line which replaces "CARDNAME" with .getName().
I think that the option panel that asks us to "Choose" from a list of spell abilities is displaying these from a list of keywords. The code which replaces "CARDNAME" with .getName() does not change the actual keyword but the spell description text?
I think that the option panel that asks us to "Choose" from a list of spell abilities is displaying these from a list of keywords. The code which replaces "CARDNAME" with .getName() does not change the actual keyword but the spell description text?
-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
Re: Two cards with {cost}, Sacrifice CARDNAME: Add {mana} t
by Rob Cashwalker » 04 Jun 2010, 19:36
That's odd.
The idea is that the "keyword" representation of an ability should stay the same, while the outward appearance is that CARDNAME is replaced on the fly.
The GUI for the list may be called in different ways, so the ManaAbility may populate the list differently, I guess.
The idea is that the "keyword" representation of an ability should stay the same, while the outward appearance is that CARDNAME is replaced on the fly.
The GUI for the list may be called in different ways, so the ManaAbility may populate the list differently, I guess.
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
Re: Two cards with {cost}, Sacrifice CARDNAME: Add {mana} t
by DennisBergkamp » 04 Jun 2010, 21:44
Yeah, exactly... I've played around with this a bit and couldn't really find a way to do a string replace.
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: Two cards with {cost}, Sacrifice CARDNAME: Add {mana} t
by Chris H. » 07 Jun 2010, 15:10
This gets even odder. I replaced all of the CARDNAME with the actual card's name for these cards in cards.txt. I then found and modified two sections of code in Abiility_Mana.isSacrifice()
and in Ability_Mana.mana()
and ran a test deck. The cards in question still display CARDNAME in the choose window. I may have made a simple mistake. I will take a second look at this later. But I am starting to feel that it is time to move on.
- Code: Select all
public boolean isSacrifice()
{
return orig.contains("Sacrifice CARDNAME: Add ") ||
orig.contains("Sacrifice " + sourceCard.getName() + " : Add ");
}
and in Ability_Mana.mana()
- Code: Select all
else if ((orig.contains("Sacrifice this creature: Add ") ||
orig.contains("Sacrifice CARDNAME: Add ") ||
orig.contains("Sacrifice " + sourceCard.getName() + ": Add "))
&& orig.contains(" to your mana pool."))
{
String m = orig.split(": Add ")[1].split(" to ")[0];
return m;
}
and ran a test deck. The cards in question still display CARDNAME in the choose window. I may have made a simple mistake. I will take a second look at this later. But I am starting to feel that it is time to move on.
-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
Re: Two cards with {cost}, Sacrifice CARDNAME: Add {mana} t
by Rob Cashwalker » 08 Jun 2010, 14:41
It starts in GameAction.playCard:
Searching for "getChoiceOptional" I find the real meat of it in GuiDisplay2 and GuiDisplay3:
SpellAbilityList has a toString method, as does SpellAbility itself. But since Ability_Mana extends SpellAbility, the Ability_Mana.toString overrides it:
BTW, SpellAbility.toString is bad as well:
- Code: Select all
} else {
SpellAbility[] choices = canPlaySpellAbility(c.getSpellAbility());
SpellAbility sa;
/*
System.out.println(choices.length);
for(int i = 0; i < choices.length; i++)
System.out.println(choices[i]);
*/
if(choices.length == 0) return;
else if(choices.length == 1) sa = choices[0];
else {
sa = AllZone.Display.getChoiceOptional("Choose", choices);
- Code: Select all
public <T> T getChoiceOptional(String message, T... choices);
Searching for "getChoiceOptional" I find the real meat of it in GuiDisplay2 and GuiDisplay3:
- Code: Select all
public <T> T getChoiceOptional(String message, T... choices) {
if(choices == null || choices.length == 0) return null;
List<T> choice = getChoices(message, 0, 1, choices);
...
public <T> List<T> getChoices(String message, int min, int max, T... choices) {
ListChooser<T> c = new ListChooser<T>(message, min, max, choices);
final JList list = c.getJList();
list.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent ev) {
if(list.getSelectedValue() instanceof Card) {
setCard((Card) list.getSelectedValue());
}
}
});
c.show();
return c.getSelectedValues();
- Code: Select all
public ListChooser(String title, String message, int minChoices, int maxChoices, List<T> list) {
this.title = title;
this.minChoices = minChoices;
this.maxChoices = maxChoices;
this.list = unmodifiableList(list);
jList = new JList(new ChooserListModel());
ok = new CloseAction(OK_OPTION, "OK");
ok.setEnabled(minChoices == 0);
cancel = new CloseAction(CANCEL_OPTION, "Cancel");
Object[] options;
if(minChoices == 0) options = new Object[] {new JButton(ok), new JButton(cancel)};
else options = new Object[] {new JButton(ok)};
p = new JOptionPane(new Object[] {message, new JScrollPane(jList)}, QUESTION_MESSAGE, DEFAULT_OPTION,
null, options, options[0]);
SpellAbilityList has a toString method, as does SpellAbility itself. But since Ability_Mana extends SpellAbility, the Ability_Mana.toString overrides it:
- Code: Select all
public String toString() {
return orig;
BTW, SpellAbility.toString is bad as well:
- Code: Select all
public String toString() {
if (description.contains("CARDNAME"))
description = description.replace("CARDNAME", this.getSourceCard().getName());
return description;
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
Re: Two cards with {cost}, Sacrifice CARDNAME: Add {mana} t
by Chris H. » 08 Jun 2010, 17:06
Thank you for looking into this situation.
Most of the code that you point out is over my level of knowledge and comprehension. I guess with a worst case scenario I could convert that one keyword to use "this creature" or "this card".
`Wow... um... huh?
Most of the code that you point out is over my level of knowledge and comprehension. I guess with a worst case scenario I could convert that one keyword to use "this creature" or "this card".

-
Chris H. - Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
Re: Two cards with {cost}, Sacrifice CARDNAME: Add {mana} t
by silly freak » 10 Jun 2010, 20:48
the "<T>" is a generic declaration. essentially, it means that the compiler replaces the type when calling. "T..." is a "vararg" array. for example, you could call it likeWow... um... huh?
- Code: Select all
public <T> T getChoiceOptional(String message, T... choices);
- Code: Select all
String choice = getChoiceOptional("Title", "a", "b");
- Code: Select all
String choice = getChoiceOptional("Title", new String[] {"a", "b"});
that's the magic

___
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
- silly freak
- DEVELOPER
- Posts: 598
- Joined: 26 Mar 2009, 07:18
- Location: Vienna, Austria
- Has thanked: 93 times
- Been thanked: 25 times
Re: Two cards with {cost}, Sacrifice CARDNAME: Add {mana} t
by Rob Cashwalker » 11 Jun 2010, 04:09
So I'm correct in guessing that the chooser is using toString (a semi-standard method most objects should implement) to generate the list? Therefore changing the Ability_Mana.toString to include the replacement should do the trick?
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
12 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 75 guests