Self - Regenerate Creatures

This is a submission I made to mtgrares by email earlier this month, to a less than stellar reception. So just in case someone else is compiling submissions, here it is.
CardFactory:
Near the top, where the shouldPump keyword is checked for already:
There are a few cards here that are already implemented in pure code, and they'll have to be removed from the code.
Cards.txt:
Card-pics.txt:
CardFactory:
Near the top, where the shouldPump keyword is checked for already:
- Code: Select all
//Check for self-regenerate ability
private final int shouldRegenerateMe(Card c)
{
ArrayList a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
if (a.get(i).toString().startsWith("RegenerateMe"))
return i;
return -1;
}
- Code: Select all
//Creatures with self-regenerate abilities
//-1 means keyword "RegenerateMe" not found
while (shouldRegenerateMe(card) != -1)
{
int n = shouldRegenerateMe(card);
if (n != -1)
{
String parse = card.getKeyword().get(n).toString();
card.removeKeyword(parse);
String k[] = parse.split(":");
final String manacost = k[1];
final Command untilEOT = new Command() {
public void execute()
{
card.setShield(0);
}
};
final SpellAbility a1 = new Ability(card, manacost) {
public boolean canPlayAI()
{
if (CardFactoryUtil.AI_isMainPhase())
{
if (CardFactoryUtil.AI_doesCreatureAttack(card))
{
//"Fuzzy logic" to determine if using a regenerate ability might be helpful because
//we can't wait to decide to play this ability during combat, like the human can
//weight[] is a set of probability percentages to be averaged later
int weight[] = new int[3];
// cards with real keywords (flying, trample, etc) are probably more desireable
if (card.getKeyword().size() > 0)
weight[0] = 75;
else
weight[0] = 0;
// if there are many cards in hand, then maybe it's not such a great idea to waste mana
CardList HandList = new CardList(AllZone.getZone(Constant.Zone.Hand, Constant.Player.Computer).getCards());
if (HandList.size() >= 4)
weight[1] = 25;
else
weight[1] = 75;
// compare the highest converted mana cost of cards in hand to the number of lands
// if there's spare mana, then regeneration might be viable
int hCMC = 0;
for (int i = 0; i < HandList.size(); i++)
if (HandList.getCard(i).getConvertedManaCost() > hCMC)
hCMC = HandList.getCard(i).getConvertedManaCost();
CardList LandList = new CardList(AllZone.getZone(Constant.Zone.Play, Constant.Player.Computer).getCards());
LandList = LandList.getType("Land");
//most regenerate abilities cost 2 or less
if (hCMC + 2 >= LandList.size())
weight[2] = 50;
else
weight[2] = 0;
// ultimately, it's random fate that dictates if this was the right play
int aw = (weight[0] + weight[1] + weight[2]) / 3;
Random r = new Random();
if (r.nextInt(100) <= aw)
return true;
}
}
return false;
}
public void resolve()
{
card.addShield();
AllZone.EndOfTurn.addUntil(untilEOT);
}
}; //SpellAbility
card.addSpellAbility(a1);
String Desc = new String();
Desc = "Regenerate " + cardName;
a1.setDescription(manacost + " : " + Desc);
a1.setStackDescription(Desc);
a1.setBeforePayMana(new Input_PayManaCost(a1));
} //if (should RegenerateMe)
} //while - card has more RegenerateMe - Jungle Troll has two Regenerate keywords
There are a few cards here that are already implemented in pure code, and they'll have to be removed from the code.
Cards.txt:
- Code: Select all
Ancient Silverback
4 G G
Creature Ape
no text
6/5
RegenerateMe:G
Carnassid
4 G G
Creature Beast
no text
5/4
Trample
RegenerateMe:1 G
Carrion Wall
1 B B
Creature Wall
no text
3/2
Defender
RegenerateMe:1 B
Charging Troll
2 W G
Creature Troll
no text
3/3
Vigilance
RegenerateMe:G
Clay Statue
4
Artifact Creature Golem
no text
3/1
RegenerateMe:2
Darkling Stalker
3 B
Creature Shade Spirit
no text
1/1
RegenerateMe:B
PTPump B:+1/+1
Diabolic Machine
7
Artifact Creature Construct
no text
4/4
RegenerateMe:3
Drowned
1 U
Creature Zombie
no text
1/1
RegenerateMe:B
Drudge Reavers
3 B
Creature Skeleton
no text
2/1
Flash
RegenerateMe:B
Drudge Skeletons
1 B
Creature Skeleton
no text
1/1
RegenerateMe:B
Eron the Relentless
3 R R
Legendary Creature Human Rogue
no text
5/2
Haste
RegenerateMe:R R R
Fog of Gnats
B B
Creature Insect
no text
1/1
Flying
RegenerateMe:B
Ghost Ship
2 U U
Creature Spirit
no text
2/4
Flying
RegenerateMe:U U U
Gorilla Chieftain
2 G G
Creature Ape
no text
3/3
RegenerateMe:1 G
Horned Troll
2 G
Creature Troll
no text
2/2
RegenerateMe:G
Jungle Troll
1 R G
Creature Troll
no text
2/1
RegenerateMe:R
RegenerateMe:G
Living Airship
3 U
Creature Metathran
no text
2/3
Flying
RegenerateMe:2 G
Living Wall
4
Artifact Creature Wall
no text
0/6
Defender
RegenerateMe:1
Malach of the Dawn
2 W W
Creature Angel
no text
2/4
Flying
RegenerateMe:W W W
Metathran Zombie
1 U
Creature Metathran Zombie
no text
1/1
RegenerateMe:B
Mire Boa
1 G
Creature Snake
no text
2/1
Swampwalk
RegenerateMe:G
Pewter Golem
5
Artifact Creature Golem
no text
4/2
RegenerateMe:1 B
Phyrexian Monitor
3 B
Creature Skeleton
no text
2/2
RegenerateMe:B
Restless Dead
1 B
Creature Skeleton
no text
1/1
RegenerateMe:B
Revered Dead
1 W
Creature Spirit Soldier
no text
1/1
RegenerateMe:W
River Boa
1 G
Creature Snake
no text
2/1
Islandwalk
RegenerateMe:G
Screeching Harpy
2 B B
Creature Harpy Beast
no text
2/2
Flying
RegenerateMe:1 B
Silvos, Rogue Elemental
3 G G G
Legendary Creature Elemental
no text
8/5
Trample
RegenerateMe:G
Skyshroud Troll
2 G G
Creature Troll Giant
no text
3/3
RegenerateMe:1 G
Tattered Drake
4 U
Creature Zombie Drake
no text
2/2
Flying
RegenerateMe:B
Tel-Jilad Exile
3 G
Creature Troll Warrior
no text
2/3
RegenerateMe:1 G
Unworthy Dead
1 B
Creature Skeleton
no text
1/1
RegenerateMe:B
Uthden Troll
2 R
Creature Troll
no text
2/2
RegenerateMe:R
Votary of the Conclave
W
Creature Human Soldier
no text
1/1
RegenerateMe:2 G
Walking Dead
1 B
Creature Zombie
no text
1/1
RegenerateMe:B
Wall of Bone
2 B
Creature Skeleton Wall
no text
1/4
Defender
RegenerateMe:B
Wall of Brambles
2 G
Creature Plant Wall
no text
2/3
Defender
RegenerateMe:G
Wall of Pine Needles
3 G
Creature Plant Wall
no text
3/3
Defender
RegenerateMe:G
Will-o'-the-Wisp
B
Creature Spirit
no text
0/1
Flying
RegenerateMe:B
Yavimaya Gnats
2 G
Creature Insect
no text
0/1
Flying
RegenerateMe:G
- Code: Select all
Clay Statue
Darkling Stalker
Drowned
Drudge Reavers
Fog of Gnats
Gorilla Chieftain
Horned Troll
Living Airship
Metathran Zombie
Mire Boa
Pewter Golem
Phyrexian Monitor
Restless Dead
Revered Dead
Skyshroud Troll
Tattered Drake
Tel-Jilad Exile
Unworthy Dead
Votary of the Conclave
Walking Dead
- Code: Select all
Carrion Wall
Charging Troll
Diabolic Machine
Drudge Skeletons
Ghost Ship
Jungle Troll
Living Wall
Malach of the Dawn
River Boa
Screeching Harpy
Uthden Troll
Wall of Bone
Wall of Brambles
Wall of Pine Needles
Yavimaya Gnats
Card-pics.txt:
- Code: Select all
Ancient Silverback http://resources.wizards.com/Magic/Cards/9ED/en-us/Card82950.jpg
Carnassid http://resources.wizards.com/Magic/Cards/ST/en-us/Card5217.jpg
Carrion Wall http://resources.wizards.com/Magic/Cards/8ED/en-us/Card45306.jpg
Charging Troll http://resources.wizards.com/Magic/Cards/IN/en-us/Card23162.jpg
Clay Statue http://resources.wizards.com/Magic/Cards/5E/en-us/Card3767.jpg
Darkling Stalker http://resources.wizards.com/Magic/Cards/TE/en-us/Card4647.jpg
Diabolic Machine http://resources.wizards.com/Magic/Cards/5E/en-us/Card3775.jpg
Drowned http://resources.wizards.com/Magic/Cards/DK/en-us/Card1750.jpg
Drudge Reavers http://resources.wizards.com/Magic/Cards/TSP/en-us/Card108850.jpg
Drudge Skeletons http://resources.wizards.com/Magic/Cards/10E/EN/Card129529.jpg
Fog of Gnats http://resources.wizards.com/Magic/Cards/GU/en-us/Card9699.jpg
Ghost Ship http://resources.wizards.com/Magic/Cards/TSB/en-us/Card107294.jpg
Gorilla Chieftain http://resources.wizards.com/Magic/Cards/7E/en-us/Card13047.jpg
Horned Troll http://resources.wizards.com/Magic/Cards/8ED/en-us/Card45404.jpg
Jungle Troll http://resources.wizards.com/Magic/Cards/MI/en-us/Card3540.jpg
Living Airship http://resources.wizards.com/Magic/Cards/AP/en-us/Card26795.jpg
Living Wall http://resources.wizards.com/Magic/Cards/3E/en-us/Card1123.jpg
Malach of the Dawn http://resources.wizards.com/Magic/Cards/PLC/en-us/Card122481.jpg
Metathran Zombie http://resources.wizards.com/Magic/Cards/IN/en-us/Card22973.jpg
Mire Boa http://resources.wizards.com/Magic/Cards/PLC/en-us/Card122420.jpg
Pewter Golem http://resources.wizards.com/Magic/Cards/MRD/en-us/Card48054.jpg
Phyrexian Monitor http://resources.wizards.com/Magic/Cards/CG/en-us/Card19113.jpg
Restless Dead http://resources.wizards.com/Magic/Cards/MI/en-us/Card3307.jpg
Revered Dead http://resources.wizards.com/Magic/Cards/PLC/en-us/Card122282.jpg
River Boa http://resources.wizards.com/Magic/Cards/6E/en-us/Card16457.jpg
Screeching Harpy http://resources.wizards.com/Magic/Cards/TE/en-us/Card4684.jpg
Silvos, Rogue Elemental http://resources.wizards.com/Magic/Cards/ONS/en-us/Card39860.jpg
Skyshroud Troll http://resources.wizards.com/Magic/Cards/TE/en-us/Card4791.jpg
Tattered Drake http://resources.wizards.com/Magic/Cards/RAV/en-us/Card87930.jpg
Tel-Jilad Exile http://resources.wizards.com/Magic/Cards/MRD/en-us/Card49436.jpg
Unworthy Dead http://resources.wizards.com/Magic/Cards/UZ/en-us/Card5780.jpg
Uthden Troll http://resources.wizards.com/Magic/Cards/TSB/en-us/Card108806.jpg
Votary of the Conclave http://resources.wizards.com/Magic/Cards/RAV/en-us/Card87948.jpg
Walking Dead http://resources.wizards.com/Magic/Cards/LE/en-us/Card1466.jpg
Wall of Bone http://resources.wizards.com/Magic/Cards/7E/en-us/Card25639.jpg
Wall of Brambles http://resources.wizards.com/Magic/Cards/5E/en-us/Card4021.jpg
Wall of Pine Needles http://resources.wizards.com/Magic/Cards/IA/en-us/Card2598.jpg
Will-o'-the-Wisp http://resources.wizards.com/Magic/Cards/9ED/en-us/Card83411.jpg
Yavimaya Gnats http://resources.wizards.com/Magic/Cards/IA/en-us/Card2604.jpg