enPump keyword
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
Re: enPump keyword
by Chris H. » 25 Mar 2010, 23:38
I spent some time today working on this keyword and I discovered that the Flash keyword is incompatible with auras. I found this small bit of code with one of the Flash auras and it appears to take care of this situation:
So, we need a variant of this in the enPump_Enchant SpellAbility located in CardFactoryUtil.java. I had to modify the code above to get it to work correctly with both Flash and non-Flash auras.
I admit that my code looks terrible but it appears to work OK. While working on this I also discovered that the setDescription test message that I created is now appearing in the Choose dialog when casting an aura with Cycling. As such, I guess that I will be able to add in the Cycling auras after all.
Unfortunately, the description still does not appear in the card detail panel but I can include that info in cards.txt.
Oh, and some of the auras are more of a curse than a buff-up. I remember Rob suggesting at one time that it may be best to have two different keywords to cover the differences in AI. I think the second aura should be named:
enCurse or enPumpCurse
Which version looks good to you Rob?
`
- Code: Select all
public boolean canPlay() {
return AllZone.GameAction.isCardInZone(card, AllZone.Human_Hand)
|| AllZone.GameAction.isCardInZone(card, AllZone.Computer_Hand); // for flash, which is not working through the keyword for some reason
}
So, we need a variant of this in the enPump_Enchant SpellAbility located in CardFactoryUtil.java. I had to modify the code above to get it to work correctly with both Flash and non-Flash auras.
- Code: Select all
public boolean canPlay() {
return (sourceCard.getKeyword().contains("Flash") && (AllZone.GameAction.isCardInZone(sourceCard, AllZone.Human_Hand) ||
AllZone.GameAction.isCardInZone(sourceCard, AllZone.Computer_Hand)) // for flash, which is not working through the keyword for some reason
||
(! sourceCard.getKeyword().contains("Flash") && // if not flash then limit to main 1 and 2 on controller's turn
(sourceCard.getController().equals(AllZone.Phase.getActivePlayer()) &&
(AllZone.Phase.getPhase().equals(Constant.Phase.Main1) || AllZone.Phase.getPhase().equals(Constant.Phase.Main2)))));
}
I admit that my code looks terrible but it appears to work OK. While working on this I also discovered that the setDescription test message that I created is now appearing in the Choose dialog when casting an aura with Cycling. As such, I guess that I will be able to add in the Cycling auras after all.

Unfortunately, the description still does not appear in the card detail panel but I can include that info in cards.txt.

Oh, and some of the auras are more of a curse than a buff-up. I remember Rob suggesting at one time that it may be best to have two different keywords to cover the differences in AI. I think the second aura should be named:
enCurse or enPumpCurse
Which version looks good to you Rob?
`
-
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: enPump keyword
by Chris H. » 31 Mar 2010, 01:39
I uploaded another version. The format at this time is:
enPump:[p/t][/][k1 & k2 ... kn][:spellDescription][:stackDescription]
power/toughness and keywords are optional, although you must have at least one of these two.
multiple keywords are separated by the "&" character.
spellDescription and stackDescription are optional.
The card description must be included in the 4th line of the cards.txt entry. The code will build these descriptions and these descriptions will be replaced by any descriptions that are included with the keyword.
Keyword'ed auras at this time are compatible with Flash and Cycling.
EDIT:
Please see the latest update at:
Re: enPump keyword (latest update)
enPump:[p/t][/][k1 & k2 ... kn][:spellDescription][:stackDescription]
power/toughness and keywords are optional, although you must have at least one of these two.
multiple keywords are separated by the "&" character.
spellDescription and stackDescription are optional.
The card description must be included in the 4th line of the cards.txt entry. The code will build these descriptions and these descriptions will be replaced by any descriptions that are included with the keyword.
Keyword'ed auras at this time are compatible with Flash and Cycling.
EDIT:
Please see the latest update at:
Re: enPump keyword (latest update)
Last edited by Chris H. on 07 Apr 2010, 23:04, edited 2 times in total.
-
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: enPump keyword
by Chris H. » 31 Mar 2010, 12:34
The CardFactory_Auras.java file has a number of occurrences of:
and I just remembered a recent message from our friend silly freak
Re: Forge 03/13 (Unofficial Beta version)
so I guess that I should change the line above to this
another SVN merge is on the way.
- Code: Select all
if(list.isEmpty()) return false;
and I just remembered a recent message from our friend silly freak
Re: Forge 03/13 (Unofficial Beta version)
so I guess that I should change the line above to this
- Code: Select all
if(list.length()==0) return false;
another SVN merge is on the way.

-
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: enPump keyword
by silly freak » 31 Mar 2010, 13:20
actually no, Collection.isEmpty() is around for years, it's just String.isEmpty() which we should avoid.
___
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: enPump keyword
by Chris H. » 31 Mar 2010, 13:37
`silly freak wrote:actually no, Collection.isEmpty() is around for years, it's just String.isEmpty() which we should avoid.
Thank you for the input. I was not aware of the difference.

-
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: enPump keyword
by Chris H. » 31 Mar 2010, 22:57
I am in the process of converting these auras to keyword:
Aspect of Mongoose
Diplomatic Immunity
Robe of Mirrors
The computer cast an Aspect of Mongoose and I disenchanted this enchantment. The Aspect of Mongoose went back to the computer's hand and it was cast again … but the returned Aspect of Mongoose remains in the computer's hand and is recast time after time ...
The Aspect of Mongoose includes the keyword "When this card is put into a graveyard from the battlefield, return this card to its owner's hand" but I am not sure if the problem is with this keyword or with my enPump keyword.
Aspect of Mongoose
Diplomatic Immunity
Robe of Mirrors
The computer cast an Aspect of Mongoose and I disenchanted this enchantment. The Aspect of Mongoose went back to the computer's hand and it was cast again … but the returned Aspect of Mongoose remains in the computer's hand and is recast time after time ...

The Aspect of Mongoose includes the keyword "When this card is put into a graveyard from the battlefield, return this card to its owner's hand" but I am not sure if the problem is with this keyword or with my enPump keyword.
-
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: enPump keyword
by Chris H. » 01 Apr 2010, 01:05
`Chris H. wrote:The computer cast an Aspect of Mongoose and I disenchanted this enchantment. The Aspect of Mongoose went back to the computer's hand and it was cast again … but the returned Aspect of Mongoose remains in the computer's hand and is recast time after time ...
After a number of tests it appears that the problem is related to my modified canPlay() method which in turn allows Flash to be used with my enPump keyword. I am not sure why this is happening.

-
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: enPump keyword
by Chris H. » 01 Apr 2010, 13:12
`After a number of tests it appears that the problem is related to my modified canPlay() method which in turn allows Flash to be used with my enPump keyword.
I think that I have fixed this in r595.

-
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: enPump keyword
by Chris H. » 02 Apr 2010, 14:06
I updated the canPlayAI() method in the enPump SpellAbility. The computer will now target any Rabid Wombat or Uril, the Miststalker that it has in play. At some point in the future this will allow a Rabid Wombat AI type deck for quest mode.
Unfortunately the AI still needs a lot of work. The computer will target a flying creature with a Flight spell at this time. So we need to prune the list of computer creatures in play and remove those creatures that would not gain any new keyword'ed abilities.
I assume that if the aura has a p/t boost above zero that it does not matter if the aura keywords given are new or not.
I am kind of lost at this time. The variable number of keywords to test for is making this section of the code even more complicated.

Unfortunately the AI still needs a lot of work. The computer will target a flying creature with a Flight spell at this time. So we need to prune the list of computer creatures in play and remove those creatures that would not gain any new keyword'ed abilities.
I assume that if the aura has a p/t boost above zero that it does not matter if the aura keywords given are new or not.
I am kind of lost at this time. The variable number of keywords to test for is making this section of the code even more complicated.
- Code: Select all
public boolean canPlayAI() {
CardList list = new CardList(AllZone.Computer_Play.getCards());
list = list.getType("Creature");
if (list.isEmpty()) return false;
//else (is there a Rabid Wombat or a Uril, the Miststalker to target?)
CardList auraMagnetList = new CardList(AllZone.Computer_Play.getCards());
auraMagnetList = auraMagnetList.filter(new CardListFilter() {
public boolean addCard(Card c) {
return c.isCreature() && (c.getName().equals("Rabid Wombat") || c.getName().equals("Uril, the Miststalker"));
}
});
if (! auraMagnetList.isEmpty()) { // AI has a special target creature(s) to enchant
auraMagnetList.shuffle();
for (int i = 0; i < auraMagnetList.size(); i++) {
if (CardFactoryUtil.canTarget(sourceCard, auraMagnetList.get(i))) {
setTargetCard(auraMagnetList.get(i)); // Target only Rabid Wombat or Uril, the Miststalker
return true;
}
}
}
//else (prune list if needed?) and set target creature
if (Power <= 0 && Tough <= 0) { // This aura is keyword only
// Need code to remove creatures from the list if
// the aura does not provide new keyword abilities.
}
CardListUtil.sortAttack(list);
CardListUtil.sortFlying(list);
for (int i = 0; i < list.size(); i++) {
if (CardFactoryUtil.canTarget(sourceCard, list.get(i))) {
setTargetCard(list.get(i));
return true;
}
}
return false;
}//canPlayAI()
-
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: enPump keyword
by DennisBergkamp » 02 Apr 2010, 18:35
How about something like this?
- Code: Select all
if (Power <= 0 && Tough <= 0) { // This aura is keyword only
list = list.filter(new CardListFilter(){
public boolean addCard(Card c){
ArrayList<String> extKeywords = new ArrayList<String>(Arrays.asList(extrinsicKeywords));
for (String s:extKeywords)
{
if (!c.getKeyword().contains(s))
return true;
}
//no new keywords:
return false;
}
});
}
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: enPump keyword
by Chris H. » 02 Apr 2010, 19:47
Thank you Dennis. This looks like it should do the job. 

-
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: enPump keyword
by Chris H. » 04 Apr 2010, 19:46
I converted the aura "Vigilance" over to keyword and I have discovered a weird "cardname" bug with this card. This is what the card now looks like:
and somehow the keyword is being changed from "Vigilance" to "cardname" which is then turned into the enchanted creatures name in the card detail panel.
- Code: Select all
Vigilance
W
Enchantment Aura
Enchanted creature has vigilance.
Enchant creature
enPump:Vigilance
and somehow the keyword is being changed from "Vigilance" to "cardname" which is then turned into the enchanted creatures name in the card detail panel.
-
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: enPump keyword
by DennisBergkamp » 04 Apr 2010, 22:04
Ahh, this is because we replace all instances.... What happens when you change it to "enPump:CARDNAME" ?
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
Re: enPump keyword
by Chris H. » 05 Apr 2010, 02:14
I tried it and I get the same result. When I revert this card back to a non-keyword'ed card that is implemented by it's own coded card object it works correctly. 

-
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: enPump keyword
by DennisBergkamp » 05 Apr 2010, 04:33
For now let's just use the hardcoded version then I suppose 

-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
45 posts
• Page 2 of 3 • 1, 2, 3
Who is online
Users browsing this forum: Google [Bot] and 12 guests