BuffedBy keyword (or SVar?)
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
15 posts
• Page 1 of 1
BuffedBy keyword (or SVar?)
by Sloth » 19 Aug 2010, 15:24
First I would change the name, since it is not an ability, then I'm not sure if it's better to make it an SVar (just to make it consistend with PlayMain1).Chris H. wrote:Rob's new SVar:PlayMain1:TRUE is great for many of the cards and the three of us have added this SVar to most of the cards that needed it. Unfortunately, the Mimics and similar cards require a whole new keyword.
In the ComputerAI_General.getMain1() code the AI would have to check every one of it's cards in play to see if it contained the abBuffedBy keyword. If a card in play returned true then parse the params. Then check cards in hand to see if there is a match. If true then the card in hand should be cast in main 1.
I have figured out the basic logic but I'm not sure if my java/coding skills is up to the task. I do have a few short lines of code:
- Code: Select all
private SpellAbility[] getMain1() {
//Card list of all cards to consider
CardList hand = new CardList(AllZone.Computer_Hand.getCards());
hand = hand.filter(new CardListFilter() {
// Beached As Start
public boolean addCard(Card c) {
//Collection<Card> play = playMain1Cards;
if (c.getSVar("PlayMain1").equals("TRUE")) return true;
if (c.isLand()) return false;
if (c.isCreature() && (c.getKeyword().contains("Haste")) || c.getKeyword().contains("Exalted")) return true;
CardList buffedBy = new CardList();
buffedBy.addAll(AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer).getCards());
buffedBy.filter(new CardListFilter() {
public boolean addCard(Card card) {
return card.getKeyword().contains("abBuffedBy");
}
});
if (buffedBy.size() > 0) {
}
EDIT: If we already guide the AI with this, we can also specify what cards to play in Main 1. Example Shorecrasher Mimic:
BuffedBy:Spell.green+blue
We can use the getValidCard method for this (I hope).
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: BuffedBy keyword (or SVar?)
by Chris H. » 19 Aug 2010, 16:20
Thank you Sloth for starting this proposal and discussion topic. AC provided us with a list of "Lord" like cards. I was able to add the SVar to the cards last week. There is a group of cards that would need a new keyword or SVar. I think the keyword may be best.
Here is a list of cards divided in groups that would make use of this BuffedBy keyword:
Here is a list of cards divided in groups that would make use of this BuffedBy keyword:
- Code: Select all
Ashenmoor Cohort
Ballynock Cohort
Briarberry Cohort
Crabapple Cohort
Mudbrawler Cohort
Bant Sureblade
Esper Stormblade
Grixis Grimblade
Jund Hackblade
Naya Hushblade
Battle Squadron
Dauntless Dourbark
Keldon Warlord
Master of Etherium
Scion of the Wild
Soulsurge Elemental
Squirrel Mob
Glassdust Hulk
Glaze Fiend
Herd Gnarr
Juniper Order Ranger
Kavu Monarch
Liu Bei, Lord of Shu
Emberstrike Duo
Gravelgill Duo
Safehold Duo
Tattermunge Duo
Thistledown Duo
Kami of the Hunt
Belligerent Hatchling
Noxious Hatchling
Sturdy Hatchling
Voracious Hatchling
-
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: BuffedBy keyword (or SVar?)
by Chris H. » 19 Aug 2010, 16:38
`Sloth wrote:EDIT: If we already guide the AI with this, we can also specify what cards to play in Main 1. Example Shorecrasher Mimic:
BuffedBy:Spell.green+blue
Most of the code that I posted already exists. The only thing new is the several lines of code for the BuffedBy keyword.
So, I think that the BuffedBy keyword could be added to this ComputerAI_General.getMain1() method. As I look through the list of cards above it comes to me that the parsing and testing could become more involved than I had originally imagined.
The code for BuffedBy would be executed every time the computer needs to decide if it has a card in hand to cast during main 1. Checking to see if it's cards in play have this keyword should take very little time. And only if the cards in play have this keyword would the computer spend time with the code that follow inside of these braces:
- Code: Select all
if (buffedBy.size() > 0) {
}
So, the BuffedBy code might not create a noticeable slowdown.

-
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: BuffedBy keyword (or SVar?)
by Sloth » 19 Aug 2010, 17:07
For testing we can start with just return true; in the braces. I will try to come up with something to parse the restrictions tomorrow.Chris H. wrote:The code for BuffedBy would be executed every time the computer needs to decide if it has a card in hand to cast during main 1. Checking to see if it's cards in play have this keyword should take very little time. And only if the cards in play have this keyword would the computer spend time with the code that follow inside of these braces:`
- Code: Select all
if (buffedBy.size() > 0) {
}
So, the BuffedBy code might not create a noticeable slowdown.
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: BuffedBy keyword (or SVar?)
by Chris H. » 20 Aug 2010, 00:05
I took a quick look at the potential candidates and thought about how to form the params:
- Code: Select all
Ashenmoor Cohort BuffedBy:Creature.Black:CrtlAnother
Ballynock Cohort BuffedBy:Creature.White:CrtlAnother
Briarberry Cohort BuffedBy:Creature.Blue:CrtlAnother
Crabapple Cohort BuffedBy:Creature.Green:CrtlAnother
Mudbrawler Cohort BuffedBy:Creature.Red:CrtlAnother
Bant Sureblade BuffedBy:Permanent.Multi:CrtlAnother
Esper Stormblade BuffedBy:Permanent.Multi:CrtlAnother
Grixis Grimblade BuffedBy:Permanent.Multi:CrtlAnother
Jund Hackblade BuffedBy:Permanent.Multi:CrtlAnother
Naya Hushblade BuffedBy:Permanent.Multi:CrtlAnother
Battle Squadron BuffedBy:Creature
Dauntless Dourbark BuffedBy:Treefolk
Keldon Warlord BuffedBy:Creature.nonWall
Master of Etherium BuffedBy:Artifact
Scion of the Wild BuffedBy:Creature
Soulsurge Elemental BuffedBy:Creature
Squirrel Mob BuffedBy:Squirrel
Glassdust Hulk BuffedBy:Artifact
Glaze Fiend BuffedBy:Artifact
Herd Gnarr BuffedBy:Creature
Juniper Order Ranger BuffedBy:Creature
Kavu Monarch BuffedBy:Kavu
Emberstrike Duo BuffedBy:Spell.Black,Red
Gravelgill Duo BuffedBy:Spell.Blue,Black
Safehold Duo BuffedBy:Spell.Green,White
Tattermunge Duo BuffedBy:Spell.Red,Green
Thistledown Duo BuffedBy:Spell.White,Blue
Kami of the Hunt BuffedBy:Arcane,Spirit
Belligerent Hatchling BuffedBy:Spell.Red,White
Noxious Hatchling BuffedBy:Spell.Black,Green
Sturdy Hatchling BuffedBy:Spell.Green,Blue
Voracious Hatchling BuffedBy:Spell.White,Black
-
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: BuffedBy keyword (or SVar?)
by Sloth » 20 Aug 2010, 11:20
I implemented BuffedBy as an SVar (and regretted it later, see below):
Work in progress: Permanent, Spell and Card (Card means everything).
To DO: Add the entries in cards.txt:
Example change slivers and allies from SVar:PlayMain1:TRUE to SVar:BuffedBy:Ally and SVar:BuffedBy:Sliver.
Edit: Finished Permanent, Spell and Card.
- Code: Select all
private SpellAbility[] getMain1() {
//Card list of all cards to consider
CardList hand = new CardList(AllZone.Computer_Hand.getCards());
hand = hand.filter(new CardListFilter() {
// Beached As Start
public boolean addCard(Card c) {
//Collection<Card> play = playMain1Cards;
if (c.getSVar("PlayMain1").equals("TRUE"))
return true;
if(c.isLand()) return false;
if(c.isCreature() && (c.getKeyword().contains("Haste")) || c.getKeyword().contains("Exalted")) return true;
CardList buffed = new CardList(AllZone.Computer_Play.getCards());
// buffed.getKeyword("BuffedBy"); //get all cards the computer controls with BuffedBy
for(int i = 0; i < buffed.size(); i++) {
Card buffedcard = buffed.get(i);
if (buffedcard.getSVar("BuffedBy").length() > 0) {
String buffedby = buffedcard.getSVar("BuffedBy");
final String bffdby[] = buffedby.split(",");
if (c.isValidCard(bffdby)) return true;
}
}
Work in progress: Permanent, Spell and Card (Card means everything).
To DO: Add the entries in cards.txt:
Example change slivers and allies from SVar:PlayMain1:TRUE to SVar:BuffedBy:Ally and SVar:BuffedBy:Sliver.
Edit: Finished Permanent, Spell and Card.
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: BuffedBy keyword (or SVar?)
by Chris H. » 20 Aug 2010, 13:28
`Sloth wrote:I implemented BuffedBy as an SVar (and regretted it later, see below):
isValidCard can handle all restrictions of dpDestroyTgt like: Creature.Blue+Black,Permanent.nonAura,Worm.tapped+unenchanted etc.
Work in progress: Permanent, Spell and Card (Card means everything).
To DO: Add the entries in cards.txt:
Example change slivers and allies from SVar:PlayMain1:TRUE to SVar:BuffedBy:Ally and SVar:BuffedBy:Sliver.
Edit: Finished Permanent, Spell and Card.
I saw the last several merges to the SVN. Did you figure out the restriction part that you were having problems with?
The SVar:Picture:{url} has periods in the url string. Is Rob doing anything special in his SVar:Picture:{url} code to allow periods?
I took a quick look at the Card.isValidCard() code and it appears to split on the period. I may release a beta based on rev 1791 and leave this SVar for the following version as we try to 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: BuffedBy keyword (or SVar?)
by Sloth » 20 Aug 2010, 13:50
Actually I it works fine, it was just a testing mistake.
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: BuffedBy keyword (or SVar?)
by Chris H. » 20 Aug 2010, 13:59
`Sloth wrote:Actually I it works fine, it was just a testing mistake.
I am glad to see that it works. Nice work.

I will release a beta based on r1791 and we will include this new SVar into the following beta. It is nice to have something "in the works" for the next beta. Gives people something to look forward to.

-
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: BuffedBy keyword (or SVar?)
by Rob Cashwalker » 20 Aug 2010, 14:24
The only thing I think this is missing is what if the condition that would "buff" another card is the presence of the condition on the human's side - either specifically "the opponent" or just "on the battlefield".
We will also have to examine the converse situation - cards that would be adversely affected given a particular condition... not many I'm sure.
Though it does make me think that (separately) the AI should check to see if a global x/-y condition may kill a 1/1 creature as soon as it's cast.
We will also have to examine the converse situation - cards that would be adversely affected given a particular condition... not many I'm sure.
Though it does make me think that (separately) the AI should check to see if a global x/-y condition may kill a 1/1 creature as soon as it's cast.
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: BuffedBy keyword (or SVar?)
by Sloth » 20 Aug 2010, 15:07
Yes, I think there are quite a few cards like this (like Timid Drake or Concordant Crossroads). We can just make a second SVar that will be checked on the human side.Rob Cashwalker wrote:The only thing I think this is missing is what if the condition that would "buff" another card is the presence of the condition on the human's side - either specifically "the opponent" or just "on the battlefield".
But how should it be called DebuffedBy, MiffedBy?
PS: Cards with symmetrical effects would just have both SVars.
PPS: I just realized SVar:BuffedBy doesn't work for Liu Bei, Lord of Shu because of the ","'s in Guan Yu, Sainted Warrior and Zhang Fei, Fierce Warrior. But I think it's the only card that can't be handled.
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: BuffedBy keyword (or SVar?)
by Rob Cashwalker » 20 Aug 2010, 15:26
YEah, but the list that AC provided was only based off cards already in Forge. These functions need to be able to handle all variations for at least the cards that have been printed so far, and most of what may be printed in the future.
getValidCards doesn't parse the comma, spDestroyTgt parses the comma, and passes a string array to getValidCards. You're free to parse any other delimiter ("/" comes to mind) before passing to getValidCards.
getValidCards doesn't parse the comma, spDestroyTgt parses the comma, and passes a string array to getValidCards. You're free to parse any other delimiter ("/" comes to mind) before passing to getValidCards.
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: BuffedBy keyword (or SVar?)
by Sloth » 20 Aug 2010, 16:23
I've added the SVar AntiBuffedBy to be used on permanents the human controls to make
the AI play certain cards in Main1. The syntax is the same.
PS: What is also a problem with parsing is being unable to use keywords with ":" in spPumpTgt, wheneverkeyword, staticeffect, etc. (When I started using keywords I was really unhappy realize this).
the AI play certain cards in Main1. The syntax is the same.
Ah, you're right, this can be changed. But since this is only a bonus for the AI, it's not serious. I will be off for two week starting tomorrow, so I leave up to you guys (maybe also gals?).Rob Cashwalker wrote:YEah, but the list that AC provided was only based off cards already in Forge. These functions need to be able to handle all variations for at least the cards that have been printed so far, and most of what may be printed in the future.
getValidCards doesn't parse the comma, spDestroyTgt parses the comma, and passes a string array to getValidCards. You're free to parse any other delimiter ("/" comes to mind) before passing to getValidCards.
PS: What is also a problem with parsing is being unable to use keywords with ":" in spPumpTgt, wheneverkeyword, staticeffect, etc. (When I started using keywords I was really unhappy realize this).
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
Re: BuffedBy keyword (or SVar?)
by Rob Cashwalker » 20 Aug 2010, 16:49
It's not so much that you can't use a keyword with ":", its that keywords for activated abilities aren't parsed in real time. Flying or trample are checked whenever combat comes around. But you can't give a creature "RegerateMe:B" because "RegenerateMe" is only parsed when the CardFactory creates a card.
If anyone wants to devise their own parsing rules for a keyword beyond simple ":" delimiters, there's no reason not to. The Whenever keyword would be a prime example of why it doesn't fit all situations. But for something as simple as "RegenerateMe:B" it makes total sense.
I sorta did that when I started with Drawback$ and Count$... we could just as easily have this sort of syntax:
If anyone wants to devise their own parsing rules for a keyword beyond simple ":" delimiters, there's no reason not to. The Whenever keyword would be a prime example of why it doesn't fit all situations. But for something as simple as "RegenerateMe:B" it makes total sense.
I sorta did that when I started with Drawback$ and Count$... we could just as easily have this sort of syntax:
- Code: Select all
spPumpTgt|Cost${mana, tap, sac, etc costs}|Power${+/-#}|Toughness${+/-#}|Drawback${db String}|Description$This spell pumps you up.
- Code: Select all
spPumpTgt|Power${+/-#}|Toughness${+/-#}|Description$This spell pumps you up.|Drawback${db String}|Cost${mana, tap, sac, etc costs}
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: BuffedBy keyword (or SVar?)
by Sloth » 20 Aug 2010, 17:44
Ah Ok, I didn't realize that activated abilities wouldn't work anyway. Then improving the parsing is not so important.Rob Cashwalker wrote:It's not so much that you can't use a keyword with ":", its that keywords for activated abilities aren't parsed in real time. Flying or trample are checked whenever combat comes around. But you can't give a creature "RegerateMe:B" because "RegenerateMe" is only parsed when the CardFactory creates a card.
If anyone wants to devise their own parsing rules for a keyword beyond simple ":" delimiters, there's no reason not to. The Whenever keyword would be a prime example of why it doesn't fit all situations. But for something as simple as "RegenerateMe:B" it makes total sense.
I sorta did that when I started with Drawback$ and Count$... we could just as easily have this sort of syntax:In fact it would be easier to parse, because the code would just iterate through all elements split by "|" and if the element started with "Power$" then it would evaluate the element as power. It would allow this to be equivalent:
- Code: Select all
spPumpTgt|Cost${mana, tap, sac, etc costs}|Power${+/-#}|Toughness${+/-#}|Drawback${db String}|Description$This spell pumps you up.
- Code: Select all
spPumpTgt|Power${+/-#}|Toughness${+/-#}|Description$This spell pumps you up.|Drawback${db String}|Cost${mana, tap, sac, etc costs}
-
Sloth - Programmer
- Posts: 3498
- Joined: 23 Jun 2009, 19:40
- Has thanked: 125 times
- Been thanked: 507 times
15 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 43 guests