AI plays zerocast cards, Update Rules folder!

Its basic pay zero for now...
Omniscience is possible :)
This commit is contained in:
Anthony Calosa
2015-11-07 09:59:30 +08:00
parent 71390046f5
commit e35c9f6087
5 changed files with 96 additions and 17 deletions

View File

@@ -11580,6 +11580,7 @@ toughness=2
[/card]
[card]
name=Boneyard Wurm
alias=001100
anyzone=type:creature:mygraveyard/type:creature:mygraveyard cdaactive
text=Boneyard Wurm's power and toughness are each equal to the number of creature cards in your graveyard.
mana={1}{G}
@@ -14097,6 +14098,7 @@ type=Sorcery
[/card]
[card]
name=Cantivore
alias=001100
abilities=vigilance
anyzone=type:enchantment:graveyard/type:enchantment:graveyard cdaactive
text=Vigilance -- Cantivore's power and toughness are each equal to the number of enchantment cards in all graveyards.
@@ -18065,6 +18067,7 @@ type=Instant
[/card]
[card]
name=Cognivore
alias=001100
abilities=flying
anyzone=type:instant:graveyard/type:instant:graveyard cdaactive
text=Flying -- Cognivore's power and toughness are each equal to the number of instant cards in all graveyards.
@@ -24371,6 +24374,7 @@ text=Destroy target artifact with converted mana cost X. It can't be regenerated
[/card]
[card]
name=Detritivore
alias=001100
anyzone=type:land[-basic]:opponentgraveyard/type:land[-basic]:opponentgraveyard cdaactive
autoexile=@counterremoved(0/0,1,Time) from(sourcecard) suspended:destroy target(land[-basic])
suspend(0)={X}{3}{R}
@@ -56072,6 +56076,7 @@ toughness=5
[/card]
[card]
name=Lhurgoyf
alias=001100
anyzone=type:creature:graveyard/plusonetype:creature:graveyard cdaactive
text=Lhurgoyf's power is equal to the number of creature cards in all graveyards and its toughness is equal to that number plus 1.
mana={2}{G}{G}
@@ -57452,6 +57457,7 @@ toughness=2
[/card]
[card]
name=Lord of Extinction
alias=001100
anyzone=type:*:graveyard/type:*:graveyard cdaactive
text=Lord of Extinction's power and toughness are each equal to the number of cards in all graveyards.
mana={3}{B}{G}
@@ -58816,6 +58822,7 @@ toughness=6
[/card]
[card]
name=Magnivore
alias=001100
abilities=haste
anyzone=type:sorcery:graveyard/type:sorcery:graveyard cdaactive
text=Haste (This creature can attack the turn it comes under your control.) -- Magnivore's power and toughness are each equal to the number of sorcery cards in all graveyards.
@@ -64584,6 +64591,7 @@ toughness=2
[/card]
[card]
name=Mortivore
alias=001100
auto={B}:regenerate
anyzone=type:creature:graveyard/type:creature:graveyard cdaactive
text=Mortivore's power and toughness are each equal to the number of creature cards in all graveyards. -- {B}: Regenerate Mortivore. (The next time this creature would be destroyed this turn, it isn't. Instead tap it, remove all damage from it, and remove it from combat.)
@@ -79780,6 +79788,7 @@ type=Artifact
[/card]
[card]
name=Revenant
alias=001100
abilities=flying
anyzone=type:creature:mygraveyard/type:creature:mygraveyard cdaactive
text=Flying -- Revenant's power and toughness are each equal to the number of creature cards in your graveyard.
@@ -90926,6 +90935,7 @@ toughness=3
[/card]
[card]
name=Slag Fiend
alias=001100
anyzone=type:artifact:graveyard/type:artifact:graveyard cdaactive
text=Slag Fiend's power and toughness are each equal to the number of artifact cards in all graveyards.
mana={R}
@@ -94631,6 +94641,7 @@ color=green
[/card]
[card]
name=Splinterfright
alias=001100
abilities=trample
anyzone=type:creature:mygraveyard/type:creature:mygraveyard cdaactive
auto=@each my upkeep:deplete:2 controller
@@ -100773,6 +100784,7 @@ type=Artifact
[/card]
[card]
name=Terravore
alias=001100
abilities=trample
anyzone=type:land:graveyard/type:land:graveyard cdaactive
text=Trample -- Terravore's power and toughness are each equal to the number of land cards in all graveyards.
@@ -105998,6 +106010,7 @@ type=Artifact
[/card]
[card]
name=Umbra Stalker
alias=001100
anyzone=type:manab:mygraveyard/type:manab:mygraveyard cdaactive
text=Chroma - Umbra Stalker's power and toughness are each equal to the number of black mana symbols in the mana costs of cards in your graveyard.
mana={4}{B}{B}{B}

View File

@@ -213,7 +213,7 @@ public:
COUNTERS = 30,
PUT_INTO_PLAY_WITH_KICKER = 31,
STANDARD_FIZZLER = 32,
CASTINGRAVEEXILE_COST = 33,
PAYZERO_COST = 33,
};
};

View File

@@ -631,10 +631,6 @@ int OrderedAIAction::getEfficiency()
{
efficiency += 55;
}
else if (dynamic_cast<MTGPayZeroRule *>(a))
{
efficiency += 45;
}
SAFE_DELETE(transAbility);
return efficiency;
}
@@ -1838,6 +1834,10 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty
{
shouldPlayPercentage = 90;
}
else if (!card->isLand() && card->has(Constants::PAYZERO))
{
shouldPlayPercentage = 70;
}
else
{
// shouldPlay == baka_effect_bad giving it a 1 for odd ball lottery chance.
@@ -1986,6 +1986,10 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty
{
shouldPlayPercentage = 90;
}
else if (!card->isLand() && card->has(Constants::PAYZERO))
{
shouldPlayPercentage = 70;
}
else
{
// shouldPlay == baka_effect_bad giving it a 1 for odd ball lottery chance.
@@ -2133,6 +2137,10 @@ MTGCardInstance * AIPlayerBaka::FindCardToPlay(ManaCost * pMana, const char * ty
{
shouldPlayPercentage = 90;
}
else if (!card->isLand() && card->has(Constants::PAYZERO))
{
shouldPlayPercentage = 70;
}
else
{
// shouldPlay == baka_effect_bad giving it a 1 for odd ball lottery chance.
@@ -2413,6 +2421,56 @@ int AIPlayerBaka::computeActions()
nextCardToPlay = NULL;
count++;
}
if(nextCardToPlay == NULL)//check if there is a free card to play, play it....
{//TODO: add potential mana if we can pay if there is a cost increaser in play
CardDescriptor cd;
if (game->hand->hasAbility(Constants::PAYZERO))
{
//Attempt to put free cards into play
cd.init();
cd.SetExclusionColor(Constants::MTG_COLOR_LAND);
MTGCardInstance *freecard = cd.match(game->hand);
int canCastCard = game->playRestrictions->canPutIntoZone(freecard, game->inPlay);
if (freecard && (canCastCard == PlayRestriction::CAN_PLAY) && freecard->has(Constants::PAYZERO) && (freecard->getIncreasedManaCost()->getConvertedCost() < 1))
{
MTGAbility * castFreeCard = observer->mLayers->actionLayer()->getAbility(MTGAbility::PAYZERO_COST);
AIAction * aa = NEW AIAction(this, castFreeCard, freecard); //TODO putinplay action
clickstream.push(aa);
break;
}
}
if (game->graveyard->hasAbility(Constants::PAYZERO) && game->graveyard->hasAbility(Constants::CANPLAYFROMGRAVEYARD))
{
//Attempt to put free cards into play
cd.init();
cd.SetExclusionColor(Constants::MTG_COLOR_LAND);
MTGCardInstance *freecard = cd.match(game->graveyard);
int canCastCard = game->playRestrictions->canPutIntoZone(freecard, game->inPlay);
if (freecard && (canCastCard == PlayRestriction::CAN_PLAY) && freecard->has(Constants::PAYZERO) && freecard->has(Constants::CANPLAYFROMGRAVEYARD) && (freecard->getIncreasedManaCost()->getConvertedCost() < 1) && (freecard->alias != 001100))
{
MTGAbility * castFreeCard = observer->mLayers->actionLayer()->getAbility(MTGAbility::PAYZERO_COST);
AIAction * aa = NEW AIAction(this, castFreeCard, freecard); //TODO putinplay action
clickstream.push(aa);
break;
}
}
if (game->exile->hasAbility(Constants::PAYZERO) && game->exile->hasAbility(Constants::CANPLAYFROMEXILE))
{
//Attempt to put free cards into play
cd.init();
cd.SetExclusionColor(Constants::MTG_COLOR_LAND);
MTGCardInstance *freecard = cd.match(game->exile);
int canCastCard = game->playRestrictions->canPutIntoZone(freecard, game->inPlay);
if (freecard && (canCastCard == PlayRestriction::CAN_PLAY) && freecard->has(Constants::PAYZERO) && freecard->has(Constants::CANPLAYFROMEXILE) && (freecard->getIncreasedManaCost()->getConvertedCost() < 1) && (freecard->alias != 001100))
{
MTGAbility * castFreeCard = observer->mLayers->actionLayer()->getAbility(MTGAbility::PAYZERO_COST);
AIAction * aa = NEW AIAction(this, castFreeCard, freecard); //TODO putinplay action
clickstream.push(aa);
break;
}
}
}//end
}
SAFE_DELETE(currentMana);

View File

@@ -1156,7 +1156,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
observer->addObserver(NEW MTGMorphCostRule(observer, -1));
return NULL;
}
found = s.find("playfromgraveyardrule");
found = s.find("payzerorule");
if(found != string::npos)
{
observer->addObserver(NEW MTGPayZeroRule(observer, -1));

View File

@@ -489,7 +489,11 @@ int MTGKickerRule::isReactingToClick(MTGCardInstance * card, ManaCost *)
}
ManaCost * playerMana = player->getManaPool();
ManaCost * withKickerCost= NEW ManaCost(card->model->data->getManaCost());
withKickerCost->add(withKickerCost->getKicker());
if(card->getIncreasedManaCost()->getConvertedCost())
withKickerCost->add(card->getIncreasedManaCost());
if(card->getReducedManaCost()->getConvertedCost())
withKickerCost->remove(card->getReducedManaCost());
withKickerCost->add(card->model->data->getManaCost()->getKicker());
if(!playerMana->canAfford(withKickerCost))
{
delete withKickerCost;
@@ -508,11 +512,15 @@ int MTGKickerRule::reactToClick(MTGCardInstance * card)
Player * player = game->currentlyActing();
ManaCost * withKickerCost= NEW ManaCost(card->model->data->getManaCost());//using pointers here alters the real cost of the card.
if (card->getManaCost()->getKicker()->isMulti)
if(card->getIncreasedManaCost()->getConvertedCost())
withKickerCost->add(card->getIncreasedManaCost());
if(card->getReducedManaCost()->getConvertedCost())
withKickerCost->remove(card->getReducedManaCost());
if (card->model->data->getManaCost()->getKicker()->isMulti)
{
while(player->getManaPool()->canAfford(withKickerCost))
{
withKickerCost->add(withKickerCost->getKicker());
withKickerCost->add(card->model->data->getManaCost()->getKicker());
card->kicked += 1;
}
card->kicked -= 1;
@@ -522,7 +530,7 @@ int MTGKickerRule::reactToClick(MTGCardInstance * card)
}
else
{
withKickerCost->add(withKickerCost->getKicker());
withKickerCost->add(card->model->data->getManaCost()->getKicker());
card->paymenttype = MTGAbility::PUT_INTO_PLAY_WITH_KICKER;
}
if (withKickerCost->isExtraPaymentSet())
@@ -638,9 +646,9 @@ int MTGAlternativeCostRule::isReactingToClick(MTGCardInstance * card, ManaCost *
if(card->has(Constants::CANPLAYFROMGRAVEYARD))
alternativeName = "Alternate Cast Card From Graveyard";
alternativeName = "Alternate Cast From Graveyard";
else if(card->has(Constants::CANPLAYFROMEXILE))
alternativeName = "Alternate Cast Card From Exile";
alternativeName = "Alternate Cast From Exile";
else if(card->model->data->getManaCost()->getAlternative() && card->model->data->getManaCost()->getAlternative()->alternativeName.size())
alternativeName = card->model->data->getManaCost()->getAlternative()->alternativeName;
@@ -1145,7 +1153,7 @@ MTGMorphCostRule * MTGMorphCostRule::clone() const
MTGPayZeroRule::MTGPayZeroRule(GameObserver* observer, int _id) :
MTGAlternativeCostRule(observer, _id)
{
aType = MTGAbility::CASTINGRAVEEXILE_COST;
aType = MTGAbility::PAYZERO_COST;
}
int MTGPayZeroRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
@@ -1166,11 +1174,11 @@ int MTGPayZeroRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
if ((!card->has(Constants::CANPLAYFROMGRAVEYARD) && player->game->graveyard->hasCard(card))||(!card->has(Constants::CANPLAYFROMEXILE) && player->game->exile->hasCard(card)))
return 0;
if(card->has(Constants::CANPLAYFROMGRAVEYARD))
CustomName = "Pay Zero To Cast From Graveyard";
CustomName = "Zero Cast From Graveyard";
else if(card->has(Constants::CANPLAYFROMEXILE))
CustomName = "Pay Zero To Cast From Exile";
CustomName = "Zero Cast From Exile";
else
CustomName = "Pay Zero To Cast";
CustomName = "Zero Cast From Anywhere";
return MTGAlternativeCostRule::isReactingToClick(card, mana, cost);
}
@@ -1182,7 +1190,7 @@ int MTGPayZeroRule::reactToClick(MTGCardInstance * card)
ManaCost * cost = NEW ManaCost(ManaCost::parseManaCost("{0}",NULL,NULL));
card->paymenttype = MTGAbility::CASTINGRAVEEXILE_COST;
card->paymenttype = MTGAbility::PAYZERO_COST;
return MTGAlternativeCostRule::reactToClick(card, cost, ManaCost::MANA_PAID);
}